/* ================================================================
   ARGUS — Design System v2
   Agencia Despachante de Aduana Oriental SRL
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Layout */
  --topbar-h: 52px;

  /* Brand palette */
  --brand:       #0d1b3e;
  --brand-mid:   #1a3362;
  --brand-link:  #1e4a8a;
  --brand-light: #e8edf8;
  --gold:        #c9a227;
  --gold-light:  #e8c060;
  --gold-faint:  #fdf8ec;

  /* Surfaces -- alineadas a la paleta neutra (Apple-gray) de Operaciones */
  --bg:          #f5f5f7;
  --surface:     #ffffff;
  --surface-sub: #fafafa;

  /* Borders */
  --border:      #e5e5e7;
  --border-mid:  #d2d2d7;

  /* Text */
  --text:        #1d1d1f;
  --text-sub:    #3a3a3c;
  --text-muted:  #6e6e73;

  /* Semantic — green */
  --pos-text:  #166534;
  --pos-bg:    #dcfce7;
  /* Semantic — red */
  --neg-text:  #991b1b;
  --neg-bg:    #fee2e2;
  /* Semantic — blue */
  --imp-text:  #075985;
  --imp-bg:    #e0f2fe;
  /* Semantic — purple */
  --ter-text:  #4c1d95;
  --ter-bg:    #ede9fe;
  /* Semantic — amber */
  --warn-text: #92400e;
  --warn-bg:   #fef3c7;

  /* Radius */
  --r-xs:   4px;
  --r-sm:   6px;
  --r:      8px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-full: 9999px;

  /* Shadow scale */
  --sh-xs: 0 1px 2px 0 rgba(15,23,42,.05);
  --sh-sm: 0 1px 3px 0 rgba(15,23,42,.09), 0 1px 2px -1px rgba(15,23,42,.07);
  --sh:    0 4px 6px -1px rgba(15,23,42,.08), 0 2px 4px -2px rgba(15,23,42,.06);
  --sh-lg: 0 10px 15px -3px rgba(15,23,42,.08), 0 4px 6px -4px rgba(15,23,42,.06);
  --sh-xl: 0 20px 25px -5px rgba(15,23,42,.10), 0 8px 10px -6px rgba(15,23,42,.07);
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ──────────────────────────────────────────────────────── */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ── Skip link ─────────────────────────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: 0; z-index: 9999;
  padding: 8px 16px; background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700; text-decoration: none;
  border-radius: 0 0 var(--r) 0;
}
.skip-link:focus { top: 0; }

/* ── Max-width wrapper ─────────────────────────────────────────── */
.wrap { max-width: 1440px; margin: 0 auto; }

/* El topbar siempre ocupa el ancho completo de la ventana, sin importar
   el max-width que cada pagina defina para su propio .wrap (varia de
   900px a 1440px segun la pagina). Sin esto el menu compartido se ve
   angosto/recortado en paginas con .wrap chico. */
.wrap .topbar {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

/* ================================================================
   TOPBAR
   ================================================================ */
.topbar {
  background: var(--brand);
  padding: 0 20px;
  height: var(--topbar-h);
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
  border-bottom: none !important;
  border-radius: 0 !important;
  box-shadow: 0 1px 0 rgba(255,255,255,.05), 0 4px 16px rgba(15,23,42,.22) !important;
  position: sticky;
  top: 0;
  z-index: 100;
}

.tb-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.tb-logo {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .24em;
  color: var(--gold);
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}

.tb-sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,.14);
  flex-shrink: 0;
  display: block;
}

.topbar h1 {
  font-size: 18px !important;
  font-weight: 600 !important;
  color: rgba(255,255,255,.88) !important;
  margin: 0 !important;
  letter-spacing: 0 !important;
  white-space: nowrap;
}

