/* =====================================================================
   DAIT Partners — Prospect App
   Design tokens + components.

   Palette is taken from the DAIT mark: a ribbon running purple → rust →
   amber. In a tool where people read 526 rows at a time, that gradient
   is an accent, never a surface. Data sits on neutrals; the brand marks
   identity, state and emphasis.
   ===================================================================== */

:root {
  /* --- brand, sampled from the logo ------------------------------- */
  --brand-purple: #7b2d63;
  --brand-plum:   #5c2049;
  --brand-rust:   #a83c0c;
  --brand-amber:  #e4a83c;
  --brand-grad:   linear-gradient(135deg, #7b2d63 0%, #a83c0c 58%, #e4a83c 100%);

  /* --- neutrals (light) ------------------------------------------- */
  --bg:           #f5f6f8;
  --surface:      #ffffff;
  --surface-2:    #fafbfc;
  --surface-sunk: #f0f2f5;
  --border:       #e2e5ea;
  --border-strong:#cbd1da;
  --text:         #0f1319;
  --text-2:       #434d5b;   /* 7.1:1 on --surface */
  --text-3:       #5f6a7a;   /* 4.9:1 on --surface — the lightest text allowed */

  /* --- semantic ---------------------------------------------------- */
  --pos:        #0f7a53;
  --pos-bg:     #e6f4ee;
  --warn:       #9a5b00;
  --warn-bg:    #fdf2dd;
  --danger:     #b42318;
  --danger-bg:  #fdebe9;
  --info:       #2a5699;
  --info-bg:    #e9effa;

  /* --- categorical series: brand-derived, distinguishable, AA on both themes */
  --c1: #7b2d63;  --c2: #c25e2a;  --c3: #d9962c;
  --c4: #2f6f7e;  --c5: #5b6eae;  --c6: #7a8290;

  /* --- type -------------------------------------------------------- */
  /* Archivo/Inter come from Google Fonts over the network. The fallbacks
     are ordered so a cold offline launch still gets a grotesque with
     tabular figures rather than Times. See README: self-hosting the two
     woff2 files is the one step left for genuinely offline typography. */
  --font-display: 'Archivo', 'Segoe UI Variable Display', 'Segoe UI', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --font-body:    'Inter', 'Segoe UI Variable Text', 'Segoe UI', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', sans-serif;

  --t-xs:   0.6875rem;  /* 11px — badges, column labels only */
  --t-sm:   0.8125rem;  /* 13px — table cells, secondary */
  --t-base: 0.9375rem;  /* 15px */
  --t-md:   1.0625rem;
  --t-lg:   1.375rem;
  --t-xl:   1.875rem;
  --t-2xl:  2.5rem;

  /* --- space / radius / shadow ------------------------------------- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-full: 999px;

  --shadow-sm: 0 1px 2px rgba(15,19,25,.06), 0 1px 1px rgba(15,19,25,.04);
  --shadow:    0 2px 4px rgba(15,19,25,.05), 0 6px 16px -4px rgba(15,19,25,.08);
  --shadow-lg: 0 8px 32px -8px rgba(15,19,25,.18);

  /* --- z scale ------------------------------------------------------ */
  --z-nav: 20; --z-sticky: 30; --z-overlay: 40; --z-modal: 50; --z-toast: 60;

  --sidebar-w: 236px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

:root[data-theme="dark"] {
  --bg:           #0d1014;
  --surface:      #161a20;
  --surface-2:    #1b2027;
  --surface-sunk: #11151a;
  --border:       #272d36;
  --border-strong:#39414d;
  --text:         #e9ecf1;
  --text-2:       #b2bac6;
  --text-3:       #8d97a5;

  --pos:    #4ac795;  --pos-bg:    #0e2e22;
  --warn:   #e0a53f;  --warn-bg:   #332512;
  --danger: #f6837a;  --danger-bg: #3a1b18;
  --info:   #87aaf0;  --info-bg:   #18233a;

  --c1: #b269a0;  --c2: #e08a53;  --c3: #e8bb5e;
  --c4: #5aa5b5;  --c5: #8f9fdc;  --c6: #9aa3b1;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 2px 4px rgba(0,0,0,.3), 0 8px 20px -6px rgba(0,0,0,.5);
  --shadow-lg: 0 10px 36px -8px rgba(0,0,0,.65);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0d1014; --surface:#161a20; --surface-2:#1b2027; --surface-sunk:#11151a;
    --border:#272d36; --border-strong:#39414d;
    --text:#e9ecf1; --text-2:#b2bac6; --text-3:#8d97a5;
    --pos:#4ac795; --pos-bg:#0e2e22; --warn:#e0a53f; --warn-bg:#332512;
    --danger:#f6837a; --danger-bg:#3a1b18; --info:#87aaf0; --info-bg:#18233a;
    --c1:#b269a0; --c2:#e08a53; --c3:#e8bb5e; --c4:#5aa5b5; --c5:#8f9fdc; --c6:#9aa3b1;
    --shadow-sm:0 1px 2px rgba(0,0,0,.4);
    --shadow:0 2px 4px rgba(0,0,0,.3), 0 8px 20px -6px rgba(0,0,0,.5);
    --shadow-lg:0 10px 36px -8px rgba(0,0,0,.65);
  }
}

/* ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: 1.55;
  font-feature-settings: 'cv05' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 650; letter-spacing: -.015em; margin: 0; line-height: 1.2; }

/* Numbers must align in columns. */
.num, td.num, .kpi-value, .stat { font-variant-numeric: tabular-nums; }

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

:where(button, [role="button"], a[href], summary, label.chip, tr[role="link"], .hbar-row) { cursor: pointer; }
:where(button, [role="button"])[disabled] { cursor: not-allowed; }

:focus-visible {
  outline: 2px solid var(--brand-purple);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:root[data-theme="dark"] :focus-visible { outline-color: var(--brand-amber); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :focus-visible { outline-color: var(--brand-amber); }
}

/* go() focuses <main> so the skip link and keyboard navigation land in
   the right place. Chrome then paints a focus ring around the entire
   content area on every navigation, which reads as a stray rule rather
   than as feedback. The landmark role still announces to a screen
   reader, so suppress the ring on this one element only. */
#main:focus, #main:focus-visible { outline: none; }

.sr-only {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

.skip-link {
  position: absolute; left: var(--s3); top: -60px; z-index: var(--z-toast);
  background: var(--surface); color: var(--text);
  padding: var(--s2) var(--s4); border-radius: var(--r);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  transition: top .18s var(--ease);
}
.skip-link:focus { top: var(--s3); }

/* =====================================================================
   App shell
   ===================================================================== */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: var(--z-nav);
}

.brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s5) var(--s4) var(--s4); }
.brand svg, .brand-mark { flex: none; }
.brand-mark { width: auto; display: block; }
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: var(--t-md); letter-spacing: -.02em; line-height: 1; }
.brand-sub { font-size: var(--t-xs); color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }

.nav { padding: var(--s2) var(--s3); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); padding: var(--s4) var(--s3) var(--s2); font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s3); border-radius: var(--r-sm);
  background: none; border: 0; width: 100%; text-align: left;
  font-size: var(--t-sm); font-weight: 500; color: var(--text-2);
  transition: background-color .15s var(--ease), color .15s var(--ease);
  min-height: 40px;
}
.nav-item:hover { background: var(--surface-sunk); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-sunk); color: var(--text); font-weight: 600; position: relative; }
.nav-item[aria-current="page"]::after {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand-grad);
}
.nav-item svg { flex: none; opacity: .85; }
.nav-item .count { margin-left: auto; font-size: var(--t-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }

.nav-locked { opacity: .45; }
.nav-locked:hover { background: none; color: var(--text-2); cursor: not-allowed; }

.user-box { border-top: 1px solid var(--border); padding: var(--s3); }
.user-chip { display: flex; align-items: center; gap: var(--s3); width: 100%; background: none; border: 0; padding: var(--s2); border-radius: var(--r-sm); text-align: left; }
.user-chip:hover { background: var(--surface-sunk); }
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-full); flex: none;
  /* Stops short of the full amber: white initials over the amber end of
     the brand gradient measure ~3.5:1, under the 4.5:1 this text needs. */
  background: linear-gradient(135deg, #7b2d63 0%, #93340e 60%, #a55c18 100%);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: var(--t-xs); letter-spacing: .02em;
}
.user-chip > span:last-child { min-width: 0; }
.user-name { display: block; font-size: var(--t-sm); font-weight: 600; line-height: 1.25; }
.user-role { display: block; font-size: var(--t-xs); color: var(--text-3); line-height: 1.2; }

/* --- top bar -------------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.topbar h1 { font-size: var(--t-lg); }
.topbar-sub { font-size: var(--t-sm); color: var(--text-3); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.content { padding: var(--s5); max-width: 1480px; width: 100%; }

/* =====================================================================
   Controls
   ===================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s4);
  border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-size: var(--t-sm); font-weight: 550;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--surface-sunk); border-color: var(--text-3); }
.btn-primary { background: var(--brand-purple); border-color: var(--brand-purple); color: #fff; }
.btn-primary:hover { background: var(--brand-plum); border-color: var(--brand-plum); color: #fff; }
.btn-icon { width: 40px; padding: 0; }
/* En la barra superior son hijos de un flex apretado: sin esto se
   encogen a 19px cuando el ancho no alcanza, y en un teléfono eso es
   un objetivo que no se acierta. Afecta a la campana, a la cuenta y al
   interruptor de tema. */
