/* TempoGestión · sistema visual de la app.
   Un único CSS: tokens (variables) → base → layout → componentes → pantallas.
   Rejilla de 8 px (--s-*), bordes de 1 px, radios suaves, sombras mínimas.
   Paleta de tempogestion.es: tinta + ámbar. Contraste AA comprobado en claro y oscuro.
   Una sola familia: Inter (variable, servida en local), 600/700 en títulos. */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations"),
       url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #eef1f4;            /* fondo de la app (paper) */
  --surface: #ffffff;       /* tarjetas, barra lateral */
  --surface-2: #f6f8fa;     /* cabeceras de tabla, hover */
  --surface-3: #edf0f3;
  --ink: #14202e;           /* texto principal       16.3:1 sobre surface */
  --ink-2: #4a5868;         /* texto secundario       7.3:1 */
  --ink-3: #5f6b79;         /* texto terciario        5.4:1 */
  --rule: #e1e6eb;          /* bordes suaves */
  --rule-2: #cfd6de;        /* bordes de campos */
  --signal: #d98e04;        /* ámbar: acentos, nunca texto pequeño sobre claro */
  --signal-text: #8a5a00;   /* ámbar legible como texto 5.9:1 */
  --signal-soft: #fdf3e1;
  --signal-ink: #1a1206;
  --ok: #1f7a50;  --ok-soft: #e7f4ed;
  --danger: #b42318; --danger-soft: #fdeceb;
  --primary: #14202e; --primary-ink: #ffffff; --primary-hover: #24354a;
  --focus: 0 0 0 3px color-mix(in srgb, var(--signal) 45%, transparent);
  --shadow-1: 0 1px 2px rgba(20, 32, 46, .04), 0 1px 1px rgba(20, 32, 46, .03);
  --shadow-2: 0 8px 24px -8px rgba(20, 32, 46, .14), 0 2px 6px rgba(20, 32, 46, .05);
  --grid: rgba(20, 32, 46, .045);

  --f-display: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 40px; --s-8: 48px; --s-9: 64px;
  --r-1: 6px; --r-2: 8px; --r-3: 12px;
  --sidebar: 264px;
  --seg-on: #ffffff;
  --topbar: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1620;
    --surface: #16202c;
    --surface-2: #1b2735;
    --surface-3: #223042;
    --ink: #e6ebf1;           /* 13.9:1 */
    --ink-2: #a9b5c3;         /*  8.0:1 */
    --ink-3: #8f9cab;         /*  5.8:1 */
    --rule: #233141;
    --rule-2: #31435a;
    --signal: #f0a51c;
    --signal-text: #f3b23f;   /*  8.6:1 */
    --signal-soft: #2b2416;
    --ok: #4cc58c;  --ok-soft: #15291f;
    --danger: #f97066; --danger-soft: #2f1a1a;
    --primary: #e6ebf1; --primary-ink: #0f1620; --primary-hover: #ffffff;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow-2: 0 12px 32px -8px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
    --grid: rgba(230, 235, 241, .035);
    --seg-on: #2a3a4f;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font: 400 14px/1.55 var(--f-body);
  font-feature-settings: "cv11", "calt";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { font-family: var(--f-display); color: var(--ink); margin: 0; font-weight: 600; letter-spacing: -.011em; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.024em; }