/* El <nav> que envuelve .tb-right es el unico hijo flexible del topbar
   (.tb-brand tiene flex-shrink:0). Sin min-width:0 un item flex no se
   encoge por debajo del ancho de su contenido, asi que en celulares/
   tablets con muchos modulos habilitados el menu empujaba toda la pagina
   y aparecia scroll horizontal en el body. Con min-width:0 + overflow-x
   el exceso se queda contenido en un scroll horizontal del propio menu. */
.topbar nav {
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.topbar nav::-webkit-scrollbar { height: 4px; }
.topbar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }
.topbar nav::-webkit-scrollbar-track { background: transparent; }

.tb-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
  min-width: 0;
}
.tb-right > * { flex-shrink: 0; }

.tb-user {
  font-size: 11px;
  color: rgba(255,255,255,.36);
  padding-right: 10px;
  margin-right: 2px;
  border-right: 1px solid rgba(255,255,255,.1);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

/* Topbar nav links */
.topbar .tb-right > a:not(.tb-logout) {
  font-size: 12px;
  color: rgba(255,255,255,.60);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: color .12s, background .12s;
}
.topbar .tb-right > a:not(.tb-logout):hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}

/* Dropdown trigger */
.topbar .dd-group { position: relative; display: none; }

.topbar .dd-label {
  font-size: 12px;
  color: rgba(255,255,255,.60);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  user-select: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .12s, background .12s;
  line-height: 1.4;
}
.topbar .dd-label::after {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid currentColor;
  opacity: .7;
  flex-shrink: 0;
  transition: transform .18s ease;
}

.topbar .dd-group:hover .dd-label,
.topbar .dd-group.open  .dd-label {
  color: var(--gold-light);
  background: rgba(255,255,255,.07);
}
.topbar .dd-group:hover .dd-label::after,
.topbar .dd-group.open  .dd-label::after { transform: rotate(180deg); opacity: 1; }

/* Bridge to prevent menu closing */
.topbar .dd-group::after {
  content: '';
  position: absolute;
  top: 100%; left: 0; right: 0;
  height: 6px;
  z-index: 199;
}

/* Dropdown menu */
.topbar .dd-menu {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xl);
  min-width: 180px;
  z-index: 500;
  padding: 6px;
  animation: dd-in .12s ease;
}
@keyframes dd-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.topbar .dd-group:hover .dd-menu,
.topbar .dd-group.open .dd-menu,
.topbar .dd-group:focus-within .dd-menu { display: block; }

.topbar .dd-menu a {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-sub) !important;
  text-decoration: none !important;
  border-radius: var(--r-sm);
  background: transparent !important;
  border: none !important;
  transition: background .1s, color .1s;
}
.topbar .dd-menu a:hover {
  background: var(--bg) !important;
  color: var(--brand-link) !important;
}

/* Logout button */
.tb-logout {
  font-size: 11px !important;
  color: rgba(255,255,255,.48) !important;
  text-decoration: none !important;
  padding: 5px 12px !important;
  border: 1px solid rgba(255,255,255,.14) !important;
  border-radius: var(--r-sm) !important;
  background: transparent !important;
  margin-left: 4px;
  transition: color .12s, border-color .12s, background .12s;
  white-space: nowrap;
}
.tb-logout:hover {
  color: var(--gold-light) !important;
  border-color: rgba(201,162,39,.38) !important;
  background: rgba(201,162,39,.07) !important;
}

/* ================================================================
   SUBBAR / TABS
   ================================================================ */
.subbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 0;
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
}

/* Company selector */
.subbar select {
  font-size: 12px; font-weight: 700;
  color: var(--brand); border: none;
  background: transparent; cursor: pointer;
  margin-right: 20px; padding: 4px 2px;
  outline: none; font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: border-color .12s;
  -webkit-appearance: none;
  appearance: none;
}
.subbar select:hover { border-bottom-color: var(--border-mid); }

.tab {
  padding: 13px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
  user-select: none;
}
.tab:hover { color: var(--text-sub); }
.tab.active {
  color: var(--brand-link);
  border-bottom-color: var(--brand-link);
  font-weight: 600;
}

.sync-lbl {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   KPI STAT CARDS
   ================================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 24px 28px 8px;
}
.stat {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh-sm);
  border: 1.5px solid transparent;
  display: flex; align-items: flex-start;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .12s;
}
.stat:hover {
  box-shadow: var(--sh);
  transform: translateY(-1px);
}
.stat.active-filter {
  border-color: var(--brand-link);
  box-shadow: 0 0 0 3px rgba(30,74,138,.1), var(--sh-sm);
  background: #f0f5ff;
}
.stat-val {
  font-size: 30px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
}
.stat-lbl {
  font-size:11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 5px;
}

/* ================================================================
   FILTER BAR
   ================================================================ */
.filtros {
  display: flex; align-items: center;
  gap: 10px;
  padding: 16px 28px 12px;
  flex-wrap: wrap;
}
.filtros input[type=search] {
  flex: 1; min-width: 200px; max-width: 300px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 13px; font-family: inherit;
  background: var(--surface); color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.filtros input[type=search]:focus {
  border-color: var(--brand-link);
  box-shadow: 0 0 0 3px rgba(30,74,138,.08);
}

.sel-orden {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 12px; font-family: inherit;
  background: var(--surface); color: var(--text);
  outline: none; cursor: pointer;
  transition: border-color .15s;
}
.sel-orden:focus { border-color: var(--brand-link); }

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  padding: 5px 14px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  transition: all .12s;
  white-space: nowrap;
  user-select: none;
  line-height: 1.4;
}
.chip:hover { border-color: var(--brand-link); color: var(--brand-link); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.chip.imp:hover  { border-color: var(--imp-text); color: var(--imp-text); }
.chip.imp.on     { background: var(--imp-text); border-color: var(--imp-text); color: #fff; }
.chip.ter:hover  { border-color: var(--ter-text); color: var(--ter-text); }
.chip.ter.on     { background: var(--ter-text); border-color: var(--ter-text); color: #fff; }

/* ================================================================
   DATA TABLE
   ================================================================ */
.ctr {
  font-size: 11px; color: var(--text-muted);
  padding: 4px 28px 10px;
  font-weight: 500;
}

.tbl-wrap { padding: 0 28px 28px; overflow-x: auto; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--border);
}
.tbl thead {
  position: sticky;
  top: calc(var(--topbar-h) + 48px);
  z-index: 10;
}
.tbl th {
  background: var(--surface-sub);
  padding: 10px 14px;
  font-size:11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
  line-height: 1.4;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-sub); }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size:11px; font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
  line-height: 1.6;
}
.b-ac  { background: var(--pos-bg); color: var(--pos-text); }
.b-ba  { background: var(--neg-bg); color: var(--neg-text); }
.b-imp { background: var(--imp-bg); color: var(--imp-text); }
.b-ter { background: var(--ter-bg); color: var(--ter-text); }

.badge-pending  { background: var(--warn-bg); color: var(--warn-text); }
.badge-approved { background: var(--pos-bg);  color: var(--pos-text); }
.badge-rejected { background: var(--neg-bg);  color: var(--neg-text); }

/* ================================================================
   BUTTONS
   ================================================================ */
button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  font-family: inherit; line-height: 1;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  text-decoration: none; white-space: nowrap;
  vertical-align: middle;
}
button[type=submit], .btn-primary {
  background: var(--brand); color: #fff;
  width: 100%; justify-content: center; padding: 10px 16px;
}
button[type=submit]:hover, .btn-primary:hover { background: var(--brand-mid); }

.btn-print {
  background: var(--brand); color: #fff;
  padding: 7px 16px; font-size: 12px;
}
.btn-print:hover { background: var(--brand-mid); }

.btn-excel {
  background: var(--surface); color: var(--text-sub);
  border-color: var(--border);
  padding: 7px 14px; font-size: 12px;
}
.btn-excel:hover {
  background: var(--bg);
  border-color: var(--border-mid);
  color: var(--text);
}

