/* ============================================================
   Daily Progress Tracking — "Nocturne" theme
   Whale Solution Sdn. Bhd.
   Dark, mobile-first app skin matching the approved Claude Design
   mockup: bottom tab bar, hero/stat cards, segmented progress bars,
   bottom sheets for logging progress and deciding approvals.
   ============================================================ */

:root {
  --bg: #0f1019;
  --bg-top: #1b1e30;
  --surface: #1e2033;
  --surface-2: #262941;
  --text: #e9e9ed;
  --text-soft: rgba(233, 233, 237, .68);
  --text-softer: rgba(233, 233, 237, .58);
  --divider: rgba(233, 233, 237, .14);
  --divider-strong: rgba(233, 233, 237, .26);

  --accent: #9184d9;
  --accent-100: #f5f4ff; --accent-200: #e7e5fe; --accent-300: #d2cefd;
  --accent-400: #b5abfc; --accent-500: #968ae0; --accent-600: #796cbf;
  --accent-700: #5d5294; --accent-800: #423a6a; --accent-900: #2b2741;

  --green: #8fc9a6; --green-soft: rgba(95, 154, 119, .16); --green-line: #5f9a77;
  --amber: #e0b877; --amber-soft: rgba(185, 139, 63, .15); --amber-line: #b98b3f;
  --red: #e6a79e; --red-soft: rgba(168, 99, 90, .15); --red-line: #a8635a;
  --neutral-soft: rgba(233, 233, 237, .1); --neutral-fg: rgba(233, 233, 237, .78);

  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
[data-sun="1"] {
  --text: #f7f7fb; --bg: #0d0f1a; --bg-top: #1c1f33;
  --surface: #262937; --surface-2: #2e3244; --divider: rgba(233, 233, 237, .34);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-top) 0%, var(--bg) 55%);
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100vh; }
.mono { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--accent-300); cursor: pointer; text-decoration: none; }
a:hover { color: var(--accent-200); }
p { margin: 0; }

button { font-family: inherit; color: inherit; -webkit-tap-highlight-color: transparent; transition: transform .1s ease, background .15s ease, border-color .15s ease; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input, select, textarea { font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.splash { display: flex; align-items: center; justify-content: center; min-height: 100vh; color: var(--text-soft); font-size: 14px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.row-label-sm { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); }
.link-danger-sm { font-size: 11.5px; color: var(--red); }

/* ---------- Skeleton loaders (replace a bare "Loading…" label with a
   shape that mirrors the screen about to appear, and avoid layout jump) ---- */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-md); }
.skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(233, 233, 237, .09), transparent);
  animation: dptShimmer 1.4s ease-in-out infinite;
}
.skel-hero { height: 132px; border-radius: var(--radius-lg); }
.skel-tile { flex: 1; height: 66px; }
.skel-tile-big { height: 84px; }
.skel-chip { flex: none; width: 74px; height: 36px; border-radius: 999px; }
.skel-card { height: 78px; }
.skel-card-lg { height: 140px; }
.skel-row-sm { height: 58px; }
@keyframes dptShimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .skel::after { animation: none; }
  .stagger > * { animation: none; }
  .sheet, .sheet-scrim, .toast { animation: none; }
}

/* ---------- App shell ---------- */
.app-shell {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  display: flex; flex-direction: column; position: relative;
  background: var(--bg);
}
.app-shell.wide { max-width: 760px; }

.app-header {
  padding: max(18px, env(safe-area-inset-top)) 16px 12px; flex: none;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px;
  background: var(--bg); border-bottom: 1px solid var(--divider); position: relative; z-index: 5;
}
.app-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-header-kicker { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-400); }
.app-header-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm);
  border: 1px solid var(--divider); background: transparent; color: var(--text);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.avatar-btn {
  width: 38px; height: 38px; flex: none; border-radius: 999px;
  border: 1px solid var(--accent-700); background: var(--accent-900); color: var(--accent-200);
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; padding: 0;
}

