/* Accesos CapitalStore — sistema de estilos propio.
   Tokens → base → capa (shell) → componentes → páginas. Sin framework. */

:root {
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e4e7ec;
  --line-2: #eef0f3;
  --navy: #0b1b33;
  --navy-2: #13294b;
  --navy-text: #b8c4d8;
  --accent: #0e6f5c;
  --accent-2: #0a5748;
  --accent-soft: #e3f3ee;
  --accent-ring: rgba(14, 111, 92, .25);
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --info-soft: #eaf1fb;
  --info: #1d4ed8;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar: 236px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font); font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 15px; }
p { margin: 0; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.ic { flex: none; vertical-align: -3px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------- Shell: barra lateral + contenido ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy); color: var(--navy-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; color: #fff;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; color: #fff;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--navy-text); letter-spacing: .04em; text-transform: uppercase; }
.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px;
  color: var(--navy-text); font-weight: 500;
}
.nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav a.activo { background: var(--navy-2); color: #fff; }
.nav a.activo .ic { color: #6fd3bc; }
.sidebar-foot { margin-top: auto; padding: 14px 16px 16px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 12px; }
.sync-box { font-size: 12px; line-height: 1.45; }
.sync-box .label { color: var(--navy-text); text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; }
.sync-box .value { color: #fff; }
.sync-box .value.err { color: #fda29b; }
.who { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.who .name { color: #fff; font-weight: 500; }
.who a { color: var(--navy-text); display: inline-flex; align-items: center; gap: 5px; }
.who a:hover { color: #fff; text-decoration: none; }

.main { min-width: 0; padding: 28px 36px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-head .sub { color: var(--ink-2); margin-top: 3px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.crumb:hover { color: var(--ink); text-decoration: none; }
.count { color: var(--ink-3); font-weight: 400; margin-left: 6px; font-size: 16px; }

/* ---------- Flash ---------- */
.flash {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid; margin-bottom: 16px; font-size: 13.5px; white-space: pre-line;
}
.flash .ic { margin-top: 2px; }
.flash-ok { background: var(--accent-soft); border-color: #bfe3d7; color: #0a5748; }
.flash-error { background: var(--danger-soft); border-color: #f6c5c0; color: #912018; }
.flash-aviso { background: var(--warn-soft); border-color: #f5dea3; color: #7a3d0a; }
.flash-info { background: var(--info-soft); border-color: #c7d7f5; color: #1e3a8a; }

/* ---------- Tarjetas y tablas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line-2); }
.card-body { padding: 16px 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table th {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfcfd; }
.table .off td { color: var(--ink-3); }
.table .off a { color: var(--ink-2); }
.table-wrap > .table th:first-child, .table-wrap > .table td:first-child { padding-left: 18px; }
.table-wrap > .table th:last-child, .table-wrap > .table td:last-child { padding-right: 18px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-top: 1px solid var(--line-2); }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.list .when { color: var(--ink-3); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { color: var(--ink-3); padding: 18px 0; text-align: center; font-size: 13px; }

/* ---------- Métricas ---------- */
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 22px; }
.stat { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.stat:hover { border-color: #c9cfd8; text-decoration: none; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.stat.warn .n { color: var(--warn); }
.stat.danger .n { color: var(--danger); }
.stat.zero .n { color: var(--ink-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack { display: grid; gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 3fr) minmax(250px, 1fr); gap: 16px; align-items: start; }

/* ---------- Badges y estados ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; line-height: 1.5; white-space: nowrap; }
.badge-ok { background: var(--accent-soft); color: var(--accent-2); }
.badge-warn { background: var(--warn-soft); color: #7a3d0a; }
.badge-danger { background: var(--danger-soft); color: #912018; }
.badge-gray { background: var(--line-2); color: var(--ink-2); }
.badge-info { background: var(--info-soft); color: #1e40af; }

/* Glifos de estado de la matriz */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot-on { background: var(--accent); }
.dot-pend { background: #d97706; }
.dot-off { border: 2px solid #c1c7d0; background: transparent; }
.dot-none { width: 6px; height: 2px; border-radius: 1px; background: var(--line); }
.dot-err { color: var(--danger); display: inline-flex; }
.matrix-list th.rot { height: 118px; padding: 0 0 10px; vertical-align: bottom; width: 34px; }
.matrix-list th.rot span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; white-space: nowrap; letter-spacing: .04em; font-weight: 500; text-transform: none; font-size: 12px; color: var(--ink-2); }
.matrix-list td.cell { padding: 10px 6px; width: 34px; }
.matrix-list tbody tr:hover td.cell { background: #f2f7f5; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 10px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; border: 1px solid transparent; line-height: 1.3; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.btn-secondary:hover:not(:disabled) { border-color: #c9cfd8; background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #f6c5c0; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 5px; width: 28px; height: 28px; justify-content: center; border-radius: 6px; }
.btn-nav { width: 100%; justify-content: center; background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.12); }
.btn-nav:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.actions { display: inline-flex; gap: 4px; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 4px; }
.label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.label .hint { color: var(--ink-3); font-weight: 400; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
  background: var(--surface); font-size: 13.5px; line-height: 1.4; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--ink-3); }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.select-sm { padding: 4px 28px 4px 8px; font-size: 13px; }
.textarea { resize: vertical; min-height: 60px; }
.textarea.mono { font-family: var(--mono); font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding-top: 8px; grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 14px; }
.filters .input, .filters .select { width: auto; }
.search { position: relative; }
.search .ic { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 30px; width: 260px; }

/* ---------- Ficha de empleado ---------- */
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; margin-bottom: 16px; font-size: 13.5px; align-items: flex-start; }
.notice .ic { margin-top: 2px; }
.notice-danger { background: var(--danger-soft); border-color: #f6c5c0; color: #912018; }
.notice-warn { background: var(--warn-soft); border-color: #f5dea3; color: #7a3d0a; }
.notice-info { background: var(--info-soft); border-color: #c7d7f5; color: #1e3a8a; }
.reveal { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.reveal code { background: #fff; border: 1px solid var(--line); padding: 4px 10px; border-radius: 6px; font-size: 15px; letter-spacing: .04em; user-select: all; color: var(--ink); }
.matrix td { padding: 12px 14px; }
.matrix .pend { opacity: .45; }
.matrix .pname { font-weight: 500; }
.matrix .purl { font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }
.matrix .rid { font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }
.matrix .login { font-size: 12px; color: var(--ink-2); }
.matrix .cred { display: inline-flex; align-items: center; gap: 10px; justify-content: flex-end; white-space: nowrap; }
.err-text { font-size: 12px; color: var(--danger); max-width: 260px; }
.login-form { display: none; }

/* ---------- Login / instalación ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth .brand { padding: 0; color: var(--ink); margin-bottom: 18px; }
.auth .brand-sub { color: var(--ink-3); }
.auth form { display: grid; gap: 12px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; margin-bottom: -1px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.activo { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .stack { display: grid; gap: 16px; }
.grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .brand { padding: 14px 16px 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 0 12px 8px; }
  .nav a { padding: 7px 10px; font-size: 13px; }
  .sidebar-foot { border-top: 0; padding: 4px 16px 12px; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; }
  .sidebar-foot .btn-nav { width: auto; }
  .sidebar-foot .who { grid-column: 1 / -1; }
  .main { padding: 20px 16px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
  .search .input { width: 100%; }
  .page-head { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