.btn-success { background: var(--pos-text); color: #fff; }
.btn-danger  { background: var(--neg-text); color: #fff; }
.btn-warn    { background: #d97706; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ================================================================
   REPORTS
   ================================================================ */
.rpt-section { padding: 20px 28px 28px; }

.rpt-title {
  font-size: 11px; font-weight: 700;
  color: var(--brand-link);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 0 0 12px;
}

.rpt-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 24px;
}

.rpt-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rpt-tbl th {
  background: var(--surface-sub);
  padding: 10px 16px;
  font-size:11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.rpt-tbl th.r, .rpt-tbl td.r { text-align: right; }
.rpt-tbl td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.rpt-tbl tr:last-child td { border-bottom: none; }
.rpt-tbl tr:hover td { background: var(--surface-sub); }
.rpt-tbl .total-row td { font-weight: 700; background: var(--surface-sub); }

.bar-wrap { display: flex; align-items: center; gap: 8px; }
.bar {
  height: 6px; border-radius: 3px;
  background: var(--brand-link);
  min-width: 2px;
}

.rpt-controls {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.rpt-controls select {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 12px; font-family: inherit;
  background: var(--surface); color: var(--text);
  outline: none;
}

.note-box {
  background: var(--warn-bg);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 11.5px; color: var(--warn-text);
  margin-bottom: 16px;
}

/* ================================================================
   FORMS
   ================================================================ */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 14px; font-family: inherit;
  color: var(--text); background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-link);
  box-shadow: 0 0 0 3px rgba(30,74,138,.08);
}

/* ================================================================
   UTILITIES
   ================================================================ */
.hidden { display: none !important; }
.error-msg {
  background: var(--neg-bg); color: var(--neg-text);
  padding: 10px 14px; border-radius: var(--r);
  font-size: 13px; margin-bottom: 12px;
}
.success-msg {
  background: var(--pos-bg); color: var(--pos-text);
  padding: 10px 14px; border-radius: var(--r);
  font-size: 13px; margin-bottom: 12px;
}
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.gap-8 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-12 { margin-top: 12px; }

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 480px; max-width: 95vw;
  box-shadow: var(--sh-xl);
  border: 1px solid var(--border);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 15px; color: var(--text); font-weight: 600; }
.modal-close {
  background: none; border: none;
  font-size: 18px; color: var(--text-muted);
  cursor: pointer; width: auto; padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: background .1s;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ================================================================
   SIDEBAR LAYOUT (for pages that use it)
   ================================================================ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--brand);
  color: #fff; display: flex;
  flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-header h2 { font-size: 15px; }
.sidebar-header span { font-size: 11px; opacity: .6; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  color: rgba(255,255,255,.75);
  text-decoration: none; font-size: 13px;
  transition: background .12s;
}
.sidebar nav a:hover,
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-footer {
  margin-top: auto; padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-footer button {
  background: transparent; color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.25); width: 100%;
  padding: 7px; font-size: 12px;
}
.sidebar-footer button:hover { background: rgba(255,255,255,.1); color: #fff; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--border);
  padding: 20px; margin-bottom: 20px;
}
.card-title {
  font-size: 11px; font-weight: 700;
  color: var(--brand-link);
  text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ================================================================
   GENERIC TABLE (shared across pages)
   ================================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--surface-sub);
  text-align: left; padding: 10px 14px;
  font-size:11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-sub); }

/* ================================================================
   LOGIN (applies only to login.html which has its own complete CSS)
   ================================================================ */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--sh-xl); padding: 40px; width: 360px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { color: var(--brand); font-size: 26px; }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-logo small { color: var(--gold); font-weight: 600; }

/* ================================================================
   PRINT
   ================================================================ */