.app-content {
  flex: 1; overflow-y: auto; padding: 14px 16px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.app-shell.has-tabbar .app-content { padding-bottom: 96px; }

.toast {
  position: sticky; top: 0; z-index: 20; margin: -2px -2px 4px;
  padding: 11px 14px; border-radius: var(--radius-md);
  background: var(--accent-900); border: 1px solid var(--accent-700); color: var(--accent-100);
  font-size: 12.5px; box-shadow: var(--shadow-md); animation: dptFade .18s ease;
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 480px; z-index: 15;
  padding: 8px 8px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 16, 25, .1), var(--bg) 40%);
  border-top: 1px solid var(--divider);
  display: flex; align-items: flex-end; gap: 4px;
}
.tabbar-item {
  flex: 1; position: relative; min-height: 52px; border: 0; background: transparent;
  border-radius: var(--radius-sm); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; color: var(--text-soft); padding: 4px 2px;
}
.tabbar-item svg { flex: none; }
.tabbar-item span.tabbar-label { font-size: 10.5px; letter-spacing: .02em; }
.tabbar-item.active { color: var(--accent-200); }
.tabbar-item.active::after {
  content: ''; position: absolute; bottom: -2px; width: 20px; height: 2px; border-radius: 2px; background: var(--accent);
}
.tabbar-badge {
  position: absolute; top: 2px; right: calc(50% - 22px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px; background: var(--accent-500); color: #1b1930; font-size: 10.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Cards & stat tiles ---------- */
.card {
  padding: 14px; border-radius: var(--radius-md); background: var(--surface);
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px;
}
.card.bordered { border: 1px solid var(--divider); box-shadow: none; }
.card.tap { cursor: pointer; text-align: left; width: 100%; border: 1px solid var(--divider); background: var(--surface); }
.card.tap:active { transform: scale(.99); }

.hero-card {
  padding: 16px; border-radius: var(--radius-lg); background: linear-gradient(180deg, var(--accent-900), var(--surface));
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px;
}
.hero-kicker { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-300); }
.hero-title { font-size: 22px; font-weight: 600; line-height: 1.18; letter-spacing: -.015em; }
.hero-sub { font-size: 13px; color: var(--text-soft); line-height: 1.45; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent; color: var(--text);
  font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.btn.block { width: 100%; }
.btn.flex { flex: 1; }
.btn.sm { min-height: 40px; font-size: 13px; padding: 0 12px; }
.btn.accent { border-color: var(--accent); background: transparent; color: var(--accent-200); }
.btn.accent:hover:not(:disabled) { background: rgba(145, 132, 217, .12); }
.btn.solid { border-color: var(--accent); background: var(--accent-700); color: var(--accent-100); }
.btn.ok { border-color: var(--green-line); background: var(--green-soft); color: var(--green); }
.btn.warn { border-color: var(--amber-line); background: transparent; color: var(--amber); }
.btn.bad { border-color: var(--red-line); background: transparent; color: var(--red); }
.btn.ghost { border: none; color: var(--accent-300); min-height: 36px; padding: 0 4px; }
.btn.dashed { border-style: dashed; color: var(--text-soft); }
.link-btn { background: none; border: 0; color: var(--accent-300); font-size: 13px; padding: 4px 0; cursor: pointer; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Mobile default: a plain stacked column, same spacing as before this
   wrapper existed. The desktop @media block below turns it into a grid. */
.card-grid { display: flex; flex-direction: column; gap: 12px; }
.stat-row { display: flex; gap: 10px; }
.stat-tile { flex: 1; padding: 12px 12px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 3px; }
.stat-tile.big { padding: 14px; }
.stat-val { font-size: 22px; font-weight: 600; line-height: 1; }
.stat-tile.big .stat-val { font-size: 27px; }
.stat-label { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-soft); }
.stat-sub { font-size: 11.5px; color: var(--text-softer); }

/* ---------- Worklist / list cards ---------- */
.wl-card { display: flex; flex-direction: column; gap: 9px; padding: 13px 14px; }
.wl-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wl-id { font-size: 15px; font-weight: 600; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.wl-sub { font-size: 12.5px; color: var(--text-soft); }
.seg-track { display: flex; gap: 3px; height: 6px; }
.seg { flex: 1; border-radius: 3px; background: rgba(233, 233, 237, .12); overflow: hidden; display: block; }
.seg > i { display: block; height: 100%; background: var(--accent-500); }
.wl-stageline { font-size: 11.5px; color: var(--text-softer); }

.filter-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.filter-chip {
  flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--divider);
  background: transparent; color: var(--text-soft); font-size: 12.5px; min-height: 36px;
}
.filter-chip.active { border-color: var(--accent); background: var(--accent-900); color: var(--accent-100); }

/* ---------- Detail screen ---------- */
.detail-head { padding: 13px 14px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; }
.detail-pct { display: flex; align-items: flex-end; gap: 8px; }
.detail-pct-num { font-size: 30px; font-weight: 600; line-height: 1; }
.detail-pct-of { font-size: 12px; color: var(--text-softer); padding-bottom: 3px; }

.component-block { border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); overflow: hidden; }
.component-head { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; border-bottom: 1px solid var(--divider); }
.component-title { font-size: 14.5px; font-weight: 600; }
.component-sub { font-size: 11.5px; color: var(--text-soft); }
.component-stages { padding: 8px; display: flex; flex-direction: column; gap: 6px; }

.stage-btn {
  text-align: left; width: 100%; padding: 10px 11px; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent;
  display: flex; align-items: center; gap: 11px;
}
.stage-btn.actionable { border-color: var(--accent-700); background: var(--accent-900); }
.stage-dot {
  width: 26px; height: 26px; flex: none; border-radius: 999px; border: 1px solid var(--divider);
  background: transparent; color: var(--text-soft); font-size: 10.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.stage-dot.done { border-color: var(--green-line); background: var(--green-soft); color: var(--green); }
.stage-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.stage-body-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.stage-name { font-size: 13.5px; font-weight: 500; }
.stage-meta { font-size: 11.5px; color: var(--text-soft); }
.stage-bar { display: block; height: 5px; border-radius: 3px; background: rgba(233, 233, 237, .12); overflow: hidden; }
.stage-bar > i { display: block; height: 100%; background: var(--accent-500); }
.stage-chev { flex: none; color: var(--text-softer); }

.final-block { border-radius: var(--radius-md); border: 1px solid var(--accent-700); background: var(--accent-900); padding: 13px 14px; display: flex; flex-direction: column; gap: 10px; }
.additional-btn { text-align: left; padding: 10px 11px; border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); display: flex; align-items: center; gap: 10px; width: 100%; }
.check-box { width: 22px; height: 22px; flex: none; border-radius: 6px; border: 1px solid var(--divider); background: transparent; display: flex; align-items: center; justify-content: center; }
.check-box.done { border-color: var(--green-line); background: var(--green-soft); }

.history-row { padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface); display: flex; align-items: center; gap: 10px; }
.history-dot { width: 7px; height: 7px; border-radius: 999px; flex: none; }

