:root {
  --bg: #f0f1f3;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #eaecf0;
  --border: #dde0e6;
  --border-light: #c8ccd4;
  --text: #111318;
  --text-dim: #5a6372;
  --text-muted: #9099a8;
  --accent: #a00014;
  --accent-soft: rgba(160, 0, 20, 0.08);
  --accent-dark: #7a0010;
  --green: #15803d;
  --green-soft: rgba(21, 128, 61, 0.10);
  --red: #dc2626;
  --yellow: #a16207;
  --yellow-soft: rgba(161, 98, 7, 0.10);
  --blue: #1e40af;
  --purple: #6d28d9;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.06);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 14.5px; line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02","cv03","cv04","cv11";
  letter-spacing: -0.01em;
}

button {
  font-family: inherit; font-size: inherit; cursor: pointer;
  border: none; background: var(--accent); color: white;
  padding: 9px 16px; border-radius: var(--radius);
  font-weight: 600; transition: opacity .15s, transform .1s, background .15s;
  letter-spacing: -0.01em;
}
button:hover:not(:disabled) { opacity: .88; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover:not(:disabled) { background: var(--surface-3); }
button.danger { background: var(--red); color: #fff; }
button.green { background: var(--green); color: #fff; }
button.yellow { background: var(--yellow); color: #fff; }
button.yellow.active { background: var(--surface-3); color: var(--yellow); border: 2px solid var(--yellow); }
button.small { padding: 6px 11px; font-size: 13px; }
button.ghost { background: transparent; color: var(--text-dim); padding: 5px 9px; font-weight: 500; }
button.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }

/* Action buttons inside tables/rows */
button.table-action {
  background: transparent; color: var(--accent);
  font-weight: 700; text-decoration: underline;
  padding: 4px 8px; font-size: 13px;
  border-radius: 4px;
}
button.table-action:hover:not(:disabled) { color: var(--accent-dark); background: var(--accent-soft); }
button.table-action.del { color: var(--red); }
button.table-action.del:hover:not(:disabled) { color: #b91c1c; background: rgba(220,38,38,0.08); }

input, select, textarea {
  font-family: inherit; font-size: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); padding: 9px 12px;
  border-radius: var(--radius-sm); width: 100%; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
label {
  display: block; font-size: 11.5px; color: var(--text-dim);
  margin-bottom: 5px; text-transform: uppercase;
  letter-spacing: 0.6px; font-weight: 600;
}

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

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); padding: 36px 32px; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.login-title { font-size: 28px; font-weight: 800; margin: 0 0 6px; color: var(--accent); letter-spacing: -0.02em; }
.login-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 26px; }
.login-card form > div { margin-bottom: 14px; }
.login-card button { width: 100%; margin-top: 10px; padding: 12px; font-size: 15px; }
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; padding: 10px 12px; background: rgba(220,38,38,0.08); border-radius: 8px; border-left: 3px solid var(--red); }

/* Top bar — brand red */
.topbar { background: var(--accent); border-bottom: none; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 2px 8px rgba(160,0,20,0.18); }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -0.02em; color: #fff; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,0.78); }
.topbar .who span { white-space: nowrap; }
.topbar button { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.topbar button:hover:not(:disabled) { background: rgba(255,255,255,0.25); opacity: 1; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 22px; }
@media (max-width: 600px) {
  .container { padding: 14px; }
  .topbar { padding: 12px 14px; }
  .topbar .who span { display: none; }
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 16px; margin: 0 0 14px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.card h3 { font-size: 13px; margin: 18px 0 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }

/* hide paid-this-month stat on mobile */
@media (max-width: 600px) { .stat.hide-mobile { display: none; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
/* 3-column single row on mobile for stats */
@media (max-width: 600px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--surface-2); padding: 13px; border-radius: 8px; border: 1px solid var(--border); }
.stat .label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.6px; font-weight: 600; }
.stat .value { font-size: 19px; font-weight: 700; margin-top: 3px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .value.accent { color: var(--accent); }
.stat .value.green { color: var(--green); }
.stat .value.yellow { color: var(--yellow); }
.stat .value.purple { color: var(--purple); }

/* Clock card */
.clock-card .timer { font-family: var(--font-mono); font-size: 44px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; margin: 14px 0; color: var(--green); letter-spacing: -1px; }
.clock-card .timer.lunch-active { color: var(--yellow); }
.clock-card .timer.lunch-capped { color: var(--red); }
.clock-card .since { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }
.clock-card .row { display: flex; gap: 10px; margin-top: 14px; }
.clock-card .row > * { flex: 1; }
.lunch-status { text-align: center; font-size: 12px; color: var(--yellow); padding: 4px 0 10px; font-weight: 600; }

/* Sessions table */
.sessions-list { width: 100%; border-collapse: collapse; font-size: 13px; }
.sessions-list th { text-align: left; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; padding: 9px 6px; border-bottom: 2px solid var(--border); font-weight: 600; }
.sessions-list td { padding: 10px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.sessions-list tr:last-child td { border-bottom: none; }
.sessions-list .actions { display: flex; gap: 2px; justify-content: flex-end; }
.sessions-list .addr { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: normal; }

/* Global mob-hide: hidden on ≤768px */
@media (max-width: 768px) {
  .mob-hide { display: none !important; }
}

/* Mobile session table: show only date, hours, and actions columns */
@media (max-width: 600px) {
  .sessions-list th, .sessions-list td { padding: 10px 4px; font-size: 13px; }
  .stat .value { font-size: 15px; }
  .stat .label { font-size: 10px; }
}

/* Alternating session rows */
.sessions-list tbody tr:nth-child(even) td { background: rgba(0,0,0,0.02); }
.sessions-list tbody tr:nth-child(odd) td { background: transparent; }
/* First row (most recent) stands out */
.sessions-list tbody tr:first-child td { color: var(--green); }

/* Session adjustments row styling */
.sessions-list tr.sadj-row td { color: var(--purple); font-style: italic; }

/* Boss employee cards */
.emp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow); }
.emp-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; cursor: pointer; transition: background .15s; gap: 12px; }
.emp-header:hover { background: var(--surface-2); }
.emp-header .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.emp-header .name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.emp-header .meta { font-size: 12px; color: var(--text-dim); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.dot.live { background: var(--green); box-shadow: 0 0 0 4px rgba(21,128,61,0.18); animation: pulse 1.5s infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(21,128,61,0.18); }
  50% { box-shadow: 0 0 0 7px rgba(21,128,61,0.05); }
}
.emp-header .summary { display: flex; gap: 18px; font-size: 13px; align-items: center; }
/* Hide stat items on desktop — only show live timer inline */
.emp-header .summary .item { display: none; }
.emp-header .summary .item .lab { display: block; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.emp-header .summary .item .val { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.emp-header .summary .owed .val { color: var(--accent); }
.emp-header .live-timer { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--green); font-variant-numeric: tabular-nums; }
.emp-header .chev { color: var(--text-muted); font-size: 12px; margin-left: 8px; transition: transform .15s; }
.emp-card.open .emp-header .chev { transform: rotate(180deg); }
@media (max-width: 700px) { .emp-header .summary { display: none; } }

/* Card action buttons — always visible, including on mobile */
.emp-header .card-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
@media (max-width: 700px) {
  .emp-header { flex-wrap: nowrap; gap: 6px; padding: 12px 14px; }
  .emp-header .left { flex: 1; min-width: 0; }
  .emp-header .card-actions { gap: 5px; }
  .emp-header .card-actions button.small { padding: 5px 9px; font-size: 12px; }
}

.emp-body { padding: 18px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.emp-body.collapsed { display: none; }

/* Inline breakdown (always visible) */
.breakdown { background: var(--surface); padding: 14px; border-radius: 8px; font-size: 13px; font-family: var(--font-mono); border: 1px solid var(--border); margin-bottom: 14px; }
.breakdown .line { display: flex; justify-content: space-between; padding: 3px 0; }
.breakdown .divider { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.breakdown .total { font-weight: 700; color: var(--accent); }

/* Payday banner */
.payday-banner { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.payday-banner .label { color: var(--text-dim); text-transform: uppercase; font-size: 11px; letter-spacing: 0.6px; font-weight: 600; margin-right: 10px; }
.payday-banner .val { font-weight: 700; }

/* Hide these on mobile */
@media (max-width: 768px) {
  .breakdown { display: none !important; }
  .payday-banner { display: none !important; }
  .hours-stats { display: none !important; }
}

/* Accordion */
details.acc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
details.acc[open] { border-color: var(--border-light); }
details.acc > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 600; color: var(--text); user-select: none; transition: background .15s; }
details.acc > summary::-webkit-details-marker { display: none; }
@media (max-width: 600px) {
  details.acc > summary { font-size: 16px; padding: 16px; }
}
details.acc > summary:hover { background: var(--surface-2); }
/* Underline makes accordions obviously tappable */
details.acc > summary .acc-title { display: flex; align-items: center; gap: 10px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-light); }
details.acc[open] > summary .acc-title { text-decoration-color: var(--accent); }
details.acc > summary .acc-count { font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; letter-spacing: 0.3px; }
details.acc > summary .acc-chev { color: var(--text-muted); font-size: 11px; transition: transform .18s; }
details.acc[open] > summary .acc-chev { transform: rotate(180deg); }
.acc-body { padding: 4px 14px 14px; }

/* Payments accordion — slightly elevated on mobile for quick access */
@media (max-width: 768px) {
  details.acc.acc-payments > summary {
    background: var(--surface-3);
    border-bottom: 2px solid var(--border-light);
  }
  details.acc.acc-payments[open] > summary { background: var(--surface-3); }
}

/* Desktop-only elements */
.desktop-only { display: block; }
@media (max-width: 768px) { .desktop-only { display: none; } }

/* Forms */
.inline-form { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; margin-bottom: 10px; padding-top: 4px; align-items: end; }
.inline-form.payment-form { grid-template-columns: 1fr 1fr 2fr auto; }
.inline-form.bonus-form { grid-template-columns: 1fr 1fr 1fr 2fr auto; }
.inline-form.adj-form { grid-template-columns: auto 1fr 2fr auto; }
.inline-form.hr-adj-form { grid-template-columns: 1fr 1fr 2fr auto; }
@media (max-width: 600px) {
  .inline-form, .inline-form.payment-form, .inline-form.bonus-form, .inline-form.adj-form, .inline-form.hr-adj-form { grid-template-columns: 1fr; }
}

.list-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; font-size: 13px; gap: 10px; }
.list-row .left { flex: 1; min-width: 0; }
.list-row .amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.list-row .note { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.list-row .actions { display: flex; gap: 4px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .row-2, .row-3 { grid-template-columns: 1fr; } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); padding: 22px; max-width: 460px; width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,0.14); }
.modal h3 { margin: 0 0 14px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.modal .field { margin-bottom: 12px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Toast */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--green); padding: 12px 16px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); animation: slidein .2s ease-out; max-width: 360px; }
.toast.error { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.emp-greeting { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); margin-bottom: 16px; }

.muted { color: var(--text-dim); font-size: 13px; }
.empty { color: var(--text-muted); font-size: 13px; padding: 12px; text-align: center; font-style: italic; }
.add-emp-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.add-emp-bar h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.flex-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tag { display: inline-block; background: var(--surface-3); color: var(--text-dim); padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.section-tip { font-size: 12px; color: var(--text-dim); margin: 0 0 10px; line-height: 1.45; }
.section-note { font-size: 12px; color: var(--yellow); margin: 0 0 10px; padding: 8px 10px; background: var(--yellow-soft); border-radius: 6px; border-left: 3px solid var(--yellow); }

.hours-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.hours-stat { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); }
.hours-stat .lab { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); font-weight: 600; }
.hours-stat .val { font-size: 16px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* Page bubble pagination */
.page-dots { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.page-dot { min-width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; transition: border-color .12s, color .12s, background .12s; }
.page-dot:hover:not(.active):not(:disabled) { border-color: var(--border-light); color: var(--text); background: var(--surface-3); }
.page-dot.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-dot.load-more-dot { border-style: dashed; }
.page-ellipsis { color: var(--text-muted); font-size: 12px; padding: 0 2px; line-height: 28px; }
.page-arrow { font-size: 16px; border-radius: 50%; }
.page-arrow:disabled { opacity: 0.3; cursor: default; }
.page-select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-weight: 600; padding: 3px 6px; height: 28px; cursor: pointer; }
.page-select:focus { outline: none; border-color: var(--accent); }
.page-of { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

/* Dividers inside modals/breakdowns */
hr.divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.line.total { font-weight: 700; color: var(--accent); }

/* Mobile-only visibility (opposite of mob-hide) */
.mob-show { display: none !important; }
@media (max-width: 768px) {
  .mob-show { display: inline !important; }
}

/* Color utility text */
.green-text { color: var(--green); }
.red-text   { color: var(--red); }
.small      { font-size: 12px; }

/* ---- Full Ledger Modal ---- */
.ledger-modal { max-height: 80vh; overflow-y: auto; min-width: 320px; }
@media (min-width: 600px) { .ledger-modal { width: 580px; } }
.ledger-summary { margin-bottom: 16px; }
.ledger-section { margin-bottom: 14px; }
.ledger-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.ledger-row {
  display: grid; grid-template-columns: 54px 1fr auto;
  gap: 8px; align-items: baseline;
  padding: 4px 0; border-bottom: 1px solid var(--surface-3);
  font-size: 13px;
}
.ledger-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; font-family: var(--font-mono); }
.ledger-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.ledger-note { color: var(--text-dim); font-size: 12px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

/* ---- Dark Mode ---- */
html.dark {
  --bg: #0e1117;
  --surface: #161b25;
  --surface-2: #1e2433;
  --surface-3: #28324a;
  --border: #2b3347;
  --border-light: #3a4560;
  --text: #e8ecf3;
  --text-dim: #8b94a8;
  --text-muted: #5c6478;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, 0.12);
  --accent-dark: #e05a2a;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.10);
  --red: #f87171;
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.08);
  --blue: #60a5fa;
  --purple: #a78bfa;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.25);
}

/* Dark mode topbar overrides — dark surface instead of red */
html.dark .topbar {
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}
html.dark .topbar h1 { color: var(--text); }
html.dark .topbar .who { color: var(--text-dim); }
html.dark .topbar .who > span { color: var(--text); }

/* Dark mode: table action buttons stay legible */
html.dark button.table-action { color: var(--accent); }
html.dark button.table-action:hover:not(:disabled) { color: var(--accent-dark); background: var(--accent-soft); }
html.dark button.table-action.del { color: var(--red); }
html.dark button.table-action.del:hover:not(:disabled) { background: rgba(248,113,113,0.10); }

/* Dark mode: login accent heading */
html.dark .login-title { color: var(--text); }

/* Dark mode: employee card owed accent */
html.dark .item.owed .val { color: var(--accent); }