.topbar-actions .btn-icon { flex: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { position: relative; display: flex; align-items: center; }
.field svg { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input, .select {
  min-height: 40px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  padding: 0 var(--s3); font-size: var(--t-sm); width: 100%;
  transition: border-color .15s var(--ease);
}
.input:hover, .select:hover { border-color: var(--text-3); }
.field .input { padding-left: 34px; }
.select { padding-right: var(--s5); appearance: none;
  background-image: linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%);
  background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.filters { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.filters .field { min-width: 240px; flex: 1 1 240px; max-width: 400px; }
/* Selects size to their content. Without this they each take a full row
   and five filters push the table off the first screen. */
.filters .select { flex: 0 1 auto; width: auto; min-width: 128px; max-width: 220px; }
.sector-select { min-width: 200px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 var(--s3);
  border-radius: var(--r-full); border: 1px solid var(--border-strong);
  background: var(--surface); font-size: var(--t-sm); font-weight: 500;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.chip:hover { background: var(--surface-sunk); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .7; }

/* =====================================================================
   Cards, KPI tiles
   ===================================================================== */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: baseline; gap: var(--s3); padding: var(--s4) var(--s5) 0; }
.card-head h3 { font-size: var(--t-base); font-weight: 650; }
.card-head .hint { font-size: var(--t-xs); color: var(--text-3); margin-left: auto; }
.card-body { padding: var(--s4) var(--s5) var(--s5); }

/* minmax(0,1fr), not 1fr: a grid item's default min-width is auto, so a
   long unbroken label pushes the whole grid past the viewport. */
.grid { display: grid; gap: var(--s4); }
.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* align-items:start so a short card beside a tall one does not stretch
   into a panel of dead white space. */
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }

.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 2px; min-height: 104px;
  position: relative; overflow: hidden;
}
.kpi-label {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650;
}
.kpi-value { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-top: 2px; }
.kpi-note { font-size: var(--t-xs); color: var(--text-3); margin-top: auto; }
.kpi-accent::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand-grad);
}
.kpi-zero .kpi-value { color: var(--text-3); }

/* =====================================================================
   Charts (inline SVG, no library)
   ===================================================================== */

