/* UPK TimeControl: sistema de diseño del portal.
   Este archivo define tokens, tipografía, estructura y componentes compartidos.
   Los estilos propios de cada pantalla están en portal.css. */

/* ── Tipografía (archivos locales, licencia OFL) ── */
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/inter-latin-400-normal.da03732a27e1.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/inter-latin-500-normal.51205681a1ba.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/inter-latin-600-normal.2ede57db1a3a.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/inter-latin-700-normal.8ca0a5155296.woff2") format("woff2"); }

/* ── Tokens ── */
:root {
  /* Marca: UPK Brand System 2.1. El azul institucional y sus apoyos vienen del kit oficial. */
  --brand: #171678;          /* azul institucional UPK */
  --brand-strong: #0f0e5a;   /* azul institucional oscurecido: hover y texto sobre tinte */
  --brand-support: #3c3598;  /* azul de apoyo del kit */
  --night: #0a0f3c;          /* tinta UPK */

  --brand-tint: #ecebf7;     /* lila del kit (#cecde6) aclarado para fondos */
  --on-brand: #ffffff;
  --plane: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --ink: #0a0f3c;
  --ink-2: #3b4163;
  --muted: #575e7c;
  --grid: #dde0ec;
  --border: #dde0ec;
  --ok: #12703b;
  --warn: #8f5500;
  --crit: #b3321f;
  --ok-tint: #e4f5ea;
  --warn-tint: #fcf1dc;
  --crit-tint: #fceae6;

  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-tight: var(--font);
  --r-control: 10px;
  --r-panel: 16px;
  --shadow-card: 0 1px 2px rgba(10, 15, 60, .04), 0 10px 28px -18px rgba(10, 15, 60, .2);
  --shadow-pop: 0 30px 70px -24px rgba(10, 15, 60, .5);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
  --sidebar: 248px;
  --s1: var(--brand);
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #a3a8ff;
    --brand-strong: #c3c6ff;
    --brand-support: #8f89e6;
    --night: #070a26;
    --brand-tint: #232263;
    --on-brand: #0a0f3c;
    --plane: #0a0c22;
    --surface: #121532;
    --surface-2: #191c3e;
    --ink: #eceefa;
    --ink-2: #c0c4dc;
    --muted: #9298b8;
    --grid: #282c55;
    --border: #282c55;
    --ok: #5bcc8f;
    --warn: #e4a849;
    --crit: #f18a7c;
    --ok-tint: #12301f;
    --warn-tint: #35270e;
    --crit-tint: #3a1a15;
    --shadow-card: none;
    --shadow-pop: 0 30px 70px -24px rgba(0, 0, 0, .7);
  }
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; letter-spacing: -.006em; font-feature-settings: "cv05", "cv08", "ss03"; color: var(--ink); background: var(--plane); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
a { color: var(--brand); }
b, strong { font-weight: 600; }
button, select, input, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.muted { color: var(--muted); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-control); }
@media (forced-colors: active) { :focus-visible { outline: 2px solid Highlight; outline-offset: 2px; } }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--grid); border-radius: var(--r-control); }
.skip-link:focus { top: 12px; }

/* ── Marca ── */
/* El logotipo es el archivo oficial del kit (static/web/brand). No se redibuja ni se recolorea. */
.brand-lockup { display: inline-flex; align-items: center; gap: 12px; line-height: 1; }
.brand-lockup picture { display: inline-flex; }
.brand-logo { display: block; height: 34px; width: auto; }
.brand-product { padding-left: 12px; border-left: 1px solid var(--grid); font-size: 15px; font-weight: 600; color: var(--ink-2); letter-spacing: -.01em; }
.brand-lockup.on-dark .brand-logo { height: 40px; }
.brand-lockup.on-dark .brand-product { border-left-color: rgba(255, 255, 255, .35); color: rgba(255, 255, 255, .9); font-size: 17px; }

