/* KaziHub — mobile-first, no external dependencies (NFR-005, NFR-006). */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde3ea;
  --text: #16212e;
  --muted: #5d6b7d;
  --faint: #8a97a6;
  --brand: #10508a;
  --brand-dark: #0b3a65;
  --brand-soft: #e7f0f8;
  --ok: #1a7a4c;
  --ok-soft: #e2f3ea;
  --warn: #9a6206;
  --warn-soft: #fdf1dc;
  --danger: #b3261e;
  --danger-soft: #fbe6e4;
  --info: #10508a;
  --radius: 10px;
  /* Height of the sticky top bar, including whatever the phone's notch adds. */
  --topbar-h: calc(52px + env(safe-area-inset-top));
  --shadow: 0 1px 2px rgba(16, 33, 46, .06), 0 2px 8px rgba(16, 33, 46, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --surface: #161e27; --surface-2: #1b242f; --border: #2b3844;
    --text: #e6edf4; --muted: #a3b1c0; --faint: #7d8b9a;
    --brand: #63a8e6; --brand-dark: #8cc2f2; --brand-soft: #16293c;
    --ok: #5cc78f; --ok-soft: #142c21; --warn: #e0a94a; --warn-soft: #2e2415;
    --danger: #f08379; --danger-soft: #331a18; --info: #63a8e6;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
/* The browser hides [hidden] with a rule in its own stylesheet, which any author
   `display:` overrides -- so `.notice { display: flex }` quietly un-hid the
   clock-in banner, leaving "Finding your location…" on screen for a worker with
   nothing to clock into, while the script had already returned without ever
   asking the browser for a position. Anything marked hidden must stay hidden. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 70; display: flex; align-items: center; gap: .75rem;
  background: #f4f6f9; color: var(--text); padding: .7rem 1.25rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}
@media (min-width: 900px) {
  .topbar {
    margin-left: 232px;
    width: calc(100% - 232px);
    background: rgba(246,248,250,.96);
    backdrop-filter: blur(6px);
  }
}
.topbar .brand { display: flex; align-items: center; }
.topbar .brand img { height: 24px; width: auto; display: block; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.nav-toggle {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 34px; height: 34px; background: none; border: 0; cursor: pointer; padding: 0;
}
.nav-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; }
.bell { position: relative; color: var(--text); text-decoration: none; display: inline-flex; }
.bell .icon { width: 1.35rem; height: 1.35rem; }
.bell .badge {
  position: absolute; top: -6px; right: -8px; background: #f0b82b; color: #fff;
  border-radius: 999px; font-size: .68rem; padding: 1px 5px; font-weight: 700;
}
.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .6rem;
  color: var(--text); padding: .2rem .05rem;
}
.usermenu summary::-webkit-details-marker { display: none; }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: rgba(16,80,138,.12);
  color: var(--brand); font-weight: 700; border: 1px solid rgba(16,80,138,.2);
}
.user-meta {
  display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.1;
  margin-top: 1px;
}
.user-name { font-weight: 600; font-size: .95rem; color: var(--text); }
.user-role {
  font-size: .72rem; color: var(--muted); font-weight: 500; margin-top: 1px;
  letter-spacing: -.01em;
}
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + .5rem); min-width: 220px; z-index: 50;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .85rem;
}
.usermenu-name { font-weight: 650; margin: 0; }
.usermenu-role { color: var(--muted); font-size: .85rem; margin: 0 0 .6rem; }
.usermenu-link { margin-bottom: .5rem; gap: .45rem; }
.usermenu-link:hover { text-decoration: none; }

/* ---------- Layout ---------- */
.shell { display: block; }
.sidenav {
  display: none; background: #0f1f38; border-right: 1px solid rgba(255,255,255,.08);
  padding: .75rem .7rem; gap: 2px; flex-direction: column;
  color: rgba(255,255,255,.9);
}
.sidenav-brand {
  display: flex; align-items: center; min-height: 56px; padding: .35rem .55rem .85rem;
  margin-bottom: .25rem;
}
.sidenav-brand img {
  height: 28px; width: auto; display: block; filter: brightness(0) invert(1);
}
/* Scoped to the widths that actually have a drawer. Left unscoped, a window
   widened while the menu was open would keep the fixed panel and the dimmed
   backdrop over a layout that already shows the sidebar. */
@media (max-width: 899px) {
  /* The drawer stops below the top bar rather than covering it, so the button
     that opened it is still on screen to close it again. */
  body.nav-open .sidenav {
    display: flex; position: fixed; inset: 0 22% 0 0; z-index: 75; overflow-y: auto;
    box-shadow: var(--shadow); padding-top: 0;
  }
  /* Tapping the page behind the drawer closes it -- the usual gesture, and
     until now the only way out was to pick a menu item and navigate. */
  body.nav-open .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(10, 22, 40, .45); border: 0; width: 100%;
  }
}
.nav-scrim { display: none; }
.sidenav a {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem;
  border-radius: 10px; color: rgba(255,255,255,.82); font-size: .98rem; text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}