.hbar { display: flex; flex-direction: column; gap: 2px; }
.hbar-row {
  display: grid; grid-template-columns: minmax(96px, 34%) 1fr auto;
  gap: var(--s3); align-items: center;
  padding: 5px var(--s2); border-radius: var(--r-sm);
  background: none; border: 0; width: 100%; text-align: left;
  transition: background-color .15s var(--ease);
}
button.hbar-row:hover { background: var(--surface-sunk); }
.hbar-label { font-size: var(--t-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: block; height: 10px; border-radius: var(--r-full); background: var(--surface-sunk); overflow: hidden; }
/* display:block matters — as an inline span the fill collapses to nothing
   and every bar renders empty. */
.hbar-fill { display: block; height: 100%; border-radius: var(--r-full); transition: width .5s var(--ease); }
.hbar-val { font-size: var(--t-sm); font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; min-width: 42px; text-align: right; }
.hbar-val .pct { font-weight: 400; color: var(--text-3); font-size: var(--t-xs); margin-left: 4px; }

.funnel { display: flex; flex-direction: column; gap: 3px; }
.funnel-step { display: grid; grid-template-columns: minmax(104px,32%) 1fr auto; gap: var(--s3); align-items: center; }
.funnel-bar { display: block; height: 28px; border-radius: var(--r-sm); position: relative; background: var(--surface-sunk); overflow: hidden; }
.funnel-fill { height: 100%; border-radius: var(--r-sm); display: flex; align-items: center; padding-left: var(--s2); }
.funnel-fill:empty { padding: 0; }   /* a zero-count stage shows nothing, not a stub */
.funnel-fill span { font-size: var(--t-xs); font-weight: 650; color: #fff; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s3); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--text-2); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.stack { display: flex; height: 32px; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-sunk); }
.stack-seg { transition: filter .15s var(--ease); min-width: 2px; }
.stack-seg:hover { filter: brightness(1.12); }

.donut-wrap { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.donut-center { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- score ring ----------------------------------------------------- */
.score { position: relative; width: 38px; height: 38px; flex: none; }
.score svg { transform: rotate(-90deg); display: block; }
.score-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: var(--t-xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.score-lg { width: 72px; height: 72px; }
.score-lg .score-num { font-size: var(--t-md); }

/* =====================================================================
   Badges
   ===================================================================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: var(--t-xs); font-weight: 650; letter-spacing: .01em;
  white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.badge-none::before { display: none; }

.b-act1 { background: var(--brand-purple); color: #fff; }
.b-act2 { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.b-act3 { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.b-act4 { background: var(--surface-sunk); color: var(--text-3); border-color: var(--border); }
.b-act5 { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.b-act0 { background: var(--pos-bg); color: var(--pos); border-color: color-mix(in srgb, var(--pos) 25%, transparent); }

.b-high   { background: var(--brand-purple); color: #fff; }
.b-medium { background: var(--warn-bg); color: var(--warn); }
.b-low    { background: var(--surface-sunk); color: var(--text-3); }

.b-pos { background: var(--pos-bg); color: var(--pos); }
.b-neu { background: var(--surface-sunk); color: var(--text-2); }
.b-warn{ background: var(--warn-bg); color: var(--warn); }
.b-dang{ background: var(--danger-bg); color: var(--danger); }

.b-lock { background: var(--surface-sunk); color: var(--text-3); border-color: var(--border); }

/* =====================================================================
   Table
   ===================================================================== */

/* The wrapper is the scroll container in both axes, so the sticky header
   anchors to IT, not the viewport. top:0 is therefore correct; an offset
   here pushes the header down over the first row. */
.table-wrap {
  overflow: auto; max-height: calc(100vh - 210px);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); overscroll-behavior: contain;
}
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  text-align: left; font-weight: 650; font-size: var(--t-xs);
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  padding: var(--s3) var(--s3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
/* Desktop-only control: thead is replaced by cards below 860px, so these
   never become touch targets. 32px is the comfortable size here. */
thead th button { background: none; border: 0; padding: 7px 0; margin: -7px 0; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
thead th button:hover { color: var(--text); }
tbody td { padding: var(--s3); border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover { background: var(--surface-sunk); }
.cell-company { font-weight: 600; color: var(--text); }
.cell-sub { font-size: var(--t-xs); color: var(--text-3); }
.t-right { text-align: right; }

/* =====================================================================
   Detail view
   ===================================================================== */

.detail-head { display: flex; gap: var(--s5); align-items: flex-start; flex-wrap: wrap; margin-bottom: var(--s5); }
.detail-title { flex: 1 1 320px; min-width: 0; }
.detail-title h2 { font-size: var(--t-xl); letter-spacing: -.025em; }
.detail-meta { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-top: var(--s2); color: var(--text-3); font-size: var(--t-sm); }
.detail-meta a { color: var(--info); text-decoration: none; }
.detail-meta a:hover { text-decoration: underline; }

.detail-grid { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: var(--s4); align-items: start; }

.brief { border-left: 3px solid transparent; border-image: var(--brand-grad) 1; }
.brief dt { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 650; margin-top: var(--s4); }
.brief dt:first-of-type { margin-top: 0; }
.brief dd { margin: var(--s1) 0 0; font-size: var(--t-base); line-height: 1.6; }
.brief .hook { font-size: var(--t-md); font-weight: 500; }

.kv { display: grid; grid-template-columns: minmax(96px,34%) 1fr; gap: var(--s2) var(--s3); font-size: var(--t-sm); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.contact-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.contact-row:last-child { border-bottom: 0; }

.score-row { display: flex; gap: var(--s4); align-items: flex-start; padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.score-row:last-child { border-bottom: 0; }

.locked-note {
  display: flex; gap: var(--s2); align-items: flex-start;
  background: var(--surface-sunk); border: 1px dashed var(--border-strong);
  border-radius: var(--r); padding: var(--s3); font-size: var(--t-sm); color: var(--text-3);
}
.locked-note svg { flex: none; margin-top: 2px; }

/* =====================================================================
   States
   ===================================================================== */

.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--text-3); }
.empty svg { opacity: .4; margin-bottom: var(--s3); }
.empty h3 { font-size: var(--t-base); color: var(--text-2); margin-bottom: var(--s1); }
.empty p { font-size: var(--t-sm); margin: 0; max-width: 42ch; margin-inline: auto; }

.skeleton { background: var(--surface-sunk); border-radius: var(--r-sm); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .5 } }

.toast {
  position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%) translateY(120%);
  z-index: var(--z-toast);
  background: var(--text); color: var(--bg);
  padding: var(--s3) var(--s5); border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 550; box-shadow: var(--shadow-lg);
  transition: transform .3s var(--ease); max-width: calc(100vw - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* =====================================================================
   Responsive
   ===================================================================== */

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; inset: auto 0 0 0; height: auto; width: 100%;
    flex-direction: row; border-right: 0; border-top: 1px solid var(--border);
    padding: var(--s1) var(--s2) calc(var(--s1) + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }
  .brand, .user-box, .nav-label { display: none; }
  .nav { flex-direction: row; padding: 0; gap: 0; overflow: visible; }
  .nav-item {
    flex: 1 1 0; min-width: 0;
    flex-direction: column; gap: 3px; justify-content: center;
    padding: var(--s2) 2px; font-size: 10px; min-height: 52px; text-align: center;
  }
  .nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-item .count { display: none; }
  /* Seven tabs do not fit a 375px bar — the admin screens move behind
     a "More" sheet and the four daily screens keep their slots. */
  .nav-item.admin-only { display: none; }
  .nav-more { display: flex !important; }
  .admin-sheet {
    position: fixed; z-index: var(--z-overlay);
    left: var(--s3); right: var(--s3); bottom: calc(60px + env(safe-area-inset-bottom));
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--s2);
  }
  .admin-sheet .nav-item { flex-direction: row; font-size: var(--t-sm); min-height: 44px; text-align: left; padding: var(--s2) var(--s3); }
  .admin-sheet .nav-item span { white-space: normal; }


  .nav-item[aria-current="page"]::after { left: 50%; top: 0; bottom: auto; transform: translateX(-50%); width: 22px; height: 3px; border-radius: 0 0 3px 3px; }

  .content { padding: var(--s4) var(--s4) 84px; }
  .topbar { padding: var(--s3) var(--s4); gap: var(--s2); min-height: 56px; }
  .topbar h1 { font-size: var(--t-md); }
  /* A 200px sector select plus the title overflows a 375px bar. */
  .topbar > div:first-child, .topbar-actions { min-width: 0; }
  .topbar-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sector-select { min-width: 0; max-width: 148px; }
  .g2 { grid-template-columns: 1fr; }
  .filters .field { min-width: 100%; max-width: none; }

  /* Tables become cards — a 10-column table cannot survive 375px. */
  .cards-on-mobile thead { display: none; }
  .cards-on-mobile, .cards-on-mobile tbody, .cards-on-mobile tr, .cards-on-mobile td { display: block; width: 100%; }
  .cards-on-mobile tr {
    border: 1px solid var(--border); border-radius: var(--r);
    margin-bottom: var(--s2); padding: var(--s3); background: var(--surface);
  }
  .cards-on-mobile td { border: 0; padding: 3px 0; }
  /* Grid, not an inline ::before — otherwise a two-line value wraps back
     under the label and the card reads as broken text. */
  .cards-on-mobile td[data-label] {
    display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: var(--s2);
    align-items: baseline; justify-items: start; padding: 4px 0;
  }
  .cards-on-mobile td[data-label]::before {
    content: attr(data-label);
    font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-3); font-weight: 650;
  }
  .cards-on-mobile .td-main { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }
  .table-wrap { border: 0; background: none; overflow: visible; max-height: none; }
}

@media (min-width: 861px) {
  .nav-more, .admin-sheet { display: none !important; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: var(--s2); }
  .kpi { padding: var(--s3); min-height: 86px; }
  .kpi-value { font-size: var(--t-lg); }
}

/* Touch devices get bigger targets everywhere it matters, without
   inflating the same controls for a mouse. */
@media (pointer: coarse) {
  .day-meta button.badge { min-height: 34px; padding: 0 14px; }
  .icon-btn { width: 40px; height: 40px; }
  .tickbox { width: 26px; height: 26px; }
  .tickbox::after { inset: -9px; }
  .chip { min-height: 40px; padding: 0 var(--s4); }
  .seg button { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .topbar-actions, .filters { display: none; }
  .app { grid-template-columns: 1fr; }
}

/* =====================================================================
   Calendar
   The month grid is a real grid of buttons: each day is one tab stop,
   arrow keys move between days, so the whole month is reachable without
   a mouse. Markers encode source by colour and state by weight.
   ===================================================================== */

.cal-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: var(--s4); align-items: start; }

.cal-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s4); flex-wrap: wrap; }
.cal-month { font-family: var(--font-display); font-size: var(--t-lg); font-weight: 650; letter-spacing: -.02em; min-width: 190px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650; text-align: center; padding-bottom: var(--s2);
}
.cal-day {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  min-height: 84px; padding: 6px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  text-align: left; font: inherit; overflow: hidden;
  transition: background-color .12s var(--ease), border-color .12s var(--ease);
}
.cal-day:hover { background: var(--surface-sunk); border-color: var(--border-strong); }
.cal-day[aria-pressed="true"] { border-color: var(--brand-purple); box-shadow: inset 0 0 0 1px var(--brand-purple); }
.cal-day.other-month { background: var(--surface-sunk); opacity: .55; }
.cal-day.is-today .cal-daynum {
  background: var(--brand-purple); color: #fff; border-radius: var(--r-full);
  width: 22px; height: 22px; display: grid; place-items: center; margin-left: -3px; flex: none;
}
.cal-daynum { font-size: var(--t-sm); font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-day.is-weekend:not(.other-month) { background: var(--surface-2); }

.cal-pill {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; line-height: 1.3; padding: 2px 5px; border-radius: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--surface-sunk); color: var(--text-2);
}
.cal-pill .dot { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.cal-pill.done { opacity: .5; text-decoration: line-through; }
.cal-more { font-size: 10px; color: var(--text-3); padding-left: 5px; }

.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; }
.cal-count {
  flex: none;
  font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--danger); background: var(--danger-bg);
  border-radius: var(--r-full); padding: 1px 5px;
}

/* --- day panel ------------------------------------------------------- */
.day-panel { position: sticky; top: 80px; }
.day-list { display: flex; flex-direction: column; gap: var(--s3); }

.day-item {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3); border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface-2);
}
.day-item.is-done { opacity: .62; }
.day-item.is-done .day-title { text-decoration: line-through; }
.day-item.from-crm { border-left: 3px solid var(--c4); }
.day-item.is-overdue { border-left: 3px solid var(--danger); }
.day-title { font-size: var(--t-sm); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.day-body { font-size: var(--t-sm); color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.day-meta { font-size: var(--t-xs); color: var(--text-3); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.day-meta button.badge { min-height: 26px; padding: 0 10px; }
.day-actions { margin-left: auto; display: flex; gap: 2px; flex: none; }
.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: var(--r-sm); border: 0; background: none; color: var(--text-3);
  transition: background-color .12s var(--ease), color .12s var(--ease);
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

.tickbox {
  position: relative;
  width: 24px; height: 24px; flex: none; margin-top: 1px;
  border-radius: 6px; border: 1.5px solid var(--border-strong);
  background: var(--surface); display: grid; place-items: center; color: transparent;
  transition: background-color .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
/* The box stays 24px because a bigger one would dominate the row, but the
   thing you actually hit is 44px. Nothing clickable sits inside that
   margin, so the expansion steals no other target. */
.tickbox::after { content: ''; position: absolute; inset: -10px; }
.tickbox:hover { border-color: var(--brand-purple); }
.tickbox[aria-pressed="true"] { background: var(--pos); border-color: var(--pos); color: #fff; }

/* --- entry form ------------------------------------------------------ */
.entry-form { display: flex; flex-direction: column; gap: var(--s3); }
.entry-form label { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; display: block; margin-bottom: 4px; }
.entry-form textarea { min-height: 64px; resize: vertical; padding: var(--s2) var(--s3); line-height: 1.5; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg button {
  border: 0; background: var(--surface); padding: 0 var(--s3); min-height: 36px;
  font-size: var(--t-sm); font-weight: 550; color: var(--text-2);
  transition: background-color .12s var(--ease), color .12s var(--ease);
}
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); }

.legend-cal { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); }

@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: 1fr; }
  .day-panel { position: static; }
}
@media (max-width: 860px) {
  .cal-day { min-height: 56px; padding: 5px; gap: 2px; }
  /* No room for titles at this width. "+3 more" with nothing to be more
     THAN is worse than nothing, so the cell carries dots and a count. */
  .cal-pill, .cal-more { display: none; }
  .cal-dot-row { display: flex; gap: 3px; flex-wrap: wrap; margin-top: auto; }
  .cal-dot-row span { width: 6px; height: 6px; border-radius: 50%; }
  .cal-total { font-size: 10px; font-weight: 650; color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }
  .cal-count { padding: 1px 4px; }
  .cal-month { font-size: var(--t-md); min-width: 0; }
  .cal-count { font-size: 9px; padding: 0 4px; }
  .cal-head { gap: var(--s2) 6px; }

  /* Below this width the bottom-nav layout already assumes a finger, and
     the width query is reliable where `pointer: coarse` is not. */
  .day-meta button.badge { min-height: 34px; padding: 0 14px; }
  .icon-btn { width: 40px; height: 40px; }
  .tickbox { width: 26px; height: 26px; }
  .tickbox::after { inset: -9px; }
  .chip { min-height: 40px; padding: 0 var(--s4); }
  .seg button { min-height: 44px; }
}
@media (min-width: 861px) { .cal-total { display: none; } }
@media (min-width: 861px) { .cal-dot-row { display: none; } }

/* =====================================================================
   Assignments
   Two halves: who is carrying what, and the pool to hand out. The action
   bar is fixed to the bottom because the selection is made by scrolling
   a long table — a button at the top would leave the screen the moment
   you started choosing.
   ===================================================================== */

.load-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s4); }