/* ---------- Queue (supervisor) ---------- */
.queue-card { border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); padding: 13px 14px; display: flex; flex-direction: column; gap: 11px; }
.queue-who { display: flex; align-items: center; gap: 10px; }
.queue-avatar { width: 32px; height: 32px; flex: none; border-radius: 999px; background: var(--accent-900); border: 1px solid var(--accent-700); color: var(--accent-200); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.queue-body { padding: 11px 12px; border-radius: var(--radius-md); background: rgba(233, 233, 237, .05); display: flex; flex-direction: column; gap: 5px; }
.queue-qty { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.queue-qty-num { font-size: 23px; font-weight: 600; }

/* ---------- People / profile ---------- */
.person-row { padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface); display: flex; align-items: center; gap: 11px; }
.person-avatar { width: 34px; height: 34px; flex: none; border-radius: 999px; background: var(--accent-900); border: 1px solid var(--accent-700); color: var(--accent-200); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.pin-req-banner { padding: 13px 14px; border-radius: var(--radius-md); border: 1px solid var(--amber-line); background: var(--amber-soft); display: flex; flex-direction: column; gap: 10px; }

.profile-row {
  min-height: 48px; text-align: left; padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
}

/* ---------- Login ---------- */
.login-wrap { flex: 1; display: flex; flex-direction: column; padding: 64px 24px 34px; gap: 20px; }
.login-brand-kicker { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-400); }
.login-title { font-size: 27px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
/* Desktop-only brand copy (see the @media(min-width:900px) block below
   for the two-pane layout that shows these) - hidden on the compact
   mobile login where there isn't room for them. */
.login-brand-sub, .login-features { display: none; }
.login-panel { display: flex; flex-direction: column; gap: 20px; }
.login-fade { height: 1px; background: linear-gradient(to right, transparent, var(--divider) 20%, var(--divider) 80%, transparent); }
.field-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft); }
.text-input {
  width: 100%; min-height: 52px; padding: 8px 14px; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-md);
  caret-color: var(--accent);
}
.text-input:hover { border-color: var(--divider-strong); }
.pin-dots { display: flex; gap: 10px; }
.pin-dot {
  flex: 1; height: 50px; border-radius: var(--radius-md); border: 1px solid var(--divider);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 600; color: var(--accent-200);
}
.pin-dot.filled { border-color: var(--accent); }
.login-error { font-size: 12.5px; color: var(--red); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 10px; }
.keypad-key {
  height: 54px; border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface);
  font-size: 20px; font-weight: 500; color: var(--text); display: flex; align-items: center; justify-content: center;
}
.keypad-key.empty { background: transparent; border-color: transparent; }
.login-hint { font-size: 11.5px; color: var(--text-softer); text-align: center; line-height: 1.5; }

