/* ─────────────────────────────────────────────────────────────
   Design system — tokens
   ───────────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-900: #0f172a;
  --brand-800: #1e293b;
  --brand-700: #1f2e4d;
  --brand-600: #334155;
  --accent-700: #0e6b6f;
  --accent-600: #0b7b7f;
  --accent-500: #14a3a8;

  /* Ink */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;

  /* Surfaces */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-hover: #fafbfd;

  /* Semantic */
  --success: #16a34a;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Shadow */
  --sh-1: 0 1px 2px rgb(15 23 42 / 0.04), 0 1px 3px rgb(15 23 42 / 0.06);
  --sh-2: 0 2px 4px rgb(15 23 42 / 0.04), 0 4px 8px rgb(15 23 42 / 0.06);
  --sh-3: 0 4px 12px rgb(15 23 42 / 0.08), 0 12px 24px rgb(15 23 42 / 0.06);
  --sh-pop: 0 12px 32px rgb(15 23 42 / 0.18);
  --ring: 0 0 0 3px rgb(11 123 127 / 0.18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink-900);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─────────────────────────────────────────────────────────────
   Header / nav
   ───────────────────────────────────────────────────────────── */
.brand-grad {
  background: linear-gradient(120deg, #0f172a 0%, #1e3a5f 50%, #0e6b6f 100%);
}

.app-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: saturate(180%) blur(8px);
}

.app-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #14a3a8 0%, #0b7b7f 100%);
  display: grid; place-items: center;
  font-weight: 700; color: white; letter-spacing: -0.02em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}

.nav-link {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  color: rgba(255,255,255,0.72);
  font-weight: 500; font-size: 0.88rem;
  letter-spacing: -0.005em;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #ffffff; }
.nav-link.active {
  background: rgba(255,255,255,0.14);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}
.nav-link svg { width: 16px; height: 16px; opacity: 0.8; }

/* ─────────────────────────────────────────────────────────────
   Page layout
   ───────────────────────────────────────────────────────────── */
.page-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.page-sub {
  font-size: 0.92rem;
  color: var(--ink-500);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.02em;
}
.section-sub {
  font-size: 0.88rem;
  color: var(--ink-500);
  margin-top: 0.15rem;
}

/* ─────────────────────────────────────────────────────────────
   Cards
   ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  border: 1px solid var(--ink-100);
}
.card-h {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ink-100);
  font-weight: 600; font-size: 0.95rem;
  color: var(--ink-900);
  display: flex; align-items: center; justify-content: space-between;
  letter-spacing: -0.01em;
}
.card-h-icon { display: inline-flex; align-items: center; gap: 0.5rem; }
.card-h-icon svg { width: 18px; height: 18px; color: var(--ink-500); }

/* ─────────────────────────────────────────────────────────────
   KPI cards
   ───────────────────────────────────────────────────────────── */
.kpi {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--sh-1);
  border: 1px solid var(--ink-100);
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.kpi-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  margin-bottom: 0.85rem;
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-label {
  font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-500);
  font-weight: 600;
}
.kpi-val {
  font-size: 2.1rem; font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.03em;
  line-height: 1.05; margin-top: 0.1rem;
}
.kpi-sub {
  font-size: 0.78rem; color: var(--ink-500);
  margin-top: 0.4rem; line-height: 1.3;
}

