:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* ─── LIGHT MODE ─── */
[data-theme="light"] {
  --bg: #f0f2fa;
  --surface: #ffffff;
  --surface2: #edf0fa;
  --border: #d4d9f0;
  --accent: #6c63ff;
  --accent2: #6c63ff;
  --text: #1a1d2e;
  --muted: #5a6480;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
}
[data-theme="light"] .topbar { box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
[data-theme="light"] .sidebar { box-shadow: 2px 0 8px rgba(0,0,0,0.06); }
[data-theme="light"] .badge-delay { background: rgba(239,68,68,0.10); }
[data-theme="light"] .badge-early { background: rgba(34,197,94,0.10); }
[data-theme="light"] .badge-ok { background: rgba(90,100,128,0.10); }
[data-theme="light"] .badge-shift-morning { background: rgba(245,158,11,0.12); }
[data-theme="light"] .badge-shift-afternoon { background: rgba(108,99,255,0.10); }
[data-theme="light"] .badge-shift-night { background: rgba(99,102,241,0.10); }
[data-theme="light"] tr:hover td { background: rgba(108,99,255,0.05); }
[data-theme="light"] ::-webkit-scrollbar-track { background: #e8ebf5; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c4cbdf; }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── LAYOUT ─── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.topbar .logo { font-size: 18px; font-weight: 700; color: var(--accent2); flex: 1; }
.topbar .branch-name { color: var(--muted); font-size: 13px; }

.main { display: flex; flex: 1; }

.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 0; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--muted); border-radius: 0;
  transition: all 0.15s; font-size: 14px;
}
.sidebar a:hover, .sidebar a.active {
  color: var(--text); background: var(--surface2); text-decoration: none;
}
.sidebar a.active { border-left: 3px solid var(--accent); color: var(--accent2); }
.sidebar .section-title {
  padding: 16px 20px 6px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.content { flex: 1; padding: 28px; max-width: 1200px; }

/* ─── CARDS ─── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text); }

/* ─── FORMS ─── */
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: 6px; font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 70px; }

/* ─── BUTTONS ─── */
.btn {
  padding: 8px 18px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 500; transition: all 0.15s; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7c75ff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── TABLE ─── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; background: var(--surface2); }
tr:hover td { background: rgba(108,99,255,0.04); }
td .actions { display: flex; gap: 6px; }

/* ─── BADGES ─── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-delay { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-early { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-ok { background: rgba(148,163,184,0.15); color: var(--muted); }
.badge-shift-morning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-shift-afternoon { background: rgba(108,99,255,0.15); color: var(--accent2); }
.badge-shift-night { background: rgba(99,102,241,0.15); color: #818cf8; }

/* ─── STAT CARDS ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
}
.stat-card .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-card .value { font-size: 22px; font-weight: 700; }
.stat-card .value.positive { color: var(--success); }
.stat-card .value.negative { color: var(--danger); }
.stat-card .value.neutral { color: var(--accent2); }

/* ─── LOGIN ─── */
#login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-box {
  width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 40px; box-shadow: var(--shadow);
}
.login-box h1 { font-size: 24px; font-weight: 700; color: var(--accent2); margin-bottom: 4px; }
.login-box .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.login-box .form-grid { gap: 16px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 4px; padding: 10px; }
.login-toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.login-toggle span { color: var(--accent2); cursor: pointer; }
.login-toggle span:hover { text-decoration: underline; }
.error-msg { color: var(--danger); font-size: 13px; padding: 8px 12px; background: rgba(239,68,68,0.1); border-radius: 6px; display: none; }

/* ─── BRANCHES ─── */
.branches-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.branch-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; cursor: pointer;
  transition: all 0.15s; position: relative;
}
.branch-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.branch-card h3 { font-size: 16px; margin-bottom: 4px; }
.branch-card .addr { font-size: 12px; color: var(--muted); }
.branch-card .cur { font-size: 12px; color: var(--accent2); margin-top: 8px; }
.new-branch-card {
  border: 2px dashed var(--border); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); min-height: 110px;
  cursor: pointer; transition: all 0.15s; border-radius: var(--radius);
}
.new-branch-card:hover { border-color: var(--accent); color: var(--accent2); }
.new-branch-card .icon { font-size: 28px; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  display: none;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; width: 500px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal h2 { font-size: 18px; margin-bottom: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ─── TABS ─── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 10px 18px; cursor: pointer; color: var(--muted); font-size: 14px;
  border-bottom: 2px solid transparent; transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent); }