/* ---------- Bottom sheets ---------- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 11, 18, .62);
  display: flex; align-items: flex-end; justify-content: center; animation: dptFade .18s ease;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  padding: 16px 16px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px;
  animation: dptSheet .28s cubic-bezier(.22, 1, .36, 1);
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sheet-kicker { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-300); }
.sheet-title { font-size: 19px; font-weight: 600; margin-top: 3px; }
.field-group { display: flex; flex-direction: column; gap: 7px; }
.field-caption { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-softer); }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.pick-chip {
  padding: 9px 13px; min-height: 42px; border-radius: var(--radius-md); border: 1px solid var(--divider);
  background: transparent; color: var(--text-soft); font-size: 13px;
}
.pick-chip.selected { border-color: var(--accent); background: var(--accent-900); color: var(--accent-100); }
.stage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stage-pick {
  padding: 10px 11px; min-height: 52px; text-align: left; border-radius: var(--radius-md);
  border: 1px solid var(--divider); background: transparent; color: var(--text);
  display: flex; flex-direction: column; gap: 2px;
}
.stage-pick.selected { border-color: var(--accent); background: var(--accent-900); color: var(--accent-100); }
.stage-pick-note { font-size: 10.5px; color: var(--text-softer); }
.stepper-row { display: flex; align-items: center; gap: 10px; }
.stepper-btn { width: 56px; height: 60px; border-radius: var(--radius-md); border: 1px solid var(--divider); background: transparent; font-size: 26px; color: var(--text); }
.stepper-btn.sm { width: 42px; height: 42px; font-size: 18px; }
.stepper-display { flex: 1; height: 60px; border-radius: var(--radius-md); border: 1px solid var(--accent-700); background: var(--accent-900); display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.stepper-num { font-size: 30px; font-weight: 600; color: var(--accent-100); }
.stepper-unit { font-size: 13px; color: var(--accent-300); }
.quick-row { display: flex; gap: 7px; }
.quick-btn { flex: 1; min-height: 40px; border-radius: var(--radius-md); border: 1px solid var(--divider); background: transparent; font-size: 12.5px; color: var(--text-soft); }
.inline-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border-radius: var(--radius-md); border: 1px solid var(--divider); }
.mini-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px; }

/* ---------- Bars / crew ---------- */
.bar-block { padding: 14px; border-radius: var(--radius-md); background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.bar-item { display: flex; flex-direction: column; gap: 5px; }
.bar-item-top { display: flex; justify-content: space-between; font-size: 12.5px; }
.bar-track2 { height: 8px; border-radius: 4px; background: rgba(233, 233, 237, .1); overflow: hidden; }
.bar-track2 > i { display: block; height: 100%; border-radius: 4px; background: var(--accent-500); }

/* ---------- Forms / modals (PE admin) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-hint { font-size: 11px; color: var(--text-softer); }
.error-box { border: 1px solid var(--red-line); background: var(--red-soft); color: var(--red); border-radius: var(--radius-md); padding: 9px 12px; font-size: 12.5px; }
.modal-scrim.center { position: fixed; inset: 0; z-index: 70; background: rgba(10, 11, 18, .62); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-center { width: min(440px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.row-gap { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.component-row { border: 1px solid var(--divider); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--divider); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-softer); padding: 9px 10px; border-bottom: 1px solid var(--divider); background: var(--surface-2); }
td { padding: 9px 10px; border-bottom: 1px solid var(--divider); }
tr:last-child td { border-bottom: none; }
.empty-state { text-align: center; color: var(--text-softer); font-size: 13.5px; padding: 48px 20px; }

/* Progressive disclosure for dense, secondary content (e.g. the PE report's
   raw per-entry log) — collapsed by default so the screen leads with the
   summarized team report, not a long flat table. */
.details-block { border-radius: var(--radius-md); border: 1px solid var(--divider); background: var(--surface); padding: 2px; }
.details-block summary {
  cursor: pointer; list-style: none; padding: 12px 12px; display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 600; color: var(--text-soft);
}
.details-block summary::-webkit-details-marker { display: none; }
.details-block .details-chev { transition: transform .15s ease; color: var(--text-softer); }
.details-block[open] .details-chev { transform: rotate(90deg); }
.details-block > .table-wrap, .details-block > button { margin: 0 10px 10px; }
.details-block[open] > .table-wrap { margin-top: 4px; }

/* ---------- Animations ---------- */
@keyframes dptUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes dptSheet { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes dptFade { from { opacity: 0; } to { opacity: 1; } }
.stagger > * { animation: dptUp .28s cubic-bezier(.22, 1, .36, 1) both; }
.stagger > *:nth-child(2) { animation-delay: .03s; }
.stagger > *:nth-child(3) { animation-delay: .06s; }
.stagger > *:nth-child(4) { animation-delay: .09s; }
.stagger > *:nth-child(5) { animation-delay: .12s; }

@media (min-width: 620px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.5); border: 1px solid var(--divider); }
  .tabbar { position: absolute; }
}

