/* ==========================================================================
   Flowdesk — design tokens
   Palette: cool paper background, deep cobalt ink, warm ember accent used
   sparingly for priority + primary actions. Space Grotesk for display type,
   Inter for body/UI, IBM Plex Mono for dates/ids/data.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-alt: #EEF1F8;
  --ink: #182233;
  --ink-muted: #6B7280;
  --ink-faint: #9CA6B8;
  --primary: #2B4570;
  --primary-dark: #1B2E4D;
  --primary-tint: #E9EEF7;
  --accent: #FF6B4A;
  --accent-tint: #FFEAE3;
  --success: #2FAE66;
  --success-tint: #E4F7EC;
  --warning: #F5A623;
  --warning-tint: #FDF1DA;
  --danger: #E5484D;
  --danger-tint: #FBE6E7;
  --border: #E4E8F1;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(24, 34, 51, 0.05);
  --shadow-md: 0 6px 20px rgba(24, 34, 51, 0.08);
  --shadow-lg: 0 20px 45px rgba(24, 34, 51, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent-tint); color: var(--primary-dark); }

.mono { font-family: 'IBM Plex Mono', monospace; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Buttons & form controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { box-shadow: 0 8px 20px rgba(255, 107, 74, 0.35); }
.btn-ghost { background: transparent; color: var(--ink-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--ink); }
.btn-danger { background: var(--danger-tint); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  font-weight: 500;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
textarea { resize: vertical; min-height: 80px; font-weight: 400; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-tint); color: var(--danger); }
.alert-success { background: var(--success-tint); color: var(--success); }

/* ---------- Auth pages ---------- */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #EAF0FB 0%, var(--bg) 55%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s var(--ease);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: inline-block;
}
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--ink-muted); font-size: 13.5px; margin: 0 0 22px; }
.auth-form { margin-top: 4px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 17px;
  padding: 6px 10px 26px;
}
.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--surface-alt); color: var(--ink); }
.nav-link.active { background: var(--primary-tint); color: var(--primary); }
.nav-divider { height: 1px; background: var(--border); margin: 14px 4px; }
.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.sidebar-user { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { font-size: 11.5px; color: var(--ink-faint); text-transform: capitalize; }
.logout-link { margin-left: auto; color: var(--ink-faint); }
.logout-link:hover { color: var(--danger); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(245, 247, 251, 0.85);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar-sub { color: var(--ink-muted); font-size: 12.5px; margin-top: 1px; }
.topbar-spacer { flex: 1; }
.menu-toggle { display: none; }

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-alt); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.badge-dot {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 12.5px;
  color: #fff;
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar-lg { width: 52px; height: 52px; font-size: 16px; }

.content { padding: 26px 28px 60px; }

/* ---------- Notification dropdown ---------- */

.dropdown-wrap { position: relative; }
.dropdown-panel {
  position: absolute;
  top: 48px; right: 0;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  animation: dropdown-in 0.18s var(--ease);
}
.dropdown-panel.open { display: block; }
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 13.5px;
}
.notif-item {
  display: flex; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  transition: background 0.15s var(--ease);
}
.notif-item:hover { background: var(--surface-alt); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-dot.type-overdue { background: var(--danger); }
.notif-dot.type-deadline_soon { background: var(--warning); }
.notif-dot.type-assigned { background: var(--primary); }
.notif-body p { margin: 0 0 3px; color: var(--ink); font-weight: 500; }
.notif-body time { color: var(--ink-faint); font-size: 11px; }
.notif-empty { padding: 30px 16px; text-align: center; color: var(--ink-faint); font-size: 12.5px; }

/* ---------- Bento dashboard ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  animation: rise 0.4s var(--ease) backwards;
}
.stat-card .stat-label { font-size: 12px; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 700; margin-top: 6px; }
.stat-card .stat-value.accent-color { color: var(--accent); }
.stat-card .stat-value.warn-color { color: var(--warning); }
.stat-card .stat-value.danger-color { color: var(--danger); }
.stat-card .stat-value.success-color { color: var(--success); }
.stat-card .stat-foot { font-size: 11.5px; color: var(--ink-faint); margin-top: 4px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h3 { font-size: 15px; }

.dash-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.member-row:last-child { border-bottom: none; }
.member-info { flex: 1; min-width: 0; }
.member-info strong { display: block; font-size: 13.5px; }
.member-info span { font-size: 11.5px; color: var(--ink-faint); }
.progress-track {
  width: 100%; height: 6px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width 0.6s var(--ease);
}
.member-count { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-muted); white-space: nowrap; }

.mini-task-list { display: flex; flex-direction: column; gap: 10px; }
.mini-task {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.mini-task:hover { transform: translateX(2px); box-shadow: var(--shadow-sm); }
.mini-task .bar { width: 3px; align-self: stretch; border-radius: 2px; flex-shrink: 0; }
.mini-task-title { font-size: 12.5px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-task-due { font-size: 11px; color: var(--ink-faint); font-family: 'IBM Plex Mono', monospace; white-space: nowrap; }
.mini-task-due.overdue { color: var(--danger); font-weight: 600; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-faint);
  font-size: 13px;
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: 0.5; }

/* ---------- Priority / status chips ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.chip-low { background: var(--surface-alt); color: var(--ink-muted); }
.chip-medium { background: var(--primary-tint); color: var(--primary); }
.chip-high { background: var(--warning-tint); color: #B67300; }
.chip-urgent { background: var(--danger-tint); color: var(--danger); }
.chip-personal { background: var(--accent-tint); color: #C24824; }

/* ---------- Kanban board ---------- */

.board-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.board-toolbar select, .board-toolbar input[type="search"] {
  padding: 8px 12px;
}
.board-toolbar .spacer { flex: 1; }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(270px, 1fr));
  gap: 16px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 12px;
}