/* ─── PAGE HEADERS ─── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 600; }
.page-header .actions { display: flex; gap: 10px; }

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 48px; color: var(--muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── ALERTS ─── */
.alert {
  padding: 10px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: rgba(239,68,68,0.12); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: rgba(34,197,94,0.12); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }

/* ─── REPORT ─── */
.report-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.report-header {
  background: var(--surface); padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.report-total {
  font-size: 18px; font-weight: 700; color: var(--success);
  padding: 16px 20px; text-align: right;
}

/* ─── BOTTOM NAV (mobile) ─── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bnav-items { display: flex; }
.bnav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 2px; color: var(--muted);
  font-size: 10px; gap: 2px;
  border: none; background: transparent; cursor: pointer;
  transition: color 0.15s; -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}
.bnav-item .bnav-icon { font-size: 20px; line-height: 1.2; }
.bnav-item.active { color: var(--accent2); }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 12px; padding-bottom: 76px; max-width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .bottom-nav { display: block; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; height: 50px; }
  .topbar .branch-name { display: none; }
  .topbar .logo { font-size: 15px; }

  /* Login */
  .login-box { width: calc(100% - 32px); padding: 28px 20px; }

  /* Tables */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 8px 8px; font-size: 12px; }

  /* Page header */
  .page-header { flex-wrap: wrap; gap: 8px; }
  .page-header h2 { font-size: 17px; }

  /* Stats */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Modal full width */
  .modal { width: 95vw; padding: 20px 16px; }

  /* Card padding */
  .card { padding: 14px; }
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── UTILS ─── */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent2); }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ─── PRINT STYLES ─── */
.no-print { }
@media print {
  .no-print, .sidebar, .topbar, .modal-overlay { display: none !important; }
  body { background: #fff !important; color: #000 !important; font-size: 12px; }
  .content { padding: 0 !important; max-width: 100% !important; }
  .print-comprobante { border: none !important; background: #fff !important; }
  .card, .report-box { background: #fff !important; border-color: #ccc !important; }
  .comp-header { background: #f5f5f5 !important; }
  a { color: #000 !important; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
  .badge { border: 1px solid #ccc; background: #eee !important; color: #000 !important; }
}

/* ─── COMPROBANTE ─── */
.print-comprobante {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
}
.comp-header {
  background: var(--surface); padding: 20px 24px;
  border-bottom: 2px solid var(--accent);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.comp-title { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.comp-branch { font-size: 18px; font-weight: 700; color: var(--accent2); margin-top: 4px; }
.comp-period { font-size: 13px; color: var(--muted); text-align: right; padding-top: 4px; }
.comp-emp-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
}
.comp-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
  gap: 0; border-bottom: 1px solid var(--border);
}
.comp-stat {
  padding: 14px 20px; border-right: 1px solid var(--border);
}
.comp-stat:last-child { border-right: none; }
.comp-stat.positive .cs-val { color: var(--success); }
.comp-stat.negative .cs-val { color: var(--danger); }
.cs-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.cs-val { font-size: 20px; font-weight: 700; }
.comp-section-title {
  padding: 12px 24px 6px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
}
.comp-total {
  font-size: 20px; font-weight: 700; padding: 16px 24px; text-align: right;
  border-top: 2px solid var(--border);
}
.comp-total.positive { color: var(--success); }
.comp-total.negative { color: var(--danger); }
.comp-firma {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 20px 24px; border-top: 1px solid var(--border);
}
.firma-box { font-size: 12px; color: var(--muted); }

/* ─── FORGOT PASSWORD ─── */
.forgot-msg {
  text-align: center; padding: 24px 8px 8px;
  color: var(--muted); font-size: 14px; line-height: 1.6;
}

/* ─── FORGOT PASSWORD ─── */
.forgot-title { font-size:17px; font-weight:700; color:var(--text); margin-bottom:8px; }
.forgot-sub { font-size:13px; color:var(--muted); margin-bottom:18px; line-height:1.5; }
#forgot-view .field { margin-bottom:14px; }