h2 { font-size: 16px; line-height: 1.35; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: inherit; }
a:not([class]) { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
a:not([class]):hover { text-decoration-color: var(--signal); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
.num, table, .kpi-valor, .count { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11"; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--surface) calc(var(--sidebar) - 1px), var(--rule) calc(var(--sidebar) - 1px), var(--rule) var(--sidebar), transparent var(--sidebar)); }
.main { display: flex; flex-direction: column; min-width: 0; }
.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: var(--s-6) var(--s-7) var(--s-9); }

/* Barra lateral */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--rule);
  padding: var(--s-4) var(--s-3);
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3) var(--s-5); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: none; color: var(--ink); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-empresa { font: 600 15px/1.2 var(--f-display); letter-spacing: -.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-producto { font: 700 10px/1.4 var(--f-display); letter-spacing: .1em; color: var(--ink-3); text-transform: uppercase; }
.brand-producto b { color: var(--signal); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: var(--s-5) var(--s-3) var(--s-2); font: 500 12px/1 var(--f-body); color: var(--ink-3); }
.nav-sep { height: 1px; margin: var(--s-3) var(--s-3); background: var(--rule); }
.nav-link, .nav-sub > summary {
  position: relative; display: flex; align-items: center; gap: var(--s-3);
  min-height: 36px; padding: 0 var(--s-3); border-radius: var(--r-1);
  color: var(--ink-2); font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-link .icon, .nav-sub > summary .icon { color: var(--ink-3); transition: color .12s; }
.nav-link:hover, .nav-sub > summary:hover { background: var(--surface-2); color: var(--ink); }
.nav-link[aria-current="page"], .nav-sub.activo > summary { color: var(--ink); font-weight: 600; }
.nav-link[aria-current="page"] { background: var(--surface-2); }
.nav-link[aria-current="page"] .icon, .nav-sub.activo > summary .icon:first-child { color: var(--signal); }
.nav-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 2px; border-radius: 0 2px 2px 0; background: var(--signal);
}
.nav-sub > summary { list-style: none; }
.nav-sub > summary::-webkit-details-marker { display: none; }
.nav-sub > summary .chevron { margin-left: auto; width: 16px; height: 16px; transition: transform .15s; }
.nav-sub[open] > summary .chevron { transform: rotate(180deg); }
.nav-sub-items { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 var(--s-2) 20px; padding-left: var(--s-3); border-left: 1px solid var(--rule); }
.nav-sub-items .nav-link { min-height: 32px; font-size: 13.5px; }
.nav-sub-items .nav-link[aria-current="page"]::before { left: -13px; }
.sidebar-foot { margin-top: auto; padding: var(--s-5) var(--s-3) var(--s-1); font-size: 12px; color: var(--ink-3); }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: var(--s-4); padding: 0 var(--s-7);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.search { position: relative; flex: 1; max-width: 480px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 44px 0 40px; background: var(--surface); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
kbd { font: 500 11px/1 var(--f-body); color: var(--ink-3); border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 4px; padding: 3px 6px; background: var(--surface-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.btn.menu-toggle { display: none; }

.usermenu { position: relative; }
.usermenu > summary { list-style: none; display: flex; align-items: center; gap: var(--s-2); padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; border: 1px solid transparent; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover, .usermenu[open] > summary { background: var(--surface); border-color: var(--rule); }
.usermenu-nombre { font-weight: 600; font-size: 13.5px; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font: 600 12px/1 var(--f-display); letter-spacing: .02em; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 232px; z-index: 30;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-3); box-shadow: var(--shadow-2);
  padding: var(--s-2);
}
.dropdown-head { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--rule); margin-bottom: var(--s-2); }
.dropdown-head strong { display: block; font-weight: 600; }
.dropdown-head span { font-size: 12.5px; color: var(--ink-3); }
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 36px; padding: 0 var(--s-3);
  border: 0; background: none; border-radius: var(--r-1); color: var(--ink-2); font: 500 13.5px/1 var(--f-body); text-decoration: none; cursor: pointer; text-align: left;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); color: var(--ink); }
.dropdown form { margin: 0; }
.dropdown hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s-2) 0; }