.column {
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 10px;
}
.column-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.column-title { font-weight: 700; font-size: 13.5px; flex: 1; }
.column-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-muted);
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 100px;
}
.column-flow {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 6px 12px;
  overflow: hidden;
}
.column-flow-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.7s var(--ease);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 60px;
  flex: 1;
}

.task-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 13px 14px 13px 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 10px;
  cursor: grab;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
  position: relative;
}
.task-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-card:active { cursor: grabbing; }
.task-card .bar { width: 3px; align-self: stretch; border-radius: 2px; flex-shrink: 0; }
.task-card-body { flex: 1; min-width: 0; }
.task-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.task-card-title { font-weight: 600; font-size: 13px; line-height: 1.35; }
.task-card-desc { font-size: 11.5px; color: var(--ink-faint); margin: 4px 0 10px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-card-due { font-size: 11px; color: var(--ink-faint); display: flex; align-items: center; gap: 4px; font-family: 'IBM Plex Mono', monospace; }
.task-card-due.overdue { color: var(--danger); font-weight: 600; }
.task-card-due.soon { color: var(--warning); font-weight: 600; }
.task-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.task-card-icons { display: flex; gap: 8px; color: var(--ink-faint); font-size: 11px; align-items: center; }
.task-card-icons span { display: flex; align-items: center; gap: 3px; }
.task-card-icons svg { width: 13px; height: 13px; }

.sortable-ghost { opacity: 0.4; }
.sortable-drag { box-shadow: var(--shadow-lg) !important; transform: rotate(-2deg) scale(1.02); }
.card-list.drag-over { background: var(--primary-tint); border-radius: var(--radius-sm); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(24, 34, 51, 0.45);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-overlay.open { display: flex; animation: fade-in 0.15s var(--ease); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.25s var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 17px; }
.modal-close { color: var(--ink-faint); background: none; border: none; padding: 4px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 22px 24px; max-height: 65vh; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.link-item, .attach-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 6px;
}
.link-item a, .attach-item a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--primary); font-weight: 600; }
.remove-x { color: var(--ink-faint); background: none; border: none; font-size: 15px; line-height: 1; padding: 2px 4px; }
.remove-x:hover { color: var(--danger); }
.add-row { display: flex; gap: 8px; margin-top: 4px; }
.add-row input { flex: 1; }

/* ---------- Team page ---------- */

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.team-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.team-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.team-card-head strong { display: block; font-size: 14px; }
.team-card-head span { font-size: 11.5px; color: var(--ink-faint); }
.team-stats { display: flex; gap: 14px; margin-top: 12px; }
.team-stats div { flex: 1; text-align: center; padding: 8px 4px; background: var(--surface-alt); border-radius: var(--radius-sm); }
.team-stats .num { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 17px; display: block; }
.team-stats .lbl { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Toast ---------- */

.toast-wrap {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s var(--ease);
  display: flex; align-items: center; gap: 8px;
}
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(4, minmax(250px, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    z-index: 90;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .menu-toggle { display: flex; }
  .content { padding: 18px; }
  .board { grid-auto-flow: column; grid-template-columns: none; }
  .board .column { width: 82vw; flex-shrink: 0; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 14px 16px; }
  .dropdown-panel { width: calc(100vw - 32px); right: -8px; }
}

.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(24,34,51,0.35);
  z-index: 80;
}
.sidebar-scrim.open { display: block; }