/* ============================================================
   Desktop layout — a genuinely different shell, not a scaled-up
   phone screen: a fixed left sidebar replaces the bottom tab bar,
   and content uses the freed-up width instead of sitting in a
   narrow centered card. Below 900px (phones/small tablets) nothing
   here applies — that's the "mobile view" above, unchanged.
   ============================================================ */
@media (min-width: 900px) {
  body { padding: 0; }
  .app-shell {
    max-width: none; width: 100%; min-height: 100vh;
    border-radius: 0; box-shadow: none; border: none;
  }
  .app-shell.wide { max-width: none; }

  /* Sidebar nav (same buttons/markup as the mobile tab bar — just
     repositioned and restyled, so no app.js changes are needed).
     Auto-hide rail: collapsed to icon-only width by default (position:
     fixed already, so it overlays rather than pushing content) and
     slides out to full width on hover or keyboard focus — the same
     drawer pattern used for the drawing screen's Tools/BOM panels. */
  .app-shell.has-tabbar .tabbar {
    position: fixed; left: 0; top: 0; bottom: auto; transform: none;
    width: 64px; max-width: 64px; height: 100vh; overflow: hidden; z-index: 50;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 2px; padding: 22px 12px; background: var(--bg-top);
    border-top: none; border-right: 1px solid var(--divider);
    transition: width .2s ease, box-shadow .2s ease;
  }
  .app-shell.has-tabbar .tabbar:hover,
  .app-shell.has-tabbar .tabbar:focus-within {
    width: 232px; max-width: 232px; box-shadow: 6px 0 28px rgba(0, 0, 0, .35);
  }
  .app-shell.has-tabbar .tabbar-item {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    min-height: 44px; padding: 0 12px; border-radius: var(--radius-md);
  }
  .app-shell.has-tabbar .tabbar-item span.tabbar-label {
    font-size: 13.5px; white-space: nowrap; opacity: 1; transition: opacity .12s ease;
  }
  .app-shell.has-tabbar .tabbar-item.active { background: var(--accent-900); color: var(--accent-100); }
  .app-shell.has-tabbar .tabbar-item.active::after { display: none; }
  .app-shell.has-tabbar .tabbar-badge { position: static; margin-left: auto; white-space: nowrap; }
  /* Collapsed state: hide the label/brand text (it has no room to sit in
     a 64px rail) rather than letting it wrap or overflow, so what's left
     is a clean icon rail; hovering fades it back in as the rail widens. */
  .app-shell.has-tabbar .tabbar:not(:hover):not(:focus-within) .tabbar-item span.tabbar-label,
  .app-shell.has-tabbar .tabbar:not(:hover):not(:focus-within)::before {
    opacity: 0;
  }

  /* A small brand mark above the nav, since the header no longer
     needs to carry the app identity on every screen. */
  .app-shell.has-tabbar .tabbar::before {
    content: 'Whale Solution Sdn. Bhd.'; display: block; padding: 0 12px 16px;
    font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-400);
    white-space: nowrap; transition: opacity .12s ease;
  }

  /* Header + content move right to clear the collapsed rail and fill
     the rest of the screen edge-to-edge - same full-bleed approach as
     the drawing screen's desktop layout, so a wide monitor isn't left
     with a narrow column and dead space down the right side. The rail
     overlays content when hovered open, rather than pushing it, so this
     margin never needs to change with hover state. */
  .app-shell.has-tabbar .app-header,
  .app-shell.has-tabbar .app-content {
    margin-left: 64px; max-width: none;
  }
  .app-shell.has-tabbar .app-header { padding: 28px 32px 16px; }
  .app-shell.has-tabbar .app-content { padding: 6px 32px 40px; }
  .app-shell.has-tabbar .app-header-title { font-size: 23px; }

  /* More columns now that there's room for the self-contained grids
     (stat tiles, bar charts); everything else stays a single,
     comfortably wide column rather than being forced into a grid
     that would scramble screens meant to be read top-to-bottom
     (worklist detail, drawing forms, step-by-step sheets). */
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-row { flex-wrap: wrap; }

  /* Card lists (worklists, drawings, approval queue) reflow into a
     multi-column grid instead of one full-width column per card, so
     the freed-up width is used for more cards visible at once rather
     than just wider individual cards. Wraps whatever the JS renderer
     produced for that list - see .card-grid usages in app.js. */
  .card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
  .card-grid > .card { margin: 0; }

  /* Sheets/modals stay centered floating panels (that pattern works
     fine at any width) but get a little more breathing room. */
  .sheet { max-width: 560px; border-radius: 18px; margin-bottom: 5vh; align-self: center; }
  .sheet-scrim { align-items: center; }

  /* Login becomes a genuine two-pane desktop screen instead of a phone
     form stretched into empty space: a branded panel with a short pitch
     on the left, the actual sign-in form centered in its own panel on
     the right. */
  .login-wrap {
    flex-direction: row; align-items: stretch; max-width: none;
    margin: 0; padding: 0; gap: 0; min-height: 100vh;
  }
  .login-brand {
    flex: 1 1 55%; display: flex; flex-direction: column; justify-content: center;
    padding: 72px 64px; gap: 18px; position: relative; overflow: hidden;
    background:
      repeating-linear-gradient(60deg, rgba(233, 233, 237, .05) 0 1px, transparent 1px 28px),
      repeating-linear-gradient(-60deg, rgba(233, 233, 237, .05) 0 1px, transparent 1px 28px),
      linear-gradient(160deg, var(--accent-900), var(--bg-top) 60%, var(--bg));
    border-right: 1px solid var(--divider);
  }
  .login-brand-kicker { font-size: 12.5px; }
  .login-title { font-size: 46px; line-height: 1.08; max-width: 560px; }
  .login-brand-sub {
    display: block; font-size: 15px; line-height: 1.65; color: var(--text-soft);
    max-width: 440px; margin-top: 4px;
  }
  .login-features { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
  .login-feature { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: var(--text-soft); }
  .login-feature svg { flex: none; color: var(--accent-300); }

  .login-panel {
    flex: 1 1 45%; max-width: 440px; margin: 0 auto; justify-content: center;
    padding: 64px 48px; gap: 22px;
  }
}