/* ---------- Cabecera de página ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-head p { margin-top: var(--s-2); color: var(--ink-2); max-width: 64ch; }
.eyebrow { display: flex; align-items: center; gap: 6px; margin-bottom: var(--s-2); font: 500 13px/1.2 var(--f-body); color: var(--ink-3); }
.eyebrow a { text-decoration: none; }
.eyebrow a:hover { color: var(--ink); }
.eyebrow .icon { width: 14px; height: 14px; }
.actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-4); border-radius: var(--r-2); border: 1px solid transparent;
  font: 600 13.5px/1 var(--f-body); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn .icon { width: 16px; height: 16px; stroke-width: 1.75; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--rule-2); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding: 0 var(--s-3); font-size: 13px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-3); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--rule); }
.card-head h2 { display: flex; align-items: center; gap: var(--s-2); font-size: 15px; }
.card-head h2 .icon { color: var(--ink-3); }
.card-body { padding: var(--s-5); }
.card-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--rule); background: var(--surface-2); border-radius: 0 0 var(--r-3) var(--r-3); }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font: 600 11.5px/1 var(--f-body); font-variant-numeric: tabular-nums; }

.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: var(--s-5); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font: 600 11.5px/1 var(--f-body); border: 1px solid var(--rule); color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.chip-signal { background: var(--signal-soft); color: var(--signal-text); border-color: color-mix(in srgb, var(--signal) 30%, transparent); }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.chip-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Indicadores ---------- */
.kpi { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.kpi-titulo { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.kpi-valor { font: 600 30px/1.1 var(--f-display); letter-spacing: -.03em; color: var(--ink); margin-top: var(--s-1); }
.kpi-valor small { font-size: 18px; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.kpi-nota { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.kpi-nota.sube { color: var(--ok); }
.kpi-nota.alerta { color: var(--signal-text); }
.kpi-nota .icon { width: 14px; height: 14px; }

/* ---------- Listas de panel ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--rule); min-height: 56px; }
.list-item:last-child { border-bottom: 0; }
.list-item form { margin: 0 0 0 auto; }
.list-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--r-2); background: var(--surface-2); border: 1px solid var(--rule); color: var(--ink-3); }
.list-icon .icon { width: 16px; height: 16px; }
.list-icon.signal { color: var(--signal-text); background: var(--signal-soft); border-color: color-mix(in srgb, var(--signal) 25%, transparent); }
.list-icon.danger { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.list-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.list-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2); padding: var(--s-6) var(--s-5); color: var(--ink-3); }
.list-empty .icon { width: 22px; height: 22px; color: var(--ink-3); }
.list-empty strong { color: var(--ink-2); font-weight: 600; }
.inline-form { display: flex; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--rule); background: var(--surface-2); border-radius: 0 0 var(--r-3) var(--r-3); flex-wrap: wrap; }
.inline-form .input, .inline-form select { height: 36px; }
.inline-form .grow { flex: 1; min-width: 160px; }

/* ---------- Formularios ---------- */
.input, select, textarea {
  width: 100%; height: 40px; padding: 0 var(--s-3);
  font: 400 14px/1.4 var(--f-body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r-2);
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 96px; padding: 10px var(--s-3); resize: vertical; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: .85; }
.input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--signal); box-shadow: var(--focus); }
.input:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-2); cursor: not-allowed; }
input[type="file"].input { padding: 6px; height: auto; }
input[type="file"]::file-selector-button { font: 600 13px/1 var(--f-body); color: var(--ink); background: var(--surface-2); border: 1px solid var(--rule-2); border-radius: var(--r-1); padding: 8px 12px; margin-right: 12px; cursor: pointer; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) var(--s-5); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.label { font-size: 13px; font-weight: 600; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.form-section { padding: var(--s-6); }
.form-section + .form-section { border-top: 1px solid var(--rule); }
.form-section-title { margin-bottom: var(--s-1); font-size: 15px; }
.form-section-desc { margin-bottom: var(--s-5); color: var(--ink-3); font-size: 13px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--rule); background: var(--surface-2); border-radius: 0 0 var(--r-3) var(--r-3); }
.form-actions .left { margin-right: auto; }
.check { display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--ink-3); font-size: 12.5px; }

/* Control segmentado (permisos) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-2); background: var(--bg); border: 1px solid var(--rule); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 12px; border-radius: 6px; font: 500 12.5px/1 var(--f-body); color: var(--ink-2); white-space: nowrap; }
.segmented input:checked + span { background: var(--seg-on); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--rule); }
.segmented input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- Tablas ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; padding: 10px var(--s-5); background: var(--surface-2); border-bottom: 1px solid var(--rule); font: 500 12.5px/1.2 var(--f-body); color: var(--ink-3); white-space: nowrap; }
.table td { padding: 0 var(--s-5); height: 52px; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.primary { color: var(--ink); font-weight: 500; }
.table td.num, .table td.r { white-space: nowrap; }
.table td.primary a { text-decoration: none; }
.table td.primary a:hover { text-decoration: underline; text-decoration-color: var(--signal); text-underline-offset: 3px; }
.table .r { text-align: right; }
.table td form { margin: 0; }
.toolbar { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.toolbar .search { max-width: 360px; }
.toolbar .search input { height: 36px; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg); border: 1px solid var(--rule); border-radius: var(--r-2); }
.tabs a { padding: 6px 12px; border-radius: 6px; text-decoration: none; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.tabs a[aria-current="page"] { background: var(--seg-on); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--rule); }
.table-empty { padding: var(--s-8) var(--s-5) !important; height: auto !important; text-align: center; }

/* ---------- Mensajes ---------- */
.alerts { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-5); }
.alert { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-2); border: 1px solid var(--rule); background: var(--surface); box-shadow: var(--shadow-1); color: var(--ink); }
.alert .icon { margin-top: 1px; color: var(--ok); }
.alert-error .icon { color: var(--danger); }
.alert-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--rule)); }

/* ---------- Estado vacío de módulos ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--s-9) var(--s-5); }
.empty-icon { position: relative; display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: var(--s-5); border-radius: 16px; background: var(--surface); border: 1px solid var(--rule); box-shadow: var(--shadow-2); color: var(--ink); }
.empty-icon .icon { width: 28px; height: 28px; stroke-width: 1.25; }
.empty-icon::after { content: ""; position: absolute; right: -3px; top: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px var(--surface); }
.empty h2 { font-size: 20px; letter-spacing: -.018em; }
.empty p { margin-top: var(--s-2); max-width: 52ch; color: var(--ink-2); }
.empty .chip { margin-top: var(--s-5); }
.empty-pattern { background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; background-position: center; border-radius: var(--r-3) var(--r-3) 0 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-4); }
.tile { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-5); text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile:hover { border-color: var(--rule-2); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }
.tile .list-icon { width: 36px; height: 36px; }
.tile .arrow { color: var(--ink-3); width: 16px; height: 16px; transition: transform .15s, color .15s; }
.tile:hover .arrow { transform: translateX(2px); color: var(--signal); }
.tile strong { font: 600 14.5px/1.3 var(--f-display); letter-spacing: -.006em; }
.tile span { font-size: 13px; color: var(--ink-3); }

/* ---------- Login ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-art {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--s-8); overflow: hidden;
  background-color: #14202e; color: #e6ebf1;
  background-image: linear-gradient(rgba(230, 235, 241, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(230, 235, 241, .05) 1px, transparent 1px);
  background-size: 24px 24px;
}
.auth-art::after { content: ""; position: absolute; right: -180px; bottom: -180px; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(240, 165, 28, .35); box-shadow: 0 0 0 64px rgba(240, 165, 28, .04), 0 0 0 128px rgba(240, 165, 28, .025); }
.auth-art .brand { padding: 0; }
.auth-art .brand-mark { color: #e6ebf1; width: 36px; height: 36px; }
.auth-art .brand-producto { color: #e6ebf1; font-size: 13px; }
.auth-claim { position: relative; z-index: 1; max-width: 30ch; }
.auth-claim h2 { color: #e6ebf1; font: 700 clamp(32px, 3.6vw, 46px)/1.08 var(--f-display); letter-spacing: -.035em; }
.auth-claim h2 em { font-style: normal; color: #f0a51c; }
.auth-claim p { margin-top: var(--s-4); color: #a9b5c3; font-size: 15px; max-width: 40ch; }
.auth-foot { position: relative; z-index: 1; display: flex; gap: var(--s-5); color: #8f9cab; font-size: 12.5px; }
.auth-foot span { display: inline-flex; align-items: center; gap: 6px; }
.auth-panel { display: grid; place-items: center; padding: var(--s-7) var(--s-5); background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 28px; }
.auth-form > p { margin: var(--s-2) 0 var(--s-6); color: var(--ink-2); }
.auth-form .field + .field { margin-top: var(--s-4); }
.auth-form .btn { margin-top: var(--s-5); height: 44px; }
.auth-form .alert { margin-bottom: var(--s-5); box-shadow: none; }
.auth-legal { margin-top: var(--s-6); font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }

/* Página de error */
.solo { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5); }
.solo .card { max-width: 440px; width: 100%; }