.sidenav a:hover { background: rgba(255,255,255,.06); }
.sidenav a.active {
  background: rgba(255,255,255,.08); color: #fff; font-weight: 600;
  border-left: 3px solid #5ba9de; padding-left: calc(.8rem - 3px);
}
.sidenav .icon { color: rgba(255,255,255,.8); }
.sidenav a.active .icon { color: #fff; }
.sidenav .count {
  margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px;
  font-size: .7rem; padding: 1px 7px; font-weight: 700;
}
.content { padding: 1rem .9rem 5.5rem; max-width: 1200px; margin: 0 auto; width: 100%; }
.account-page { padding: 1.5rem 1.5rem 0; }
.account-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.4rem; padding: .2rem 0;
}
.account-header h1 {
  font-size: 2.2rem; letter-spacing: -.03em; margin: 0 0 .2rem; color: #10243a;
}
.account-header p { margin: 0; color: var(--muted); font-size: 1rem; }
.account-header .crumbs {
  display: inline-flex; align-items: center; gap: .45rem; color: var(--muted);
  font-size: .84rem; padding-top: .5rem;
}
.account-header .crumbs a { color: var(--muted); }
.account-grid {
  display: grid; grid-template-columns: minmax(0, 2.05fr) minmax(300px, 1fr); gap: 1.5rem;
  align-items: start;
}
.panel {
  background: rgba(255,255,255,.82); border: 1px solid #dfe7f0; border-radius: 16px;
  box-shadow: 0 1px 0 rgba(16,33,46,.03);
  padding: 1.1rem 1.2rem 1.2rem;
}
.panel-head {
  display: flex; align-items: center; gap: .9rem; margin-bottom: 1.1rem;
}
.panel-head.compact { align-items: center; }
.panel-head h2 {
  margin: 0; font-size: 1.15rem; color: #10243a;
}
.panel-head p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }
.user-chip { display: flex; align-items: center; justify-content: center; }
.user-chip .avatar { width: 40px; height: 40px; }
.user-initial {
  display: inline-flex; width: 44px; height: 44px; border-radius: 50%; align-items: center;
  justify-content: center; background: #dfeaf7; color: var(--brand); font-weight: 700;
}
.panel-action {
  margin-left: auto; background: #e8f4ec; border-color: #d6eedd; color: #1a6f49; }
.panel-action:hover { background: #d9efe2; border-color: #bfe0c7; }
.detail-layout {
  display: grid; grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: 1.6rem; align-items: start;
}
.profile-identity {
  display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: .3rem;
}
.profile-avatar-large {
  width: 92px; height: 92px; border-radius: 50%; background: #0d2d4f; color: #fff;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 700; margin-bottom: .8rem;
}
.profile-avatar-photo { overflow: hidden; }
.profile-avatar-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-name {
  font-size: 1.95rem; font-weight: 700; letter-spacing: -.04em; color: #10243a; line-height: 1.1;
}
.profile-role-tag {
  display: inline-block; margin-top: .6rem; background: #eaf2ff; color: #1f5aa2;
  border-radius: 999px; font-size: .75rem; font-weight: 700; padding: .3rem .7rem;
}
.detail-list { display: grid; gap: .8rem; }
.detail-row {
  display: grid; grid-template-columns: 180px 1fr; gap: .8rem; align-items: center;
  padding: .8rem 0; border-top: 1px solid var(--border);
}
.detail-row:first-child { border-top: 0; }
.detail-label {
  display: flex; align-items: center; gap: .5rem; color: var(--muted); font-weight: 600;
  font-size: .95rem;
}
.detail-label .icon { color: var(--muted); }
.detail-value {
  color: #1b2a35; font-weight: 600; display: flex; align-items: center; gap: .5rem; min-height: 24px;
  font-size: .98rem;
}
.info-banner {
  display: flex; align-items: center; gap: .7rem; margin-top: 1.2rem; padding: .85rem .9rem;
  border-radius: 10px; background: #eaf4ff; color: #225a8d; border: 1px solid #d4e6fa;
  font-size: .9rem;
}
.info-banner .icon { color: #2d74c2; }
.security-panel .panel-head { margin-bottom: 1rem; }
.security-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: #e9f8ee; color: #1d8f5d; font-size: 1.2rem;
}
.security-status {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem;
  padding: .8rem .9rem; background: #eaf9ef; border: 1px solid #d4efdc; border-radius: 14px;
  color: #1e5e3e; margin-bottom: .9rem;
}
.security-status-icon {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(26,123,76,.14); color: #1a7a4c;
}
.security-status strong, .security-status span { display: block; }
.security-status span { font-size: .82rem; }
.status-check {
  width: 22px; height: 22px; border-radius: 50%; background: #1b9b5a; color: #fff;
  display: grid; place-items: center; font-size: .72rem;
}
.security-action {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem;
  width: 100%; margin-top: .3rem; padding: .8rem .9rem; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(255,255,255,.5); color: var(--text); font-weight: 600; text-decoration: none;
}
.security-action:hover { text-decoration: none; background: var(--surface-2); }
.security-action-icon {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
  background: #f2f5fa; color: var(--muted);
}
.chevron { font-size: 1.4rem; color: var(--muted); }
.security-list {
  list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .75rem;
}
.security-list li {
  display: flex; align-items: center; gap: .55rem; color: #203146; font-size: .92rem;
}
.security-list .icon { color: #1b9b5a; }

/* ---------- Bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; display: flex;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: .45rem .2rem .5rem; font-size: .68rem;
  color: var(--muted); text-decoration: none; display: flex; flex-direction: column; gap: 2px;
}
.tabbar a .icon { width: 1.35rem; height: 1.35rem; margin: 0 auto; vertical-align: baseline; }
.tabbar a.active { color: var(--brand); font-weight: 650; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; align-items: start; }
  .sidenav {
    display: flex; position: sticky; top: 0;
    height: 100vh; max-height: 100vh; margin-top: calc(-1 * var(--topbar-h));
    overflow-y: hidden; gap: 0; padding: 0 .55rem .35rem;
    overscroll-behavior: contain;
  }
  .sidenav-brand { min-height: 42px; padding: 0 .45rem .4rem; margin-bottom: .1rem; }
  .sidenav-brand img { height: 23px; }
  .sidenav a { gap: .55rem; padding: .48rem .65rem; font-size: .9rem; border-radius: 8px; }
  .sidenav a.active { padding-left: calc(.65rem - 3px); }
  .nav-toggle, .tabbar { display: none; }
  .content { padding: 1.5rem 1.75rem 3rem; }
}

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.grid { display: grid; gap: .8rem; grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 620px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-sidebar { grid-template-columns: 2fr 1fr; }
}

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem .9rem; box-shadow: var(--shadow);
}
.stat .label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; margin-bottom: .3rem;
}
.stat .value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .value.sm { font-size: 1.15rem; }
.stat .sub { font-size: .78rem; color: var(--faint); margin-top: .2rem; }
.stat.accent-ok .value { color: var(--ok); }
.stat.accent-warn .value { color: var(--warn); }
.stat.accent-danger .value { color: var(--danger); }
.stat.accent-brand .value { color: var(--brand); }

/* ---------- Progress ---------- */
.bar { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden;
       border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }
.bar-label { display: flex; justify-content: space-between; font-size: .78rem;
             color: var(--muted); margin-bottom: .25rem; }

/* Budget waterfall: Budget -> Committed -> Approved -> Paid -> Remaining */
.waterfall { display: flex; flex-direction: column; gap: .55rem; }
.waterfall .row { display: grid; grid-template-columns: 6.5rem 1fr auto; gap: .6rem;
                  align-items: center; font-size: .85rem; }
.waterfall .row .name { color: var(--muted); }
.waterfall .row .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.waterfall .track { height: 14px; background: var(--surface-2); border: 1px solid var(--border);
                    border-radius: 4px; overflow: hidden; }
.waterfall .track > i { display: block; height: 100%; }
.w-budget > i { background: var(--brand-dark); }
.w-committed > i { background: #7aa7cc; }
.w-approved > i { background: var(--warn); }
.w-paid > i { background: var(--ok); }
.w-remaining > i { background: var(--faint); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1rem; padding: 0 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border);
         vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
     color: var(--muted); font-weight: 650; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact th, .table-compact td { padding: .4rem .5rem; }

/* On a phone a seven-column table cannot be read sideways, so each row becomes
   a card and each value carries its column heading. stacked-tables.js copies
   the headings in; without it these rules never apply and the table keeps the
   horizontal scroll above. */
@media (max-width: 719px) {
  .table-wrap.has-stacked { overflow-x: visible; margin: 0; padding: 0; }
  table.stacked, table.stacked tbody, table.stacked tr, table.stacked td,
  table.stacked th { display: block; }
  table.stacked thead { display: none; }
  table.stacked tbody tr {
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
    padding: .55rem .7rem; margin-bottom: .55rem;
  }
  table.stacked tbody tr:hover { background: var(--surface); }
  table.stacked td, table.stacked tbody th {
    border: 0; padding: .18rem 0; text-align: left;
  }
  /* The label is taken out of flow rather than made a grid or flex item: a cell
     often holds several children -- a star and a number, a name and a code --
     and as items those each claimed their own column and fell out of line. */
  table.stacked td[data-label], table.stacked tbody th[data-label] {
    position: relative; padding-left: 8.15rem; min-height: 1.5rem;
  }
  table.stacked td[data-label]::before, table.stacked tbody th[data-label]::before {
    content: attr(data-label); position: absolute; left: 0; top: .3rem; width: 7.5rem;
    font-size: .68rem; text-transform: uppercase; line-height: 1.2;
    letter-spacing: .05em; font-weight: 650; color: var(--muted);
  }
  /* Blank heading: an actions column. It gets the full width and a rule above,
     so the buttons read as the end of the card rather than another value. */
  table.stacked td:not([data-label]) {
    display: block; margin-top: .45rem; padding-top: .5rem;
    border-top: 1px solid var(--border);
  }
  table.stacked tr.stacked-full td { display: block; padding: .2rem 0; }
  table.stacked tr.stacked-full td::before { content: none; }
  table.stacked td.num { text-align: left; }
}

/* ---------- Pills / status ---------- */
.pill {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill-muted { background: var(--surface-2); color: var(--faint); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font-size: .88rem; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit; min-height: 40px;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn-quiet { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-quiet:hover { background: var(--surface-2); }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #14603c; border-color: #14603c; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #8f1e17; border-color: #8f1e17; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; min-height: 32px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .28rem; }
.field .help { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local],
input[type=password], input[type=email], input[type=tel], input[type=file],
select, textarea {
  width: 100%; padding: .55rem .65rem; font: inherit; font-size: 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
.errorlist { list-style: none; margin: .3rem 0 0; padding: 0; color: var(--danger);
             font-size: .8rem; }

/* ---------- Dashboard ----------
   Plain reading order: the day, four numbers, then the lists. No rule codes,
   no footnotes, nothing that needs a key to understand. */
.eyebrow { margin: 1.6rem 0 .2rem; font-size: .75rem; letter-spacing: .08em;
           text-transform: uppercase; color: var(--muted); }
.eyebrow .icon { vertical-align: -.12em; }
.dash-head .eyebrow { margin-top: 0; }
.dash-head h1 { margin: 0; }
.dash-stats { margin-bottom: .4rem; }
.dash-h { margin: 0 0 .7rem; }
.dash-list { padding: 0; }

/* One row per worker, read across: who, trade, where, whether they are in.
   Rows rather than a table so there is nothing to scroll sideways on a phone
   and no column headings to carry around. */
.roster-row { display: grid; align-items: center; gap: .5rem;
              grid-template-columns: 1.3fr 1fr 1.3fr 1fr auto;
              padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.roster-row:last-child { border-bottom: 0; }
.roster-row-2 { grid-template-columns: 1fr 2fr; }
.roster .who a { font-weight: 600; }
.roster .r-time { text-align: right; white-space: nowrap; }

@media (max-width: 719px) {
  /* Name and time on the top line, the rest folded underneath it. */
  .roster-row { grid-template-columns: 1fr auto; row-gap: .15rem; }
  .roster-row .who { grid-column: 1; grid-row: 1; }
  .roster-row .r-time { grid-column: 2; grid-row: 1; }
  .roster-row .r-trade, .roster-row .r-site, .roster-row .r-status {
    grid-column: 1 / -1;
  }
}
.dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%;
       margin-right: .45rem; background: var(--muted); vertical-align: .05em; }
.dot-in { background: var(--ok); }
.dot-none { background: var(--danger); }
.dot-out { background: var(--muted); }

.jobcard-head { display: flex; align-items: flex-start; gap: .5rem; }
.jobcard-head h3 { margin: 0; flex: 1 1 auto; }
.jobcard-foot { display: flex; align-items: baseline; gap: .5rem; margin: .6rem 0 .4rem; }
.listrow { display: flex; align-items: center; gap: .5rem; padding: .5rem 0;
           border-bottom: 1px solid var(--border); }
.listrow:last-of-type { border-bottom: 0; }

/* ---------- Faces ----------
   A photo where a worker's name appears, so the person handing out work can
   tell who is in front of them. Square-cropped and round, because a passport
   photo arrives in whatever shape the phone took it in. */
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
          flex: 0 0 auto; background: var(--surface-2);
          border: 1px solid var(--border); display: inline-flex;
          align-items: center; justify-content: center;
          font-weight: 700; overflow: hidden; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-blank { font-size: .8rem; font-weight: 700; color: var(--muted);
                letter-spacing: .02em; }
.avatar-lg.avatar-blank { font-size: 1.35rem; }
/* Name-with-face cell: the two sit on one line and the text wraps beside it. */
.who { display: flex; align-items: center; gap: .55rem; }
.photo-field { display: flex; align-items: flex-start; gap: .8rem; }
.photo-field > div { flex: 1 1 auto; min-width: 0; }

/* Live answer on a confirmation field, written by confirm-password.js. Colour
   alone would leave it unsaid for anyone who cannot see it, so the wording
   carries the meaning and this only reinforces it. */
.field-check { font-weight: 600; }
.field-bad { color: var(--danger); }
.field-ok { color: var(--ok); }
input.is-mismatch { border-color: var(--danger); }

/* Password reveal. The wrapper is built by reveal-password.js, so without the
   script none of this applies and the input keeps its ordinary full width. */
.reveal { position: relative; display: block; }
.reveal input { padding-right: 2.75rem; }
.reveal-btn {
  position: absolute; top: 0; right: 0; height: 100%; width: 2.6rem;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 0 8px 8px 0; background: none; padding: 0;
  color: var(--muted); cursor: pointer; font-size: 1.05rem;
}
.reveal-btn:hover { color: var(--text); }
.reveal-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.reveal-btn[aria-pressed="true"] { color: var(--brand); }
.form-row { display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 620px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; }
                            .form-row.cols-3 { grid-template-columns: repeat(3, 1fr); } }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem;
           margin: 0 0 1rem; }
legend { font-size: .8rem; font-weight: 700; text-transform: uppercase;
         letter-spacing: .05em; color: var(--muted); padding: 0 .4rem; }

/* ---------- Flash messages ---------- */
.messages { margin-bottom: 1rem; display: grid; gap: .5rem; }
.flash { padding: .65rem .85rem; border-radius: 8px; font-size: .88rem;
         border-left: 3px solid var(--info); background: var(--brand-soft); color: var(--text); }
.flash-success { border-color: var(--ok); background: var(--ok-soft); }
.flash-warning { border-color: var(--warn); background: var(--warn-soft); }
.flash-error { border-color: var(--danger); background: var(--danger-soft); }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); font-size: .85em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .big { font-size: 2rem; display: block; margin-bottom: .4rem; }

/* Inline SVG icons. Sized in em so they track the text they sit beside, and
   stroked in currentColor so they inherit link, hover and active states. */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.19em; }
.icon-lg { width: 2.2rem; height: 2.2rem; vertical-align: baseline; }
.empty .icon-lg { display: block; margin: 0 auto .5rem; opacity: .55; }
.icon-star { width: 1em; height: 1em; color: var(--warn); }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: .7rem; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap;
             margin-bottom: 1rem; }
.page-head .spacer { margin-left: auto; }
.kv { display: grid; grid-template-columns: minmax(7rem, auto) 1fr; gap: .35rem .8rem;
      font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; flex: 1 1 140px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .5rem 0 .5rem 1.1rem; border-left: 2px solid var(--border);
               position: relative; font-size: .86rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .8rem;
  width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.timeline li.done::before { background: var(--ok); }
.timeline li.current::before { background: var(--brand); }
.timeline li.rejected::before { background: var(--danger); }
.alert-row { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem 0;
             border-bottom: 1px solid var(--border); font-size: .87rem; }
.alert-row:last-child { border-bottom: 0; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: .42rem; flex: none; }
.alert-info .alert-dot { background: var(--info); }
.alert-warning .alert-dot { background: var(--warn); }
.alert-critical .alert-dot { background: var(--danger); }
.rule-note { font-size: .78rem; color: var(--faint); font-style: italic; }
.blockquote { border-left: 3px solid var(--border); padding: .3rem 0 .3rem .7rem;
              color: var(--muted); font-size: .87rem; margin: 0 0 .6rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border);
        margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .8rem; font-size: .87rem; color: var(--muted);
          border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 650; }
.app-foot { text-align: center; color: var(--faint); font-size: .74rem;
            margin: 2.5rem 0 0; }
.anon-foot { position: fixed; left: 0; right: 0; bottom: .9rem; margin: 0;
             text-align: center; font-size: .74rem; color: rgba(255,255,255,.55); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem;
              background: linear-gradient(160deg, var(--brand-dark), #071f36); }
.login-card { background: var(--surface); border-radius: 14px; padding: 1.75rem 1.5rem;
              width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card h1 { text-align: center; margin-bottom: .2rem; }
.login-logo { display: block; height: 38px; width: auto; margin: 0 auto .7rem; }
.login-sub { text-align: center; color: var(--muted); font-size: .87rem; margin-bottom: 1.25rem; }

/* Language switch. A segmented pair rather than a <select>, so both languages
   are legible at a glance to someone who cannot read the other one. Labelled by
   two-letter code -- the full names took up half the top bar; each button still
   carries its language's own name as a tooltip and accessible name. */
.langswitch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px;
              overflow: hidden; background: var(--surface); }
.langswitch-opt { appearance: none; border: 0; background: none; cursor: pointer;
                  font: inherit; font-size: .78rem; font-weight: 700; padding: .34rem .7rem;
                  letter-spacing: .06em; color: var(--muted); }
.langswitch-opt:hover { background: var(--surface-2); color: var(--text); }
.langswitch-opt.is-active { background: var(--brand); color: #fff; }
.usermenu-panel .langswitch { display: flex; width: 100%; margin: 0 0 .6rem; }
.usermenu-panel .langswitch-opt { flex: 1; text-align: center; }
.lang-floating { position: fixed; top: 1rem; right: 1rem; z-index: 30; }
/* Signed-out pages sit on a dark full-height panel, so this is light-on-dark. */
.anon-home {
  position: fixed; top: 1rem; left: 1rem; z-index: 30;
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .34rem .8rem .34rem .55rem; border-radius: 999px;
  font-size: .82rem; font-weight: 650; color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.28);
  backdrop-filter: blur(4px);
}
.anon-home:hover { background: rgba(255,255,255,.22); color: #fff; text-decoration: none; }
.anon-home .icon { width: 1rem; height: 1rem; }
@media (max-width: 560px) { .lang-floating { top: .6rem; right: .6rem; } }

/* Route into the other half of the front door: workers sign themselves up. */
.login-forgot { margin: .8rem 0 0; text-align: center; font-size: .85rem; }
.login-forgot a { color: var(--brand); }
.login-alt { margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--border);
             text-align: center; }
.login-alt span { display: block; font-size: .83rem; color: var(--muted);
                  margin-bottom: .5rem; }
.login-alt .btn { display: inline-flex; align-items: center; justify-content: center;
                  gap: .45rem; }

/* Worker self-registration: a longer form, so it gets more room than sign-in. */
.login-wrap-wide { align-items: start; padding-top: 2rem; padding-bottom: 3rem; }
.login-card-wide { max-width: 640px; }
.register-head { text-align: center; margin-bottom: 1.25rem; }
.register-head .icon-lg { color: var(--brand); opacity: 1; }
.register-head h1 { margin: .35rem 0 .2rem; }
.register-head .login-sub { margin-bottom: 0; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius);
            padding: .9rem 1rem 1rem; margin: 0 0 1rem; }
.fieldset legend { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
                   font-weight: 700; color: var(--muted); padding: 0 .4rem; }
.field-row { display: grid; gap: 0 .8rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } }
.checkgrid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem .9rem;
                grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.checkgrid label { display: flex; align-items: center; gap: .45rem; font-weight: 400;
                   font-size: .9rem; }
.checkgrid input { width: auto; margin: 0; }

/* The skills catalogue, folded away behind a summary and grouped under its
   categories: an open column of every trade in the list is the first thing the
   eye lands on, and it tells the reader what kind of work the system is for. */
.picker { margin: .2rem 0 .6rem; }
.picker summary { cursor: pointer; font-size: .82rem; font-weight: 600;
                  padding: .45rem 0; color: var(--brand); }
.picker[open] summary { margin-bottom: .4rem; }
.checkgrid-grouped { max-height: 17rem; overflow-y: auto; padding-right: .3rem; }
/* Top level is the groups; each group holds its own list of options. */
.checkgrid-grouped > ul { display: block; }
.checkgrid-grouped > ul > li { margin-bottom: .55rem; font-size: .74rem;
                               font-weight: 700; letter-spacing: .06em;
                               text-transform: uppercase; color: var(--muted); }
.checkgrid-grouped > ul > li > ul { margin-top: .25rem; }

.register-note { text-align: center; margin: 1rem 0 0; }

/* Shown to a worker whose registration has not been verified yet (BR-001). */
.notice { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem;
          border-radius: var(--radius); background: var(--warn-soft);
          border: 1px solid var(--warn); color: var(--text); margin-bottom: 1rem; }
.notice .icon { color: var(--warn); margin-top: .15rem; }
.notice p { margin: 0; font-size: .9rem; }
.notice strong { display: block; margin-bottom: .15rem; }
.notice-ok { background: var(--ok-soft); border-color: var(--ok); }
.notice-ok .icon { color: var(--ok); }
.notice-danger { background: var(--danger-soft); border-color: var(--danger); }
.notice-danger .icon { color: var(--danger); }

/* Clock-in: one big target per site, usable one-handed on a phone in the sun. */
.clockcard .clockbtn { padding: .85rem; font-size: 1.05rem; margin-top: .4rem; }
.clockcard .clockbtn:disabled { opacity: .5; cursor: not-allowed; }
.clockcard .clockhint { text-align: center; margin: .4rem 0 0; }
/* Where the worker is, in words, under the status line it belongs to. */
.geo-place { display: block; margin-top: .25rem; color: var(--muted); font-size: .82rem; }
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
                 gap: .5rem; }
.evidence-grid img { width: 100%; height: 100px; object-fit: cover; border-radius: 8px;
                     border: 1px solid var(--border); display: block; }
/* ---------- Work record (the printable CV) ----------
   Laid out to survive print-to-PDF: no colour needed to read it, every entry
   kept whole on one page, and nothing on it that only makes sense on screen. */
.cv { max-width: 46rem; }
.cv-head { display: flex; align-items: flex-start; gap: .8rem; flex-wrap: wrap;
           padding-bottom: .8rem; border-bottom: 1px solid var(--border); }
.cv-head h2 { margin: 0 0 .15rem; }
.cv-issued { margin: 0; white-space: nowrap; }
.cv-stats { margin: .9rem 0; }
.cv-h { margin: 1.2rem 0 .6rem; font-size: .95rem; text-transform: uppercase;
        letter-spacing: .06em; color: var(--muted); }
.cv-entry { padding: .7rem 0; border-top: 1px solid var(--border);
            break-inside: avoid; }
.cv-entry-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.cv-facts { margin: .35rem 0 0; padding-left: 1.1rem; }
.cv-facts li { margin: .1rem 0; }
.cv-empty { padding: 1.5rem 0; }
.cv-foot { margin: 1.2rem 0 0; padding-top: .7rem; border-top: 1px solid var(--border); }

@media print {
  .topbar, .sidenav, .tabbar, .btn-row, .filters, .no-print { display: none !important; }
  .content { padding: 0; } .card { box-shadow: none; break-inside: avoid; }
  /* The work record is a document, not a screenshot of an app. */
  .cv { max-width: none; border: 0; padding: 0; }
  .cv-entry, .cv-foot, .cv-head { border-color: #999; }
}
