:root{
  --bg:#1E1B18;
  --surface:#26221E;
  --surface-2:#322C26;
  --text:#F2EDE4;
  --text-muted:#A69C8F;
  --green:#3C9A5C;
  --green-dark:#2C7845;
  --red:#C6362A;
  --red-dark:#992A20;
  --amber:#F0A93B;
  --amber-dark:#C98A2A;
  --border:#3D362F;
  --on-accent:#1A1712;
  --accent-glow:rgba(240,169,59,0.18);
  --overlay-1:rgba(255,255,255,0.02);
  --overlay-2:rgba(255,255,255,0.045);
  --radius-sm:6px;
  --radius-md:10px;
  --font-display:'Space Grotesk', system-ui, sans-serif;
  --font-mono:'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
*{box-sizing:border-box;}
html,body{
  margin:0; padding:0; background:var(--bg); color:var(--text);
  font-family:var(--font-display);
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior-y:contain;
}
body{
  min-height:100vh; min-height:100dvh;
  display:flex; flex-direction:column;
  padding-bottom:env(safe-area-inset-bottom);
}
a{ color:var(--amber); }

/* ---- App header (index + admin) ---- */
header.app-header{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 18px; gap:12px; flex-wrap:wrap;
  border-bottom:1px solid var(--border);
}
header.app-header .brand{
  font-size:17px; font-weight:700; margin:0; letter-spacing:0.01em;
  display:flex; align-items:center; gap:8px;
}
header.app-header .brand .dot{
  width:11px; height:11px; border-radius:50%; background:var(--amber); display:inline-block;
}
.user-nav{
  display:flex; align-items:center; gap:14px; font-size:13px; flex-wrap:wrap;
}
.user-nav .user-name{ color:var(--text-muted); }
.theme-select{
  background:var(--surface-2); color:var(--text); border:1.5px solid var(--border);
  border-radius:var(--radius-sm); padding:5px 22px 5px 8px; font-family:var(--font-display);
  font-size:12.5px; appearance:none; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23A69C8F'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5H5.5z'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 6px center;
}
.user-nav a, .user-nav button.link{
  background:none; border:none; color:var(--amber); font-family:var(--font-display);
  font-size:13px; cursor:pointer; padding:4px 0; text-decoration:none;
}
.user-nav a:hover, .user-nav button.link:hover{ text-decoration:underline; }

/* ---- Hero / timer button ---- */
.hero{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:18px 20px 24px; gap:16px;
}
.hero .hero-caption{ font-size:12.5px; color:var(--text-muted); text-align:center; }
.sync-banner{
  display:flex; align-items:center; justify-content:center; gap:8px; flex-wrap:wrap;
  font-size:12.5px; color:var(--amber); text-align:center; padding:6px 20px 0;
}
.sync-banner button.link{
  background:none; border:none; color:var(--amber); text-decoration:underline;
  font-size:12.5px; cursor:pointer; padding:0; font-family:var(--font-display);
}
.pending-badge{
  display:inline-block; font-size:10px; padding:1px 6px; border-radius:20px;
  border:1px solid var(--amber-dark); color:var(--amber); margin-left:6px; vertical-align:middle;
}
.btn-timer{
  --state-color:var(--green); --state-color-dark:var(--green-dark);
  width:min(56vw, 220px); height:min(56vw, 220px);
  border-radius:50%; border:none; cursor:pointer; position:relative;
  background:
    radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--state-color) 88%, white 12%), var(--state-color) 55%, var(--state-color-dark) 100%);
  box-shadow:
    0 10px 0 var(--state-color-dark), 0 14px 22px rgba(0,0,0,0.45),
    inset 0 3px 6px rgba(255,255,255,0.25), inset 0 -10px 14px rgba(0,0,0,0.25),
    0 0 0 8px var(--surface-2), 0 0 0 9px var(--border);
  color:var(--on-accent); font-family:var(--font-display); font-weight:700;
  font-size:clamp(19px, 5.5vw, 25px);
  transition:transform .08s ease, box-shadow .08s ease;
}
.btn-timer.state-stop{ --state-color:var(--red); --state-color-dark:var(--red-dark); color:#FCEFEC; }
.btn-timer:disabled{ opacity:0.5; cursor:not-allowed; }
.btn-timer:active:not(:disabled){
  transform:translateY(6px);
  box-shadow:
    0 4px 0 var(--state-color-dark), 0 6px 10px rgba(0,0,0,0.4),
    inset 0 3px 6px rgba(255,255,255,0.2), inset 0 -6px 10px rgba(0,0,0,0.3),
    0 0 0 8px var(--surface-2), 0 0 0 9px var(--border);
}
.timer-status{ text-align:center; min-height:44px; }
.timer-elapsed{
  font-family:var(--font-mono); font-size:32px; font-weight:500; color:var(--amber);
  letter-spacing:0.02em; font-variant-numeric:tabular-nums;
}
.timer-hint{ font-size:13px; color:var(--text-muted); }
.btn-pause{
  padding:9px 24px; border-radius:999px; border:1.5px solid var(--amber);
  background:transparent; color:var(--amber); font-family:var(--font-display);
  font-weight:600; font-size:13.5px; cursor:pointer; letter-spacing:0.01em;
}
.btn-pause:active{ background:var(--amber); color:var(--on-accent); }
.btn-pause.state-paused{ border-color:var(--green); color:var(--green); }
.btn-pause.state-paused:active{ background:var(--green); color:var(--on-accent); }

/* ---- Main panel ---- */
main{
  flex:1; background:var(--surface); border-top:1px solid var(--border);
  border-radius:20px 20px 0 0; padding:20px 16px 28px;
  display:flex; flex-direction:column; gap:14px;
}
main.admin-main{ border-radius:0; }

.target-switch{
  display:flex; align-items:center; justify-content:center; gap:10px;
  font-size:13px; color:var(--text-muted);
}
.target-switch select{
  background:var(--surface-2); color:var(--text); border:1.5px solid var(--border);
  border-radius:var(--radius-sm); padding:7px 10px; font-family:var(--font-display); font-size:13.5px;
}

.month-nav{ display:flex; align-items:center; justify-content:center; gap:18px; }
.month-nav button{
  background:none; border:none; color:var(--amber); font-size:20px; line-height:1;
  padding:6px 10px; cursor:pointer; border-radius:6px;
}
.month-nav button:focus-visible{ outline:2px solid var(--amber); }
.month-nav .month-label{ font-weight:600; font-size:15px; min-width:150px; text-align:center; }

.table-wrap{ overflow-x:auto; border:1px solid var(--border); border-radius:var(--radius-sm); }
table{ width:100%; border-collapse:collapse; min-width:480px; font-size:13px; }
thead th{
  text-align:left; font-weight:600; font-size:11.5px; color:var(--text-muted);
  padding:8px 8px; border-bottom:1px solid var(--border); background:var(--surface-2);
  position:sticky; top:0;
}
tbody td{ padding:8px 8px; border-bottom:1px solid var(--border); vertical-align:middle; }
tbody tr:nth-child(even){ background:var(--overlay-1); }
tbody tr:last-child td{ border-bottom:none; }
td.num, th.num{ font-family:var(--font-mono); font-variant-numeric:tabular-nums; white-space:nowrap; }
.row-editable{ cursor:pointer; }
.row-editable:hover, .row-editable:focus-visible{ background:var(--overlay-2); outline:none; }
td.edit-hint{ width:24px; text-align:center; color:var(--text-muted); font-size:13px; }
tfoot td{ padding:11px 10px 4px; font-weight:600; border-top:2px solid var(--border); font-family:var(--font-mono); }

.empty-state{ text-align:center; color:var(--text-muted); font-size:13.5px; padding:26px 10px; }

.actions{ display:flex; flex-direction:column; align-items:center; gap:10px; margin-top:4px; }
.btn-export{
  width:100%; max-width:340px; padding:13px 18px; border-radius:var(--radius-sm);
  border:1.5px solid var(--amber); background:transparent; color:var(--amber);
  font-family:var(--font-display); font-weight:600; font-size:14.5px; cursor:pointer;
}
.btn-export:active{ background:var(--amber); color:var(--on-accent); }
.link-export-all{
  background:none; border:none; color:var(--text-muted); font-size:12.5px;
  text-decoration:underline; text-underline-offset:3px; cursor:pointer; padding:6px;
}
.export-row{ display:flex; gap:8px; width:100%; max-width:340px; }
.export-row .btn-export{ max-width:none; flex:1; }
.export-format-select{
  flex:0 0 108px; padding:0 10px; font-size:14px; background:var(--surface-2);
  border:1.5px solid var(--border); color:var(--text); border-radius:var(--radius-sm);
  font-family:var(--font-display); appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23A69C8F'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5H5.5z'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 8px center; padding-right:26px;
}

/* ---- Modal ---- */
.overlay{
  position:fixed; inset:0; background:rgba(10,9,7,0.72);
  display:flex; align-items:center; justify-content:center; padding:20px; z-index:50;
  opacity:0; pointer-events:none; transition:opacity .15s ease;
}
.overlay.open{ opacity:1; pointer-events:auto; }
.modal{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md);
  width:100%; max-width:340px; max-height:88vh; overflow-y:auto; padding:22px 22px 18px;
  transform:translateY(8px); transition:transform .15s ease;
}
.overlay.open .modal{ transform:translateY(0); }
.modal .step-flag{ font-family:var(--font-mono); font-size:11px; color:var(--text-muted); margin:0 0 6px; }
.modal .modal-title{ font-weight:600; font-size:15px; margin:0 0 16px; }
.modal label{ display:block; font-weight:600; font-size:15px; margin-bottom:10px; }
.field-group{ margin-bottom:14px; }
.field-group label{ font-size:13px; margin-bottom:6px; }
.modal input[type="text"], .modal input[type="password"], .modal input[type="email"], .modal input[type="number"], .modal input[type="datetime-local"],
.auth-card input[type="text"], .auth-card input[type="password"], .auth-card input[type="email"], .auth-card input[type="number"]{
  width:100%; padding:13px 12px; font-size:16px; background:var(--surface-2);
  border:1.5px solid var(--border); color:var(--text); border-radius:var(--radius-sm);
  font-family:var(--font-display);
}
.modal input[type="datetime-local"]{ font-family:var(--font-mono); font-size:14.5px; }
.modal input[type="datetime-local"]::-webkit-calendar-picker-indicator{ filter:invert(0.75); cursor:pointer; }
.modal input:focus, .auth-card input:focus{
  outline:none; border-color:var(--amber); box-shadow:0 0 0 3px var(--accent-glow);
}
.modal select.dyn-input{
  width:100%; padding:13px 12px; font-size:16px; background:var(--surface-2);
  border:1.5px solid var(--border); color:var(--text); border-radius:var(--radius-sm);
  font-family:var(--font-display); appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23A69C8F'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5H5.5z'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 12px center; padding-right:34px;
}
.modal select.dyn-input:focus{
  outline:none; border-color:var(--amber); box-shadow:0 0 0 3px var(--accent-glow);
}
.checklist-box{
  display:flex; flex-direction:column; gap:2px; background:var(--surface-2);
  border:1.5px solid var(--border); border-radius:var(--radius-sm); padding:4px;
}
.checklist-item{
  display:flex; align-items:center; gap:10px; padding:10px 8px; font-size:14.5px;
  cursor:pointer; border-radius:5px;
}
.checklist-item:hover{ background:var(--overlay-2); }
.checklist-item input{ width:18px; height:18px; accent-color:var(--amber); flex-shrink:0; }
.modal .modal-actions{ display:flex; justify-content:space-between; align-items:center; margin-top:18px; }
.modal-actions-3{ display:flex; justify-content:space-between; align-items:center; margin-top:6px; }
.modal-actions-3 .modal-actions-right{ display:flex; gap:4px; }
.btn-ghost{
  background:none; border:none; color:var(--text-muted); font-size:14px; padding:8px;
  cursor:pointer; font-family:var(--font-display);
}
.btn-ghost.btn-danger{ color:var(--red); }
.btn-primary{
  background:var(--amber); color:var(--on-accent); border:none; font-weight:700; font-size:14.5px;
  padding:11px 22px; border-radius:var(--radius-sm); cursor:pointer; font-family:var(--font-display);
}
.btn-primary:disabled{ opacity:0.6; cursor:not-allowed; }
.btn-block{ width:100%; padding:13px 22px; }
.edit-error{ color:var(--red); font-size:12.5px; margin:-6px 0 12px; }

/* ---- Auth page ---- */
.auth-body{ align-items:center; justify-content:center; padding:24px; }
.auth-card{
  width:100%; max-width:340px; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-md); padding:32px 26px 26px; text-align:center; position:relative;
}
.auth-icon{
  width:56px; height:56px; border-radius:50%; margin:0 auto 18px;
  background:radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--amber) 88%, white 12%), var(--amber) 60%, var(--amber-dark) 100%);
  box-shadow:0 0 0 6px var(--surface-2), 0 0 0 7px var(--border);
}
.auth-card h1{ font-size:20px; margin:0 0 4px; }
.auth-sub{ font-size:13px; color:var(--text-muted); margin:0 0 24px; }
.auth-card form{ text-align:left; }
.auth-card .field-group label{ font-size:13px; }

/* ---- Admin page ---- */
.admin-section{ margin-bottom:8px; }
.admin-section h2{ font-size:15px; margin:0 0 12px; }
.admin-card{
  background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:14px; margin-bottom:14px;
}
.user-row{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 4px; border-bottom:1px solid var(--border); font-size:13.5px;
}
.user-row:last-child{ border-bottom:none; }
.user-row .u-name{ font-weight:600; }
.user-row .u-meta{ color:var(--text-muted); font-size:12px; }
.badge{
  display:inline-block; font-size:11px; padding:2px 8px; border-radius:20px;
  border:1px solid var(--border); color:var(--text-muted); margin-left:6px;
}
.badge.chef{ color:var(--amber); border-color:var(--amber-dark); }
.badge.inactive{ color:var(--red); border-color:var(--red-dark); }
.row-actions{ display:flex; gap:6px; flex-wrap:wrap; }
.row-actions button{
  background:none; border:1px solid var(--border); color:var(--text-muted);
  font-size:11.5px; padding:5px 9px; border-radius:5px; cursor:pointer; font-family:var(--font-display);
}
.row-actions button:hover{ border-color:var(--amber); color:var(--amber); }
.new-user-form{ display:flex; flex-direction:column; gap:10px; }
.new-user-form input{
  padding:11px 12px; font-size:15px; background:var(--surface); border:1.5px solid var(--border);
  color:var(--text); border-radius:var(--radius-sm); font-family:var(--font-display);
}
.checkbox-row{ display:flex; align-items:center; gap:8px; font-size:13.5px; }
.checkbox-row input{ width:16px; height:16px; }
.wage-input{
  width:92px; padding:5px 8px; font-size:12.5px; background:var(--surface);
  border:1.5px solid var(--border); color:var(--text); border-radius:var(--radius-sm);
  font-family:var(--font-display);
}
.team-cal-controls{ display:flex; justify-content:flex-end; margin-bottom:10px; }
.team-cal-controls input[type="month"]{
  padding:7px 10px; font-size:13.5px; background:var(--surface); border:1.5px solid var(--border);
  color:var(--text); border-radius:var(--radius-sm); font-family:var(--font-display);
}
.team-cal-name{ white-space:nowrap; font-weight:600; }
.team-cal-total{ font-family:var(--font-mono); font-weight:600; }
main.leader-view .admin-section:not(.section-team-calendar){ display:none; }
.audit-row{ padding:8px 4px; border-bottom:1px solid var(--border); font-size:12.5px; }
.audit-row:last-child{ border-bottom:none; }
.audit-row .a-what{ font-weight:600; }
.audit-row .a-meta{ color:var(--text-muted); font-size:11.5px; margin-top:2px; }