.load-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s4); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--s3);
}
.load-card.is-target { border-color: var(--brand-purple); box-shadow: inset 0 0 0 1px var(--brand-purple); }
.load-head { display: flex; align-items: center; gap: var(--s3); }
/* Both are spans inside a span: without display:block they render as
   "Carlos TorresAdministrator". */
.load-head > span:nth-child(2) { min-width: 0; }
.load-name { display: block; font-weight: 650; font-size: var(--t-base); line-height: 1.25; }
.load-role { display: block; font-size: var(--t-xs); color: var(--text-3); line-height: 1.2; }
.load-total { margin-left: auto; text-align: right; }
.load-total b { font-family: var(--font-display); font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; display: block; line-height: 1; }
.load-total span { font-size: var(--t-xs); color: var(--text-3); }

.load-bar { display: flex; height: 8px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-sunk); }
.load-bar span { display: block; }

.load-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.load-stat { text-align: center; padding: var(--s2) 4px; border-radius: var(--r-sm); background: var(--surface-sunk); }
.load-stat b { display: block; font-size: var(--t-base); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.load-stat span { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.load-stat.alert b { color: var(--danger); }

/* --- selection table -------------------------------------------------- */
.pick-col { width: 42px; }
tbody tr.is-picked { background: color-mix(in srgb, var(--brand-purple) 7%, var(--surface)); }
tbody tr.is-picked:hover { background: color-mix(in srgb, var(--brand-purple) 11%, var(--surface)); }

.selectall-note {
  display: flex; align-items: center; justify-content: center; gap: var(--s3);
  flex-wrap: wrap; padding: var(--s3);
  background: var(--info-bg); color: var(--info);
  font-size: var(--t-sm); font-weight: 550;
  border-bottom: 1px solid var(--border);
}
.selectall-note button { background: none; border: 0; font: inherit; text-decoration: underline; color: inherit; }

/* --- the action bar --------------------------------------------------- */
/* Fixed, not sticky: sticky keeps an element from scrolling away, but it
   cannot pull one that starts below the fold into view — and with the
   workload cards above it, that is exactly where it starts. */
.assign-bar {
  position: fixed; z-index: var(--z-sticky);
  left: calc(var(--sidebar-w) + var(--s5)); right: var(--s5); bottom: var(--s4);
  max-width: calc(1480px - var(--s5) * 2);
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  margin-top: var(--s4);
  padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
/* With nothing selected this is a hint, not an action — pinning it to the
   bottom of the screen would cover a row of the table permanently. */
.assign-bar.is-idle {
  position: static; max-width: none; box-shadow: none; border-style: dashed;
  justify-content: center; color: var(--text-3);
}
/* Room so the fixed bar never covers the last row. */
.assign-spacer { height: 84px; }
.assign-bar .count { font-weight: 650; font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.assign-bar .spacer { flex: 1 1 auto; }
.assign-bar .select { min-width: 150px; width: auto; }
.assign-bar label { font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; }

@media (max-width: 860px) {
  /* A row of label-then-control wraps into orphaned labels at this width.
     Two columns instead: count + Clear, then the two choices, then the
     action across the bottom. */
  .assign-bar {
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2);
    align-items: center;
    left: var(--s3); right: var(--s3); bottom: calc(64px + env(safe-area-inset-bottom));
    max-width: none; padding: var(--s3);
  }
  .assign-spacer { height: 150px; }
  .assign-bar .spacer { display: none; }
  .assign-bar .select, .assign-bar .btn, .assign-bar .chip { width: 100%; min-width: 0; }
  .assign-bar .btn-primary { grid-column: 1 / -1; }
  .assign-bar .cell-sub { grid-column: 1 / -1; }
  /* sr-only, not display:none — hiding a label outright takes it out of
     the accessibility tree and leaves the selects unnamed. */
  .assign-bar label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .load-stats { grid-template-columns: repeat(3, 1fr); }
}

/* =====================================================================
   Account picker
   Cycling through accounts on click worked with two. With four it means
   clicking three times to reach the one you want, so it is a menu.
   ===================================================================== */

.sheet-backdrop {
  position: fixed; inset: 0; border: 0;
  z-index: calc(var(--z-overlay) - 1); background: rgba(0,0,0,.3);
}
.sheet-backdrop.under-sidebar { background: transparent; }

/* The picker is a child of .app, not of .sidebar: the sidebar is its own
   stacking context, and on a phone it is display:none, which would leave
   no way to switch account at all. */

.user-menu {
  position: fixed; z-index: var(--z-overlay);
  left: var(--s3); width: calc(var(--sidebar-w) - var(--s3) * 2); bottom: 76px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: var(--s2); display: flex; flex-direction: column; gap: 2px;
}
.user-menu-label {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650; padding: var(--s2) var(--s2) var(--s1);
}
.user-opt {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: var(--s2); border: 0; background: none;
  border-radius: var(--r-sm); text-align: left; min-height: 44px;
  transition: background-color .12s var(--ease);
}
.user-opt:hover { background: var(--surface-sunk); }
.user-opt[aria-current="true"] { background: var(--surface-sunk); }
.user-opt .avatar { width: 28px; height: 28px; font-size: 10px; }
.user-opt-name { display: block; font-size: var(--t-sm); font-weight: 600; line-height: 1.25; }
.user-opt-role { display: block; font-size: var(--t-xs); color: var(--text-3); line-height: 1.2; }
.user-opt .tick { margin-left: auto; color: var(--pos); flex: none; }

/* Shown only where the sidebar's own chip is hidden. */
.topbar-account { display: none; }

@media (max-width: 860px) {
  /* The sidebar is the bottom bar here, so the picker hangs off a button
     in the top bar instead. */
  .user-menu { left: var(--s3); right: var(--s3); width: auto; bottom: auto; top: 60px; max-width: 420px; margin-inline: auto; }
  .topbar-account { display: grid; width: 40px; height: 40px; padding: 0; place-items: center; }
  .topbar-account .avatar { width: 28px; height: 28px; font-size: 10px; }
}

/* =====================================================================
   Sign in
   ===================================================================== */

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-left)) ;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: var(--s6) var(--s5) var(--s5);
}
.auth-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); }
.auth-card h1 { font-size: var(--t-lg); margin-bottom: var(--s1); }
.auth-card .sub { font-size: var(--t-sm); color: var(--text-3); margin: 0 0 var(--s5); }
.auth-field { margin-bottom: var(--s4); }
.auth-field label {
  display: block; font-size: var(--t-xs); text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); font-weight: 650; margin-bottom: 5px;
}
.auth-card .btn-primary { width: 100%; min-height: 44px; margin-top: var(--s2); }
.auth-error {
  display: flex; gap: var(--s2); align-items: flex-start;
  background: var(--danger-bg); color: var(--danger);
  border-radius: var(--r-sm); padding: var(--s3);
  font-size: var(--t-sm); margin-bottom: var(--s4);
}
.auth-error svg { flex: none; margin-top: 2px; }
.auth-note { font-size: var(--t-xs); color: var(--text-3); margin: var(--s5) 0 0; line-height: 1.5; }

