/* ===========================================================================
   Tema Hápax (v1.6): azul noche de las propuestas + lima de acento + dorado para «hoy»
   =========================================================================== */
:root {
  --bg: #06142E;
  --bg-2: #0A1D45;
  --surface: #0D2250;
  --surface-2: #14295C;
  --surface-3: #1B3470;
  --ink: #F3F6FB;
  --ink-2: #B8C4DB;
  --ink-3: #7F8FB0;
  --line: #1E3668;
  --line-strong: #2C4A85;
  --cell-empty: #0E2350;
  --cell-empty-hover: #183266;
  --accent: #C8F560;
  --accent-ink: #0A1D45;
  --gold: #F5C842;
  --today: #F5C842;
  --danger: #FF6B6B;
  --shadow: 0 18px 48px rgba(0, 5, 20, .55), 0 2px 8px rgba(0, 5, 20, .35);
  --radius: 14px;
  --head-font: "Space Grotesk", "Inter", system-ui, sans-serif;
  --body-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 var(--body-font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .cell:focus-visible, .chip:focus-visible { outline: 2px solid var(--today); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.icon { width: 34px; padding: 0; font-size: 18px; }
.btn.block { width: 100%; height: 42px; margin-top: 8px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: #0E2350; color: #7CF04A; display: grid; place-items: center;
  font: 600 18px var(--head-font); flex: none; }
.weeknav { display: flex; align-items: center; gap: 6px; }
.datepick { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; }
.actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 40px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 40; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu form { margin: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }

/* ---------- Pestañas Grilla / Tareas ---------- */
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px; border-radius: 7px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15,20,35,.12); }
.tab-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #3D8EEA; color: #fff; font-size: 11px; font-weight: 700; }

/* ---------- Leyenda / pincel ---------- */
.legend { display: flex; align-items: center; gap: 10px; padding: 12px 20px 6px; flex-wrap: wrap; }
.legend-hint { font-size: 12px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.legend-hint.dim { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-3); }
.legend-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px 0 6px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font: 500 13px var(--head-font); text-transform: uppercase; letter-spacing: .04em; }
.chip .sw { width: 22px; height: 20px; border-radius: 5px; flex: none; }
.chip .k { font: 500 11px var(--body-font); color: var(--ink-3); }
.chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface-2); }
body.painting .cell { cursor: crosshair; }

