/* SGB Timesheet – responsive admin UI, vertical left navigation */
:root {
  --bg: #f6f2ec;
  --surface: #ffffff;
  --surface-2: #faf7f2;
  --text: #2b2420;
  --muted: #7a6e66;
  --border: #e7dfd5;
  --primary: #b4532a;
  --primary-ink: #ffffff;
  --primary-soft: #f6e3d8;
  --side-bg: #2e2420;
  --side-text: #d9cfc7;
  --side-muted: #9c8e84;
  --side-active: #3f322c;
  --ok: #2f7d4f;   --ok-bg: #e2f2e8;
  --warn: #9a5b00; --warn-bg: #fdf0d9;
  --err: #b42318;  --err-bg: #fde7e5;
  --info: #285e9c; --info-bg: #e3edf9;
  --hol: #fff3c9;
  --over: #fde8d0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(46,36,32,.06), 0 1px 1px rgba(46,36,32,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --side-w: 252px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1715; --surface: #241f1c; --surface-2: #2a2421; --text: #eee6df; --muted: #a89a90;
    --border: #3a322d; --primary: #e07a4b; --primary-soft: #44291d; --side-bg: #15110f; --side-active: #2c2420;
    --ok-bg: #1d3526; --ok: #7fd3a1; --warn-bg: #3d2d12; --warn: #f2c06b; --err-bg: #42201d; --err: #ff9b8f;
    --info-bg: #1d2c40; --info: #9cc3f2; --hol: #3b3317; --over: #43301f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 1.5rem; font-weight: 700; margin: 0; }
.mt { margin-top: 1rem; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 6px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* ---------- layout ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; overflow-y: auto; z-index: 40; transition: transform .2s ease;
}
.main-wrap { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--primary); color: #fff; font-weight: 800; display: grid; place-items: center; letter-spacing: .5px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: .98rem; }
.brand-text small { color: var(--side-muted); font-size: .76rem; }
.sidebar nav { flex: 1; padding: 4px 10px 12px; }
.nav-section { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: var(--side-muted); padding: 14px 10px 6px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); font-size: .92rem; }
.sidebar nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.sidebar nav svg { width: 19px; height: 19px; fill: currentColor; opacity: .85; flex: none; }
.sidebar-foot { padding: 12px 16px 18px; border-top: 1px solid rgba(255,255,255,.07); }
.calc-flags { display: flex; gap: 6px; flex-wrap: wrap; }
.flag { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.flag.on { background: var(--ok-bg); color: var(--ok); }
.flag.off { background: var(--err-bg); color: var(--err); }
.sidebar .flag.on { background: rgba(127,211,161,.15); color: #8fd9ad; }
.sidebar .flag.off { background: rgba(255,155,143,.15); color: #ffaa9f; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.page-title { font-size: 1.25rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; margin-left: -6px; border-radius: 8px; color: var(--text); cursor: pointer; }
.menu-btn svg { width: 26px; height: 26px; fill: currentColor; display: block; }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 4px 8px; border-radius: 8px; }
.user-chip:hover { background: var(--surface); text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta small { color: var(--muted); font-size: .75rem; }
.content { padding: 22px 24px 48px; max-width: 1500px; width: 100%; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.card.narrow { max-width: 560px; }
details.card > summary { cursor: pointer; }
.grid { display: grid; gap: 18px; }
.grid > .card { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.two-1 { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 18px; }
.kpi { padding: 14px 16px; }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filters, form.inline { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.push-right { margin-left: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, black); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-bg); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: .82rem; }
.btn-block { width: 100%; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 38px; max-width: 100%; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 17px; height: 17px; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.w-sm { width: 100px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.form label > input, .form label > select, .form label > textarea { color: var(--text); font-weight: 400; font-size: .95rem; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form-row label { flex: 1 1 160px; }
fieldset.seg, fieldset.seg-v { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 0; display: flex; gap: 16px; flex-wrap: wrap; }
fieldset.seg-v { flex-direction: column; gap: 8px; }
fieldset legend { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
fieldset label { flex-direction: row !important; align-items: center; gap: 6px !important; color: var(--text) !important; font-weight: 500 !important; }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--info-bg); color: var(--info); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--hol); color: var(--text); font-size: .85rem; margin: 2px 0; }
.text-danger { color: var(--err); font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 22px 8px !important; }
.list { list-style: none; padding: 0; margin: 0; }
.list > li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list > li.def-edit { display: block; background: var(--surface-2); padding: 12px; border-radius: 8px; }
.def-edit { margin-top: 10px; }
.checklist { margin: 0; padding-left: 20px; }
.checklist li { margin: 4px 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 20px; margin: 0 0 14px; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; word-break: break-word; }
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tab { padding: 5px 12px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: .88rem; }
.tab.active { background: var(--primary-soft); color: var(--primary); }
.tab:hover { text-decoration: none; color: var(--text); }
.pp-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.bulkbar .muted { margin-right: auto; }
.stat-det summary { cursor: pointer; list-style: none; }
.stat-det summary::-webkit-details-marker { display: none; }
.stat-det[open] { background: var(--surface-2); border-radius: 6px; padding: 6px 8px; min-width: 220px; }
.hol-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--hol); border: 1px solid var(--border); vertical-align: middle; margin-right: 4px; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table tfoot th, .table tfoot td { background: var(--surface-2); border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 35%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .strong { font-weight: 700; }
.table .chk { width: 32px; }
.table .actions-col { text-align: right; white-space: nowrap; }
.table .actions-col form { display: inline; }
.table .wrap { white-space: normal; word-break: break-word; max-width: 340px; }
.table .truncate { max-width: 220px; }
.row-muted td, .row-muted th { color: var(--muted); }
.row-current { background: var(--primary-soft); }
.row-hol { background: var(--hol); }
.table-grid { font-size: .82rem; }
.table-grid th, .table-grid td { padding: 6px 7px; }
.table-grid thead th { text-align: center; line-height: 1.15; }
.table-grid .hol { background: var(--hol); }
.table-grid .wkend { color: var(--primary); }
.table-grid .over { background: var(--over); font-weight: 700; }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: nowrap; min-width: 190px; font-weight: 500; }
thead .sticky-col, tfoot .sticky-col { background: var(--surface-2); }

/* settings switches */
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.switch-row:last-of-type { border-bottom: 0; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { color: var(--muted); }
input.switch { appearance: none; -webkit-appearance: none; width: 46px !important; height: 26px !important; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; flex: none; border: 0; padding: 0; transition: background .15s; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
input.switch:checked { background: var(--ok); }
input.switch:checked::after { transform: translateX(20px); }
.sticky-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }

/* upload */
.dropzone { position: relative; border: 2px dashed var(--border); border-radius: 12px; padding: 34px 16px; text-align: center; display: flex !important; flex-direction: column; align-items: center; gap: 4px !important; cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone.drag, .dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dz-title { font-size: 1rem; color: var(--text); }
.dz-file { color: var(--primary); font-weight: 700; }

/* auth */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(46,36,32,.08); }
.brand-lg { padding: 0 0 18px; }
.brand-lg .brand-text strong { color: var(--text); }
.brand-lg .brand-text small { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.two-1 { grid-template-columns: 1fr; }
}
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: block; }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
  .card { padding: 14px; }
  .user-meta, .user-menu .btn { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; }
  .toolbar > *, .filters { width: 100%; }
  .filters > *, form.inline > select { flex: 1 1 140px; }
  .kpi-value { font-size: 1.3rem; }
  /* stacked tables: each row becomes a card */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 6px 10px; background: var(--surface); }
  .table-stack td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table-stack td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; font-size: .8rem; }
  .table-stack td:not([data-label])::before { content: none; }
  .table-stack td.num { text-align: right; }
  .table-stack td.actions-col { justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
  .table-stack td.chk { justify-content: flex-start; }
  .table-stack td.empty { display: block; }
  .table-stack tfoot { display: block; }
  .table-stack tfoot tr { display: flex; flex-wrap: wrap; gap: 6px 12px; }
  .table-stack tfoot td, .table-stack tfoot th { display: inline; padding: 0; }
  .table .wrap { max-width: none; }
}
@media print {
  .sidebar, .topbar, .toolbar, .btn, .actions { display: none !important; }
  .main-wrap { margin: 0; }
  .card { box-shadow: none; border: 0; }
}

/* stat pay calculation page */
.calc-step h3 { display: flex; align-items: center; gap: 10px; font-size: 1rem; }
.step-no { width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-size: .85rem; font-weight: 800; flex: none; }
.formula { font-variant-numeric: tabular-nums; font-size: 1.05rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; line-height: 1.7; }
.calc-step.result { border-color: var(--primary); }
.calc-table td { vertical-align: middle; }
.pp-head .right { text-align: right; }
@media (max-width: 720px) { .pp-head .right { text-align: left; } }
.cap-note { display: inline-block; font-size: .7rem; font-weight: 700; color: var(--warn); background: var(--warn-bg); border-radius: 999px; padding: 1px 6px; margin-left: 4px; }