.mode-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--t-xs); font-weight: 650;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--warn-bg); color: var(--warn);
}

/* =====================================================================
   Avisos
   ===================================================================== */

.notif-btn { position: relative; }
.notif-dot {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: var(--r-full);
  background: var(--brand-purple); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  font-variant-numeric: tabular-nums;
  /* Un aro del color de la barra, para que el contador se despegue del
     icono en vez de mezclarse con sus trazos. */
  box-shadow: 0 0 0 2px var(--bg);
}

.notif-menu {
  position: fixed; z-index: var(--z-overlay);
  top: 60px; right: var(--s5); width: min(360px, calc(100vw - var(--s4) * 2));
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: var(--s2); display: flex; flex-direction: column; gap: 2px;
  max-height: min(70vh, 560px); overflow-y: auto;
}
.notif-head {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650; padding: var(--s2) var(--s2) var(--s1);
}
.notif-item {
  display: flex; align-items: flex-start; gap: var(--s3); text-align: left;
  width: 100%; padding: var(--s3); border: 0; border-radius: var(--r-md);
  background: none; color: inherit; cursor: pointer; font: inherit;
  position: relative;
}
.notif-item:hover { background: var(--surface-2); }
/* Lo no leído se marca con una barra, no con color de fondo: el fondo ya
   lo usa el hover y los dos juntos se pelean. */