.kpi--brand .kpi-icon { background: #e0e7ff; color: #4338ca; }
.kpi--brand .kpi-val { color: var(--brand-700); }
.kpi--accent .kpi-icon { background: #cffafe; color: var(--accent-700); }
.kpi--accent .kpi-val { color: var(--accent-700); }
.kpi--warning .kpi-icon { background: var(--warning-bg); color: var(--warning); }
.kpi--warning .kpi-val { color: #b45309; }
.kpi--danger .kpi-icon { background: var(--danger-bg); color: var(--danger); }
.kpi--danger .kpi-val { color: var(--danger); }
.kpi--success .kpi-icon { background: var(--success-bg); color: #047857; }
.kpi--success .kpi-val { color: #047857; }

/* ─────────────────────────────────────────────────────────────
   Pills & chips
   ───────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.pill-Done       { background: #dcfce7; color: #166534; }
.pill-In\ Progress { background: var(--warning-bg); color: #92400e; }
.pill-On\ Hold     { background: #ffe4e6; color: #9f1239; }
.pill-To-Do      { background: #dbeafe; color: #1e40af; }
.pill-Backlog    { background: var(--ink-100); color: var(--ink-600); }
.pill-P0  { background: #dc2626; color: #fff; }
.pill-P1  { background: #ea580c; color: #fff; }
.pill-P2  { background: #fbbf24; color: var(--ink-900); }
.pill-P3  { background: var(--ink-400); color: #fff; }
.pill-overdue { background: #fee2e2; color: var(--danger); }

/* Brand / project chip */
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.18rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem; font-weight: 600;
  border: 1px solid;
  white-space: nowrap; max-width: 14rem;
  overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, currentColor 8%, white);
  border-color: color-mix(in srgb, currentColor 25%, white);
}
.chip::before {
  content: ""; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────
   Tables
   ───────────────────────────────────────────────────────────── */
table { border-collapse: separate; border-spacing: 0; }

thead th {
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-500);
  padding: 0.65rem 0.85rem;
  background: var(--ink-50);
  border-bottom: 1px solid var(--ink-100);
  text-align: left;
  white-space: nowrap;
}
thead th.num, thead th.right { text-align: right; }
thead th.center { text-align: center; }
thead.sticky th { position: sticky; top: 0; z-index: 5; }

tbody td {
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  color: var(--ink-800);
  border-top: 1px solid var(--ink-100);
  vertical-align: middle;
  text-align: left;
}
tbody td.num, tbody td.right { text-align: right; font-variant-numeric: tabular-nums; }
tbody td.center { text-align: center; }
tbody td.muted { color: var(--ink-500); }

tr.task-row { transition: background 0.12s; }
tr.task-row:hover { background: var(--surface-hover); }
.row-overdue { background: #fff7f7 !important; }
.row-overdue:hover { background: #fff0f0 !important; }

/* New row HTMX insertion animation */
@keyframes flash-in {
  0%   { background: var(--success-bg); transform: translateY(-2px); opacity: 0.6; }
  60%  { background: var(--success-bg); }
  100% { background: transparent; transform: translateY(0); opacity: 1; }
}
tr.task-row.htmx-added { animation: flash-in 0.7s ease; }

/* Section group separator (Tasks page) */
tr.group-row td {
  background: var(--ink-50);
  padding: 0.45rem 0.85rem;
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-500);
  font-weight: 700;
  border-top: 1px solid var(--ink-200);
  border-bottom: 1px solid var(--ink-200);
}
tr.group-row.first td { border-top: 0; }

/* Quick-add row (Tasks) */
tr.quick-add-row td {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  padding: 0.65rem 0.85rem;
  border-bottom: 2px solid #fbbf24;
}
tr.quick-add-row input,
tr.quick-add-row select {
  font-size: 0.86rem; padding: 0.4rem 0.65rem;
  background: white;
}
tr.quick-add-row input[name="title"] { font-weight: 500; }

/* ─────────────────────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────────────────────── */
input[type=text], input[type=date], input[type=password],
input[type=number], select, textarea {
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--r-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--ink-900);
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-600);
  box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--ink-400); }

/* Tighter inputs in toolbars */
input.compact, select.compact { padding: 0.35rem 0.6rem; font-size: 0.85rem; }

label.field-label {
  display: block;
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: 0.35rem;
}
label.field-label .opt {
  font-weight: 400; text-transform: none;
  letter-spacing: 0; color: var(--ink-400);
}
.field-help {
  font-size: 0.72rem; color: var(--ink-400);
  margin-top: 0.35rem; line-height: 1.4;
}

/* ─────────────────────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: filter 0.12s, background 0.12s, transform 0.05s, box-shadow 0.12s;
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--brand-700); color: white; }
.btn-primary:hover { background: var(--brand-600); }

.btn-teal { background: var(--accent-600); color: white; }
.btn-teal:hover { background: var(--accent-700); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.05); }

.btn-ghost {
  background: transparent;
  color: var(--ink-700);
  border-color: var(--ink-200);
}
.btn-ghost:hover { background: var(--ink-50); border-color: var(--ink-300); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.05); }

.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.78rem; }
.btn-icon { padding: 0.4rem; }

/* ─────────────────────────────────────────────────────────────
   Standup grid
   ───────────────────────────────────────────────────────────── */
.standup-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
}
.standup-grid th, .standup-grid td {
  border: 1px solid var(--ink-200);
  padding: 0; vertical-align: top;
}
.standup-grid th {
  background: var(--brand-700);
  color: white;
  font-weight: 600;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  position: sticky;
  text-align: center;
  letter-spacing: -0.005em;
}
.standup-grid thead tr:nth-child(1) th { top: 0;     z-index: 6; background: var(--brand-700); }
.standup-grid thead tr:nth-child(2) th { top: 32px;  z-index: 5; background: #2a3d63; }
.standup-grid thead tr:nth-child(3) th { top: 64px;  z-index: 4; background: #4a5c7a; font-weight: 500; }
.standup-grid th.sub { background: #2a3d63; font-weight: 500; }
.standup-grid th.subtrack { background: #4a5c7a; font-weight: 500; }

.standup-grid td.date-cell {
  background: var(--brand-700); color: white;
  font-weight: 600; text-align: center;
  vertical-align: middle; min-width: 96px;
  padding: 0.6rem 0.7rem;
  position: sticky; left: 0; z-index: 3;
}
.standup-grid td.date-cell.today { background: var(--accent-600); }
.standup-grid td.date-cell .small {
  font-size: 0.66rem; opacity: 0.75;
  text-transform: uppercase; letter-spacing: 0.08em;
}

.standup-grid td.kind {
  font-weight: 600; text-align: center;
  padding: 0.5rem 0.6rem; min-width: 80px;
  font-size: 0.78rem;
  position: sticky; left: 96px; z-index: 2;
}
.kind-Update { background: #dbeafe; color: #1e40af; }
.kind-To-Do  { background: #fef3c7; color: #92400e; }
.kind-Done   { background: #dcfce7; color: #166534; }

.standup-grid td.cell {
  min-width: 240px; max-width: 320px;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem; line-height: 1.45;
  cursor: text; white-space: pre-wrap;
  background: var(--surface);
  text-align: left;
}
.standup-grid td.cell:hover { background: var(--surface-hover); }
.standup-grid td.cell.today { background: #fffbeb; }
.standup-grid td.cell.today:hover { background: #fef3c7; }
.standup-grid tbody tr.today td.date-cell { box-shadow: inset 2px 0 0 #fbbf24; }

textarea.cell-edit {
  width: 100%; height: 100%; min-height: 80px;
  border: 0; padding: 0.55rem 0.7rem;
  resize: none; font-family: inherit;
  font-size: 0.85rem; line-height: 1.45;
  background: var(--surface);
  color: var(--ink-900);
}
textarea.cell-edit:focus { box-shadow: inset 0 0 0 2px var(--accent-600); }

.scroll-x { overflow-x: auto; overflow-y: visible; }

/* ─────────────────────────────────────────────────────────────
   Status pill dropdown (Tasks page)
   ───────────────────────────────────────────────────────────── */
.status-dropdown summary::-webkit-details-marker { display: none; }
.status-dropdown summary::marker { content: ""; }
.status-dropdown summary { list-style: none; cursor: pointer; }
.status-dropdown[open] summary { outline: 2px solid color-mix(in srgb, var(--accent-600) 20%, transparent); border-radius: 999px; }

/* Hide default <details> triangle for any popover */
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ""; }
details > summary { list-style: none; }

/* ─────────────────────────────────────────────────────────────
   Flash messages
   ───────────────────────────────────────────────────────────── */
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--r-md);
  margin-bottom: 1rem;
  font-size: 0.88rem;
  display: flex; align-items: center; gap: 0.5rem;
  box-shadow: var(--sh-1);
}
.flash-success { background: var(--success-bg); color: #065f46; }
.flash-error   { background: var(--danger-bg); color: #991b1b; }

/* ─────────────────────────────────────────────────────────────
   HTMX indicator
   ───────────────────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity 0.15s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* Smooth insert for HTMX-added rows */
[hx-swap-oob], .htmx-added {
  animation: flash-in 0.7s ease;
}

/* ─────────────────────────────────────────────────────────────
   Print
   ───────────────────────────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }
  body { background: white; }
}

/* ─────────────────────────────────────────────────────────────
   Utilities
   ───────────────────────────────────────────────────────────── */
.text-tabular { font-variant-numeric: tabular-nums; }
.text-tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-500); }
.muted-2 { color: var(--ink-400); }
