/* =========================================================================
   SICOR — Sistema de diseño
   Tema claro/oscuro con tokens. Azul corporativo + amarillo de marca.
   Un único archivo para todo el sistema (admin, supervisor, operador).
   ========================================================================= */

/* ---------- Tokens: TEMA CLARO (por defecto) ---------- */
:root {
  --bg:            #eef1f6;
  --surface:       #ffffff;
  --surface-2:     #f7f9fc;
  --surface-3:     #eff3f9;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --text:          #0f172a;
  --text-soft:     #334155;
  --text-muted:    #64748b;
  --text-faint:    #94a3b8;

  --primary:       #2563eb;
  --primary-600:   #1d4ed8;
  --primary-700:   #1e40af;
  --primary-weak:  #eaf1fe;
  --on-primary:    #ffffff;

  --brand:         #f59e0b;   /* amarillo de marca, versión sobria */
  --brand-600:     #d97706;
  --brand-weak:    #fef3c7;

  --ok:            #16a34a;
  --ok-weak:       #dcfce7;
  --warn:          #d97706;
  --warn-weak:     #fef3c7;
  --danger:        #dc2626;
  --danger-weak:   #fee2e2;
  --info:          #0891b2;
  --info-weak:     #cffafe;

  --sidebar-bg:      #0e1a2b;
  --sidebar-surface: #16273e;
  --sidebar-text:    #b8c6da;
  --sidebar-text-mut:#7d8fa9;
  --sidebar-active:  #2563eb;
  --sidebar-border:  rgba(255,255,255,.07);

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.12);

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  --sidebar-w: 260px;
  --topbar-h:  64px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