@media print {
  .topbar, .subbar, .filtros, .btn-print, .btn-excel, .rpt-controls {
    display: none !important;
  }
  body { background: #fff; }
  .rpt-card { box-shadow: none; border: 1px solid #ccc; }
  .tbl { box-shadow: none; }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --topbar-h: 48px; }
  .topbar { padding: 0 16px; }
  .subbar { padding: 0 16px; }
  .stats { padding-inline: 16px; gap: 12px; }
  .filtros { padding-inline: 16px; }
  .tbl-wrap { padding-inline: 16px; }
  .ctr { padding-inline: 16px; }
  .rpt-section { padding-inline: 16px; }
  .stat-val { font-size: 24px; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tb-user { display: none; }
}

/* ================================================================
   MENU HAMBURGUESA (<= 900px) — el boton lo inyecta api.js en todas
   las paginas con topbar; esta seccion solo define su aspecto y, bajo
   el breakpoint, convierte el nav horizontal en un panel vertical de
   pantalla completa. No fuerza display en .dd-group ni en los links
   gateados por permiso (lnkUsuarios, lnkArchivo, etc.) -- esos siguen
   ocultos/visibles segun el inline style que ya les pone cada pagina;
   aqui solo se ajusta layout de lo que YA esta visible.
   ================================================================ */
.tb-hamburger {
  display: none;
  background: transparent;
  border: none;
  width: 36px; height: 36px; padding: 0;
  cursor: pointer; flex-shrink: 0;
  align-items: center; justify-content: center;
  border-radius: var(--r-sm);
}
.tb-hamburger:hover { background: rgba(255,255,255,.08); }
.tb-hamburger span,
.tb-hamburger span::before,
.tb-hamburger span::after {
  display: block;
  width: 20px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.tb-hamburger span { position: relative; }
.tb-hamburger span::before,
.tb-hamburger span::after { content: ''; position: absolute; left: 0; }
.tb-hamburger span::before { top: -6px; }
.tb-hamburger span::after  { top: 6px; }
.topbar.nav-open .tb-hamburger span { background: transparent; }
.topbar.nav-open .tb-hamburger span::before { transform: translateY(6px) rotate(45deg); }
.topbar.nav-open .tb-hamburger span::after  { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 900px) {
  .tb-hamburger { display: inline-flex; }

  .topbar nav {
    position: fixed;
    top: var(--topbar-h); left: 0; right: 0; bottom: 0;
    overflow-y: auto; overflow-x: hidden;
    background: var(--brand);
    max-height: 0;
    visibility: hidden;
    transition: max-height .22s ease, visibility 0s linear .22s;
    z-index: 150;
    border-top: 1px solid rgba(255,255,255,.08);
    -webkit-overflow-scrolling: touch;
  }
  .topbar.nav-open nav {
    max-height: calc(100vh - var(--topbar-h));
    visibility: visible;
    transition: max-height .22s ease;
  }

  .tb-right {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
    padding: 8px 0 28px;
  }
  .tb-user {
    max-width: none; flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,.1);
    padding: 14px 20px; margin: 0 0 4px;
  }
  .topbar .tb-right > a:not(.tb-logout) {
    font-size: 15px;
    padding: 14px 20px;
    border-radius: 0;
    display: block;
  }
  .topbar .dd-group { width: 100%; }
  .topbar .dd-label {
    font-size: 15px;
    padding: 14px 20px;
    width: 100%;
    justify-content: space-between;
  }
  .topbar .dd-menu {
    position: static !important;
    top: auto !important; right: auto !important;
    box-shadow: none; border: none; border-radius: 0;
    background: rgba(0,0,0,.18);
    min-width: 0; width: 100%; padding: 0;
    animation: none;
  }
  .topbar .dd-menu a {
    display: flex;
    color: rgba(255,255,255,.75) !important;
    padding: 12px 20px 12px 36px;
    border-radius: 0;
    font-size: 14px;
  }
  .topbar .dd-menu a:hover {
    background: rgba(255,255,255,.06) !important;
    color: #fff !important;
  }
  .tb-logout {
    display: block !important;
    text-align: center;
    margin: 16px 20px 0 !important;
  }
}

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