/* ===== Fuente (alojada en el propio sitio: sin llamadas a Google) ===== */
@font-face { font-family: "Atkinson"; src: url("fonts/atkinson-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("fonts/atkinson-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ===== Tokens ===== */
:root {
  --bg: #F2F5F9;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --ink: #13293D;
  --ink-2: #4A5D70;
  --line: #D6DFE8;
  --primary: #0B5CAD;
  --primary-hover: #094C8F;
  --primary-soft: #E2EDF8;
  --on-primary: #FFFFFF;
  --ok: #1B7F50;
  --ok-soft: #E0F2E8;
  --ko: #C2352B;
  --ko-soft: #FBE6E3;
  --wait: #8A5A00;
  --wait-soft: #FFF1D1;
  --muted-soft: #ECEFF3;

  /* Turnos */
  --m-bg: #DDEBFA; --m-ink: #0A4F94;
  --t-bg: #FFE6C7; --t-ink: #8A3F00;
  --n-bg: #22305C; --n-ink: #F1F4FF;

  --radius-s: 8px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(19, 41, 61, .06), 0 4px 14px rgba(19, 41, 61, .05);
  --font: "Atkinson", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side: 248px;
  --tab: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1A26; --surface: #15263A; --surface-2: #1A2D44; --ink: #E7EEF6; --ink-2: #A9B9CA; --line: #2A4058;
    --primary: #5AA2EC; --primary-hover: #7DB7F1; --primary-soft: #1C3753; --on-primary: #08213B;
    --ok: #5CC992; --ok-soft: #173A2B; --ko: #F08378; --ko-soft: #432222; --wait: #F0C25E; --wait-soft: #3C3016; --muted-soft: #22344A;
    --m-bg: #1E3E63; --m-ink: #CFE4FB; --t-bg: #4A3018; --t-ink: #FFD9AE; --n-bg: #0A1230; --n-ink: #D8DEFF;
    --shadow: none;
    color-scheme: dark;
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.5 var(--font); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.boot { padding: 3rem; text-align: center; color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.hint { color: var(--ink-2); font-size: .92rem; }
.err { color: var(--ko); font-weight: 700; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===== Login ===== */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.login-box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem 1.75rem; box-shadow: var(--shadow); }
.login-mark { width: 52px; height: 52px; border-radius: 14px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; margin-bottom: 1.25rem; }
.login-mark svg { width: 28px; height: 28px; }
.login h1 { font-size: 1.75rem; }

/* ===== Layout ===== */
.layout { min-height: 100dvh; }
.layout > div { min-width: 0; }
.side { display: none; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-title { font-weight: 700; margin-right: auto; display: flex; flex-direction: column; line-height: 1.15; }
.top-title small { font-weight: 400; color: var(--ink-2); font-size: .82rem; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 4px; right: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--ko); color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
main { padding: 1.25rem 1rem calc(var(--tab) + 1.5rem + env(safe-area-inset-bottom)); max-width: 1180px; outline: none; }

.tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tab) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .74rem; color: var(--ink-2); text-decoration: none; background: none; border: 0; cursor: pointer; }
.tabbar svg { width: 24px; height: 24px; }
.tabbar [aria-current="page"] { color: var(--primary); font-weight: 700; }
.tabbar .tab-new svg { background: var(--primary); color: var(--on-primary); border-radius: 12px; padding: 6px; width: 36px; height: 36px; }

.drawer { border: 0; padding: 0; margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(320px, 86vw); background: var(--surface); color: var(--ink); }
.drawer::backdrop { background: rgba(10, 20, 35, .45); }
.drawer nav { padding: calc(1rem + env(safe-area-inset-top)) .75rem 1rem; }

.navlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.navlist a { display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 10px; color: var(--ink); text-decoration: none; }
.navlist a:hover { background: var(--surface-2); }
.navlist a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.navlist .count { margin-left: auto; background: var(--ko); color: #fff; border-radius: 10px; font-size: .75rem; padding: 0 7px; font-weight: 700; }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: var(--side) 1fr; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 1.25rem .75rem; background: var(--surface); border-right: 1px solid var(--line); }
  .side-brand { display: flex; gap: .7rem; align-items: center; padding: 0 .5rem 1.25rem; }
  .side-brand .login-mark { width: 40px; height: 40px; margin: 0; border-radius: 11px; }
  .side-brand .login-mark svg { width: 22px; height: 22px; }
  .side-brand b { display: block; }
  .side-brand small { color: var(--ink-2); }
  .side-foot { margin-top: auto; padding: .5rem; font-size: .88rem; color: var(--ink-2); }
  .tabbar, .top .menu-btn { display: none; }
  .top { padding: .75rem 1.5rem; }
  .top .top-title b { display: none; }
  main { padding: 1.75rem 2rem 3rem; }
}

/* ===== Componentes ===== */
.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; margin-right: auto; }
.section { margin-top: 1.75rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px; border: 1px solid transparent; background: var(--primary); color: var(--on-primary); font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ko { background: var(--ko); color: #fff; }
.btn.ko-ghost { background: var(--surface); color: var(--ko); border-color: var(--ko); }
.btn.small { min-height: 36px; padding: .35rem .8rem; font-size: .92rem; }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 700; cursor: pointer; text-decoration: underline; }

.field { display: grid; gap: .3rem; margin-bottom: 1rem; }
.field > span { font-weight: 700; font-size: .95rem; }
input[type=text], input[type=email], input[type=search], input[type=date], input[type=month], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
textarea { resize: vertical; }
input.otp { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.radio { display: flex; gap: .6rem; align-items: flex-start; padding: .35rem 0; }
.radio input { margin-top: .3rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.filters > * { flex: 1 1 160px; width: auto; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: .7rem .9rem; border-bottom: 3px solid transparent; color: var(--ink-2); font-weight: 700; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .n { display: inline-block; margin-left: .35rem; padding: 0 .45rem; border-radius: 9px; background: var(--muted-soft); font-size: .8rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-2); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .btn { margin-top: .75rem; }

/* Turno: la pieza visual de la app */
.chip { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .7rem .4rem .55rem; border-radius: 999px; font-size: .93rem; white-space: nowrap; }
.chip svg { width: 18px; height: 18px; }
.chip-M { background: var(--m-bg); color: var(--m-ink); }
.chip-T { background: var(--t-bg); color: var(--t-ink); }
.chip-N { background: var(--n-bg); color: var(--n-ink); }
.chip b { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }

button.pick { border: 2px solid transparent; cursor: pointer; }
button.pick:hover { filter: brightness(.97); }
button.pick[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--surface) inset; }
button.pick[aria-pressed="true"]::after { content: "✓"; font-weight: 700; margin-left: .15rem; }
button.pick:disabled { opacity: .4; cursor: not-allowed; }

/* Ticket de cambio */
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ticket + .ticket { margin-top: .9rem; }
.ticket-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.ticket-h .who-line { font-size: .92rem; color: var(--ink-2); }
.ticket-body { display: grid; grid-template-columns: 1fr; }
.half { padding: .9rem 1rem; }
.half .who { margin: 0 0 .45rem; font-weight: 700; }
.perf { position: relative; height: 0; border-top: 2px dashed var(--line); margin: 0 1rem; }
.perf::before, .perf::after { content: ""; position: absolute; top: -10px; width: 18px; height: 18px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); }
.perf::before { left: -27px; } .perf::after { right: -27px; }
@media (min-width: 640px) {
  .ticket-body { grid-template-columns: 1fr auto 1fr; }
  .perf { height: auto; width: 0; border-top: 0; border-left: 2px dashed var(--line); margin: .8rem 0; }
  .perf::before { left: -10px; top: -27px; } .perf::after { left: -10px; right: auto; top: auto; bottom: -27px; }
}
.msg { margin: 0 1rem .9rem; padding: .6rem .85rem; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reject { margin: 0 1rem .9rem; padding: .6rem .85rem; border-radius: 8px; background: var(--ko-soft); color: var(--ko); }
.ticket-f { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; padding: .75rem 1rem; border-top: 1px solid var(--line); background: var(--surface-2); }
.ticket-f .btn { flex: 1 1 auto; }
@media (min-width: 640px) { .ticket-f .btn { flex: 0 0 auto; } }

.estado { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .84rem; font-weight: 700; }
.estado-wait { background: var(--wait-soft); color: var(--wait); }
.estado-ok { background: var(--ok-soft); color: var(--ok); }
.estado-ko { background: var(--ko-soft); color: var(--ko); }
.estado-muted { background: var(--muted-soft); color: var(--ink-2); }

/* Inicio */
.hello { margin-bottom: 1.25rem; }
.hello p { color: var(--ink-2); margin: 0; }
.todo { display: grid; gap: .6rem; margin-bottom: 1.5rem; }
.todo a { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.todo a:hover { border-color: var(--primary); }
.todo .big { font-size: 1.6rem; font-weight: 700; min-width: 2ch; text-align: center; color: var(--primary); font-variant-numeric: tabular-nums; }
.todo .todo-ko .big { color: var(--ko); }
.todo-ok { padding: .9rem 1rem; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); font-weight: 700; }

/* Asistente de nueva solicitud */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; max-width: 760px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.step-h { display: flex; align-items: center; gap: .75rem; }
.step-h h2 { margin: 0; font-size: 1.05rem; margin-right: auto; }
.step-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--primary-soft); color: var(--primary); flex: none; }
.step.done .step-n { background: var(--ok); color: #fff; }
.step.locked { opacity: .55; box-shadow: none; }
.step-b { margin-top: .9rem; }
.rule { padding: .6rem .8rem; border-radius: 8px; background: var(--primary-soft); color: var(--ink); font-size: .93rem; margin-bottom: .8rem; }
.people { display: grid; gap: .45rem; }
.person { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; padding: .7rem .85rem; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; }
.person[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--muted-soft); font-weight: 700; font-size: .85rem; flex: none; }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Cuadrante */
.grid-wrap { overflow: auto; max-height: calc(100dvh - 260px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.grid { font-size: .82rem; width: max-content; min-width: 100%; }
table.grid th, table.grid td { padding: 0; border-right: 1px solid var(--line); text-align: center; }
table.grid thead th { position: sticky; top: 0; z-index: 2; padding: .35rem .2rem; min-width: 38px; line-height: 1.1; }
table.grid thead th small { display: block; font-weight: 400; color: var(--ink-2); }
table.grid .who { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding: .4rem .7rem; min-width: 150px; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.grid thead .who { z-index: 3; background: var(--surface-2); }
table.grid tr.me .who { font-weight: 700; color: var(--primary); }
table.grid .cat th, table.grid .cat td { background: var(--surface-2); }
table.grid .cat th.who { font-weight: 700; color: var(--ink-2); }
table.grid .we { background: var(--surface-2); }
table.grid .today { box-shadow: inset 0 0 0 2px var(--primary); }
.cell { display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; min-height: 34px; width: 100%; padding: 3px 2px; background: none; border: 0; }
button.cell { cursor: pointer; }
button.cell:hover { background: var(--primary-soft); }
.mini { display: inline-block; width: 22px; line-height: 18px; border-radius: 5px; font-weight: 700; font-size: .75rem; }
.mini-M { background: var(--m-bg); color: var(--m-ink); }
.mini-T { background: var(--t-bg); color: var(--t-ink); }
.mini-N { background: var(--n-bg); color: var(--n-ink); }
@media (max-width: 640px) { table.grid .who { min-width: 110px; max-width: 120px; font-size: .78rem; } }
.legend { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 0; }

/* Diálogos */
dialog.modal { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.modal.wide { width: min(820px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(10, 20, 35, .5); }
.dlg { padding: 1.25rem 1.25rem 1rem; }
.dlg-acts { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .75rem 0; }
.summary div { padding: .6rem .75rem; border-radius: 10px; background: var(--surface-2); }
.summary b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; }

/* Avisos */
.notice { display: flex; gap: .8rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.notice:last-child { border-bottom: 0; }
.notice.unread { background: var(--primary-soft); }
.notice .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: .5rem; flex: none; }
.notice:not(.unread) .dot { background: transparent; }
.notice time { display: block; color: var(--ink-2); font-size: .85rem; }

/* Avisos emergentes */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab) + 1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; max-width: calc(100vw - 2rem); padding: .75rem 1.1rem; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.toast.ko { background: var(--ko); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 1.5rem; } }

dl.data { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 0; }
dl.data dt { color: var(--ink-2); }
dl.data dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
