/* ============ Tokens ============ */
:root {
  --bg: #F6F7F4;
  --surface: #FFFFFF;
  --surface-2: #EEF0EA;
  --surface-hover: #E6E9E1;
  --border: #DEE2D8;
  --text: #1B211D;
  --text-muted: #5C665F;
  --text-faint: #8B948B;
  --accent: #2F6F5E;
  --accent-strong: #235A4C;
  --accent-soft: #E1EEE9;
  --accent-contrast: #FFFFFF;
  --good: #2E7D46;
  --good-soft: #E4F3E7;
  --warning: #A66A05;
  --warning-soft: #FBF0DA;
  --critical: #C23B3B;
  --critical-soft: #FBE7E7;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 8px 24px -12px rgba(20, 30, 25, 0.18);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-display: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Public Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141815;
    --surface: #1C211D;
    --surface-2: #242A24;
    --surface-hover: #2C332C;
    --border: #343C34;
    --text: #E9ECE6;
    --text-muted: #A2AB9E;
    --text-faint: #6F786E;
    --accent: #55B295;
    --accent-strong: #6FC7AA;
    --accent-soft: #1E332C;
    --accent-contrast: #0C1310;
    --good: #4CAF6D;
    --good-soft: #1B3324;
    --warning: #D9A13B;
    --warning-soft: #3A2E13;
    --critical: #E0716F;
    --critical-soft: #3A1E1E;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; text-wrap: balance; color: var(--text); }
p { margin: 0; }
button { font-family: inherit; }
a { color: var(--accent); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

::selection { background: var(--accent-soft); }

/* ============ Boot / loading ============ */
.boot-loader { height: 100vh; display: flex; align-items: center; justify-content: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.05s;
  background: var(--surface-2); color: var(--text);
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--critical-soft); color: var(--critical); }
.btn-danger:hover { background: var(--critical); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }

/* ============ Forms ============ */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: var(--font-body); font-size: 14px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 12.5px; color: var(--text-faint); margin-top: 5px; }
.field-error { font-size: 12.5px; color: var(--critical); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .field-full { grid-column: 1 / -1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ============ Layout: auth screens ============ */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(1200px 600px at 15% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px 32px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-contrast); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 14px; }
.auth-brand .name { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text-muted); letter-spacing: 0.02em; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.auth-error { background: var(--critical-soft); color: var(--critical); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; }
.auth-footer-note { margin-top: 18px; font-size: 12.5px; color: var(--text-faint); text-align: center; }

/* ============ App shell ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.sidebar-brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-contrast); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 13px; flex-shrink: 0; }
.sidebar-brand .company { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 600; font-size: 14px; cursor: pointer; border: none; background: transparent;
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--critical); margin-left: auto; }
.sidebar-user { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 10px; }
.sidebar-user .who { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.sidebar-user .role { font-size: 12px; color: var(--text-faint); margin-bottom: 10px; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; justify-content: space-between; padding: 14px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.content { flex: 1; padding: 28px 32px; max-width: 1180px; width: 100%; margin: 0 auto; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 24px; }
.page-header .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ============ Cards / KPIs ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px 18px; }
.kpi-card .label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.kpi-card .value { font-family: var(--font-display); font-size: 30px; font-weight: 800; }
.kpi-card .value.warn { color: var(--warning); }
.kpi-card .value.crit { color: var(--critical); }
.kpi-card .value.ok { color: var(--good); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.card-header h3 { font-size: 16px; }
.section-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }

.empty-state { text-align: center; padding: 34px 16px; color: var(--text-faint); }
.empty-state .big { font-size: 30px; margin-bottom: 8px; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.8px; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-faint); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--font-mono); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============ Badges ============ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-pendiente { background: var(--warning-soft); color: var(--warning); }
.badge-aprobada { background: var(--good-soft); color: var(--good); }
.badge-rechazada { background: var(--critical-soft); color: var(--critical); }
.badge-cancelada { background: var(--surface-2); color: var(--text-faint); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }

.pill-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; gap: 2px; }
.pill-toggle button { border: none; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.pill-toggle button.active { background: var(--accent); color: var(--accent-contrast); }

/* ============ Filters bar ============ */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters-bar .field { margin-bottom: 0; min-width: 160px; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 16, 12, 0.45); display: flex;
  align-items: center; justify-content: center; padding: 20px; z-index: 100; backdrop-filter: blur(1px);
}
.modal-box { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 17px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-faint); cursor: pointer; line-height: 1; padding: 4px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ Horario editor ============ */
.horario-editor { display: flex; flex-direction: column; gap: 6px; }
.horario-row { display: grid; grid-template-columns: 90px 24px 1fr 1fr; gap: 10px; align-items: center; padding: 6px 0; }
.horario-row .day-label { font-weight: 700; font-size: 13.5px; }
.horario-row.off { opacity: 0.45; }

/* ============ Toasts ============ */
.toast-root { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); max-width: 320px; animation: toast-in 0.2s ease-out; }
.toast.error { background: var(--critical); color: #fff; }
.toast.success { background: var(--good); color: #fff; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ Employee kiosk-style dashboard ============ */
.employee-shell { max-width: 760px; margin: 0 auto; padding: 26px 20px 60px; }
.emp-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.emp-topbar .greeting { font-size: 20px; font-family: var(--font-display); font-weight: 700; }
.emp-tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.emp-tab { padding: 10px 4px; margin-right: 18px; border: none; background: none; font-weight: 700; color: var(--text-faint); cursor: pointer; border-bottom: 2px solid transparent; font-size: 14px; white-space: nowrap; }
.emp-tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

.clock-card { text-align: center; padding: 30px 20px; }
.clock-time { font-family: var(--font-mono); font-size: 48px; font-weight: 600; letter-spacing: 0.02em; }
.clock-date { color: var(--text-muted); font-size: 14px; margin-top: 4px; text-transform: capitalize; }
.clock-status { margin: 18px 0; font-size: 15px; }
.punch-btn {
  width: 100%; max-width: 320px; margin: 10px auto 0; padding: 20px; border-radius: 16px; border: none;
  font-family: var(--font-display); font-weight: 800; font-size: 18px; cursor: pointer; color: #fff;
  background: var(--good); box-shadow: var(--shadow);
}
.punch-btn.out { background: var(--critical); }
.punch-btn:active { transform: translateY(1px); }

.balance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.balance-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; text-align: center; }
.balance-card .n { font-family: var(--font-display); font-size: 34px; font-weight: 800; color: var(--accent-strong); }
.balance-card .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.balance-card .sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.horario-view { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.horario-day { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 6px; text-align: center; font-size: 12.5px; }
.horario-day.off { opacity: 0.4; }
.horario-day .d { font-weight: 700; margin-bottom: 4px; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .content { padding: 20px 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .section-grid { grid-template-columns: 1fr; }
  .balance-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 26px 20px; }
}

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mt-0 { margin-top: 0; }
.flex-row { display: flex; align-items: center; gap: 10px; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }
