:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #97a0b0;
  --accent: #ffc24b;       /* clapperboard amber */
  --accent-2: #5b8cff;
  --green: #3fb968;
  --red: #e8575b;
  --amber: #f0a93b;
  --blue: #5b8cff;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent-2); }
button { font-family: inherit; cursor: pointer; }

/* Layout */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; letter-spacing: .3px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand .dot { color: var(--accent); }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; }
.nav { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.nav button {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.nav button:hover { color: var(--text); background: var(--panel-2); }
.nav button.active { color: var(--bg); background: var(--accent); }
.nav button .badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 6px;
  background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; text-align: center;
}
.spacer { flex: 1; }
.whoami { text-align: right; font-size: 12px; color: var(--muted); }
.whoami b { color: var(--text); display: block; font-size: 13px; }
.role-chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px;
  font-weight: 700; background: var(--panel-2); border: 1px solid var(--border); color: var(--accent);
}
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

/* Cards & panels */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .n { font-size: 26px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

/* Buttons */
.btn { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #1a1300; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.green { background: var(--green); color: #04210f; border-color: var(--green); }
.btn.red { background: transparent; color: var(--red); border-color: var(--red); }
.btn.red:hover { background: rgba(232,87,91,.12); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.clickable { cursor: pointer; }

/* Status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; border: 1px solid transparent; }
.pill.draft { background: #2a2f3a; color: #c0c7d4; }
.pill.submitted { background: rgba(91,140,255,.15); color: #8fb0ff; border-color: rgba(91,140,255,.3); }
.pill.dept_approved { background: rgba(240,169,59,.15); color: var(--amber); border-color: rgba(240,169,59,.3); }
.pill.approved { background: rgba(63,185,104,.15); color: #6fe09a; border-color: rgba(63,185,104,.3); }
.pill.rejected { background: rgba(232,87,91,.15); color: #ff8a8d; border-color: rgba(232,87,91,.3); }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); }
.field { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Auth */
.auth-wrap { max-width: 380px; margin: 8vh auto; }
.auth-wrap .card { padding: 26px; }
.demo-list { font-size: 12px; color: var(--muted); margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.demo-list code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; color: var(--accent); }
.demo-row { display:flex; justify-content:space-between; padding:3px 0; cursor:pointer; }
.demo-row:hover { color: var(--text); }

/* Timesheet editor */
.dtr-table { font-size: 12.5px; }
.dtr-table input, .dtr-table select { padding: 5px 6px; font-size: 12.5px; }
.dtr-table th { white-space: nowrap; }
.dtr-table td { padding: 5px 6px; vertical-align: middle; }
.time-input { width: 78px; }
.mini { width: 64px; }
.totbar { display:flex; gap:18px; flex-wrap:wrap; background:var(--panel-2); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-top:14px; }
.totbar .t .v { font-size:18px; font-weight:800; }
.totbar .t .k { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.4px; }
.totbar .t.big .v { color: var(--accent); }

/* Timeline */
.timeline { list-style:none; padding:0; margin:0; }
.timeline li { display:flex; gap:10px; padding:8px 0; border-bottom:1px dashed var(--border); }
.timeline .ico { width:26px; height:26px; border-radius:50%; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:13px; }
.timeline .ico.approve { background: rgba(63,185,104,.2); color: var(--green); }
.timeline .ico.reject { background: rgba(232,87,91,.2); color: var(--red); }
.timeline .ico.submit { background: rgba(91,140,255,.2); color: var(--blue); }
.timeline .meta { font-size:12px; color:var(--muted); }

/* Misc */
.muted { color: var(--muted); }
.right { text-align: right; }
.empty { text-align:center; color:var(--muted); padding:40px 0; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border:1px solid var(--border); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; font-size:13px; }
.toast.err { border-color: var(--red); color: #ff9a9c; }
.toast.ok { border-color: var(--green); color: #8fe6ad; }
.flag { display:inline-block; font-size:11px; padding:1px 6px; border-radius:5px; background:rgba(240,169,59,.15); color:var(--amber); margin-left:4px; }
@media (max-width: 720px){ .form-grid{ grid-template-columns:1fr; } .nav button{ padding:6px 9px; } }

/* --- v2: approval chain, day chips, employee blocks --- */
.chain { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin:10px 0; }
.chain-step { display:flex; align-items:center; gap:6px; font-size:12px; font-weight:600; color:var(--muted);
  background:var(--panel-2); border:1px solid var(--border); border-radius:999px; padding:4px 11px; }
.chain-step .dot2 { width:18px; height:18px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  font-size:11px; background:var(--border); color:var(--text); }
.chain-step.done { color:#8fe6ad; border-color:rgba(63,185,104,.4); }
.chain-step.done .dot2 { background:var(--green); color:#04210f; }
.chain-step.active { color:var(--accent); border-color:var(--accent); }
.chain-step.active .dot2 { background:var(--accent); color:#1a1300; }
.chain-arrow { color:var(--muted); font-weight:700; }

.daychip { font-size:11px; font-weight:700; padding:2px 8px; border-radius:6px; background:var(--panel-2); border:1px solid var(--border); color:var(--muted); }
.daychip.approved { color:#8fe6ad; border-color:rgba(63,185,104,.35); }
.daychip.submitted { color:#8fb0ff; border-color:rgba(91,140,255,.35); }
.daychip.draft, .daychip.rejected { color:var(--amber); }

.emp { border:1px solid var(--border); border-radius:var(--radius); padding:12px; margin-bottom:12px; background:var(--panel-2); }
.emp-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.emp .dtr-table th { font-size:11px; }

/* --- v2: week attachments --- */
.filelist { list-style:none; padding:0; margin:0; }
.filelist li { padding:7px 0; border-bottom:1px dashed var(--border); display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.filelist a { font-weight:600; }

/* --- v2: signature capture --- */
.modal-ov { position:fixed; inset:0; background:rgba(0,0,0,.62); display:flex; align-items:center; justify-content:center; z-index:100; }
.modal { background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); padding:20px; width:540px; max-width:94vw; box-shadow:var(--shadow); }
.modal h2 { margin:0 0 12px; }
.sigpad { width:100%; height:170px; background:#fff; border:1px solid var(--border); border-radius:8px; touch-action:none; cursor:crosshair; }
.sigwrap { display:flex; flex-wrap:wrap; gap:12px; margin-top:8px; }
.sigtile { border:1px solid var(--border); border-radius:8px; padding:8px; background:var(--panel-2); width:210px; }
.sigimg { background:#fff; border-radius:6px; height:72px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.sigimg img { max-height:70px; max-width:100%; }
.signame { font-weight:600; margin-top:6px; }

/* --- v3: responsive / mobile polish --- */
.dash-act-wrap { overflow-x:auto; }
@media (max-width: 820px){
  .topbar { flex-wrap:wrap; gap:8px; padding:10px 12px; align-items:flex-start; }
  .brand small { display:none; }
  .nav { margin-left:0; order:3; width:100%; overflow-x:auto; flex-wrap:nowrap; -webkit-overflow-scrolling:touch; padding-bottom:2px; }
  .nav button { white-space:nowrap; flex:0 0 auto; }
  .card table, table { -webkit-overflow-scrolling:touch; }
  .spacer { display:none; }
  .whoami { text-align:left; order:2; }
  .container { padding:12px; }
  .grid.stats { grid-template-columns:repeat(2,1fr); }
  table { display:block; overflow-x:auto; white-space:nowrap; }
  .form-grid { grid-template-columns:1fr 1fr; }
  .modal { padding:16px; }
  h2 { font-size:19px; }
}
@media (max-width: 520px){
  .grid.stats { grid-template-columns:1fr 1fr; }
  .form-grid { grid-template-columns:1fr; }
  .row { flex-wrap:wrap; }
  .btn { padding:9px 12px; }
  .whoami b { display:block; }
}

/* --- v4: dashboard quick-action cards --- */
.stat.qa { transition: transform .08s ease, border-color .15s ease; }
.stat.qa:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat.qa .l { font-weight: 600; color: var(--text); }

/* --- v5: consistency, empty states, toasts, a11y --- */
.btn, .nav button, input, select, textarea { transition: background .12s ease, border-color .12s ease, color .12s ease, transform .05s ease, filter .12s ease; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .nav button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(91,140,255,.18); }

/* Friendlier empty / loading states */
.empty { text-align:center; color:var(--muted); padding:38px 16px; }
.empty::before { content:""; display:block; width:34px; height:34px; margin:0 auto 12px; border-radius:50%;
  border:1px solid var(--border); background:var(--panel-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2397a0b0' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Cpath d='M12 8v4'/%3E%3C/svg%3E") center/18px no-repeat; }
td.muted { color: var(--muted); }
tbody tr td.muted { text-align:center; padding:26px 10px; }

/* Toasts — slide up, colored accent, dismiss */
@keyframes toastIn { from { opacity:0; transform: translate(-50%, 14px); } to { opacity:1; transform: translate(-50%, 0); } }
.toast { animation: toastIn .18s ease both; border-left-width:4px; padding:11px 20px; display:flex; align-items:center; gap:9px; max-width:90vw; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.ok::before { content:"\2713"; color: var(--green); font-weight:800; }
.toast.err::before { content:"\26A0"; color: var(--red); }

/* Clickable table rows */
tr[data-open], tr.clickable { cursor: pointer; }

/* Consistent section headings inside cards */
.card h3 { font-size: 14px; margin: 0 0 8px; }
.card > .sub:last-child { margin-bottom: 0; }

@media (max-width: 520px){
  /* 16px inputs stop iOS Safari from auto-zooming on focus */
  input, select, textarea { font-size: 16px; }
  .container { margin: 14px auto; }
  .card { padding: 15px; }
}

/* --- v6: notifications bell --- */
.bellwrap { position: relative; }
#bell { position: relative; font-size: 15px; padding: 5px 9px; }
.bell-badge { position:absolute; top:-5px; right:-5px; min-width:16px; height:16px; padding:0 4px; background:var(--red); color:#fff; border-radius:999px; font-size:10px; font-weight:800; line-height:16px; text-align:center; }
.bell-panel { position:absolute; right:0; top:38px; width:300px; max-width:80vw; background:var(--panel); border:1px solid var(--border); border-radius:10px; box-shadow:var(--shadow); z-index:60; overflow:hidden; }
.bell-head { font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.4px; padding:10px 12px; border-bottom:1px solid var(--border); }
.bell-item { display:flex; gap:10px; align-items:center; padding:10px 12px; font-size:13px; cursor:pointer; border-bottom:1px solid var(--border); }
.bell-item:last-child { border-bottom:none; }
.bell-item:hover { background:var(--panel-2); }
.bell-ic { font-size:15px; }
.bell-empty { padding:14px 12px; color:var(--muted); font-size:13px; }

/* --- v7: full mobile pass --- */
html, body { max-width: 100%; overflow-x: hidden; }
@media (max-width: 820px){
  .modal { max-height: 88vh; overflow-y: auto; }
  .bell-panel { width: 84vw; max-width: 320px; }
  .card { padding: 14px; }
  .card h2, h2 { font-size: 18px; }
  .totbar { gap: 12px; padding: 12px; }
  .btn.sm { padding: 7px 11px; }            /* bigger tap targets */
  .nav button { padding: 8px 12px; font-size: 13px; }
  .row { gap: 7px; }
  .form-grid { gap: 10px; }
  .grid { gap: 10px; }
  .demo-row { padding: 6px 0; }             /* easier to tap on login */
}
@media (max-width: 430px){
  .grid.stats { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .whoami { font-size: 11px; }
  .brand { font-size: 16px; }
  .stat .n { font-size: 22px; }
  h2 { font-size: 17px; }
  /* stack action buttons full-width so they're easy to hit */
  .modal .row .btn, .card > .row > .btn { flex: 1 1 auto; }
}
