/* DSM2 — estilos base. Marca: morado del logo #382260, oscuro del sitio #312F4C, gris #C9C8CC. */
:root {
  --brand: #382260;
  --brand-ink: #312F4C;
  --brand-soft: #EFEAF7;
  --brand-hover: #4A2F86;
  --ground: #F3F4F8;
  --surface: #FFFFFF;
  --column: #E9EBF2;
  --border: #DCE0EA;
  --border-soft: #EDEFF4;
  --text: #1A1830;
  --muted: #5A5870;
  --faint: #6B6880;
  --tag: #EEF0F5;
  --overdue-bg: #FDE2D3; --overdue-fg: #9A3412;
  --today-bg: #FFF1E6;   --today-fg: #B4400F;
  --soon-bg: #FFF8E1;    --soon-fg: #7A5A00;
  --ok-bg: #EEF0F5;      --ok-fg: #3E4A5E;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Figtree, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--ground); font-size: 14px; }
a { color: var(--brand-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: 0 0 236px; background: var(--surface); border-right: 1px solid #E4E2EA; padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo img { width: 150px; height: auto; display: block; margin: 4px 8px 4px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--faint); padding: 0 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 8px; color: #45425C; text-decoration: none; }
.nav-link:hover { background: #F5F3F9; color: var(--brand); }
.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-link.disabled { opacity: .55; pointer-events: none; }
.nav-link .badge { margin-left: auto; font-size: 12px; background: var(--brand); color: #fff; border-radius: 10px; padding: 1px 8px; }
.nav-link svg { flex: 0 0 auto; }
.user-card { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: #F5F3F9; }
.user-card .who { display: flex; flex-direction: column; min-width: 0; }
.user-card .who b { font-size: 14px; }
.user-card a { margin-left: auto; font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #E7E1F3; color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.empty { background: #F1F3F7; color: var(--faint); }

.main { flex: 1; min-width: 0; padding: 24px 28px 32px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head .title { margin-right: auto; display: flex; flex-direction: column; gap: 2px; }
.page-head h1 { margin: 0; font-size: 26px; }
.page-head .sub { color: var(--muted); }

/* Controls */
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; min-height: 44px; flex: 0 1 360px; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(56, 34, 96, .12); }
.search input { border: 0; outline: none; flex: 1; min-width: 0; background: transparent; }
.btn { min-height: 44px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; text-decoration: none; color: var(--text); }
.btn:hover { border-color: #BFC6D4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 44px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid #E1E4EC; border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; }
.kpi .hint { font-size: 13px; color: var(--muted); margin-left: 8px; }
.kpi.warn .value { color: var(--overdue-fg); }
.kpi.today .value { color: var(--today-fg); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip.alert { background: #FFF4ED; border-color: #F1C7AE; color: var(--overdue-fg); font-weight: 600; }
.chip.alert.on { background: var(--overdue-fg); border-color: var(--overdue-fg); color: #fff; }
.chips .count { margin-left: auto; color: var(--muted); font-size: 13px; }

/* Board */
.board-scroll { overflow-x: auto; padding-bottom: 8px; }
.board { display: flex; gap: 14px; align-items: flex-start; min-width: min-content; }
.column { width: 276px; flex: 0 0 276px; background: var(--column); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 2px; }
.column-head .dot { width: 10px; height: 10px; border-radius: 50%; }
.column-head h2 { margin: 0; font-size: 14px; }
.column-head .n { margin-left: auto; font-size: 12px; font-weight: 600; color: #3E4A5E; background: var(--surface); border-radius: 10px; padding: 1px 8px; }
.cards { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.board.dragging .column.hidden-empty { display: flex; }
.column.hidden-empty { display: none; }
.empty-board { padding: 48px; text-align: center; color: var(--muted); background: var(--surface); border-radius: 12px; border: 1px dashed var(--border); }

.card { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; color: var(--text); text-decoration: none; cursor: pointer; text-align: left; width: 100%; }
.card:hover { border-color: #B9B0D0; box-shadow: 0 2px 6px rgba(49, 47, 76, .08); }
.card:focus-visible { outline: 3px solid rgba(56, 34, 96, .35); outline-offset: 2px; }
.card.sortable-ghost { opacity: .4; }
.card .row { display: flex; align-items: center; gap: 8px; }
.card .container { font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.size { font-size: 11px; font-weight: 600; color: #3E4A5E; border: 1px solid #D3DAE6; border-radius: 4px; padding: 0 5px; }
.card .id { margin-left: auto; font-size: 12px; color: var(--faint); }
.card .client { font-size: 13px; font-weight: 600; }
.card .route { font-size: 12px; color: var(--muted); }
.card .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card .foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border-soft); padding-top: 8px; font-size: 12px; font-weight: 500; }
.card .foot.none { color: var(--faint); }
.tag { font-size: 12px; border-radius: 6px; padding: 2px 8px; background: var(--tag); color: #3E4A5E; }
.urg { font-weight: 600; }
.urg-overdue { background: var(--overdue-bg); color: var(--overdue-fg); }
.urg-today { background: var(--today-bg); color: var(--today-fg); }
.urg-soon { background: var(--soon-bg); color: var(--soon-fg); }
.urg-ok, .urg-none { background: var(--ok-bg); color: var(--ok-fg); }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(26, 24, 48, .28); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--border); z-index: 50; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(26, 24, 48, .12); }
.drawer-head { padding: 20px 24px 16px; border-bottom: 1px solid #E8EBF2; display: flex; flex-direction: column; gap: 12px; }
.drawer-head .meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.drawer-head .meta .btn { margin-left: auto; }
.drawer-head h2 { margin: 0; font-family: var(--mono); font-size: 24px; letter-spacing: .4px; }
.badge-live { font-size: 12px; font-weight: 600; color: #7A3B00; background: #FFF1D6; border-radius: 4px; padding: 2px 6px; }
.status-pill { font-size: 13px; font-weight: 600; border-radius: 6px; padding: 4px 10px; color: #fff; }
.progress { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; }
.progress li { height: 6px; border-radius: 3px; background: #E3E6EE; }
.progress li.done, .progress li.current { background: var(--brand); }
.drawer-body { flex: 1; overflow: auto; padding: 18px 24px; display: flex; flex-direction: column; gap: 20px; }
.section-title { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .8px; color: var(--muted); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.box { border: 1px solid #E1E4EC; border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.box .k { font-size: 12px; color: var(--muted); }
.box .v { font-size: 14px; font-weight: 600; }
.box .s { font-size: 12px; color: var(--muted); }
.strip { display: flex; align-items: center; gap: 10px; background: #F5F6FA; border-radius: var(--radius); padding: 10px 12px; margin-top: 10px; }
.strip .btn { margin-left: auto; }
dl.fields { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
dl.fields dt { font-size: 12px; color: var(--muted); }
dl.fields dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; word-break: break-word; }
.drawer .note { margin: 0; line-height: 1.5; background: #FFFBEB; border: 1px solid #F3E2A9; border-radius: var(--radius); padding: 12px; white-space: pre-line; }
.drawer-foot { padding: 14px 24px; border-top: 1px solid #E8EBF2; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.drawer-foot select { min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 10px; background: var(--surface); margin-left: auto; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--brand-ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 60; }

/* Login */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; background: #F5F3F9; }
.login .hero { flex: 1 1 420px; background: var(--brand-ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.login .hero .eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 1.4px; color: #C9C8CC; }
.login .hero h1 { margin: 0 0 16px; font-size: 40px; line-height: 1.15; max-width: 460px; }
.login .hero p { margin: 0; font-size: 17px; line-height: 1.55; color: #DCDAE3; max-width: 460px; }
.login .hero ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.login .hero li { font-size: 12px; font-weight: 600; border: 1px solid #5E5B78; border-radius: 6px; padding: 4px 10px; }
.login .panel { flex: 1 1 420px; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.login form { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid #E4E2EA; border-radius: 16px; padding: 36px 32px; display: flex; flex-direction: column; gap: 18px; }
.login form img { width: 170px; align-self: center; }
.login form h2 { margin: 0; font-size: 22px; text-align: center; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.login input { min-height: 46px; border: 1px solid #D6D3DF; border-radius: var(--radius); padding: 0 14px; font-size: 15px; font-weight: 400; }
.login .error { background: #FDE2D3; color: var(--overdue-fg); padding: 10px 12px; border-radius: 8px; font-size: 14px; }

/* Top bar (como la barra + pestañas de AIR) */
:root { --topbar-h: 60px; }
.topbar { background: var(--surface); border-bottom: 1px solid #E4E2EA; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 0 24px; min-height: var(--topbar-h); box-sizing: border-box; position: sticky; top: 0; z-index: 30; }
.topbar .logo img { width: 92px; height: auto; display: block; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tabs.right { margin-left: auto; }
.tab { min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 8px; color: #45425C; text-decoration: none; font-size: 14px; }
.tab:hover { background: #F5F3F9; color: var(--brand); }
.tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.tab.disabled { opacity: .5; pointer-events: none; }
.topbar form { margin: 0; }
body > .main { padding: 16px 24px 32px; display: flex; flex-direction: column; gap: 14px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.toolbar .title { display: flex; flex-direction: column; margin-right: auto; }
.toolbar h1 { margin: 0; font-size: 22px; }
.toolbar .sub { color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg a { min-height: 42px; display: inline-flex; align-items: center; padding: 0 14px; color: #45425C; text-decoration: none; font-weight: 500; }
.seg a.on { background: var(--brand); color: #fff; font-weight: 600; }

/* Summary (tabla por secciones, estilo AIR) */
.sum-table { display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.sum-head, .sum-row { display: grid; grid-template-columns: var(--grid); gap: 0 14px; padding: 11px 16px; align-items: center; }
/* Título de sección + encabezados de columnas se quedan fijos bajo la barra superior mientras se recorre esa sección */
.sec > summary { position: sticky; top: var(--topbar-h); z-index: 6; }
.sum-head { position: sticky; top: calc(var(--topbar-h) + 47px); z-index: 5; background: #FAFAFC; border-bottom: 1px solid #ECEDF3; color: var(--muted); padding-top: 7px; padding-bottom: 7px; font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.sec { background: var(--surface); border: 1px solid #E4E6EE; border-radius: 12px; }
.sec > summary { border-radius: 12px 12px 0 0; }
.sec:not([open]) > summary { border-radius: 12px; }
.sec > .sum-row:last-child { border-radius: 0 0 12px 12px; }
.sec > summary { list-style: none; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 16px; font-size: 14px; font-weight: 700; cursor: pointer; user-select: none; background: var(--surface); border-bottom: 3px solid var(--sec); }
.sec:not([open]) > summary { border-bottom-color: transparent; box-shadow: inset 4px 0 0 var(--sec); }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary .chev { display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; }
.sec[open] > summary .chev { transform: rotate(90deg); }
.sec > summary .swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--sec); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.sec > summary .n { background: #EEF0F5; color: var(--text); border-radius: 10px; padding: 1px 9px; font-size: 12px; }
.sec > summary:hover { background: #FAFAFC; }
.sec > summary:focus-visible { outline: 3px solid rgba(56, 34, 96, .4); outline-offset: -3px; }
.sum-row { width: 100%; border: 0; border-top: 1px solid #F0F1F5; background: var(--surface); text-align: left; cursor: pointer; font-size: 13px; line-height: 1.35; color: var(--text); }
.sum-head + .sum-row { border-top: 0; }
.sec-body > .sum-row:last-child { border-radius: 0 0 12px 12px; }
.sum-row:hover { background: #F8F6FC; }
.sum-row:focus-visible { outline: 3px solid rgba(56, 34, 96, .35); outline-offset: -3px; }
.sum-row > span { min-width: 0; }
.sum-row .one { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-row .client { display: flex; flex-direction: column; }
.sum-row .num, .sum-head .num { text-align: right; }
.sum-row .container { font-family: var(--mono); font-weight: 600; letter-spacing: .2px; }
.sum-row .size { margin-left: 4px; }
.sum-row .muted, .muted { color: var(--muted); }
.sum-row .xs { font-size: 12px; }
.sum-row .sm, .mono.sm { font-size: 12px; }
.sum-row b { font-weight: 600; }
.note { display: inline-block; max-width: 100%; font-size: 12px; line-height: 1.4; word-break: break-word; color: #3A3850; }
.note.tinted { border-radius: 6px; padding: 2px 7px; color: var(--text); }
.clamp { display: -webkit-inline-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; vertical-align: top; }
.tag-live { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .5px; color: #fff; background: #5A6478; border-radius: 4px; padding: 0 5px; margin-right: 2px; vertical-align: 1px; }
.tag-live.live { background: #8A4A12; }
.lfd { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.lfd.urg-ok, .lfd.urg-none { background: transparent; padding-left: 0; color: var(--text); font-weight: 500; }
.ow-text { color: var(--overdue-fg); font-weight: 700; }
.sec-empty { padding: 12px 16px; color: var(--muted); }
@media (max-width: 1100px) {
  .sum-table { overflow-x: auto; }
  .sum-head, .sum-row { min-width: 1240px; }
}

/* Acciones de la fila y edición en la celda */
.row-menu { width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.sum-row:hover .row-menu, .row-menu:focus-visible { border-color: var(--border); background: var(--surface); color: var(--brand); }
.cell-btn { all: unset; box-sizing: border-box; display: block; max-width: 100%; min-height: 28px; padding: 3px 6px; margin: -3px -6px; border-radius: 6px; cursor: text; }
.cell-btn:hover { box-shadow: inset 0 0 0 1px #CFC6E2; background: #FBFAFE; }
.cell-btn:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.cell-btn .add { color: transparent; font-size: 12px; }
.sum-row:hover .cell-btn .add, .cell-btn:focus-visible .add { color: #8A87A0; }
.link-btn { all: unset; cursor: pointer; }
.link-btn:hover { color: var(--brand); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
.sum-row .cell { position: relative; }
.act-form.mode-inline { position: absolute; z-index: 20; top: -8px; left: -8px; min-width: 240px; background: var(--surface); border: 1px solid #CFC6E2; border-radius: 10px; box-shadow: 0 8px 24px rgba(26, 24, 48, .18); padding: 10px; display: flex; flex-direction: column; gap: 8px; cursor: default; }
.act-form.mode-inline textarea { min-width: 300px; }
.act-form .fld { display: flex; flex-direction: column; gap: 4px; }
.act-form .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.act-form input, .act-form select, .act-form textarea { min-height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); font-size: 14px; }
.act-form textarea { resize: vertical; line-height: 1.4; }
.act-form input:focus, .act-form select:focus, .act-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(56, 34, 96, .12); }
.act-form .hint { font-size: 12px; color: var(--muted); }
.act-buttons { display: flex; gap: 8px; }
.form-error { background: var(--overdue-bg); color: var(--overdue-fg); border-radius: 8px; padding: 8px 10px; font-size: 13px; }

/* Ventanita (menú de acciones y formularios) */
.dialog { position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); width: min(460px, calc(100vw - 32px)); max-height: 76vh; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: 0 20px 48px rgba(26, 24, 48, .25); z-index: 50; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-head { display: flex; align-items: center; gap: 10px; }
.dialog-head h2 { margin: 0; font-size: 18px; margin-right: auto; display: flex; flex-direction: column; gap: 2px; }
.dialog-head h2 .muted { font-size: 13px; font-weight: 500; }
.dialog .act-form { display: flex; flex-direction: column; gap: 12px; }
.action-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.action-list button, .action-list a { all: unset; box-sizing: border-box; width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 10px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); }
.action-list button:hover, .action-list a:hover { background: var(--brand-soft); color: var(--brand); }
.action-list button:focus-visible, .action-list a:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.action-list button:disabled { opacity: .5; cursor: not-allowed; background: none; color: var(--text); }
.action-list .ai { width: 34px; height: 34px; border-radius: 8px; background: #F3F1F8; color: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.action-list .soon { margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 0 6px; }

/* Historial en el panel de detalle */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history li { display: grid; grid-template-columns: 8px 1fr; gap: 10px; font-size: 13px; line-height: 1.4; }
.history li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #CFC6E2; margin-top: 6px; }
.history .when { color: var(--muted); font-size: 12px; }

/* Two-step verification */
.login .otp-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid #E4E2EA; border-radius: 16px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.login .otp-card h2 { margin: 0; font-size: 22px; }
.otp-lead { margin: 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
.otp-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
.otp-qr { align-self: center; width: 200px; height: 200px; padding: 8px; border: 1px solid #E4E2EA; border-radius: 12px; background: #fff; }
.otp-qr svg { width: 100%; height: 100%; display: block; }
.otp-manual summary { cursor: pointer; color: var(--brand-hover); font-size: 13px; font-weight: 600; }
.otp-manual code { display: block; margin-top: 8px; padding: 10px; background: #F5F3F9; border-radius: 8px; font-size: 14px; letter-spacing: 1px; word-break: break-all; }
.login input.otp-code { font-family: var(--mono); font-size: 22px; letter-spacing: 6px; text-align: center; }
.login label.otp-check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; color: #45425C; min-height: 44px; }
.login label.otp-check input { min-height: 0; width: 18px; height: 18px; accent-color: var(--brand); }
.otp-help { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; text-align: center; }
.otp-codes { list-style: none; margin: 0; padding: 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; background: #F5F3F9; border-radius: 10px; font-size: 16px; text-align: center; }
@media print { .login .hero, .login .btn { display: none; } .login .otp-card { border: 0; } }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; }
  .sidebar .nav-label, .user-card { display: none; }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login .hero { padding: 32px 16px; }
}

/* ---------- New order ---------- */
.no-form { display: flex; flex-direction: column; gap: 16px; max-width: 1280px; }
.toolbar.end { justify-content: flex-end; }
.seg-radio { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.seg-radio label { cursor: pointer; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio span { display: flex; flex-direction: column; min-width: 170px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-weight: 600; }
.seg-radio small { font-weight: 400; color: var(--muted); font-size: 12px; }
.seg-radio input:checked + span { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); color: var(--brand); }
.seg-radio input:focus-visible + span { outline: 3px solid rgba(56, 34, 96, .35); }
.no-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--surface); border: 1px solid #E4E6EE; border-radius: 12px; padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 2px; font-size: 15px; }
.card h2 small { font-weight: 400; font-size: 13px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.f, .picker { display: flex; flex-direction: column; gap: 5px; min-width: 0; position: relative; }
.f > span, .picker .lbl { font-size: 12px; font-weight: 600; color: #45425C; }
.f .opt { font-weight: 400; color: var(--muted); }
.f small, .picker small { font-size: 12px; color: var(--muted); }
.f em, .picker em { font-style: normal; font-size: 12px; color: var(--overdue-fg); font-weight: 600; }
.no-form input[type=text], .no-form input[type=date], .no-form input[type=email], .no-form select, .no-form textarea { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--surface); font-size: 14px; width: 100%; box-sizing: border-box; }
.no-form textarea { resize: vertical; line-height: 1.4; }
.no-form input:focus, .no-form select:focus, .no-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(56, 34, 96, .12); }
.no-form .bad input, .no-form .bad select, .no-form .bad textarea, .picker.bad .picker-q { border-color: var(--overdue-fg); }
.no-form input.up { text-transform: uppercase; }
.no-form input[type=file] { font-size: 13px; }
.yn { display: flex; gap: 6px; }
.yn label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 14px; }
.yn label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.yn input { accent-color: var(--brand); }
.no-form[data-kind=single] .only-many, .no-form[data-kind=export] .only-many { display: none; }
.no-form:not([data-kind=export]) .only-export { display: none; }
.no-form[data-kind=export] .only-import { display: none; }
.ct-head, .ct-row { display: grid; grid-template-columns: minmax(200px, 1.3fr) minmax(120px, .8fr) minmax(120px, .8fr) 36px; gap: 10px; align-items: start; }
.ct-head { font-size: 12px; font-weight: 600; color: #45425C; }
#ct-rows { display: flex; flex-direction: column; gap: 8px; }
.ct-row .kg { display: block; margin-top: 3px; }
.cc-msg { min-height: 0; margin-top: 3px; font-size: 12px; }
.cc.ok { color: #157F3B; }
.cc.warn { color: #8A5A00; }
.cc.error { color: var(--overdue-fg); font-weight: 600; }
.picker-list:empty { display: none; }
.picker-list { position: absolute; z-index: 25; top: 62px; left: 0; right: 0; max-height: 300px; overflow: auto; background: var(--surface); border: 1px solid #CFC6E2; border-radius: 10px; box-shadow: 0 10px 28px rgba(26, 24, 48, .16); padding: 4px; }
.picker-list button { all: unset; box-sizing: border-box; width: 100%; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.picker-list button:hover, .picker-list button:focus-visible { background: var(--brand-soft); }
.picker-list button small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-empty { margin: 0; padding: 10px; color: var(--muted); font-size: 13px; }
.picker-new summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--brand-hover); width: fit-content; }
.picker-new[open] { border: 1px dashed #CFC6E2; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.stack1 { display: flex; flex-direction: column; }
@media (max-width: 700px) { .row2, .ct-head, .ct-row { grid-template-columns: 1fr; } .ct-head { display: none; } }

/* Delivery order + lectura con IA */
.do-card { border-color: #D9CFEC; background: linear-gradient(0deg, #FFFFFF, #FFFFFF), var(--surface); }
.do-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.do-text { flex: 1 1 320px; display: flex; flex-direction: column; gap: 2px; }
.do-text small { color: var(--muted); font-size: 13px; }
.do-err { font-style: normal; color: var(--overdue-fg); font-weight: 600; font-size: 13px; }
.do-msg { border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.45; background: #F5F3F9; }
.do-msg.ok { background: #E9F6EC; color: #14532D; }
.do-msg.warn { background: #FFF6E5; color: #6B4500; }
.do-msg.error { background: var(--overdue-bg); color: var(--overdue-fg); font-weight: 600; }
.do-msg ul { margin: 6px 0 0; padding-left: 18px; }
.ai-filled, .no-form input.ai-filled, .no-form select.ai-filled, .no-form textarea.ai-filled { background: #F3EEFB !important; border-color: #B9A6DE !important; }
.yn.ai-filled { background: transparent !important; border-radius: 10px; box-shadow: 0 0 0 2px #D9CFEC; }
.ai-chip { background: #F3EEFB; border: 1px solid #B9A6DE; border-radius: 4px; padding: 0 5px; color: var(--brand); font-weight: 600; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #CFC6E2; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.do-msg.busy { background: #F3EEFB; color: var(--text); border: 1px solid #D9CFEC; }
.do-progress { display: flex; flex-direction: column; gap: 8px; }
.do-progress-head { display: flex; justify-content: space-between; gap: 12px; }
.do-progress-head span { font-variant-numeric: tabular-nums; color: var(--brand); font-weight: 700; }
.do-progress ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.do-progress li { font-size: 13px; }
.do-progress li.done { color: #157F3B; }
.do-progress li.now { color: var(--brand); font-weight: 600; }
.do-progress li.todo { color: #8A87A0; }
.do-progress small { color: var(--muted); }
.no-form.is-reading .no-grid { opacity: .45; pointer-events: none; filter: saturate(.6); transition: opacity .2s; }

/* Archive */
.st { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px; }
.st-done { background: #EEF0F5; color: #3E4A5E; }
.st-billing { background: #FFF4CC; color: #7A5A00; }
.st-paid { background: #D5F2D8; color: #14532D; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 6px 0 12px; color: var(--muted); font-size: 13px; }

/* Admin (manage) */
.alerts { display: flex; flex-wrap: wrap; gap: 8px; }
.alert { border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; }
.alert.expired { background: var(--overdue-bg); color: var(--overdue-fg); }
.alert.soon { background: var(--today-bg); color: var(--today-fg); }
.subtabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid #E4E2EA; }
.subtab { padding: 10px 14px; text-decoration: none; color: #45425C; border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 500; }
.subtab:hover { color: var(--brand); }
.subtab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
#filters select { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; background: var(--surface); }
.mtable-wrap { overflow-x: auto; background: var(--surface); border: 1px solid #E4E6EE; border-radius: 12px; }
.mtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.mtable th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); background: #FAFAFC; padding: 9px 14px; border-bottom: 1px solid #ECEDF3; }
.mtable td { padding: 10px 14px; border-top: 1px solid #F0F1F5; vertical-align: middle; }
.mtable tr.off td { color: var(--faint); }
.mtable td.acts { white-space: nowrap; text-align: right; }
.mtable td.acts .btn + .btn { margin-left: 4px; }
.mtable td.addr { max-width: 320px; }
.dialog.wide { width: min(720px, calc(100vw - 32px)); }
.mgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.mgrid .full { grid-column: 1 / -1; }
.mgrid .fld.chk { flex-direction: row; align-items: center; gap: 8px; min-height: 40px; }
.mgrid .fld.chk input { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }
.mgrid .fld em { font-style: normal; font-size: 12px; color: var(--overdue-fg); font-weight: 600; }
.mgrid .fld .opt { font-weight: 400; color: var(--muted); }
.act-form .fld.bad input, .act-form .fld.bad select, .act-form .fld.bad textarea { border-color: var(--overdue-fg); }
.temp-pass { display: flex; flex-direction: column; gap: 6px; background: #F3EEFB; border: 1px solid #D9CFEC; border-radius: 10px; padding: 12px; }
.temp-pass code { font-size: 20px; letter-spacing: 1px; color: var(--brand); }
a.avatar { text-decoration: none; }
@media (max-width: 700px) { .mgrid { grid-template-columns: 1fr; } }

/* Elección de método de verificación */
.method-card { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text); background: var(--surface); }
.method-card:hover { border-color: var(--brand); background: #FBFAFE; }
.method-card:focus-visible { outline: 3px solid rgba(56, 34, 96, .35); }
.method-card.recommended { border-color: #B9A6DE; box-shadow: inset 0 0 0 1px #B9A6DE; }
.method-card .mi { width: 44px; height: 44px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.method-card .mt { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.method-card .mt small { color: var(--muted); font-size: 13px; }
.badge-rec { font-size: 11px; font-weight: 700; color: #14532D; background: #D5F2D8; border-radius: 10px; padding: 2px 8px; }
.otp-card .otp-form { display: flex; flex-direction: column; gap: 14px; max-width: none; padding: 0; border: 0; background: none; }
.otp-inline { padding: 0 !important; border: 0 !important; background: none !important; max-width: none !important; gap: 0 !important; align-items: center; }
.link-btn.resend { color: var(--brand-hover); font-weight: 600; font-size: 13px; }

/* Formularios grandes de Admin (choferes, empleados): ventana amplia, 3 columnas y botones siempre visibles */
.dialog.wide { width: min(980px, calc(100vw - 32px)); top: 4vh; max-height: 92vh; padding-bottom: 0; }
.dialog.wide .mgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dialog.wide .act-buttons { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 16px; border-top: 1px solid #EEF0F5; margin-top: 4px; }
@media (max-width: 900px) { .dialog.wide .mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .dialog.wide { top: 0; max-height: 100vh; border-radius: 0; width: 100vw; } .dialog.wide .mgrid { grid-template-columns: 1fr; } }

.mgrid input, .mgrid select, .mgrid textarea { width: 100%; box-sizing: border-box; }
.mgrid textarea { min-height: 76px; }