/* ---------- Resumen del día ---------- */
.summary { display: flex; flex-direction: column; gap: 6px; padding: 4px 20px 10px; font-size: 12px; color: var(--ink-2); }
.summary-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.summary-label { font-weight: 600; color: var(--ink-2); min-width: 128px; }
.summary .pill.strong { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
.meter { display: inline-block; width: 60px; height: 6px; border-radius: 99px; background: var(--cell-empty); overflow: hidden; vertical-align: middle; }
.meter b { display: block; height: 100%; background: #7CF04A; }
.summary .pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.summary .pill i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Grilla ---------- */
.grid-wrap { margin: 0 20px 20px; overflow: auto; max-height: calc(100vh - var(--grid-top, 200px) - 16px); overscroll-behavior: contain; }
.grid { border-collapse: separate; border-spacing: 3px; min-width: 980px; width: 100%; table-layout: fixed; }
.grid th, .grid td { padding: 0; vertical-align: middle; }
.grid thead th { position: sticky; top: 0; z-index: 6; background: var(--bg); padding: 6px 0 4px; font: 600 26px/1 var(--head-font);
  letter-spacing: .02em; text-transform: uppercase; color: var(--ink); }
.grid thead th small { display: block; font: 500 12px var(--body-font); color: var(--ink-3); letter-spacing: 0; margin-top: 4px; text-transform: none; }
.grid thead th.today { color: var(--today); }
.grid thead th.today small { color: var(--today); }
.grid thead th.corner { width: 210px; text-align: left; font-size: 12px; font-family: var(--body-font); color: var(--ink-3); font-weight: 500; vertical-align: bottom; }
.grid col.c-client { width: 210px; }

.client { position: sticky; left: 0; z-index: 4; background: var(--bg); }
.grid thead th.corner { position: sticky; left: 0; z-index: 7; }
.client-inner { display: flex; align-items: stretch; height: 34px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; }
.client .bar { width: 14px; flex: none; border: 0; cursor: pointer; background: var(--cell-empty); padding: 0; border-right: 1px solid var(--line-strong); }
.client .bar:hover { filter: brightness(.92); }
.client .name { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 8px; background: none; border: 0; cursor: pointer; text-align: left;
  font: 500 14px/1 var(--head-font); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client .name:hover { background: var(--surface-2); }
.client .handle { width: 18px; flex: none; display: grid; place-items: center; color: var(--ink-3); cursor: grab; opacity: 0; font-size: 12px; user-select: none; }
.client-inner:hover .handle { opacity: 1; }
.client.archived .name { color: var(--ink-3); text-decoration: line-through; }
tr.dragging { opacity: .4; }
tr.drop-before .client-inner { box-shadow: 0 -3px 0 var(--today); }
tr.drop-after .client-inner { box-shadow: 0 3px 0 var(--today); }

.cell { position: relative; display: flex; vertical-align: top; box-sizing: border-box; align-items: center; justify-content: center; width: 100%; height: 34px; border-radius: 5px;
  background: var(--cell-empty); border: 1px solid color-mix(in srgb, var(--line-strong) 55%, transparent); cursor: pointer; padding: 0 6px;
  font: 500 13px/1.05 var(--head-font); text-transform: uppercase; letter-spacing: .05em; text-align: center; overflow: hidden; transition: filter .08s; user-select: none; }
.cell:hover { filter: brightness(.94); }
.cell.empty:hover { background: var(--cell-empty-hover); filter: none; }
td.today-col .cell.empty { background: color-mix(in srgb, var(--today) 7%, var(--cell-empty)); }
.cell .note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.wide .note { letter-spacing: .5em; }
.cell .chs { position: absolute; right: 3px; bottom: 2px; display: flex; gap: 2px; }
.cell .chs b { font: 700 8px/1 var(--body-font); padding: 2px 3px; border-radius: 3px; background: rgba(255, 255, 255, .88); color: #12151C; letter-spacing: 0; }
.cell .chs b.bad { background: #E6E24C; }
.cell .auto { position: absolute; left: 4px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.cell.selected { outline: 2px solid var(--today); outline-offset: 1px; }

.empty-msg { text-align: center; color: var(--ink-2); padding: 40px 0; }

/* ---------- Popover de celda ---------- */
.pop { position: fixed; z-index: 50; width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; }
.pop h3 { margin: 0 0 2px; font: 600 16px var(--head-font); text-transform: uppercase; letter-spacing: .03em; }
.pop .sub { margin: 0 0 12px; color: var(--ink-3); font-size: 12px; }
.st-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 12px; }
.st-btn { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 12.5px; text-align: left; }
.st-btn .sw { width: 16px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgba(0, 0, 0, .12); }
.st-btn .k { margin-left: auto; color: var(--ink-3); font-size: 11px; }
.st-btn[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.field { display: block; margin-bottom: 10px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.field input, .field select, .field textarea { display: block; width: 100%; margin-top: 4px; height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--surface); font-size: 14px; }
.field textarea { height: auto; padding: 8px 10px; resize: vertical; }
.ch-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.ch-btn { height: 28px; min-width: 40px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font: 600 11px var(--body-font); }
.ch-btn.on { color: #fff; border-color: transparent; }
.pop-actions { display: flex; gap: 6px; justify-content: space-between; margin-top: 4px; }
.meta { font-size: 11px; color: var(--ink-3); margin: 8px 0 0; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(10, 14, 24, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 22px; }
.modal h2 { margin: 0 0 14px; font: 600 22px var(--head-font); text-transform: uppercase; letter-spacing: .02em; }
.modal h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .row .spacer { flex: 1; }
.status-pick { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.status-pick button { width: 34px; height: 28px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.status-pick button[aria-pressed="true"] { border-color: var(--ink); }
.status-pick button.none { background: var(--cell-empty); font-size: 11px; color: var(--ink-2); }
.copybox { display: flex; gap: 6px; }
.copybox input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.copybox .btn { height: 34px; }
pre.snippet { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; overflow: auto; white-space: pre-wrap; }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list td.r { text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }
.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); }

/* ---------- Guardar ---------- */
.save-btn { min-width: 118px; font-weight: 600; }
.save-btn:disabled { color: var(--ink-3); cursor: default; background: var(--surface); }
.save-btn.dirty { background: #FF5A36; border-color: #FF5A36; color: #fff; }
.save-btn.dirty:hover { filter: brightness(1.06); background: #FF5A36; }
.save-btn .badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: rgba(255,255,255,.25); font-size: 12px; }
.savebar { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 8px;
  background: #12151C; color: #fff; padding: 8px 8px 8px 16px; border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.35); max-width: calc(100vw - 24px); }
.savebar #saveCount { font-weight: 600; font-size: 14px; white-space: nowrap; margin-right: 6px; }
.savebar-dot { width: 9px; height: 9px; border-radius: 50%; background: #FF5A36; flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.savebar .btn { height: 44px; padding: 0 16px; background: transparent; color: #fff; border-color: rgba(255,255,255,.22); }
.savebar .btn:hover { background: rgba(255,255,255,.08); }
.savebar .btn:disabled { opacity: .4; }
.savebar .btn.primary { background: #FF5A36; border-color: #FF5A36; font-weight: 700; min-width: 110px; }
.savebar-kbd { font: 600 11px var(--body-font); color: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.2); border-radius: 5px; padding: 2px 6px; margin-right: 4px; }
.cell.pending { outline: 2px dashed #FF5A36; outline-offset: -3px; }
.client .bar.pending { outline: 2px dashed #FF5A36; outline-offset: -2px; }
.cell.pending.selected { outline-style: solid; outline-offset: 1px; }
body:has(.savebar:not([hidden])) .toast { bottom: 92px; }
.grid-wrap { padding-bottom: 72px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: #12151C; color: #fff; padding: 10px 16px;
  border-radius: 9px; font-size: 13px; pointer-events: none; transition: .2s; z-index: 80; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

/* ---------- Login / instalador ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card.wide { width: min(560px, 100%); }
.auth-card h1 { font: 600 26px var(--head-font); text-transform: uppercase; margin: 22px 0 14px; }
.auth-card label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 10px; }
.auth-card input, .auth-card select, .auth-card textarea { display: block; width: 100%; height: 40px; margin-top: 4px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); font-size: 14px; }
.auth-card textarea.code { height: auto; padding: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.auth-card label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); }
.auth-card label.check input { width: auto; height: auto; margin: 0; }
.auth-card fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 4px; margin: 0 0 14px; }
.auth-card legend { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 0 6px; }
.row2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); padding: 9px 12px; border-radius: 8px; font-size: 13px; }
.warn { background: color-mix(in srgb, #E6E24C 25%, var(--surface)); padding: 9px 12px; border-radius: 8px; font-size: 13px; }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .actions { margin-left: 0; width: 100%; }
  .actions #copyWeek { flex: 1; }
  .legend, .summary { padding-left: 16px; padding-right: 16px; }
  .legend-hint.dim { display: none; }
  .legend-chips, .summary-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .legend-chips { max-width: 100%; }
  .summary-row > * { flex: none; }
  .summary-label { min-width: 0; }
  .chip { flex: none; }
  .chip .k { display: none; }
  .grid-wrap { margin: 0 16px 16px; }
  .grid thead th.corner, .grid col.c-client { width: 140px; }
  .client .name { font-size: 12.5px; }
  .brand small { max-width: 180px; }
  .datepick { display: none; }
  .savebar { left: 12px; right: 12px; transform: none; padding-left: 12px; gap: 6px; }
  .savebar #saveCount { font-size: 13px; flex: 1; white-space: normal; }
  .savebar-kbd, .savebar-dot { display: none; }
  .savebar .btn { padding: 0 10px; }
}

/* ===========================================================================
   Tema Hápax v1.6 — capa visual (va al final para ganar a las reglas anteriores)
   =========================================================================== */
body { background: var(--bg) url("topo.svg") center top / 1600px auto fixed; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(200, 245, 96, .07), transparent 60%),
              radial-gradient(900px 600px at -10% 110%, rgba(61, 142, 234, .12), transparent 60%); }
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: var(--accent); }

/* ---------- Botones en píldora ---------- */
.btn { border-radius: 999px; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: var(--ink); height: 36px; padding: 0 16px; }
.btn:hover { background: rgba(255, 255, 255, .12); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, .08); }
.btn.icon { width: 36px; }
.btn.sm { height: 30px; padding: 0 12px; }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, .35); background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .cell:focus-visible, .chip:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Barra superior: logo · píldoras · menú ---------- */
.topbar { background: rgba(6, 20, 46, .72); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(255, 255, 255, .07); padding: 12px 24px; gap: 20px; flex-wrap: nowrap; }
.brand { text-decoration: none; color: var(--ink); gap: 12px; flex: none; }
.brand-logo { display: block; height: 24px; width: auto; filter: brightness(0) invert(1); }
.brand-sub { display: block; font-size: 12px; color: var(--ink-3); padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .15); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tabs { background: #EEF2F9; border: 0; border-radius: 999px; padding: 4px; gap: 2px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.tab { height: 34px; padding: 0 16px; border-radius: 999px; color: #2A3E66; font-weight: 600; font-size: 13.5px; }
.tab:hover { color: #06142E; background: rgba(10, 29, 69, .06); }
.tab.active { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.tab.active::before { content: "•"; margin-right: 2px; }
.tab-badge { background: #0A1D45; color: var(--accent); }
.actions { gap: 8px; }
.menu { background: var(--surface); border-color: var(--line-strong); border-radius: 16px; top: 44px; }
.menu button:hover { background: var(--surface-2); }
.menu form { border-color: var(--line); }

/* ---------- Barra de herramientas de la grilla ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 18px 24px 8px; flex-wrap: wrap; }
.range-title { margin: 0 0 0 6px; font: 500 22px/1.1 var(--head-font); letter-spacing: -.01em; color: var(--ink-2); text-transform: capitalize; }
.range-title b { color: var(--ink); font-weight: 700; }
.today-tag { display: inline-block; vertical-align: 3px; margin-left: 6px; padding: 2px 9px; border-radius: 999px; background: var(--gold); color: #2A2000;
  font: 700 11px/1.5 var(--body-font); text-transform: uppercase; letter-spacing: .06em; }
.toolbar .spacer { flex: 1; }
.datepick { height: 36px; border-radius: 999px; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: var(--ink); padding: 0 12px; color-scheme: dark; }
.seg { display: inline-flex; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg button span { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 99px; background: rgba(255, 255, 255, .1); font-size: 11px; font-weight: 700; color: inherit; }
.seg button[aria-pressed="true"] span { background: rgba(10, 29, 69, .15); }
.seg button span.hot { background: var(--gold); color: #2A2000; }

/* ---------- Leyenda / pincel ---------- */
.legend { padding: 6px 24px 4px; }
.legend-hint { color: var(--ink-3); }
.chip { border-radius: 999px; background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .1); font: 600 12px var(--head-font); padding: 0 12px 0 5px; height: 32px; }
.chip .sw { width: 22px; height: 22px; border-radius: 50%; }
.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: rgba(200, 245, 96, .1); }

/* ---------- Resumen ---------- */
.summary { padding: 4px 24px 12px; }
.summary .pill { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .1); }
.summary .pill.strong { background: rgba(200, 245, 96, .1); border-color: rgba(200, 245, 96, .35); }
.summary .pill i { border-radius: 50%; }
.meter { background: rgba(255, 255, 255, .12); }
.meter b { background: var(--accent); }

/* ---------- Grilla ---------- */
.board { display: flex; gap: 16px; align-items: flex-start; margin: 0 24px 24px; }
.board .grid-wrap { flex: 1; min-width: 0; margin: 0; background: rgba(13, 34, 80, .55); border: 1px solid rgba(255, 255, 255, .07); border-radius: 22px; padding: 8px 10px 72px; }
.grid { border-spacing: 4px; }
.grid thead th { background: transparent; font: 700 18px/1 var(--head-font); letter-spacing: .04em; color: var(--ink); padding: 10px 0 8px; }
.grid thead tr { background: transparent; }
.grid thead th { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); background: rgba(13, 34, 80, .85); }
.grid thead th:first-child { border-top-left-radius: 14px; }
.grid thead th:last-child { border-top-right-radius: 14px; }
.grid thead th small { color: var(--ink-3); }
.grid thead th.today, .grid thead th.today small { color: var(--gold); }
.grid thead th.focus small { color: var(--accent); }
.grid thead th.corner { color: var(--ink-3); font: 500 12px var(--body-font); padding-left: 8px; }
.client { background: transparent; }
.client-inner { background: var(--surface-2); border: 1px solid rgba(255, 255, 255, .08); border-radius: 10px; height: 36px; }
.client .bar { border-right: 0; background: rgba(255, 255, 255, .08); width: 8px; }
.client .name { font: 600 13px/1 var(--head-font); letter-spacing: .03em; color: var(--ink); }
.client .name:hover { background: var(--surface-3); }
.cell { height: 36px; border-radius: 10px; font: 600 12px/1.05 var(--head-font); letter-spacing: .06em; border: 1px solid rgba(255, 255, 255, .06); background: var(--cell-empty); }
.cell.empty { background: rgba(255, 255, 255, .025); border: 1px dashed rgba(159, 182, 230, .16); }
.cell.empty:hover { background: rgba(255, 255, 255, .07); }
.cell[data-st="hoy_no_toca"] { border-color: rgba(159, 182, 230, .18) !important; }
td.today-col .cell.empty { background: rgba(245, 200, 66, .06); border-color: rgba(245, 200, 66, .25); }
.cell.selected { outline-color: var(--accent); }
.cell .chs b { background: rgba(6, 20, 46, .75); color: #fff; border-radius: 4px; }
/* Seguir la fila: resalta toda la fila al pasar el mouse (útil de jueves a domingo) */
.grid tbody tr:hover .client-inner { background: var(--surface-3); border-color: rgba(200, 245, 96, .4); }
.grid tbody tr:hover td .cell { box-shadow: 0 0 0 1px rgba(200, 245, 96, .28); }
.grid tbody tr:nth-child(even) .client-inner { background: color-mix(in srgb, var(--surface-2) 82%, var(--bg)); }
.grid tbody tr:nth-child(even):hover .client-inner { background: var(--surface-3); }

/* ---------- Vista por día ---------- */
.grid.day { min-width: 0; }
.grid.day col.c-mini { width: 168px; }
.grid.day thead th { font-size: 20px; text-transform: capitalize; text-align: left; padding-left: 14px; }
.grid.day thead th.corner { padding-left: 8px; }
.grid.day thead th.mini-h { font: 600 11px var(--body-font); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); text-align: center; padding-left: 0; }
.grid.day thead th.mini-h small { display: flex; justify-content: space-between; padding: 0 10px; margin-top: 6px; }
.grid.day thead th.mini-h small span.on { color: var(--accent); font-weight: 700; }
.grid.day .client-inner, .grid.day .cell { height: 46px; }
.grid.day .client .name { font-size: 15px; }
.grid.day .cell { justify-content: flex-start; padding: 0 16px; font-size: 13px; }
.grid.day .cell .chs { position: static; margin-left: auto; }
.grid.day .cell .chs b { font-size: 10px; padding: 3px 5px; }
.grid.day .cell .note { letter-spacing: .06em; }
.grid.day .cell.carry { opacity: .82; }
.carry-tag { margin-left: 10px; font: 500 11px var(--body-font); text-transform: none; letter-spacing: 0; opacity: .8; }
.mini-week { display: flex; gap: 4px; justify-content: space-between; padding: 0 6px; }
.mini-d { width: 18px; height: 28px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .05); cursor: pointer; padding: 0; }
.mini-d.empty { background: rgba(255, 255, 255, .03); border-style: dashed; }
.mini-d.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.mini-d:hover { transform: translateY(-1px); }

/* ---------- Panel de ayuda (vista Día) ---------- */
.day-panel { flex: 0 0 340px; position: sticky; top: calc(var(--grid-top, 200px)); max-height: calc(100vh - var(--grid-top, 200px) - 24px); overflow: auto;
  display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.dp-hero { background: linear-gradient(160deg, #13306A, #0D2250 70%); border: 1px solid rgba(255, 255, 255, .08); border-radius: 22px; padding: 18px 20px; }
.dp-kicker { margin: 0; font: 600 12px var(--body-font); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.dp-big { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 10px; }
.dp-big b { font: 700 54px/1 var(--head-font); letter-spacing: -.03em; color: var(--ink); }
.dp-big span { color: var(--ink-2); font-size: 14px; }
.dp-bar { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.dp-bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); box-shadow: 0 0 16px rgba(200, 245, 96, .55); transition: width .3s; }
.dp-chips { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.dp-chips i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dp-chips i.empty { border: 1px dashed var(--ink-3); }
.dp-alert { display: block; padding: 12px 16px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; font-size: 13.5px; }
.dp-sec { background: rgba(13, 34, 80, .7); border: 1px solid rgba(255, 255, 255, .07); border-radius: 20px; padding: 14px 16px; }
.dp-sec h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font: 600 14px var(--head-font); }
.dp-sec .count { min-width: 22px; padding: 0 7px; border-radius: 99px; background: rgba(255, 255, 255, .1); font: 700 11px/20px var(--body-font); text-align: center; }
.dp-more { margin-left: auto; font: 500 12px var(--body-font); color: var(--ink-3); text-decoration: none; }
.dp-more:hover { color: var(--accent); }
.dp-list { list-style: none; margin: 0; padding: 0; }
.dp-list li { display: flex; align-items: center; gap: 8px; border-top: 1px solid rgba(255, 255, 255, .06); }
.dp-list li:first-child { border-top: 0; }
.dp-list a { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 8px 0; text-decoration: none; color: var(--ink); }
.dp-list a:hover .pi-main { color: var(--accent); }
.pi-main { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-sub { font-size: 12px; color: var(--ink-3); }
.dp-empty { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.due { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); color: var(--ink-2); white-space: nowrap; }
.due.soon { background: rgba(245, 200, 66, .18); color: var(--gold); }
.due.late { background: rgba(255, 107, 107, .18); color: #FF8A8A; }

/* ---------- Popover, modal, campos ---------- */
.pop, .modal { background: #0F2656; border: 1px solid var(--line-strong); border-radius: 20px; }
.modal-bg { background: rgba(2, 8, 22, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal h2, .pop h3 { font-family: var(--head-font); text-transform: none; letter-spacing: -.01em; }
.modal h2 { font-size: 24px; font-weight: 700; }
.field input, .field select, .field textarea, .auth-card input, .sg-search, form.deliver input, .todo-form input[name=text], .t-filters select, #fAssignee, #fClient {
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .14); color: var(--ink); border-radius: 12px; color-scheme: dark; }
.field input:focus, .field select:focus, .field textarea:focus, .auth-card input:focus, .sg-search:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field select option, .t-filters select option { background: var(--surface); color: var(--ink); }
.st-btn, .ch-btn, .chips button { border-radius: 999px; background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .12); color: var(--ink); }
.st-btn[aria-pressed="true"], .chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: none; }
.tag { border-radius: 99px; background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .12); }
table.list td { border-color: var(--line); }
pre.snippet, .copybox input { background: rgba(255, 255, 255, .05); border-color: var(--line); }

/* ---------- Guardar / avisos ---------- */
.save-btn.dirty, .save-btn.dirty:hover { background: var(--gold); border-color: var(--gold); color: #2A2000; }
.savebar { background: #0F2656; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 6px 6px 18px; }
.savebar-dot { background: var(--gold); }
.savebar .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cell.pending, .client .bar.pending { outline-color: var(--gold); }
.toast { background: #EEF2F9; color: #06142E; border-radius: 999px; font-weight: 600; }

/* ---------- Login ---------- */
.auth-card { background: rgba(13, 34, 80, .85); border-color: rgba(255, 255, 255, .1); border-radius: 26px; padding: 34px 32px; backdrop-filter: blur(8px); }
.auth-logo { display: block; height: 40px; width: auto; filter: brightness(0) invert(1); }
.auth-sub { margin: 8px 0 0; color: var(--ink-3); font-size: 13px; }
.auth-card h1 { font: 700 28px var(--head-font); text-transform: none; letter-spacing: -.02em; }
.auth-card .btn.primary { height: 46px; font-size: 15px; }

/* ---------- Tarjetas de Tareas y Seguimiento con el mismo lenguaje ---------- */
.t-card, .sg-card, .tcard, .work-card, .camp, .kpi { border-radius: 20px; }
.t-card, .sg-card, .tcard { background: rgba(13, 34, 80, .7); border-color: rgba(255, 255, 255, .08); }
.sg-card:hover, .tcard:hover { border-color: rgba(200, 245, 96, .35); }
.person { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .08); border-radius: 14px; }
.person.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.avatar { background: var(--accent); color: var(--accent-ink); }
.t-empty { background: rgba(13, 34, 80, .55); border-color: rgba(255, 255, 255, .12); border-radius: 20px; }
.drive-pill { background: rgba(200, 245, 96, .14); color: var(--accent); }
.d-notes { background: rgba(255, 255, 255, .04); border-color: var(--line); border-radius: 14px; }

@media (max-width: 1180px) {
  .day-panel { flex-basis: 290px; }
  .range-title { font-size: 19px; }
}
/* iPad vertical y pantallas medianas: el panel baja debajo de la grilla */
@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; }
  .board { flex-direction: column; }
  .day-panel { position: static; max-height: none; width: 100%; flex-basis: auto; display: grid; grid-template-columns: 1fr 1fr; }
  .day-panel .dp-hero, .day-panel .dp-alert { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .brand-sub { display: none; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .toolbar { padding: 12px 14px 6px; }
  .range-title { width: 100%; order: 5; margin: 4px 0 0; }
  .board { margin: 0 12px 16px; }
  .board .grid-wrap { padding: 6px 6px 72px; border-radius: 16px; }
  .day-panel { grid-template-columns: 1fr; }
  .grid.day col.c-mini { width: 0; }
  .grid.day .mini, .grid.day .mini-h { display: none; }
}

/* ajustes tras revisar en pantalla */
.range-title { text-transform: none; }
.range-title::first-letter { text-transform: uppercase; }
.grid.day thead th.corner { font: 500 12px var(--body-font); text-transform: none; vertical-align: bottom; }
.grid.day thead th:not(.corner):not(.mini-h) { text-transform: none; }
.grid.day thead th:not(.corner):not(.mini-h)::first-letter { text-transform: uppercase; }
.range-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
@media (max-width: 760px) {
  .topbar .actions { width: auto; margin-left: auto; order: 2; }
  .topbar .brand { order: 1; }
}

/* v1.8: acceso al Centro de mando (separado de las pestañas) */
.agent-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; border-radius: 999px; text-decoration: none; color: var(--accent);
  border: 1.5px solid rgba(200, 245, 96, .55); background: rgba(200, 245, 96, .06); font: 600 13.5px var(--body-font); white-space: nowrap; }
.agent-btn:hover, .agent-btn.on { background: var(--accent); color: var(--accent-ink); }
.ag-dot { width: 9px; height: 9px; border-radius: 50%; background: #7F8FB0; flex: none; }
.ag-dot.on { background: var(--accent); box-shadow: 0 0 0 3px rgba(200, 245, 96, .25); }
.ag-dot.busy { background: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.ag-dot.idle { background: #3D8EEA; }
.ag-dot.off { background: #FF6B6B; }
.agent-btn.on .ag-dot.on { box-shadow: 0 0 0 3px rgba(10, 29, 69, .25); background: var(--accent-ink); }
.tab-badge.ag { background: var(--gold); color: #2A2000; }
.tab-badge.jobs { background: #0A1D45; color: var(--accent); }
@media (max-width: 760px) { .agent-btn { padding: 0 10px; } }

/* v1.9: el botón Agente avisa en dorado si el agente tiene una pregunta */
.agent-btn.asks { border-color: var(--gold); color: var(--gold); background: rgba(245, 200, 66, .1); animation: ask-pulse 2.4s ease-in-out infinite; }
.agent-btn.asks:hover, .agent-btn.asks.on { background: var(--gold); color: #2A2000; }
@keyframes ask-pulse { 50% { box-shadow: 0 0 0 5px rgba(245, 200, 66, .18); } }