.grant-target-picker{ display:flex; align-items:center; gap:10px; margin-bottom:10px; flex-wrap:wrap; }
.grant-list{ display:flex; flex-direction:column; gap:6px; }
.grant-row{ display:flex; align-items:center; justify-content:space-between; font-size:13.5px; padding:6px 2px; }
.switch{ position:relative; display:inline-block; width:38px; height:22px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.switch .slider{
  position:absolute; cursor:pointer; inset:0; background:var(--border);
  transition:.15s; border-radius:22px;
}
.switch .slider:before{
  position:absolute; content:""; height:16px; width:16px; left:3px; bottom:3px;
  background:var(--text-muted); transition:.15s; border-radius:50%;
}
.switch input:checked + .slider{ background:var(--amber-dark); }
.switch input:checked + .slider:before{ background:var(--amber); transform:translateX(16px); }

.toast{
  position:fixed; left:50%; bottom:24px; transform:translateX(-50%);
  background:var(--surface-2); border:1px solid var(--border); color:var(--text);
  padding:11px 18px; border-radius:var(--radius-sm); font-size:13px; z-index:100;
  box-shadow:0 8px 20px rgba(0,0,0,0.4);
  opacity:0; pointer-events:none; transition:opacity .2s ease, transform .2s ease;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.toast.error{ border-color:var(--red-dark); color:#FCEFEC; }

.visually-hidden{
  position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap;
}

@media (prefers-reduced-motion:reduce){ *{ transition:none !important; } }

/* ---- Themes ----
   Default (no data-theme attribute, or data-theme="amber") is the palette
   defined in :root above. Every other theme only needs to override the
   handful of variables actually used for color everywhere else in this
   file -- layout, spacing and structure stay identical across themes. */
:root[data-theme="ocean"]{
  --bg:#0F1922; --surface:#16232E; --surface-2:#1E2E3A; --text:#EAF3F7; --text-muted:#8FA6B2;
  --amber:#3FB6C9; --amber-dark:#2C8C9C; --border:#233543;
  --green:#3FAE6E; --green-dark:#2E8654; --red:#E1604F; --red-dark:#B24A3C;
  --on-accent:#08252B; --accent-glow:rgba(63,182,201,0.22);
  --overlay-1:rgba(255,255,255,0.02); --overlay-2:rgba(255,255,255,0.045);
}
:root[data-theme="forest"]{
  --bg:#131C14; --surface:#1A251B; --surface-2:#243323; --text:#EEF3EB; --text-muted:#98AB96;
  --amber:#7EC161; --amber-dark:#5CA23F; --border:#2B3A29;
  --green:#4CAE6B; --green-dark:#398752; --red:#D2564A; --red-dark:#A5443A;
  --on-accent:#12240F; --accent-glow:rgba(126,193,97,0.22);
  --overlay-1:rgba(255,255,255,0.02); --overlay-2:rgba(255,255,255,0.045);
}
:root[data-theme="rose"]{
  --bg:#1C1320; --surface:#261A2B; --surface-2:#332338; --text:#F5EAF2; --text-muted:#B39AB0;
  --amber:#E26FA0; --amber-dark:#BB537F; --border:#3A2A40;
  --green:#4CAE6B; --green-dark:#2C7845; --red:#E2554D; --red-dark:#B24239;
  --on-accent:#280F1C; --accent-glow:rgba(226,111,160,0.22);
  --overlay-1:rgba(255,255,255,0.02); --overlay-2:rgba(255,255,255,0.045);
}
:root[data-theme="light"]{
  --bg:#F6F3ED; --surface:#FFFFFF; --surface-2:#F0EBE1; --text:#24201A; --text-muted:#6E6459;
  --amber:#C9791E; --amber-dark:#A6621A; --border:#E1D9CA;
  --green:#2C7845; --green-dark:#1F5A33; --red:#B33226; --red-dark:#8C271D;
  --on-accent:#FFFBF3; --accent-glow:rgba(201,121,30,0.18);
  --overlay-1:rgba(0,0,0,0.025); --overlay-2:rgba(0,0,0,0.05);
}
:root[data-theme="light"] .overlay{ background:rgba(40,34,26,0.45); }
:root[data-theme="light"] .btn-timer.state-stop{ color:#FFF5F2; }