/* ── Estructura ── */
#layout { display: flex; min-height: 100vh; }
#sidebar { width: var(--sidebar); flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 22px 14px 18px; background: var(--surface); border-right: 1px solid var(--grid); }
.logo-row { padding: 0 8px 22px; }
#nav { display: flex; flex-direction: column; gap: 20px; }
.nav-title { margin: 0 12px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.nav-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; margin: 2px 0; border: 0; border-radius: var(--r-control); background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer; }
.nav-btn .icon { flex-shrink: 0; color: var(--muted); }
.nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-btn.act { background: var(--brand-tint); color: var(--brand-strong); font-weight: 600; }
.nav-btn.act .icon { color: var(--brand); }
.sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--grid); font-size: 12.5px; color: var(--muted); }
.sidebar-foot p { margin: 0 0 3px; }
.sidebar-org { display: flex; flex-direction: column; gap: 1px; color: var(--ink-2); font-weight: 500; overflow-wrap: anywhere; }
#country-label { color: var(--muted); font-weight: 400; }
#country-label:empty { display: none; }

#main { flex: 1; min-width: 0; padding: 26px 36px 36px; }
#cabecera { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
#titulo-vista { font-size: 26px; letter-spacing: -.02em; }
#fecha-vista { margin: 2px 0 0; font-size: 13.5px; }
#fecha-vista::first-letter { text-transform: uppercase; }
.cab-der { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#userbox { display: flex; align-items: center; gap: 10px; padding: 5px 16px 5px 5px; background: var(--surface); border: 1px solid var(--grid); border-radius: 999px; line-height: 1.25; }
#userbox .sub { font-size: 12px; }
#contenido:focus { outline: none; }
.page-foot { margin-top: 40px; color: var(--muted); font-size: 12.5px; }

/* ── Avatares ── */
.avatar { width: 36px; height: 36px; flex-shrink: 0; display: inline-grid; place-items: center; border-radius: 50%; font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.avatar.tone-0 { background: #e2eefb; color: #1c5aa6; }
.avatar.tone-1 { background: #e1f4ee; color: #12715a; }
.avatar.tone-2 { background: #f8ecd9; color: #8a5a0b; }
.avatar.tone-3 { background: #efe6fa; color: #6a3fb0; }
.avatar.tone-4 { background: #fbe6ea; color: #a8324a; }
.avatar.tone-5 { background: #e3f1f6; color: #17657e; }
@media (prefers-color-scheme: dark) {
  .avatar.tone-0 { background: #18344f; color: #9cc6f2; }
  .avatar.tone-1 { background: #143a31; color: #86d8bf; }
  .avatar.tone-2 { background: #3d2e13; color: #ebc078; }
  .avatar.tone-3 { background: #30234a; color: #c7a9f1; }
  .avatar.tone-4 { background: #46202a; color: #f2a3b3; }
  .avatar.tone-5 { background: #153844; color: #8fd0e3; }
}
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .sub { margin-top: 1px; }
.person b { white-space: nowrap; }

/* ── Botones ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 16px; border: 1px solid var(--grid); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none; transition: background-color .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: color-mix(in srgb, var(--muted) 45%, var(--grid)); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.pri:hover:not(:disabled) { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--grid)); }
.btn.crit { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, var(--grid)); }
.btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--grid)); }
.btn.ok:hover:not(:disabled) { background: var(--ok-tint); }
.btn.crit:hover:not(:disabled) { background: var(--crit-tint); }
.btn.warn:hover:not(:disabled) { background: var(--warn-tint); }

/* ── Formularios ── */
input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--grid); border-radius: var(--r-control); background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: color-mix(in srgb, var(--muted) 55%, var(--grid)); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--brand); }
label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.campo { display: grid; gap: 6px; margin: 0 0 14px; }
.check-line { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--ink); line-height: 1.5; }
.check-line input { margin-top: 2px; }
fieldset { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--grid); border-radius: var(--r-panel); }
legend { padding: 0 8px; font-weight: 700; font-size: 14.5px; }

/* ── Superficies ── */
.card { padding: 22px 24px; background: var(--surface); border: 1px solid var(--grid); border-radius: var(--r-panel); box-shadow: var(--shadow-card); }
.card h3 { margin-bottom: 10px; font-size: 16px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 30px 0 14px; }
#contenido > .section-head:first-child { margin-top: 4px; }
.section-head p { margin: 4px 0 0; }
.nota { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 16px; background: var(--warn-tint); border-radius: var(--r-control); color: var(--ink); }
.error-box { margin: 0 0 16px; padding: 12px 16px; background: var(--crit-tint); border-radius: var(--r-control); color: var(--crit); font-weight: 500; }
.error-box .btn { margin-left: 8px; }
.empty-state { padding: 44px 24px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed color-mix(in srgb, var(--muted) 35%, var(--grid)); border-radius: var(--r-panel); }
.empty-state::before { content: ""; display: block; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; background: var(--brand-tint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233c3598' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M12 7v5l3.2 2'/%3E%3C/svg%3E") center / 26px no-repeat; }
#feedback:empty { display: none; }

/* ── Indicadores ── */
.kpis, .incident-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin: 0 0 18px; }
.kpi { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--grid); border-radius: var(--r-panel); box-shadow: var(--shadow-card); }
.kpi-icon { width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: var(--brand-tint); color: var(--brand); }
.kpi-icon .icon { width: 22px; height: 22px; }
.kpi-body { min-width: 0; }
.kv { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kl { margin-top: 4px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.kpi .sub { margin: 3px 0 0; font-size: 12.5px; }

/* ── Tablas ── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--grid); border-radius: var(--r-panel); box-shadow: var(--shadow-card); }
.tabla { width: 100%; min-width: 620px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabla th { padding: 14px 18px 12px; text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tabla td { padding: 13px 18px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: var(--surface-2); }
.tabla .num { text-align: right; }
.tabla .date-cell { white-space: nowrap; }
.tabla td .btn { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin: 14px 0; }
.pager .sub { margin-right: auto; }

/* ── Etiquetas de estado ── */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.chip.ok::before, .chip.warn::before, .chip.crit::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-tint); color: var(--ok); }
.chip.warn { background: var(--warn-tint); color: var(--warn); }
.chip.crit { background: var(--crit-tint); color: var(--crit); }
.chip.info { background: var(--brand-tint); color: var(--brand-strong); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Pestañas ── */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: color-mix(in srgb, var(--grid) 60%, var(--plane)); border-radius: 12px; }
.tabs .btn { min-height: 32px; padding: 5px 14px; border-color: transparent; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 500; }
.tabs .btn:hover:not(:disabled) { background: color-mix(in srgb, var(--surface) 60%, transparent); border-color: transparent; }
.tabs .btn.active, .tabs .btn.pri { background: var(--surface); border-color: transparent; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(10, 15, 60, .14); }

/* ── Diálogos ── */
dialog { width: min(760px, calc(100% - 32px)); max-height: 88vh; overflow: auto; padding: 0 28px 28px; background: var(--surface); color: var(--ink); border: 0; border-radius: 20px; box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(10, 15, 60, .5); backdrop-filter: blur(2px); }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 -28px 20px; padding: 20px 28px 16px; background: var(--surface); border-bottom: 1px solid var(--grid); }
.dialog-head h2 { font-size: 19px; }
.dialog-head .btn { flex-shrink: 0; }
dialog h3 { margin: 18px 0 8px; }
pre { margin: 0; padding: 14px; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 12.5px; background: var(--surface-2); border-radius: var(--r-control); }

/* ── Estado de carga ── */
.loading { display: grid; gap: 16px; }
.loading-band { height: 104px; border-radius: var(--r-panel); }
.loading-rows { display: grid; gap: 1px; background: var(--grid); border: 1px solid var(--grid); border-radius: var(--r-panel); overflow: hidden; }
.loading-rows i { display: block; height: 52px; }
.loading-band, .loading-rows i { background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%) 0 0 / 220% 100%; animation: loading-sweep 1.4s linear infinite; }
@keyframes loading-sweep { to { background-position: -220% 0; } }

/* ── Pantallas pequeñas ── */
@media (max-width: 760px) {
  #layout { display: block; }
  #sidebar { position: static; width: 100%; height: auto; padding: 14px 14px 10px; border-right: 0; border-bottom: 1px solid var(--grid); }
  .logo-row { padding: 0 2px 12px; }
  #nav { flex-direction: row; gap: 4px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .nav-group { display: flex; gap: 4px; }
  .nav-title, .sidebar-foot { display: none; }
  .nav-btn { width: auto; white-space: nowrap; flex-shrink: 0; margin: 0; }
  #main { padding: 18px 14px 28px; }
  #titulo-vista { font-size: 22px; }
  .kpis, .incident-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { flex-direction: column; gap: 10px; padding: 16px; }
  .kv { font-size: 24px; }
  dialog { padding: 0 18px 20px; border-radius: 16px; }
  .dialog-head { margin: 0 -18px 16px; padding: 14px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