/* ---------- Varios ---------- */
.perfil-head { display: flex; align-items: center; gap: var(--s-4); }
.backdrop { display: none; }
.results-group + .results-group { margin-top: var(--s-5); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(var(--sidebar), 86vw); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-2); }
  body.menu-abierto .sidebar { transform: none; }
  body.menu-abierto .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 22, 32, .45); }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 0 var(--s-4); gap: var(--s-2); }
  .content { padding: var(--s-5) var(--s-4) var(--s-8); }
  .usermenu-nombre, .usermenu .chevron, .search kbd { display: none; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .form-section { padding: var(--s-5); }
  .form-actions { padding: var(--s-4) var(--s-5); }
}
@media (max-width: 560px) {
  .grid-4 { gap: var(--s-3); }
  .kpi { padding: var(--s-4); }
  .kpi-valor { font-size: 24px !important; }
  .kpi-valor small { font-size: 15px; }
  h1 { font-size: 22px; }
  .kpi-valor { font-size: 26px; }
  .table th, .table td { padding-left: var(--s-3); padding-right: var(--s-3); }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Marca (mismo símbolo que tempogestion.es) */
.brand-mark .aguja { stroke: var(--signal); }
.brand-mark .centro { fill: var(--signal); }
.auth-art .brand-mark .aguja { stroke: #f0a51c; }
.auth-art .brand-mark .centro { fill: #f0a51c; }
.section-title { margin: var(--s-7) 0 var(--s-4); font-size: 15px; }
#volver { justify-content: center; padding-bottom: var(--s-8); }
#panel-listas, #panel-docs { margin-top: var(--s-5); }
.inline-form .auto, select.auto { width: auto; }
#total { margin-left: auto; font-size: 12.5px; }
.usercell { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.usercell .avatar { width: 32px; height: 32px; font-size: 11.5px; }
.block { display: block; }
.small { font-size: 12.5px; font-weight: 400; }
.perm-row td { height: 60px; }
.perfil-grid { align-items: start; }
.datos { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-3) var(--s-5); margin: 0; padding: var(--s-5); }
.datos dt { color: var(--ink-3); font-size: 13px; }
.datos dd { margin: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.stack-sm > * + * { margin-top: var(--s-4); }
#docs { margin-top: var(--s-5); }
.result { text-decoration: none; transition: background .1s; }
.result:hover { background: var(--surface-2); }
.results-group:last-child { margin-bottom: 0; }

/* Tarjetas de panel: formulario siempre al pie aunque la vecina sea más alta */
#panel-listas > .card { display: flex; flex-direction: column; }
#panel-listas > .card > .list, #panel-listas > .card > .list-empty { flex: 1; }
.kpis-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.kpis-head h2 { font-size: 15px; }
.section-title.first { margin-top: 0; }

/* ---------- Marca del cliente ---------- */
.logo-empresa { display: block; max-width: 100%; height: auto; object-fit: contain; }
.brand-cliente { flex-direction: column; align-items: flex-start; gap: var(--s-2); }
.brand-cliente .logo-empresa { height: 40px; width: auto; max-width: 200px; }
.brand-cliente .brand-empresa { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.sidebar-foot { display: flex; align-items: center; gap: 6px; }
.mini-marca { width: 14px; height: 14px; color: var(--ink-3); }
.auth-logo { margin-bottom: var(--s-5); }
.auth-logo .logo-empresa { height: 56px; width: auto; max-width: 240px; }
@media (prefers-color-scheme: dark) {
  /* Logo pensado para fondo claro: se apoya en una placa clara discreta. */
  .logo-empresa.con-placa { background: #f4f6f8; padding: 6px 10px; border-radius: var(--r-2); box-shadow: 0 0 0 1px rgba(255, 255, 255, .06); }
}

/* Configuración */
.logo-previews { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.logo-preview { display: grid; place-items: center; min-height: 112px; padding: var(--s-4); border-radius: var(--r-2); border: 1px solid var(--rule); }
.logo-preview .logo-empresa { height: 56px; width: auto; max-width: 220px; }
.logo-preview.fondo-claro { background: #ffffff; }
.logo-preview.fondo-oscuro { background: #16202c; border-color: #233141; }
.logo-preview.fondo-oscuro .logo-empresa.con-placa { background: #f4f6f8; padding: 6px 10px; border-radius: var(--r-2); }
.logo-preview .muted { font-size: 12.5px; text-align: center; }
.logo-preview-label { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.logo-acciones { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; margin-top: var(--s-3); }
.color-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
input[type="color"].input { width: 56px; height: 40px; padding: 4px; cursor: pointer; }
.swatch-demo { display: inline-flex; align-items: center; gap: var(--s-2); }
.auditoria { font-size: 12.5px; color: var(--ink-3); margin-right: auto; }
.errores { margin: 0; padding-left: 18px; }
.logo-preview.fondo-claro .logo-empresa.con-placa { background: none; padding: 0; box-shadow: none; }

/* Autocompletado (código postal y futuros combobox) */
.combo { position: relative; }
.combo-lista {
  position: absolute; z-index: 25; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: var(--s-1);
  list-style: none; max-height: 248px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-2); box-shadow: var(--shadow-2);
}
.combo-lista li { padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.combo-lista li:hover, .combo-lista li[aria-selected="true"] { background: var(--surface-2); }
.combo-lista li[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--signal); }
.cp-msg:empty { display: none; }
.cp-msg.error { color: var(--danger); }
.creditos { padding-top: 0; font-size: 12px; color: var(--ink-3); }
.chips-fila { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: calc(-1 * var(--s-3)) 0 var(--s-5); }
.chips-fila .muted { font-size: 12.5px; margin-right: var(--s-1); }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-4); padding: var(--s-5); }
.cifra-valor { font: 600 26px/1.1 var(--f-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.cifra-titulo { font-size: 13px; color: var(--ink-2); margin-top: var(--s-1); }
.limite { display: flex; align-items: center; gap: var(--s-3); }
.limite-barra { width: 96px; flex: none; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; max-width: 160px; }
.limite-barra progress { display: block; width: 100%; height: 100%; appearance: none; border: 0; background: transparent; }
.limite-barra progress::-webkit-progress-bar { background: transparent; }
.limite-barra progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
.limite-barra progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
.limite.lleno .limite-barra progress::-webkit-progress-value { background: var(--signal); }
.limite.lleno .limite-barra progress::-moz-progress-bar { background: var(--signal); }
#plan { margin-top: var(--s-5); }
.limite .num { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.limite .num strong { color: var(--ink); }
.nowrap { white-space: nowrap; }

/* ---------- Demos internas ---------- */
.selector-demo > summary { padding: 6px 10px; border-radius: var(--r-2); }
.selector-texto { font-size: 13px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-ancho { min-width: 300px; max-height: 70vh; overflow-y: auto; }
.dropdown button[aria-current="true"] { color: var(--ink); font-weight: 600; background: var(--surface-2); }
.marca-check { margin-left: auto; color: var(--signal); }
.demo-opcion { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; line-height: 1.2; }
.demo-opcion small { color: var(--ink-3); font-size: 11.5px; font-weight: 400; }
.dropdown button { min-height: 40px; }
.punto-color { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--signal); box-shadow: 0 0 0 1px var(--rule-2); }
.franja-demo { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; padding: 8px var(--s-7); font-size: 13px;
  background: var(--signal-soft); color: var(--ink); border-bottom: 1px solid color-mix(in srgb, var(--signal) 30%, var(--rule)); }
.franja-demo > span { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; }
.franja-demo .icon { color: var(--signal-text); }
.franja-demo form { margin: 0; }
.enlace { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
.enlace:hover { text-decoration-color: currentColor; }
.franja-demo .enlace { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--signal-text); }
.demos-tabla .acciones { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.demos-tabla .acciones form { margin: 0; }
.vocab-tabla td { height: 48px; }
.vocab-tabla .input, .vocab-tabla select { height: 36px; }
.enlace-nuevo { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.enlace-nuevo .input { flex: 1; min-width: 260px; font-family: ui-monospace, monospace; font-size: 12.5px; }
.borrar-demo { display: flex; gap: 4px; align-items: center; }
.borrar-demo .input { width: 150px; height: 32px; font-size: 12.5px; }
@media (max-width: 900px) { .franja-demo { padding: 8px var(--s-4); } .selector-texto .muted { display: none; } }
.tipos-contacto { display: flex; gap: var(--s-5); flex-wrap: wrap; padding: 10px 0; }
.chips-celda { display: inline-flex; gap: 4px; flex-wrap: wrap; }