/* ---------- Tokens: TEMA OSCURO ---------- */
:root[data-theme="dark"] {
  --bg:            #0a0e16;
  --surface:       #121926;
  --surface-2:     #0f1622;
  --surface-3:     #1a2434;
  --border:        #223049;
  --border-strong: #33455f;

  --text:          #e6edf6;
  --text-soft:     #c2cede;
  --text-muted:    #8b9cb5;
  --text-faint:    #61728c;

  --primary:       #3b82f6;
  --primary-600:   #2563eb;
  --primary-700:   #1d4ed8;
  --primary-weak:  #16233b;
  --on-primary:    #ffffff;

  --brand:         #fbbf24;
  --brand-600:     #f59e0b;
  --brand-weak:    #2a2411;

  --ok:            #22c55e;
  --ok-weak:       #10241a;
  --warn:          #f59e0b;
  --warn-weak:     #2a2411;
  --danger:        #ef4444;
  --danger-weak:   #2a1616;
  --info:          #22d3ee;
  --info-weak:     #0c2429;

  --sidebar-bg:      #0b1220;
  --sidebar-surface: #141f33;
  --sidebar-text:    #b3c1d6;
  --sidebar-text-mut:#6f819b;
  --sidebar-active:  #3b82f6;
  --sidebar-border:  rgba(255,255,255,.06);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 1px 3px rgba(0,0,0,.5);
  --shadow-md: 0 4px 14px rgba(0,0,0,.45);
  --shadow-lg: 0 14px 40px rgba(0,0,0,.55);
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
[hidden] { display: none !important; }

/* =========================================================================
   LAYOUT (app shell)
   ========================================================================= */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  z-index: 1000;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px; height: var(--topbar-h);
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar__logo {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand), var(--brand-600));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #1a1205; font-size: 18px;
}
.sidebar__brand b { color: #fff; font-size: 18px; letter-spacing: .5px; font-weight: 800; }
.sidebar__brand span { display: block; color: var(--sidebar-text-mut); font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar__label { padding: 14px 12px 6px; font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--sidebar-text-mut); font-weight: 700; }
.sidebar__link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 3px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.sidebar__link:hover { background: var(--sidebar-surface); color: #fff; text-decoration: none; }
.sidebar__link.is-active { background: var(--sidebar-active); color: #fff; box-shadow: var(--shadow-sm); }
.sidebar__link .ico { width: 20px; text-align: center; font-size: 16px; flex: 0 0 auto; }
.sidebar__link .count {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.sidebar__foot { padding: 12px; border-top: 1px solid var(--sidebar-border); }

.sidebar__logout {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; border-radius: var(--radius-sm);
  color: #fca5a5; font-weight: 600; font-size: 13px;
  border: 1px solid rgba(248,113,113,.25); background: rgba(248,113,113,.08);
}
.sidebar__logout:hover { background: rgba(248,113,113,.16); text-decoration: none; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; z-index: 900;
}
.topbar__title h1 { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.topbar__title p { font-size: 12px; color: var(--text-muted); }
.topbar__right { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; color: var(--text-soft);
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.96); }
.icon-btn .count {
  position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}

.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 40px; border: 1px solid var(--border); background: var(--surface); }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.user-chip .u-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.1; }
.user-chip .u-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* Main content */
.main { margin-left: var(--sidebar-w); padding-top: var(--topbar-h); min-height: 100vh; }
.content { padding: 24px; max-width: 1360px; margin: 0 auto; }

/* Hamburger + overlay (móvil) */
.hamburger { display: none; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; align-items: center; justify-content: center; }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; position: relative; }
.hamburger span::before, .hamburger span::after { content: ""; position: absolute; left: 0; width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
.hamburger span::before { top: -6px; } .hamburger span::after { top: 6px; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(2,6,15,.5); backdrop-filter: blur(2px); z-index: 990; }
.overlay.is-open { display: block; }

/* =========================================================================
   COMPONENTES
   ========================================================================= */

/* Page header dentro del contenido */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.page-head .sub { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__head h3 { font-size: 15px; font-weight: 700; }
.card__body { padding: 20px; }
.card--pad { padding: 20px; }

/* Grid utilidades */
.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Stat tile */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
}
.stat__icon { width: 48px; height: 48px; border-radius: 12px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat__icon--blue   { background: var(--primary-weak); color: var(--primary); }
.stat__icon--amber  { background: var(--brand-weak);   color: var(--brand-600); }
.stat__icon--green  { background: var(--ok-weak);      color: var(--ok); }
.stat__icon--red    { background: var(--danger-weak);  color: var(--danger); }
.stat__icon--cyan   { background: var(--info-weak);    color: var(--info); }
.stat__meta { min-width: 0; }
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1; }
.stat__label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat__trend { font-size: 11.5px; font-weight: 600; margin-top: 6px; }
.trend-up { color: var(--ok); } .trend-down { color: var(--danger); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--primary-600); }
.btn--brand { background: var(--brand); color: #1a1205; }
.btn--brand:hover { background: var(--brand-600); }
.btn--ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.94); }
.btn--sm { padding: 7px 12px; font-size: 12.5px; }
.btn--icon { padding: 8px; width: 36px; height: 36px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 40px; font-size: 11.5px; font-weight: 700; line-height: 1.5; }
.badge--ok    { background: var(--ok-weak);     color: var(--ok); }
.badge--warn  { background: var(--warn-weak);   color: var(--warn); }
.badge--bad   { background: var(--danger-weak); color: var(--danger); }
.badge--info  { background: var(--info-weak);   color: var(--info); }
.badge--muted { background: var(--surface-3);   color: var(--text-muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Tablas */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl thead th {
  text-align: left; padding: 12px 16px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-soft); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Formularios */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Alertas */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; margin-bottom: 18px; border: 1px solid transparent; }
.alert--ok   { background: var(--ok-weak);     color: var(--ok);     border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert--warn { background: var(--warn-weak);   color: var(--warn-600, var(--warn)); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert--bad  { background: var(--danger-weak); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert--info { background: var(--info-weak);   color: var(--info);   border-color: color-mix(in srgb, var(--info) 30%, transparent); }

/* Estado vacío */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty .em-ico { font-size: 42px; opacity: .5; margin-bottom: 10px; }
.empty h4 { color: var(--text-soft); font-size: 16px; margin-bottom: 4px; }

/* Barras de gráfico (CSS puro) */
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.chart-bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bars .bar { width: 100%; max-width: 46px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--primary), var(--primary-700)); min-height: 4px; transition: height .5s ease; position: relative; }
.chart-bars .bar:hover { filter: brightness(1.08); }
.chart-bars .bar-val { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.chart-bars .bar-lbl { font-size: 11px; color: var(--text-muted); }

/* Progreso */
.progress { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); }

/* Utilidades */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.mt-8{margin-top:8px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}.mb-0{margin-bottom:0}
.text-muted { color: var(--text-muted); } .text-soft { color: var(--text-soft); }
.text-right { text-align: right; } .text-center { text-align: center; }
.fw-700 { font-weight: 700; } .fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; }
.hide-sm { }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { left: 0; padding: 0 14px; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .hamburger { display: inline-flex; }
  .topbar__title p { display: none; }
  .user-chip .u-meta { display: none; }
  .hide-sm { display: none !important; }
}
@media (max-width: 560px) {
  .page-head h2 { font-size: 19px; }
  .stat { padding: 14px 16px; gap: 12px; }
  .stat__value { font-size: 22px; }
  .card__body, .card--pad { padding: 16px; }
}

/* =========================================================================
   TABS
   ========================================================================= */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: 18px; }
.tabs button {
  padding: 10px 16px; background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; } .tab-panel.is-active { display: block; }

/* =========================================================================
   MODAL
   ========================================================================= */
.modal { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px;
  background: rgba(2,6,15,.55); backdrop-filter: blur(4px); }
.modal.is-open { display: flex; }
.modal__box { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 17px; font-weight: 700; }
.modal__close { background: transparent; border: 0; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.modal__close:hover { color: var(--danger); }
.modal__body { padding: 22px; }
.modal__foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Avatar de fila y acciones de tabla */
.row-actions { display: inline-flex; gap: 6px; }

/* Respeto a reduce-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