.notif-item.is-new::before {
  content: ''; position: absolute; inset: var(--s3) auto var(--s3) 0; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand-grad);
}
.notif-item.is-new { padding-left: calc(var(--s3) + 6px); }
.notif-i { flex: none; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: var(--r-full); background: var(--surface-2); color: var(--text-3); }
.tone-new  .notif-i { background: color-mix(in srgb, var(--brand-purple) 14%, var(--surface)); color: var(--brand-purple); }
.tone-today .notif-i { background: color-mix(in srgb, var(--brand-amber) 20%, var(--surface)); color: var(--brand-rust); }
.tone-late .notif-i { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.notif-body { min-width: 0; display: block; }
.notif-title { display: block; font-weight: 600; font-size: var(--t-sm); line-height: 1.3; }
.notif-sub {
  display: block; font-size: var(--t-xs); color: var(--text-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notif-empty { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s3);
  font-size: var(--t-sm); color: var(--text-3); }
.notif-empty-i { flex: none; display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--r-full); background: var(--surface-2); color: var(--ok, var(--text-3)); }
.notif-foot {
  font-size: var(--t-xs); color: var(--text-3);
  padding: var(--s2) var(--s2) var(--s1); border-top: 1px solid var(--border); margin-top: var(--s2);
}

@media (max-width: 760px) {
  .notif-menu { left: var(--s3); right: var(--s3); width: auto; max-width: 420px; margin-inline: auto; }
  /* 19px de ancho en un pulgar no se acierta. El botón se ve de 40 y se
     toca de 44, igual que las casillas de la lista. */
  .notif-btn { display: grid; width: 40px; height: 40px; padding: 0; place-items: center; }
  .notif-btn::after { content: ''; position: absolute; inset: -2px; }
}
