/* =====================================================================
   GS Tasks — app.css
   ---------------------------------------------------------------------
   Built from docs/mockup/theme.css (the mockup's look as a clean
   stylesheet); class names are the mockup's own, so the skeletons in
   docs/mockup/theme-guide.md render unchanged. Sections 1–31 are the
   theme; section 32 holds what the server-rendered app adds (focus
   states, flash messages, search results, the compose dialog, shared
   partials). Change the theme sections only to fix a real problem.

   Font: Figtree from Google Fonts, linked in the layouts, with the
   system font stack as the fallback.

   Conventions
   - Colours come from the custom properties below.
   - Per-item colours are passed inline: style="--c:#hex",
     style="--pc:#hex", style="width:40%".
   ===================================================================== */


/* =====================================================================
   1. Design tokens
   ===================================================================== */

/* Light (default) */
:root {
  --side: #e8eef8;
  --side2: #dbe4f3;
  --sidek: #1d2840;
  --sidem: #5d6b85;
  --sideon: #ffffff;
  --hbg1: #0f5132;
  --hbg2: #1f7a52;
  --hink: #f2fbf6;
  --hline: #0f5132;
  --bg: #f7f5f1;
  --panel: #ffffff;
  --panel2: #f9f8f5;
  --ink: #161b26;
  --muted: #5f6779;
  --line: #e6e2da;
  --brand: #1d4ed8;
  --brand2: #e8eefc;
  --ok: #137a38;
  --okbg: #e7f6ec;
  --warn: #b45309;
  --warnbg: #fff4dc;
  --bad: #c81e1e;
  --badbg: #fdeaea;
  --wa: #1fa855;
  /* Fills that carry white text (buttons, count bubbles, pills): every one
     keeps >= 4.5:1 against #fff in both themes. The plain colours above stay
     for text and borders on the page background. */
  --brandfill: #1d4ed8;
  --okfill: #15803d;
  --badfill: #c81e1e;
  --warnfill: #b45309;
  --wafill: #167c43;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .05);
  --r: 12px;

  /* Added (not in the mockup's :root): the status colours its JS used
     inline for the "Tasks by status" bar chart. Same in both themes. */
  --st-pending: #94a3b8;
  --st-progress: #3b82f6;
  --st-reopened: #f59e0b;
  --st-overdue: #dc2626;
  --st-review: #8b5cf6;
  --st-done: #16a34a;
}

/* Dark — follows the OS unless the user explicitly chose light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --side: #121a2b;
    --side2: #1a2439;
    --sidek: #dfe6f3;
    --sidem: #8c9ab3;
    --sideon: #22304b;
    --hbg1: #0c2e20;
    --hbg2: #134a33;
    --hink: #e3f5ec;
    --hline: #1d5a40;
    --bg: #0e1117;
    --panel: #161a22;
    --panel2: #1b2029;
    --ink: #e7e9ef;
    --muted: #98a1b3;
    --line: #272d39;
    --brand: #6b95ff;
    --brand2: #1c2740;
    --ok: #4ade80;
    --okbg: #14301f;
    --warn: #fbbf24;
    --warnbg: #33290f;
    --bad: #f87171;
    --badbg: #3a1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --brandfill: #3563d9;
    --okfill: #15803d;
    --badfill: #dc2626;
    --warnfill: #b45309;
    --self: #2dd4bf;
    --review: #c4b5fd;
    color-scheme: dark;
  }
}

/* Dark — explicit choice (<html data-theme="dark">) */
:root[data-theme=dark] {
  --side: #121a2b;
  --side2: #1a2439;
  --sidek: #dfe6f3;
  --sidem: #8c9ab3;
  --sideon: #22304b;
  --hbg1: #0c2e20;
  --hbg2: #134a33;
  --hink: #e3f5ec;
  --hline: #1d5a40;
  --bg: #0e1117;
  --panel: #161a22;
  --panel2: #1b2029;
  --ink: #e7e9ef;
  --muted: #98a1b3;
  --line: #272d39;
  --brand: #6b95ff;
  --brand2: #1c2740;
  --ok: #4ade80;
  --okbg: #14301f;
  --warn: #fbbf24;
  --warnbg: #33290f;
  --bad: #f87171;
  --badbg: #3a1717;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --brandfill: #3563d9;
  --okfill: #15803d;
  --badfill: #dc2626;
  --warnfill: #b45309;
  --self: #2dd4bf;
  --review: #c4b5fd;
  color-scheme: dark;
}


/* =====================================================================
   2. Base & typography
   ===================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 15px;
}

a {
  color: var(--brand);
}

code {
  font: 13px ui-monospace, monospace;
  background: var(--panel2);
  padding: 1px 6px;
  border-radius: 5px;
}


/* =====================================================================
   3. Forms
   ===================================================================== */

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

input,
select,
textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 70px;
  resize: vertical;
}

input[type=checkbox],
input[type=radio] {
  width: auto;
}

input[type=range] {
  padding: 0;
  border: 0;
  background: none;
}

/* Labels wrap their control: <label>Title<input name="title"></label> */
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

label > input,
label > select,
label > textarea {
  margin-top: 4px;
  font-weight: 400;
}

/* Form error line (keeps its height so the layout does not jump) */
.err {
  color: var(--bad);
  font-size: 13px;
  min-height: 18px;
}

/* Checkbox list (one per line) */
.checks label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--ink);
  font-weight: 400;
  padding: 3px 0;
}

/* Multi-column checkbox picker (assign to people) */
.pickgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 2px 10px;
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.pickgrid label {
  display: flex;
  gap: 6px;
  align-items: center;
  font-weight: 400;
  color: var(--ink);
  font-size: 13px;
}

/* Star rating input */
.stars {
  display: flex;
  gap: 4px;
  font-size: 30px;
  cursor: pointer;
  color: #d1d5db;
}

.stars span.on {
  color: #f59e0b;
}

/* Form section inside a modal */
.sect {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.sect h3 {
  margin-bottom: 8px;
}

/* Bordered form section (profile / settings) */
.fsec {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
}

.fsec h3 {
  font-size: 14px;
  margin: 0;
}


/* =====================================================================
   4. Utilities & layout helpers
   ===================================================================== */

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

/* promoted: the mockup set this font inline on task codes */
.mono {
  font-family: ui-monospace, monospace;
}

.nw {
  white-space: nowrap;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Coloured project dot: <span class="dot" style="background:#hex"></span> */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

@media (max-width: 640px) {
  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }
}


/* =====================================================================
   5. Buttons
   ===================================================================== */

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover {
  border-color: var(--brand);
}

.btn.primary {
  background: var(--brandfill);
  border-color: var(--brandfill);
  color: #fff;
}

.btn.danger {
  color: var(--bad);
}

.btn.ok {
  background: var(--okfill);
  border-color: var(--okfill);
  color: #fff;
}

/* WhatsApp green */
.btn.wa {
  background: var(--wafill);
  border-color: var(--wafill);
  color: #fff;
}

.btn.sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn.wide {
  width: 100%;
  justify-content: center;
  padding: 10px;
}

/* Toggle-button "pressed" state */
.btn.on {
  border-color: var(--brand);
  color: var(--brand);
}

/* Square icon button (top bar, modal close) */
.iconbtn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
}

/* Red count bubble on an icon button */
.iconbtn .dotc {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--badfill);
  color: #fff;
  font-size: 10px;
  border-radius: 9px;
  padding: 0 5px;
  font-weight: 700;
}

/* Added for server-rendered views: the mockup used <button>/<div> with
   onclick; when these become <a href> links they must not pick up the
   global link colour/underline. Variant colours (.btn.primary, .tab.on,
   .dlchip.bad …) out-rank these and still apply. */
a.btn,
a.tab,
a.kpi,
a.tile,
a.trow,
a.tcard,
a.pc2,
a.ptab2,
a.dlchip,
a.citem,
a.arow,
a.pcard,
a.scard,
a.pcard2 {
  color: inherit;
  text-decoration: none;
}

a.pastbtn {
  text-decoration: none;
}

/* cards are block-level when not inside a grid (e.g. board columns) */
a.tcard,
a.pcard {
  display: block;
}

/* Bell wiggle when the alert count goes up (add once, then remove) */
.shake {
  animation: shake .6s;
}

@keyframes shake {
  20% { transform: rotate(-14deg); }
  40% { transform: rotate(12deg); }
  60% { transform: rotate(-8deg); }
  80% { transform: rotate(5deg); }
}


/* =====================================================================
   6. App shell: sidebar + main column
   ---------------------------------------------------------------------
   <div class="shell"> <aside class="side">…</aside> <main class="main">…
   Desktop: fixed-width sidebar, sticky full height.
   ≤860px: the sidebar turns into a sticky horizontal icon strip at the
   top of the page (no hamburger, no off-canvas drawer) — see 6c.
   ===================================================================== */

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* 6a. Sidebar */
.side {
  background: var(--side);
  color: var(--sidek);
  border-right: 1px solid var(--side2);
  padding: 16px 12px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.side .muted {
  color: var(--sidem);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 8px 16px;
}

/* Square logo tile; staff portals set style="background:<project colour>" */
.logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brandfill);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -.5px;
}

.nav {
  flex: 1;
}

/* Section heading inside the nav ("Overview", "People", …) */
.navsec {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--sidem);
  padding: 14px 12px 5px;
}

.navsec:first-child {
  padding-top: 4px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--sidek);
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 2px;
  font-weight: 500;
  font-size: 14px;
}

.nav a:hover {
  background: var(--side2);
}

.nav a.on {
  background: var(--sideon);
  color: var(--brand);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(20, 40, 80, .12);
}

/* Emoji icon cell */
.nav .nic {
  width: 22px;
  text-align: center;
}

/* Red count pill at the right of a nav item */
.nav .cnt {
  margin-left: auto;
  background: var(--badfill);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 0 7px;
  font-weight: 700;
}

/* Signed-in user + sign-out button at the bottom of the sidebar */
.sidefoot {
  border-top: 1px solid var(--side2);
  padding: 12px 4px 2px;
  margin-top: 10px;
}

/* promoted */
.sidefoot .row {
  gap: 8px;
}

.sidefoot .row > .small {
  min-width: 0;
  flex: 1;
}

.sidefoot .row > .small b {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidefoot .btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

/* 6b. Main column and sticky top bar */
.main {
  padding: 16px 22px 60px;
  min-width: 0;
}

.top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 8px;
  z-index: 20;
  backdrop-filter: blur(8px);
}

/* Page title + date at the left of the top bar */
.ptop {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  margin-right: 6px;
}

.ptop h1 {
  font-size: 19px;
  margin: 0;
  white-space: nowrap;
}

.ptop span {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

/* Search box with live-results dropdown */
.sbox {
  position: relative;
  flex: 1;
  max-width: 380px;
  min-width: 0;
}

.top .search {
  border-color: transparent;
  background: var(--panel2);
}

.sres {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  margin-top: 4px;
  max-height: 380px;
  overflow: auto;
  padding: 4px;
}

/* Hidden while it has no children — render it with no whitespace inside */
.sres:empty {
  display: none;
}

/* "+ New ▾" button and its dropdown menu */
.newwrap {
  position: relative;
}

.newbtn {
  font-weight: 700;
}

.newmenu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .18);
  padding: 6px;
  min-width: 210px;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.newmenu button {
  border: 0;
  background: none;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

/* added: menu items may also be links */
.newmenu a {
  padding: 9px 10px;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  color: inherit;
  text-decoration: none;
}

.newmenu button:hover,
.newmenu a:hover {
  background: var(--panel2);
}

.newmenu button span,
.newmenu a span {
  width: 22px;
  text-align: center;
}

/* Profile button holding a 30px avatar.
   (The mockup's 40px round .who2 size lost to .iconbtn, so it renders
   as a 36px rounded square; only these two declarations take effect.) */
.who2 {
  padding: 0;
  overflow: hidden;
}

/* 6c. Present (full-screen) mode: hide chrome */
.shell.present {
  grid-template-columns: 1fr;
}

.shell.present .side,
.shell.present .top,
.shell.present .banners {
  display: none;
}

.shell.present .main {
  padding: 20px;
}

/* 6d. Shell responsive rules */
@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes a sticky, horizontally scrolling strip */
  .side {
    flex-direction: row;
    top: 0;
    position: sticky;
    z-index: 5;
    height: auto;
    align-items: center;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .navsec,
  .sidefoot {
    display: none;
  }

  .brand {
    padding: 0 6px 0 0;
  }

  /* hide org name / role next to the logo */
  .brand div:last-child {
    display: none;
  }

  .nav {
    display: flex;
    gap: 2px;
  }

  .nav a {
    white-space: nowrap;
    margin: 0;
    padding: 6px 9px;
  }

  /* icons only, except the current page which keeps its label */
  .nav a span.lbl {
    display: none;
  }

  .nav a.on span.lbl {
    display: inline;
  }

  .main {
    padding: 12px 14px 60px;
  }

  /* Page title moves out; top bar sticks below the icon strip */
  .ptop {
    display: none;
  }

  .top {
    top: 56px;
  }
}

@media (max-width: 560px) {
  .top {
    gap: 6px;
  }

  .top .sbox {
    max-width: none;
    flex: 1;
    min-width: 0;
  }

  .top > .spacer {
    display: none;
  }

  /* The mockup hides the theme toggle on phones by its title attribute;
     .themebtn is offered as a sturdier hook. */
  .top .iconbtn[title='Light / dark'],
  .top .iconbtn.themebtn {
    display: none;
  }

  .newbtn {
    padding: 6px 9px;
  }
}


/* =====================================================================
   7. Banners (stacked under the top bar inside <div class="banners">)
   ===================================================================== */

.banner {
  display: flex;
  gap: 10px;
  align-items: center;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid;
}

.banner.reminder {
  background: var(--brand2);
  border-color: var(--brand);
}

.banner.urgent {
  background: var(--warnbg);
  border-color: var(--warn);
}

.banner.final {
  background: var(--badbg);
  border-color: var(--bad);
}

.banner.info {
  background: var(--panel);
  border-color: var(--line);
}

/* Admin "viewing as <person>" — fixed amber, sticks under the top bar */
.banner.viewas {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f;
  position: sticky;
  top: 78px;
  z-index: 15;
}


/* =====================================================================
   8. Page headers
   ===================================================================== */

/* Generic page heading: title + subtitle on the left, action on the right */
.pagehead {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* Person header card: <div class="card phead"> avatar · name · stats · actions.
   (.card's 14px padding wins over the mockup's 10px 14px.) */
.phead {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.phead h2 {
  font-size: 19px;
}

/* Toolbar header card used by Tasks / Team / Messages:
   title + counts + view switcher on row 1, filters on row 2 */
.tbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}

.tbar1,
.tbar2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

/* promoted */
.tbar1 h2 {
  font-size: 19px;
}

.tbar2 .tabs {
  flex-wrap: nowrap;
  /* promoted */
  padding: 0;
  flex: 1;
  min-width: 0;
}

/* promoted: compact filter selects */
.tbar2 select {
  width: auto;
  padding: 4px 8px;
  font-size: 13px;
}

/* Dashboard hero: greeting card + quote card side by side */
.bhero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.bh-l {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}

.bh-date {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
}

.bh-l h1 {
  font-size: 26px;
  line-height: 1.15;
  text-wrap: balance;
  margin: 0;
}

.bh-sum {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
  max-width: 60ch;
}

.tbad {
  color: var(--bad);
}

@media (max-width: 900px) {
  .bhero {
    grid-template-columns: 1fr;
  }
}

/* Green-gradient "quote of the day" card (--hbg1 → --hbg2).
   This is the only place the green tokens are used. It is a carousel:
   .hview clips, .htrack slides by translateX(-N*100%). */
.hadith {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  padding: 16px 18px 12px;
  background: linear-gradient(135deg, var(--hbg1), var(--hbg2));
  color: var(--hink);
  border: 1px solid var(--hline);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.bhero .hadith {
  margin-bottom: 0;
  height: 100%;
}

.hlabel {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 800;
  opacity: .85;
  display: flex;
  gap: 8px;
  align-items: center;
}

.hnum {
  margin-left: auto;
  font-weight: 600;
  opacity: .8;
}

.hview {
  overflow: hidden;
  flex: 1;
  display: flex;
  margin-top: 8px;
}

.htrack {
  display: flex;
  transition: transform .5s ease;
  width: 100%;
}

.hslide {
  min-width: 100%;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.htext {
  font: italic 17px/1.45 Georgia, 'Times New Roman', serif;
  text-wrap: pretty;
}

.href {
  font-size: 12px;
  opacity: .85;
}

.hnav {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.hnav button {
  border: 0;
  background: rgba(255, 255, 255, .18);
  color: inherit;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.hdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  cursor: pointer;
}

.hdot.on {
  opacity: 1;
  width: 18px;
  border-radius: 5px;
}


/* =====================================================================
   9. Cards, panels ("box") and grids
   ===================================================================== */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px;
}

/* Grid of boxes (2+ columns on desktop) */
.boxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

@media (max-width: 640px) {
  .boxes {
    grid-template-columns: 1fr;
  }
}

/* Panel with a header bar (.bh), optional .tabs, and a scrolling body (.bb) */
.box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.box > .bh {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

/* Count pill at the right of a box header */
.box > .bh .n {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 8px;
  font-size: 12px;
}

.box > .bb {
  padding: 8px 10px;
  max-height: 380px;
  overflow: auto;
}

/* Empty-state line. Must come after .card so <div class="card empty">
   gets this padding, as in the mockup. */
.empty {
  color: var(--muted);
  text-align: center;
  padding: 18px 8px;
  font-size: 13px;
}

/* Full-width child inside .boxes */
.donebox {
  grid-column: 1 / -1;
}

/* Two-up boxes with a coloured left edge: <div class="box" style="--c:#hex"> */
.dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.dl .box {
  border-left: 5px solid var(--c);
}

@media (max-width: 700px) {
  .dl {
    grid-template-columns: 1fr;
  }
}

/* Project group inside a box body: heading row + its items */
.pgroup {
  margin-bottom: 8px;
}

.ptitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: 6px 4px 4px;
}

/* Per-person sub-heading inside a group */
.psub {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 6px 3px;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
}

.psub:first-child {
  border-top: 0;
  margin-top: 0;
}

/* Key / value list */
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}

.kv div:nth-child(odd) {
  color: var(--muted);
}

/* Small scrolling log (one entry per <div>) */
.log {
  font-size: 12px;
  max-height: 180px;
  overflow: auto;
}

.log div {
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}

.quote {
  font-style: italic;
  color: var(--muted);
  margin-top: 4px;
}


/* =====================================================================
   10. Stat tiles, KPI buttons, team strip
   ===================================================================== */

/* Simple tiles: <div class="tile bad"><b>3</b><span class="small muted">Late</span></div> */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.tile b {
  display: block;
  font-size: 24px;
}

.tile.bad b {
  color: var(--bad);
}

.tile.warn b {
  color: var(--warn);
}

.tile.ok b {
  color: var(--ok);
}

/* Dashboard KPI row (8 across → 4 → 2):
   <button class="kpi bad"><span class="ki">🔴</span><b>3</b><span>Late</span></button>
   Use .zero instead of the colour class when the number is 0. */
.kpis {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.kpi {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  box-shadow: var(--shadow);
}

.kpi:hover {
  transform: translateY(-1px);
}

.kpi .ki {
  grid-row: 1 / 3;
  font-size: 20px;
}

.kpi b {
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi span:last-child {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.kpi.bad {
  border-color: var(--bad);
  background: var(--badbg);
}

.kpi.bad b {
  color: var(--bad);
}

.kpi.warn {
  border-color: var(--warn);
  background: var(--warnbg);
}

.kpi.warn b {
  color: var(--warn);
}

.kpi.rev {
  border-color: #a78bfa;
}

.kpi.rev b {
  color: #7c3aed;
}

.kpi.info b {
  color: var(--brand);
}

.kpi.zero {
  opacity: .6;
  box-shadow: none;
}

@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Team summary strip (5 across → 2): <div class="tstrip"><div class="ok"><b>9</b><span>Logged in</span></div>… */
.tstrip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.tstrip > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.tstrip b {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.tstrip span {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.tstrip .ok b {
  color: var(--ok);
}

.tstrip .warn b {
  color: var(--warn);
}

.tstrip .bad b {
  color: var(--bad);
}

@media (max-width: 700px) {
  .tstrip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* =====================================================================
   11. Tabs, segmented controls, filter bars
   ===================================================================== */

/* Pill tabs (project filter). Current tab gets .on (inverted ink). */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 10px 0;
}

.tab {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.tab.on {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
}

/* Dashboard project tabs row */
.bp-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin: 4px 0 12px;
}

.bp-tabs a {
  margin-left: 8px;
}

/* Segmented control (view switcher). Current button gets .on (brand fill). */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel);
  flex-wrap: wrap;
}

.seg button {
  border: 0;
  background: none;
  padding: 6px 11px;
  cursor: pointer;
  font-size: 13px;
}

.seg.sm button,
.seg.sm a {
  padding: 4px 9px;
  font-size: 12px;
}

.seg button.on,
.seg a.on {
  background: var(--brandfill);
  color: #fff;
}

/* added: same look when the segments are server links */
.seg a {
  padding: 6px 11px;
  font-size: 13px;
  color: inherit;
  text-decoration: none;
}

/* Green "Past tasks" toggle with a count */
.pastbtn {
  border: 1px solid var(--ok);
  color: var(--ok);
  background: var(--okbg);
  border-radius: 9px;
  padding: 4px 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.pastbtn b {
  background: var(--panel);
  border-radius: 999px;
  padding: 0 6px;
  font-size: 11px;
}

.pastbtn.on {
  background: var(--okfill);
  color: #fff;
}

.pastbtn.on b {
  color: var(--ok);
}

/* Deadline strip: overdue / due-soon chips followed by task-code links */
.dlbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  margin-bottom: 12px;
}

.dlchip {
  border: 1px solid;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: var(--panel);
  white-space: nowrap;
}

.dlchip.bad {
  color: var(--bad);
  border-color: var(--bad);
}

.dlchip.warn {
  color: var(--warn);
  border-color: var(--warn);
}

.dlchip.bad.on {
  background: var(--badfill);
  color: #fff;
}

.dlchip.warn.on {
  background: var(--warnfill);
  color: #fff;
}

.dlcodes {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.dlcode {
  font: 600 11px ui-monospace, monospace;
  text-decoration: none;
  border-radius: 5px;
  padding: 2px 6px;
}

.dlcode.bad {
  background: var(--badbg);
  color: var(--bad);
}

.dlcode.warn {
  background: var(--warnbg);
  color: var(--warn);
}

.dlsep {
  width: 1px;
  height: 20px;
  background: var(--line);
}

@media (max-width: 600px) {
  .dlsep {
    display: none;
  }
}

/* People filter bar: project pills (.ptab2) that expand a grid of
   person chips (.pc2) in .pbar-body. Pills carry style="--pc:#hex". */
.pbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pbar-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.ptab2 {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  flex: none;
}

.ptab2 b {
  font-size: 11px;
  font-weight: 700;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 7px;
  color: var(--muted);
}

.ptab2 .late {
  background: var(--badfill);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  padding: 0 6px;
}

/* ▾ / ▴ caret */
.ptab2 .car {
  color: var(--muted);
  font-size: 11px;
}

.ptab2:hover {
  border-color: var(--pc, var(--brand));
}

/* expanded project */
.ptab2.open {
  background: var(--pc);
  border-color: var(--pc);
  color: #fff;
}

.ptab2.open b {
  background: rgba(255, 255, 255, .25);
  border-color: transparent;
  color: #fff;
}

.ptab2.open .car {
  color: #fff;
}

/* project that contains the selected person */
.ptab2.has:not(.open) {
  border-color: var(--pc);
  box-shadow: inset 0 0 0 1px var(--pc);
}

/* "Everyone" pill when no person is selected */
.ptab2.all.sel {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
}

.ptab2.all.sel b {
  background: transparent;
  color: inherit;
  border-color: rgba(255, 255, 255, .4);
}

/* Selected-person chip with ✕ */
.selchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand2);
  border-radius: 999px;
  padding: 3px 4px;
  font-size: 13px;
  white-space: nowrap;
  flex: none;
}

.selchip button {
  border: 0;
  background: var(--panel);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
}

.pbar-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--panel2);
  animation: drop .18s ease;
}

@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.pc2 {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  min-width: 0;
}

.pc2:hover {
  border-color: var(--brand);
}

.pc2.on {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
  background: var(--brand2);
}

.pc2t {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.pc2t b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc2t span {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc2n {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.pc2n .late {
  background: var(--badbg);
  color: var(--bad);
  font-weight: 700;
  border-radius: 5px;
  padding: 0 5px;
}

/* ◀ ▶ reorder buttons (admin "arrange" mode) */
.pc2 .mv {
  display: flex;
  gap: 2px;
}

.pc2 .mv button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 5px;
  font-size: 10px;
  padding: 3px 6px;
  cursor: pointer;
  color: var(--ink);
}

.pc2 .mv button:disabled {
  opacity: .3;
}

.pbar-arr {
  grid-column: 1 / -1;
  font-size: 12px;
  text-align: right;
}


/* =====================================================================
   12. Collapsible sections (<details>)
   ===================================================================== */

/* "✅ Done (n)" fold under a list */
details.donefold {
  margin-top: 6px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--panel2);
}

details.donefold > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ok);
}

details.donefold > summary::-webkit-details-marker {
  display: none;
}

/* ▶ arrow that rotates when open (also used by .chartsfold) */
details.donefold > summary .arr {
  transition: transform .15s;
  display: inline-block;
  color: var(--muted);
}

details.donefold[open] > summary .arr {
  transform: rotate(90deg);
}

details.donefold > .dfin {
  padding: 0 8px 8px;
}

/* Dashboard "Charts, money & phases" fold */
details.chartsfold {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

details.chartsfold > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 800;
  font-size: 15px;
}

details.chartsfold > summary::-webkit-details-marker {
  display: none;
}

details.chartsfold > summary .arr {
  transition: transform .15s;
  color: var(--muted);
}

details.chartsfold[open] > summary .arr {
  transform: rotate(90deg);
}

/* Dashed link row pointing to Past tasks */
.pastlink {
  margin-top: 8px;
  padding: 9px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  background: var(--panel2);
}

.pastlink:hover {
  border-color: var(--ok);
  color: var(--ok);
}


/* =====================================================================
   13. Small indicators: avatar, chip, tag, status stamp, due, priority,
       progress bars
   ===================================================================== */

/* Avatar: <img class="av"> or initials <span class="av">AB</span>.
   Size is inline: style="width:28px;height:28px;font-size:11px"
   (font-size = 40% of the size; default size 28px). */
.av {
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand2);
  color: var(--brand);
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  flex: none;
  vertical-align: middle;
}

/* Group-chat avatar (emoji on a project-coloured circle) */
.gav {
  color: #fff !important;
  font-size: 15px;
}

/* Generic pill: project chip, filter chip, "GM", "⚡ 3 today" */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--panel2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

/* Inline person (avatar + name) and a wrapping list of them */
.ppl2 {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* Project name in its colour: <span class="pname" style="--c:#hex">. The
   colour is pulled halfway towards the ink so any project colour reads at
   4.5:1 or better in both themes (also on the tinted unseen row). */
.pname {
  font-weight: 700;
  color: color-mix(in srgb, var(--c, var(--muted)) 50%, var(--ink));
}

/* Tiny uppercase tag: NEW (not viewed) / UPDATED / SELF-ADDED */
.tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  border-radius: 5px;
  padding: 1px 6px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Calm outline tags (ui-reference: fewer loud pills): the words carry the
   colour, a thin inset ring marks the tag. */
.tag.new,
.tag.upd,
.tag.self {
  background: transparent;
  box-shadow: inset 0 0 0 1px currentColor;
}

.tag.new {
  color: var(--brand);
}

/* quirk fixed: a legacy bare .upd rule made this tag taller in the mockup */
.tag.upd {
  color: var(--warn);
}

.tag.self {
  color: var(--self, #0f766e);
}

/* Status stamp: <span class="stamp st-in_progress">In progress</span>
   States: pending · in_progress · review · done · overdue · reopened */
.stamp {
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
  border: 1px solid;
}

.st-pending {
  color: var(--muted);
  border-color: var(--line);
}

.st-in_progress {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand2);
}

.st-review {
  color: var(--review, #6d28d9);
  border-color: #a78bfa;
  background: rgba(124, 58, 237, .08);
}

.st-done {
  color: var(--ok);
  border-color: var(--ok);
  background: var(--okbg);
}

.st-overdue {
  color: #fff;
  border-color: var(--badfill);
  background: var(--badfill);
}

.st-reopened {
  color: var(--warn);
  border-color: var(--warn);
  background: var(--warnbg);
}

/* Due badge: plain date, .yellow (due today/tomorrow), .red (late) */
.due {
  font-size: 12px;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 6px;
}

.due.yellow {
  background: var(--warnbg);
  color: var(--warn);
  font-weight: 700;
}

.due.red {
  background: var(--badbg);
  color: var(--bad);
  font-weight: 700;
}

/* Priority text: <span class="prio high">HIGH</span> */
.prio {
  font-size: 11px;
  font-weight: 700;
}

.prio.high {
  color: var(--bad);
}

.prio.medium {
  color: var(--warn);
}

.prio.low {
  color: var(--muted);
}

/* Progress bar: <div class="bar"><i style="width:40%"></i></div> */
.bar {
  height: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-width: 50px;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--brand);
}

.bar.big {
  height: 10px;
}

/* Fixed 70px mini bar used in fold summaries */
.minibar {
  width: 70px;
  height: 6px;
  border-radius: 4px;
  background: var(--panel2);
  border: 1px solid var(--line);
  overflow: hidden;
  display: inline-block;
}

.minibar i {
  display: block;
  height: 100%;
  background: var(--brand);
}

/* Small red unread count */
.ucnt {
  background: var(--badfill);
  color: #fff;
  border-radius: 10px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 700;
}


/* =====================================================================
   14. Task row (list item)
   ---------------------------------------------------------------------
   <div class="trow unseen isdone"> dot · .code · .tt(b + span) · tag ·
   bar · due · stamp. .unseen = not yet opened; .isdone = faded.
   ===================================================================== */

.trow {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 3px;
  flex-wrap: wrap;
  row-gap: 4px;
}

.trow:hover {
  border-color: var(--line);
  background: var(--panel2);
}

/* Not yet opened: a quiet brand accent on the left instead of a blue wash
   (ui-reference: calmer "Not viewed"). */
.trow.unseen {
  box-shadow: inset 3px 0 0 var(--brand);
  border-radius: 4px 9px 9px 4px;
}

.trow.isdone {
  opacity: .75;
}

.trow .code {
  font: 600 11px ui-monospace, monospace;
  color: var(--muted);
  min-width: 62px;
}

.trow.unseen .code {
  color: var(--ink);
  font-weight: 800;
}

.trow .tt {
  flex: 1 1 200px;
  min-width: 0;
}

.trow .tt b {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}

.trow.unseen .tt b {
  font-weight: 800;
}

.trow .tt span {
  font-size: 12px;
  color: var(--muted);
}

.trow .tt > span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* promoted: progress bar inside a row is 54px wide */
.trow .bar {
  width: 54px;
}

/* Task title weight toggled by "seen" state (cards, table) */
.ttl {
  font-weight: 400;
}

.unseen .ttl,
.ttl.unseen {
  font-weight: 800;
}


/* =====================================================================
   15. Task card grid and kanban board
   ===================================================================== */

/* <div class="tcards"><div class="tcard unseen" style="--c:<project colour>">… */
.tcards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.tcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, #999);
  border-radius: 10px;
  padding: 11px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.tcard.unseen {
  outline: 2px solid var(--brand);
}

/* promoted: spacing the mockup set inline on card internals */
.tcard .pname {
  margin-top: 4px;
}

.tcard .ttl {
  margin: 2px 0 6px;
  font-size: 15px;
}

.tcard .row + .row {
  margin-top: 8px;
}

/* avatar row directly under the title */
.tcard .ttl + .row {
  gap: 4px;
}

/* progress bar row: bar stretches */
.tcard .row .bar {
  flex: 1;
}

/* Board: 6 status columns, scrolls sideways on narrow screens */
.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.col {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  min-height: 120px;
}

.col h4 {
  margin: 2px 4px 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}

.col .tcard {
  margin-bottom: 8px;
}


/* =====================================================================
   16. Tables
   ===================================================================== */

.tblwrap {
  overflow-x: auto;
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.tbl th,
.tbl td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.tbl th {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel2);
  font-weight: 700;
}

/* Clickable rows */
.tbl tr.click {
  cursor: pointer;
}

.tbl tr.click:hover td {
  background: var(--panel2);
}

/* Compact table inside task detail (only the td size survived the cascade) */
.tt2 td {
  font-size: 13px;
}

/* Past-tasks table with month separator rows (<tr class="pmon">) */
.pasthead {
  padding: 12px 14px;
  font-weight: 800;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.pastt td {
  font-size: 13.5px;
}

.pastt tr.pmon td {
  background: var(--panel2);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}

.pastt tr.pmon span {
  font-weight: 600;
  margin-left: 6px;
}

/* Login-log cell chip: .y present, .n absent, .l leave */
.lg {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  border-radius: 6px;
  padding: 2px 4px;
  font-size: 11px;
  font-weight: 700;
}

.lg.y {
  background: var(--okbg);
  color: var(--ok);
}

.lg.n {
  background: var(--badbg);
  color: var(--bad);
}

.lg.l {
  background: var(--panel2);
  color: var(--muted);
}


/* =====================================================================
   17. Calendars
   ===================================================================== */

/* Month grid: 7 .dh headers then 42 .day cells (Mon-first).
   Events: <div class="ev" style="background:<project colour or var(--bad)>"> */
.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal .dh {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.cal .day {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 92px;
  padding: 4px;
  overflow: hidden;
}

.cal .day.other {
  opacity: .45;
}

.cal .day.today {
  outline: 2px solid var(--brand);
}

.cal .dn {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.cal .ev {
  font-size: 11px;
  border-radius: 5px;
  padding: 1px 5px;
  margin-top: 2px;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Routine done/missed month grid: .y done, .n missed, .off not due, .today */
.rcal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.rcd {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 44px;
  padding: 3px;
  text-align: center;
  font-size: 15px;
  background: var(--panel);
}

.rcd span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-align: left;
}

.rcd.y {
  background: var(--okbg);
  border-color: var(--ok);
  color: var(--ok);
}

.rcd.n {
  background: var(--badbg);
  border-color: var(--bad);
  color: var(--bad);
}

.rcd.off {
  opacity: .4;
}

.rcd.today {
  outline: 2px solid var(--brand);
}

/* Last-N-days history squares: <div class="hist"><i class="y"></i><i class="n"></i><i></i></div> */
.hist {
  display: flex;
  gap: 3px;
}

.hist i {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--panel2);
  border: 1px solid var(--line);
  display: block;
}

.hist i.y {
  background: var(--ok);
  border-color: var(--ok);
}

.hist i.n {
  background: var(--bad);
  border-color: var(--bad);
}


/* =====================================================================
   18. Charts (pure CSS horizontal bars — the mockup has no SVG/donut)
   ---------------------------------------------------------------------
   <div class="hbar"><span class="lab">Label</span>
     <div class="track"><i style="width:60%;background:var(--brand)"></i>
                        <i style="width:10%;background:var(--bad)"></i></div>
     <b>12</b></div>
   Multiple <i> segments stack left-to-right.
   ===================================================================== */

.hbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  font-size: 12px;
}

.hbar .lab {
  width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hbar .track {
  flex: 1;
  height: 14px;
  background: var(--panel2);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.hbar .track i {
  display: block;
  height: 100%;
}


/* =====================================================================
   19. Dashboard: project cards, project sections, staff cards
   ===================================================================== */

/* Project summary card with a coloured top edge: style="--c:#hex" */
.pcards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.pcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--c);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* Project section: coloured header band (style="--pc:#hex") + body */
.psec {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.psec-h {
  background: var(--pc);
  color: #fff;
  padding: 14px 18px;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: center;
  background-image: linear-gradient(120deg, rgba(255, 255, 255, .14), rgba(0, 0, 0, .12));
}

.psec-t {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.psec-t h3 {
  font-size: 19px;
  color: #fff;
}

.pmeta {
  opacity: .85;
  font-size: 13px;
}

/* ▾ / ▸ */
.chev {
  font-size: 14px;
  opacity: .85;
  width: 12px;
}

.psec-s {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.psec-s span {
  background: rgba(255, 255, 255, .18);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.psec-s span.hot {
  background: #fff;
  color: var(--bad);
  font-weight: 700;
}

/* "% on track" white meter at top right of the band */
.psec-health {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}

.psec-health .hb {
  width: 120px;
  height: 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .3);
  overflow: hidden;
}

.psec-health .hb i {
  display: block;
  height: 100%;
  background: #fff;
}

@media (max-width: 600px) {
  .psec-health {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

.psec-b {
  padding: 14px;
}

/* "Needs attention" pills: .rev review, .bad missed, .warn expiring */
.patt {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 20px;
  padding: 3px 4px 3px 10px;
  cursor: pointer;
}

.pa:not(.rev) {
  padding-right: 10px;
}

.pa.rev {
  border-color: #a78bfa;
  background: rgba(124, 58, 237, .07);
}

.pa.bad {
  border-color: var(--bad);
  background: var(--badbg);
  color: var(--bad);
}

.pa.warn {
  border-color: var(--warn);
  background: var(--warnbg);
  color: var(--warn);
}

/* Staff card: .st-red / .st-amber / .st-green sets the avatar ring colour */
.scards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.scard {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .15s, transform .15s;
}

.scard:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
  transform: translateY(-2px);
}

.scard.st-red {
  --ring: var(--bad);
}

.scard.st-amber {
  --ring: var(--warn);
}

.scard.st-green {
  --ring: var(--ok);
}

.scard .sc-top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.scard .sc-top .av {
  box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--ring);
}

.sc-id {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.sc-id b {
  font-size: 15px;
}

.sc-id span {
  font-size: 12px;
  color: var(--muted);
}

/* Login state text: .in logged in, .out not yet, .leave on leave */
.li {
  font-weight: 700;
}

.li.in {
  color: var(--ok) !important;
}

.li.out {
  color: var(--bad) !important;
}

.li.leave {
  color: var(--warn) !important;
}

.sc-act {
  display: flex;
  gap: 4px;
}

/* 5 numbers: Open / Late / Soon / Review / Done 7d */
.sc-nums {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  text-align: center;
  background: var(--panel2);
  border-radius: 10px;
  padding: 6px 2px;
}

.sc-nums b {
  display: block;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.sc-nums span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

.sc-nums .bad b {
  color: var(--bad);
}

.sc-nums .warn b {
  color: var(--warn);
}

.sc-nums .rev b {
  color: #7c3aed;
}

.sc-nums .ok b {
  color: var(--ok);
}

.sc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.sc-bar .bar {
  flex: 1;
}

/* Up to 3 urgent tasks */
.sc-urg {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sc-t {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 4px;
  border-radius: 6px;
}

.sc-t:hover {
  background: var(--panel2);
}

.sc-t .code {
  font: 600 10px ui-monospace, monospace;
  color: var(--muted);
}

.sc-t .nm {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-t .nm.unseen {
  font-weight: 800;
}

.sc-ok {
  font-size: 12px;
  color: var(--ok);
  font-weight: 600;
  padding: 2px 4px;
}

/* Last activity line */
.sc-last {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  min-width: 0;
}

.sc-last .when {
  color: var(--brand);
  font-weight: 700;
  white-space: nowrap;
}

.sc-last .lt {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* =====================================================================
   20. Team page: people cards
   ===================================================================== */

.tsecp {
  margin-bottom: 18px;
}

.tsecp-h {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 2px 10px;
}

.tsecp-h h3 {
  font-size: 16px;
  margin: 0;
}

.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

/* Profile card: coloured cover (inherits --pc from .tsecp), 76px avatar
   with a presence dot, name, status, 4 stats, action buttons */
.pcard2 {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}

.pcard2:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .12);
}

.pc-cover {
  height: 56px;
  width: 100%;
  background: var(--pc);
  background-image: linear-gradient(120deg, rgba(255, 255, 255, .22), rgba(0, 0, 0, .1));
}

.pc-av {
  position: relative;
  margin-top: -38px;
}

.pc-av .av {
  box-shadow: 0 0 0 4px var(--panel);
}

/* Presence dot: grey default, .in green, .leave amber */
.pc-dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid var(--panel);
  background: #9ca3af;
}

.pc-dot.in {
  background: #22c55e;
}

.pc-dot.leave {
  background: #f59e0b;
}

.pc-name {
  display: flex;
  flex-direction: column;
  padding: 8px 12px 2px;
  min-width: 0;
  width: 100%;
}

.pc-name b {
  font-size: 16px;
}

.pc-name span {
  font-size: 12.5px;
  color: var(--muted);
}

.pc-also {
  font-size: 11px !important;
  margin-top: 2px;
}

.pc-status {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin: 4px 0 8px;
}

.pc-status.in {
  color: var(--ok);
}

.pc-status.leave {
  color: var(--warn);
}

.pc-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pc-stats div {
  padding: 8px 2px;
  display: flex;
  flex-direction: column;
}

.pc-stats div + div {
  border-left: 1px solid var(--line);
}

.pc-stats b {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.pc-stats span {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
}

.pc-stats .bad b {
  color: var(--bad);
}

.pc-stats .rev b {
  color: #7c3aed;
}

.pc-stats .ok b {
  color: var(--ok);
}

.pc-act {
  display: flex;
  width: 100%;
}

.pc-act button {
  flex: 1;
  border: 0;
  background: var(--panel);
  padding: 10px 0;
  cursor: pointer;
  font-size: 15px;
}

.pc-act button + button {
  border-left: 1px solid var(--line);
}

.pc-act button:hover:not(:disabled) {
  background: var(--brand2);
}

.pc-act button:disabled {
  opacity: .3;
  cursor: default;
}

.pc-act .wa:hover {
  background: #dcfce7;
}

/* Profile page header */
.prof-h {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.prof-ph .av {
  box-shadow: 0 0 0 4px var(--panel), 0 0 0 6px var(--brand2);
}

.prof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

/* Photo picker row with an empty placeholder avatar */
.phrow {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.phempty {
  font-size: 30px;
  border: 2px dashed var(--line);
  background: var(--panel2) !important;
}


/* =====================================================================
   21. Modal — right-hand drawer by default, centred dialog with .center
   ---------------------------------------------------------------------
   One host element, as in the mockup:
   <div id="modal" class="modal hidden">
     <div class="mbox [wide|wide xwide] [anim]">
       <div class="mh"><h3>Title</h3><button class="iconbtn">✕</button></div>
       <form><div class="mb">…</div><div class="mf">…buttons</div></form>
     </div>
   </div>
   The drawer look is keyed on the #modal id (kept from the mockup so the
   specificity relationships stay identical). .modal alone gives the
   older top-centred dialog.
   ===================================================================== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 22, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 12px;
  overflow: auto;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.mbox {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
}

.mbox.wide {
  max-width: 820px;
}

.mh {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

/* promoted */
.mh h3 {
  flex: 1;
}

.mb {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mf {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* Drawer (the effective look of every modal in the mockup) */
#modal {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  background: rgba(10, 14, 22, .42);
}

#modal .mbox {
  height: 100%;
  max-height: 100vh;
  border-radius: 18px 0 0 18px;
  display: flex;
  flex-direction: column;
  max-width: 600px;
  border-right: 0;
  box-shadow: -20px 0 50px rgba(0, 0, 0, .2);
}

#modal .mbox.wide {
  max-width: 860px;
}

#modal .mbox.xwide {
  max-width: 1180px;
}

/* Header and footer stay put; the body scrolls */
#modal .mbox > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#modal .mb {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

#modal .mh {
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  background: var(--panel);
}

#modal .mf {
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  background: var(--panel);
}

/* .anim only on first open (not on re-render of an open modal) */
#modal .mbox.anim {
  animation: slidein .26s cubic-bezier(.2, .8, .2, 1);
}

@keyframes slidein {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* Centred small dialog (PIN prompt, confirm): <div id="modal" class="modal center"> */
#modal.center {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#modal.center .mbox {
  height: auto;
  max-height: 90vh;
  border-radius: 16px;
  max-width: 460px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}

#modal.center .mbox.anim {
  animation: pop .18s ease;
}

@keyframes pop {
  from {
    transform: scale(.96);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@media (max-width: 700px) {
  /* full-screen drawer on phones (centred dialogs keep their shape) */
  #modal .mbox {
    border-radius: 0;
    max-width: none;
  }
}


/* =====================================================================
   22. Task detail (inside <div class="mbox wide xwide">)
   ===================================================================== */

/* <div class="mb tdet"> — grey page background behind the white sections
   (.mb's 12px gap wins over the mockup's 14px) */
.tdet {
  background: var(--bg);
}

/* White section card with a .tsh header */
.tsec {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tsh {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tsh h3 {
  font-size: 15px;
  margin: 0;
}

/* Big brand-coloured percentage */
.pbig {
  margin-left: auto;
  font-size: 20px;
  color: var(--brand);
}

/* Fact table: grid of label/value cells.
   <div class="ttab"><div class="tc"><span>Label</span><div>Value</div></div>…
   <div class="tc wide"> spans the full width. */
.ttab {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.tc {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.tc:nth-child(odd):not(.wide) {
  border-right: 1px solid var(--line);
}

.tc > span {
  background: var(--panel2);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.tc > div {
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.tc.wide {
  grid-column: 1 / -1;
  grid-template-columns: 130px minmax(0, 1fr);
  border-bottom: 0;
}

.tc.wide > span {
  align-items: flex-start;
}

/* In the extra-wide drawer the fact table goes 3 across.
   quirk fixed: the mockup's odd-cell reset out-ranked the 3-column
   borders, dropping some dividers; here every cell but each 3rd has one. */
.xwide .ttab {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.xwide .tc:not(.wide) {
  border-right: 1px solid var(--line);
}

.xwide .tc:nth-child(3n):not(.wide) {
  border-right: 0;
}

@media (max-width: 1000px) {
  .xwide .ttab {
    grid-template-columns: 1fr 1fr;
  }

  .xwide .tc:not(.wide) {
    border-right: 0;
  }

  .xwide .tc:nth-child(odd):not(.wide) {
    border-right: 1px solid var(--line);
  }
}

@media (max-width: 700px) {
  .ttab {
    grid-template-columns: 1fr;
  }

  .tc:nth-child(odd):not(.wide) {
    border-right: 0;
  }

  .tc {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .xwide .ttab {
    grid-template-columns: 1fr;
  }

  .xwide .tc:nth-child(odd):not(.wide) {
    border-right: 0;
  }
}

/* Folding sections (Progress / Checklist / Files / Chat), two across;
   an open fold spans both columns.
   <details class="tsec tfold"><summary><h3>…</h3>summary bits
   <span class="spacer"></span><span class="fcar">Show ▾</span></summary>
   <div class="tfb">…</div></details> */
.tfolds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

@media (max-width: 800px) {
  .tfolds {
    grid-template-columns: 1fr;
  }
}

details.tfold {
  padding: 0;
  gap: 0;
}

details.tfold > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  min-width: 0;
}

details.tfold > summary::-webkit-details-marker {
  display: none;
}

details.tfold > summary h3 {
  font-size: 14px;
  margin: 0;
  white-space: nowrap;
}

details.tfold[open] {
  grid-column: 1 / -1;
}

details.tfold[open] > summary {
  border-bottom: 1px solid var(--line);
}

details.tfold .pbig {
  margin-left: 0;
  font-size: 15px;
}

/* "Show ▾ / Hide ▾" */
.fcar {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

details.tfold[open] .fcar {
  color: var(--brand);
}

.tfb {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Updates list: date column + text. .w = a written update (emphasised) */
.slist {
  max-height: 420px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.sl {
  display: flex;
  gap: 14px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
}

.sl:last-child {
  border-bottom: 0;
}

.sl-d {
  width: 86px;
  flex: none;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.sl-t {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
}

.sl-t b {
  margin-right: 4px;
}

.sl.w .sl-t {
  color: var(--ink);
  font-weight: 500;
}

.sl:not(.w) .sl-t {
  color: var(--muted);
}

.sl:not(.w) .sl-t b {
  color: var(--ink);
}

/* "Add update" input row */
.addupd {
  display: flex;
  gap: 6px;
  align-items: center;
}

.addupd input {
  flex: 1;
  min-width: 0;
}

/* Progress slider row */
.pupd {
  margin-top: 4px;
  background: var(--panel2);
  border-radius: 8px;
  padding: 8px 10px;
}

/* Checklist: <div class="checks clist2"><label class="cdone"><input type="checkbox" checked> …</label> */
.clist2 label {
  border-bottom: 1px dashed var(--line);
}

.clist2 label.cdone {
  color: var(--muted);
  text-decoration: line-through;
}


/* =====================================================================
   23. Attachments and the full-screen file viewer
   ===================================================================== */

.fgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

/* <div class="fcard"><div class="fprev"><img>|<div class="fpdf">📄<span>PDF</span></div>
   <span class="fbadge pdf">PDF</span></div><div class="fmeta"><b>name</b><span>size</span></div>
   <div class="fbtns"><button>👁 View</button><button>⬇ Download</button></div></div> */
.fcard {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
}

.fcard:hover {
  border-color: var(--brand);
}

.fcard img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  background: var(--panel2);
}

.fprev {
  position: relative;
  cursor: zoom-in;
}

.fbadge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(15, 23, 42, .75);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 5px;
  padding: 1px 6px;
  letter-spacing: .4px;
}

.fbadge.pdf {
  background: #c81e1e;
}

.fpdf {
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--panel2);
  font-size: 34px;
}

.fpdf span {
  font-size: 11px;
  font-weight: 800;
  color: var(--bad);
}

.fmeta {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  font-size: 12px;
  min-width: 0;
}

.fmeta b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fmeta span {
  color: var(--muted);
  font-size: 11px;
}

.fbtns {
  display: flex;
  border-top: 1px solid var(--line);
}

.fbtns button {
  flex: 1;
  border: 0;
  background: var(--panel);
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}

.fbtns button + button {
  border-left: 1px solid var(--line);
}

.fbtns button:hover {
  background: var(--brand2);
  color: var(--brand);
}

/* Small 64px thumbnails (staff documents): <div class="files"><img class="fileth"><div class="pdf">name</div></div> */
.files {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.fileth {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
}

/* quirk fixed: was a bare .pdf, which also hit .fbadge.pdf */
.files .pdf {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  background: var(--panel2);
  text-align: center;
  padding: 4px;
  overflow: hidden;
}

/* Viewer host, as in the mockup: <div id="fviewer" class="fv hidden" role="dialog">
   .fvbar (icon · .fvmeta · .fvact buttons) / .fvbody (img | .fvpdf | .fvnone,
   .fvnav.l/.r arrows) / .fvstrip thumbnails (.fvth.on) */
#fviewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #0b0f17;
  display: flex;
  flex-direction: column;
  color: #fff;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#fviewer.hidden {
  display: none;
}

.fvbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .06);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.fvic {
  font-size: 24px;
}

.fvmeta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.fvmeta b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
}

.fvmeta span {
  font-size: 12px;
  opacity: .7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fvact {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fvact button {
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border-radius: 8px;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  cursor: pointer;
  font-size: 15px;
}

.fvact button:hover {
  background: rgba(255, 255, 255, .18);
}

/* zoom percentage readout */
.fvact #fvz {
  font-size: 12px;
  opacity: .8;
  min-width: 40px;
  text-align: center;
}

.fvact .fvdl {
  background: #16a34a;
  border-color: #16a34a;
  font-weight: 700;
  font-size: 14px;
}

.fvact .fvdl:hover {
  background: #15803d;
}

.fvbody {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: auto;
  padding: 16px;
}

.fvbody > img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  background: #fff;
}

.fvbody > img.zoomed {
  max-width: none;
  max-height: none;
}

.fvpdf {
  width: min(1000px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fvpdf iframe {
  flex: 1;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

.fvnote {
  font-size: 12px;
  opacity: .7;
  text-align: center;
}

.fvpages {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 4px;
}

.fvpage {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  max-width: 100%;
  height: auto;
}

.fvload {
  margin: auto;
  opacity: .75;
}

.fvnone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  opacity: .9;
}

.fvnav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  z-index: 2;
}

.fvnav:hover {
  background: rgba(255, 255, 255, .28);
}

.fvnav.l {
  left: 14px;
}

.fvnav.r {
  right: 14px;
}

.fvstrip {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow-x: auto;
  background: rgba(255, 255, 255, .04);
}

.fvcount {
  font-size: 12px;
  opacity: .7;
  margin-right: 6px;
  white-space: nowrap;
}

.fvth {
  width: 54px;
  height: 54px;
  flex: none;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  background: rgba(255, 255, 255, .1);
  cursor: pointer;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.fvth img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fvth.on {
  border-color: #4ade80;
}

@media (max-width: 600px) {
  .fvbar {
    flex-wrap: wrap;
    padding: 8px 10px;
  }

  .fvact {
    width: 100%;
    justify-content: flex-end;
  }

  .fvnav {
    width: 38px;
    height: 38px;
    font-size: 22px;
  }

  .fvnav.l {
    left: 6px;
  }

  .fvnav.r {
    right: 6px;
  }
}


/* =====================================================================
   24. Messages (chat page) and task chat
   ===================================================================== */

/* <div class="chat"><div class="card clist">…</div><div class="card thread">
   <div class="mh">…</div><div class="msgs">…</div><div class="row">input + Send</div></div></div> */
.chat {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 10px;
  height: calc(100vh - 150px);
  min-height: 420px;
}

@media (max-width: 700px) {
  .chat {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.clist {
  overflow: auto;
}

/* "Groups ＋" / "People" heading in the contact list */
.csec {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: 10px 8px 4px;
}

.csec a {
  text-decoration: none;
  font-size: 14px;
}

.citem {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.citem.on,
.citem:hover {
  background: var(--brand2);
}

.thread {
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

/* promoted */
.card.thread {
  padding: 0;
}

.thread > .row {
  padding: 10px;
  border-top: 1px solid var(--line);
}

.msgs {
  flex: 1;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Bubble: theirs on the left, .mine on the right in brand blue */
.msg {
  max-width: 78%;
  padding: 7px 11px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  align-self: flex-start;
  word-wrap: break-word;
}

.msg.mine {
  align-self: flex-end;
  background: var(--brandfill);
  color: #fff;
  border-color: var(--brandfill);
}

/* timestamp */
.msg .mt {
  font-size: 10px;
  opacity: .7;
  margin-top: 2px;
}

/* sender name in group threads */
.mfrom {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 2px;
}

/* Compact chat box inside the task drawer */
.tchat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
  background: var(--panel2);
  border-radius: 10px;
  padding: 10px;
}


/* =====================================================================
   25. Other list rows: alerts, reminders, routines, daily log
   ===================================================================== */

/* Alert / notification row: <div class="arow unread"><span class="dotu"></span>
   <div class="at"><b>text</b><span>when</span></div></div> */
.arow {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
  margin-bottom: 3px;
  border: 1px solid transparent;
}

.arow:hover {
  border-color: var(--line);
  background: var(--panel2);
}

.arow .at {
  flex: 1;
  min-width: 0;
}

.arow .at b {
  display: block;
  font-weight: 400;
  white-space: normal;
}

.arow .at span {
  font-size: 12px;
  color: var(--muted);
}

.arow.unread {
  background: var(--brand2);
}

.arow.unread .at b {
  font-weight: 800;
}

.arow .dotu {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: 6px;
  flex: none;
}

.arow:not(.unread) .dotu {
  background: transparent;
}

/* Sub-heading inside an alerts list */
.asub {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: 8px 6px 3px;
}

/* Reminder list: <div class="sidrem"><div class="sritem due"><div class="nm">…</div><div class="small">…</div></div> */
.sidrem {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.sritem {
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
  border-left: 3px solid var(--line);
}

.sritem:hover {
  background: var(--panel2);
}

/* quirk fixed: .sritem.due also matched the .due badge rule in the mockup */
.sritem.due {
  border-left-color: var(--brand);
  background: var(--brand2);
  font-size: inherit;
  white-space: normal;
  padding: 6px 8px;
  border-radius: 8px;
}

.sritem.due .small {
  color: var(--brand);
  font-weight: 700;
}

.sritem .nm {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 860px) {
  .sidrem {
    display: none;
  }
}

/* Routine row: wraps a .trow; hover/focus reveals a details grid (.rdet).
   <div class="rrow" tabindex="0"><div class="trow">…</div><div class="rdet">
   <div><span>Label</span>value</div>…</div></div> */
.rrow {
  border-radius: 10px;
  border: 1px solid transparent;
  margin-bottom: 4px;
  cursor: pointer;
  outline: none;
}

.rrow:hover,
.rrow:focus {
  border-color: var(--brand);
  background: var(--panel2);
}

.rrow .trow {
  margin: 0;
}

.rrow .trow:hover {
  background: none;
  border-color: transparent;
}

.rdet {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  padding: 4px 12px 10px 28px;
  font-size: 12px;
}

.rdet span:first-child {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  font-weight: 700;
}

.rrow:hover .rdet,
.rrow:focus .rdet,
.rrow:focus-within .rdet {
  display: grid;
}

@media (hover: none) {
  .rrow:hover .rdet {
    display: none;
  }
}

@media (max-width: 600px) {
  .rdet {
    grid-template-columns: 1fr;
  }
}

/* Daily work log: <div class="dayp"><div class="ent"><span class="tm">09:30</span>text</div></div> */
.dayp {
  margin-bottom: 12px;
}

.dayp .ent {
  display: flex;
  gap: 10px;
  padding: 5px 4px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.dayp .ent:last-child {
  border-bottom: 0;
}

/* A written update in the day log: <div class="ent upd">.
   quirk fixed: was a bare .upd rule (with !important) that also hit .tag.upd */
.dayp .ent.upd {
  background: var(--brand2);
  border-radius: 6px;
  padding: 4px 6px;
  border-bottom: 0;
  margin: 2px 0;
}

.dayp .tm {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 62px;
  white-space: nowrap;
}


/* =====================================================================
   26. Sticky notes, certificate, receipt
   ===================================================================== */

.notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

/* Yellow note (same in both themes) with a ✕ button */
.note {
  background: #fff7c2;
  color: #3b3200;
  border-radius: 8px;
  padding: 10px;
  position: relative;
  min-height: 70px;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
}

.note button {
  position: absolute;
  top: 4px;
  right: 4px;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: .6;
}

/* Completion certificate */
.cert {
  border: 6px double var(--brand);
  border-radius: 14px;
  padding: 22px 18px;
  text-align: center;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cert-org {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.cert-title {
  font: 700 26px/1.1 Georgia, 'Times New Roman', serif;
  color: var(--brand);
}

.cert-no {
  font: 12px ui-monospace, monospace;
  color: var(--muted);
}

.cert-sub {
  font-style: italic;
  color: var(--muted);
  margin-top: 6px;
}

.cert-name {
  font: 700 21px Georgia, serif;
}

.cert-task {
  font-size: 16px;
}

.cert-stars {
  font-size: 28px;
  color: #f59e0b;
}

.cert-sign {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 22px;
  font-size: 13px;
}

.cert-sign span {
  flex: 1;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

/* Dashed receipt box */
.receipt {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}

.receipt h2 {
  letter-spacing: 1px;
}


/* =====================================================================
   27. Toast
   ---------------------------------------------------------------------
   <div class="toast [bad]">Saved</div> appended to <body>, removed after
   ~2.6 s. Inverted ink pill at the bottom centre; .bad = red.
   ===================================================================== */

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--panel);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 99;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.toast.bad {
  background: var(--badfill);
  color: #fff;
}


/* =====================================================================
   28. Login screen (full-bleed backdrop, glass card)
   ---------------------------------------------------------------------
   .lg2 grid: .lg2-bgs (gradient backdrop) · .lg2-shade ·
   .lg2-top (mark + org) · .lg2-left (quote card + headline) ·
   .lg2-panel (form.lg2-card).
   Always dark, independent of the theme.
   ===================================================================== */

.lg2 {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
  grid-template-rows: auto 1fr;
  color: #fff;
  background: #0b1220 center / cover no-repeat;
  text-align: left;
  overflow: hidden;
}

.lg2-bgs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0b1220;
}

/* No photographs (nothing but the font is loaded from elsewhere): the
   backdrop is a deep gradient with two soft colour fields instead. */
.lg2-bgs {
  background:
    radial-gradient(1200px 700px at 12% 18%, rgba(37, 99, 235, .38), transparent 60%),
    radial-gradient(900px 600px at 88% 85%, rgba(15, 81, 50, .45), transparent 60%),
    linear-gradient(160deg, #0b1220 0%, #101a30 55%, #0a1a14 100%);
}

.lg2-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 10, 20, .55) 0%, rgba(5, 10, 20, .1) 32%, rgba(5, 10, 20, .1) 55%, rgba(5, 10, 20, .75) 100%),
    linear-gradient(90deg, rgba(5, 10, 20, 0) 50%, rgba(5, 10, 20, .45) 100%);
  pointer-events: none;
}

.lg2-top {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 28px max(28px, env(safe-area-inset-left, 0px));
}

.lg2-top b {
  display: block;
  font-size: 16px;
  letter-spacing: .2px;
}

.lg2-top span {
  font-size: 12px;
  opacity: .7;
}

.lg2-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .28);
  backdrop-filter: blur(8px);
}

.lg2-left {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(28px, env(safe-area-inset-left, 0px)) 44px;
  min-width: 0;
}

.lg2-copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
}

.lg2-copy h1 {
  font-size: 40px;
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .6);
}

.lg2-copy p {
  margin: 0;
  font-size: 16px;
  opacity: .85;
  max-width: 44ch;
}

/* The quote card turns into dark glass on the login screen */
.lg2-had {
  max-width: 620px;
}

.lg2-had .hadith {
  margin: 0;
  min-height: 0;
  background: rgba(10, 16, 30, .45);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  backdrop-filter: blur(10px);
}

.lg2-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px max(28px, env(safe-area-inset-right, 0px)) 40px 24px;
}

.lg2-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  background: rgba(14, 20, 34, .62);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 20px;
  padding: 30px 28px;
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}

.lg2-card h2 {
  font-size: 26px;
  margin: 0 0 6px;
  color: #fff;
}

.lg2-card > p {
  margin: 0 0 22px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, .65);
}

.lg2-card label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  color: rgba(255, 255, 255, .75);
  margin: 0 0 6px;
}

.lg2-card input {
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #fff;
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 15px;
  margin: 0 0 16px;
  width: 100%;
}

.lg2-card input:focus {
  outline: none;
  border-color: #7aa7ff;
  box-shadow: 0 0 0 3px rgba(122, 167, 255, .25);
  background: rgba(255, 255, 255, .1);
}

/* Password field with an inline Show/Hide button */
.lg2-pin {
  position: relative;
}

.lg2-pin input {
  padding-right: 64px;
}

.lg2-pin button {
  position: absolute;
  right: 6px;
  top: 6px;
  height: 34px;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .7);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 10px;
  border-radius: 8px;
}

.lg2-pin button:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

/* Error line; hidden while empty (render with no whitespace inside) */
.lg2-err {
  min-height: 0;
  font-size: 13px;
  color: #fca5a5;
  margin: -6px 0 10px;
}

.lg2-err:empty {
  display: none;
}

.lg2-go {
  border: 0;
  border-radius: 11px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  color: #0b1220;
  background: #fff;
  cursor: pointer;
  margin-top: 4px;
  transition: transform .12s, box-shadow .12s;
}

.lg2-go:hover {
  box-shadow: 0 8px 24px rgba(255, 255, 255, .18);
  transform: translateY(-1px);
}

.lg2-go:focus-visible {
  outline: 3px solid #7aa7ff;
  outline-offset: 2px;
}

.lg2-note {
  margin-top: 18px;
  font-size: 12px;
  color: rgba(255, 255, 255, .55);
  text-align: center;
}

.lg2-note b {
  color: rgba(255, 255, 255, .85);
}

.lg2-date {
  font-size: 12px;
  color: rgba(255, 255, 255, .45);
}

/* Wrong-password shake: add .shakec to the card, remove after 400 ms */
.shakec,
.lg2-card.shakec {
  animation: shk .4s;
}

@keyframes shk {
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}

@media (max-width: 900px) {
  .lg2 {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    background-position: 30% center;
  }

  .lg2-shade {
    background: linear-gradient(0deg, rgba(3, 6, 13, .92) 0%, rgba(3, 6, 13, .55) 55%, rgba(3, 6, 13, .25) 100%);
  }

  /* form first, headline + quote under it */
  .lg2-left {
    order: 3;
    padding: 0 20px 36px;
  }

  .lg2-copy h1 {
    font-size: 28px;
  }

  .lg2-copy p {
    display: none;
  }

  .lg2-had .hadith {
    min-height: 0;
  }

  .lg2-panel {
    order: 2;
    padding: 8px 16px 20px;
    justify-content: flex-start;
  }

  .lg2-top {
    padding: 20px;
  }
}


/* =====================================================================
   29. Reduced motion
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  #modal .mbox.anim,
  .pbar-body {
    animation: none;
  }

  .htrack {
    transition: none;
  }

}


/* =====================================================================
   30. Print
   ---------------------------------------------------------------------
   Hides the chrome and prints the open modal inline. The mockup wrote
   the modal rules as .modal / .modal .mbox, which lost to its #modal
   drawer rules; they are written against #modal here so they apply.
   ===================================================================== */

/* Shown only when printing (kept late so no screen rule overrides it) */
.printonly {
  display: none;
}

@media print {
  body {
    background: #fff;
  }

  .side,
  .top,
  .banners,
  .noprint,
  .modal .mf,
  .modal .mh button {
    display: none !important;
  }

  .shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .modal,
  #modal {
    position: static;
    background: none;
    padding: 0;
  }

  .mbox,
  #modal .mbox {
    height: auto;
    max-height: none;
    box-shadow: none;
    border: 0;
  }

  .printonly {
    display: block;
  }

  .card,
  .box {
    box-shadow: none;
  }
}


/* =====================================================================
   31. Optional extras — styled in the mockup's CSS but not rendered by
   its current screens. Kept because they are coherent, reusable
   patterns (activity timeline, history-kind chips, sticky-header table).
   Delete freely.
   ===================================================================== */

/* Activity timeline: .tl > .tl-day (sticky date pill) + .tl-i items.
   Kinds on .tl-i: tl-upd · tl-prog · tl-stat · tl-edit · tl-file · tl-msg · tl-alert; .tl-hl highlights. */
.tl {
  position: relative;
  max-height: 460px;
  overflow: auto;
  padding: 2px 4px 2px 2px;
}

.tl-day {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  padding: 8px 0 6px;
}

.tl-day span {
  background: var(--ink);
  color: var(--panel);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 2px 10px;
}

.tl-day em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.tl-i {
  display: flex;
  gap: 10px;
  position: relative;
  padding: 0 0 10px 0;
}

.tl-i::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 30px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.tl-dot {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: var(--panel2);
  border: 2px solid var(--line);
  position: relative;
  z-index: 1;
}

.tl-upd .tl-dot {
  background: var(--brandfill);
  border-color: var(--brandfill);
  color: #fff;
}

.tl-prog .tl-dot {
  background: #dbeafe;
  border-color: #93c5fd;
}

.tl-stat .tl-dot {
  background: var(--okbg);
  border-color: var(--ok);
}

.tl-edit .tl-dot {
  background: var(--warnbg);
  border-color: var(--warn);
}

.tl-file .tl-dot {
  background: #f3e8ff;
  border-color: #c084fc;
}

.tl-msg .tl-dot {
  background: #dcfce7;
  border-color: #4ade80;
}

.tl-alert .tl-dot {
  background: var(--badbg);
  border-color: var(--bad);
}

.tl-c {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  background: var(--panel);
}

.tl-hl .tl-c {
  background: var(--brand2);
  border-color: var(--brand);
}

.tl-h {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}

.tl-h b {
  font-size: 13px;
}

.tl-t {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tl-x {
  font-size: 13.5px;
  margin-top: 3px;
  word-wrap: break-word;
}

.tl-hl .tl-x {
  font-weight: 600;
}

/* History-kind chip: <span class="hk hk-upd">Update</span> */
.hk {
  font-size: 11px;
  font-weight: 700;
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
  background: var(--panel2);
  color: var(--muted);
}

.hk-upd {
  background: var(--brandfill);
  color: #fff;
}

.hk-prog {
  background: #dbeafe;
  color: #1e40af;
}

.hk-stat {
  background: var(--okbg);
  color: var(--ok);
}

.hk-edit {
  background: var(--warnbg);
  color: var(--warn);
}

.hk-file {
  background: #f3e8ff;
  color: #7e22ce;
}

.hk-msg {
  background: #dcfce7;
  color: #15803d;
}

.hk-alert {
  background: var(--badbg);
  color: var(--bad);
}

/* Scrolling table with sticky header and day-separator rows */
.hwrap {
  max-height: 340px;
  overflow: auto;
  border-radius: 10px;
}

.htab th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.htab tr.hday td {
  background: var(--panel2);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: 5px 8px;
}

.htab tr.hupd td {
  background: var(--brand2);
}

/* Horizontally scrolling tab row (for many tabs) */
.htabs {
  align-self: flex-start;
  max-width: 100%;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.htabs button {
  white-space: nowrap;
}

.htabs b {
  font-weight: 700;
  opacity: .7;
  margin-left: 2px;
}

/* Tiny inverted "ADMIN" badge */
.adm {
  font-size: 10px;
  font-weight: 700;
  background: var(--ink);
  color: var(--panel);
  border-radius: 4px;
  padding: 0 4px;
}

/* Two-column detail layout (wide main + narrow side) */
.tgrid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.tcol {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

@media (max-width: 900px) {
  .tgrid {
    grid-template-columns: 1fr;
  }
}



/* =====================================================================
   32. GS Tasks additions — what the server-rendered app needs on top of
       the mockup's theme. Keep new shared styles here, not inline.
   ===================================================================== */

[hidden],
[x-cloak] {
  display: none !important;
}

.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;
}

/* Skip link: first focusable element, visible only when focused */
.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--brandfill);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.skip:focus {
  top: 10px;
}

/* ---- Focus states: a clear ring for keyboard users, none for mouse clicks */
:where(a, button, summary, [tabindex], .btn, .iconbtn, .tab, .ptab2, .pc2):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 8px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

input[type=checkbox]:focus-visible,
input[type=radio]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: none;
}

.nav a:focus-visible {
  outline-offset: -2px;
}

input[type=checkbox],
input[type=radio] {
  accent-color: var(--brand);
}

.btn:disabled,
.btn[aria-disabled=true] {
  opacity: .55;
  cursor: not-allowed;
}

.btn:disabled:hover {
  border-color: var(--line);
}

.btn.primary:disabled:hover {
  border-color: var(--brand);
}

.btn.danger:hover {
  border-color: var(--bad);
}

/* Field hint under a control */
.hint {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 4px;
}

label .err,
.err:empty {
  min-height: 0;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--bad);
}

/* ---- Sidebar badges: fixed footprint so a count appearing never moves text */
.nav .cnt {
  min-width: 22px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
}

.iconbtn .dotc {
  min-width: 18px;
  text-align: center;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}

.brand .logo {
  flex: none;
}

.brand b {
  display: block;
  line-height: 1.2;
}

.sidefoot .row .av {
  flex: none;
}

/* Top-bar avatar button */
.who2 .av,
.who2 img.av {
  width: 100%;
  height: 100%;
  border-radius: 0;
  font-size: 13px;
}

a.iconbtn {
  color: inherit;
  text-decoration: none;
}

/* ---- Live search results (top bar) */
.sres a {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-size: 13px;
}

.sres a:hover,
.sres a.on {
  background: var(--panel2);
}

.sres a .code {
  font: 600 11px ui-monospace, monospace;
  color: var(--muted);
  min-width: 62px;
}

.sres a .tt {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sres .sres-all {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  color: var(--brand);
  font-weight: 600;
}

.sres .sres-none {
  padding: 10px 8px;
  color: var(--muted);
  font-size: 13px;
}

/* ---- Flash messages: successes as toasts, problems as a banner */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 99;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}

.toasts .toast {
  position: static;
  transform: none;
  pointer-events: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 560px;
  animation: toastin .2s ease;
}

.toasts .toast a {
  color: inherit;
  font-weight: 700;
}

.toast.out {
  opacity: 0;
  transition: opacity .3s;
}

@keyframes toastin {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.banner > .bx {
  margin-left: auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  color: inherit;
  opacity: .7;
  padding: 2px 6px;
  border-radius: 6px;
}

.banner > .bx:hover {
  opacity: 1;
}

/* Comfortable tap targets on touch screens (MODULE-BRIEF: ≥ 36 px): every
   button, the banner dismiss ✕, and links inside banners. */
@media (pointer: coarse), (max-width: 760px) {
  .btn,
  .btn.sm {
    min-height: 36px;
  }

  .banner > .bx {
    min-width: 36px;
    min-height: 36px;
    display: inline-grid;
    place-items: center;
  }

  .banner .bt a {
    display: inline-block;
    padding-block: 9px;
    margin-block: -9px;
  }
}

.banner .bt {
  flex: 1;
  min-width: 0;
}

.banner.viewas form {
  margin: 0;
}

.banner.viewas .btn {
  background: #fff;
  border-color: #f59e0b;
  color: #78350f;
  font-weight: 700;
}

@media (max-width: 860px) {
  .banner.viewas {
    top: 118px;
  }
}

@media (max-width: 560px) {
  /* On a phone a sticky, wrapping banner would eat the screen: keep it short and in the flow. */
  .banner.viewas {
    position: static;
  }

  .banner.viewas .vx {
    display: none;
  }
}

/* ---- Page skeleton pieces shared by every module */
.page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pagehead h2 {
  margin-bottom: 2px;
}

.pagehead .muted {
  font-size: 13px;
}

/* "This section is being built" */
.building {
  text-align: center;
  padding: 48px 20px;
}

.building .big {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
}

.building h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.building p {
  color: var(--muted);
  margin: 0 auto;
  max-width: 46ch;
}

/* Empty state with an icon and an optional action */
.empty .ei {
  display: block;
  font-size: 26px;
  margin-bottom: 6px;
}

.empty .btn {
  margin-top: 10px;
}

/* Pagination */
.pager {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 13px;
}

.pager .on {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
}

/* Inline form that holds a single button (delete, view as …) */
form.inline {
  display: inline;
  margin: 0;
}

/* Project chip: <span class="chip pchip" style="--c:#hex"><span class="dot"></span>Factory</span> */
.pchip .dot {
  background: var(--c, var(--brand));
}

/* People bar: person chip avatar column stays square */
.pc2 .av {
  flex: none;
}

.pbar-tabs .selchip a {
  border: 0;
  background: var(--panel);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  text-decoration: none;
  color: inherit;
}

.pbar-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.pbar-head .stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---- Profile page */
.prof {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.prof .kv {
  grid-template-columns: 130px 1fr;
}

@media (max-width: 860px) {
  .prof {
    grid-template-columns: 1fr;
  }
}

.switch {
  display: flex !important;
  gap: 10px;
  align-items: center;
  font-size: 14px !important;
  color: var(--ink) !important;
  font-weight: 500 !important;
}

/* ---- Compose dialog (WhatsApp / email) */
.compose textarea {
  min-height: 320px;
  font-size: 14px;
  line-height: 1.5;
}

.compose .to {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}

.compose .warn {
  color: var(--warn);
}

/* Modal: keep the drawer above sticky banners; lock page scroll while open */
body.modal-open {
  overflow: hidden;
}

#modal {
  z-index: 60;
}

#modal .mbox:focus {
  outline: none;
}

/* ---- Search page */
.results .trow {
  margin-bottom: 2px;
}

/* ---- Mobile: the shell at 390 px */
@media (max-width: 860px) {
  /* One column: the strip takes its own height, the page the rest (without
     this a short page stretches the strip to fill the spare height). */
  .shell {
    grid-template-rows: auto 1fr;
    align-content: start;
  }

  .side .nav a .cnt {
    margin-left: 2px;
    font-size: 10px;
    padding: 0 5px;
    min-width: 18px;
    line-height: 16px;
  }

  .side {
    scrollbar-width: none;
  }

  .side::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 560px) {
  .newbtn .lbl {
    display: none;
  }

  .main {
    padding: 10px 10px 60px;
  }

  .top {
    padding: 6px 8px;
  }

  .pagehead {
    align-items: flex-start;
  }

  .kv {
    grid-template-columns: 1fr !important;
    gap: 2px 0;
  }

  .kv div:nth-child(odd) {
    margin-top: 6px;
  }
}

/* Print: never print the shell's own furniture */
@media print {
  .toasts,
  .skip {
    display: none !important;
  }
}

/* Search page: the query box keeps its width on desktop, shrinks on a phone. */
.search-page-q {
  width: 260px;
  max-width: 100%;
}

/* =====================================================================
   33. House style (docs/ARCHITECTURE.md → "House style")
   ---------------------------------------------------------------------
   The one set of page skeletons, spacing, status colours and responsive
   rules every module uses. Module stylesheets add only what is unique to
   their page; they never restyle these classes.
   ===================================================================== */

:root {
  --sp1: 4px;
  --sp2: 8px;
  --sp3: 12px;
  --sp4: 16px;
  --sp5: 24px;
  --sp6: 32px;
  --pad: 16px;              /* card padding */
  --gap: 16px;              /* between the blocks of a page */
  --scrollshade: rgba(15, 23, 42, .16);
}

:root[data-theme=dark] { --scrollshade: rgba(0, 0, 0, .55); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) { --scrollshade: rgba(0, 0, 0, .55); }
}

@media (max-width: 640px) {
  :root { --pad: 12px; --gap: 12px; }
}

::selection {
  background: color-mix(in srgb, var(--brand) 28%, transparent);
}

/* Numbers that line up: counts, money, times, percentages */
.num,
.tbl td,
.kpi b,
.tile b,
.nav .cnt,
.dotc,
.ucnt,
.due,
.stamp,
.sl-d,
.mono {
  font-variant-numeric: tabular-nums;
}

td.num,
th.num,
.tbl td.num,
.tbl th.num {
  text-align: right;
  white-space: nowrap;
}

/* One line, ellipsis; put the full text in title="" */
.trunc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.m0 { margin: 0; }
.mt2 { margin-top: var(--sp2); }
.stack { display: flex; flex-direction: column; gap: var(--sp2); }
.stack-tight { display: flex; flex-direction: column; gap: var(--sp1); }
.gap-s { gap: 6px; }

/* ---- Page: blocks 16 px apart (12 px on phones) */
.page {
  gap: var(--gap);
}

.card {
  padding: var(--pad);
}

/* ---- List and form page heading
   <header class="pagehead"><div class="ph-text"><h2>…</h2><p class="ph-sub">…</p></div>
   <div class="ph-actions">…buttons, primary last…</div></header> */
.pagehead {
  margin-bottom: 0;
  align-items: flex-end;
  gap: var(--sp3);
}

.pagehead h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.2px;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: var(--sp2);
  flex-wrap: wrap;
}

.pagehead h2 .count {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}

.ph-text {
  min-width: 0;
  flex: 1 1 260px;
}

.ph-sub,
.pagehead > div > p.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 72ch;
}

.ph-actions {
  display: flex;
  gap: var(--sp2);
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .pagehead h2 { font-size: 20px; }
  .ph-actions { width: 100%; justify-content: flex-start; }
}

/* ---- Toolbar card under a list page heading: view switch, tabs, filters */
.tbar { margin-bottom: 0; padding: var(--sp2) var(--sp3); }

/* Filters that fold behind a "Filters" button on phones:
   <div class="filters" data-filters> <button type="button" class="btn sm filters-toggle" data-filters-toggle aria-expanded="false">⚙︎ Filters</button>
   <div class="filters-body">…</div></div> */
.filters-toggle {
  display: none;
}

@media (max-width: 640px) {
  .filters-toggle {
    display: inline-flex;
  }

  .filters .filters-body {
    display: none !important;
  }

  .filters.open .filters-body {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
  }

  .filters.open .filters-body > *:not(.sr-only) {
    width: 100%;
    max-width: none;
    flex: 0 0 auto;
  }
}

/* ---- Back link above detail and form pages: <a class="back" href="…">‹ All requests</a> */
.back {
  align-self: flex-start;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: calc(var(--gap) * -0.5);
}

.back:hover {
  color: var(--brand);
  text-decoration: underline;
}

@media (pointer: coarse), (max-width: 760px) {
  .back {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    margin-bottom: calc(var(--gap) * -0.75);
  }
}

/* ---- Detail page header card
   <section class="card dhead [has-accent]" style="--c:#project">
     <div class="dh-top"><span class="code">FAC-011</span><h2>Title</h2><span class="stamp …">…</span></div>
     <div class="dh-meta">…</div>
     <div class="dh-actions">primary · secondary · <span class="spacer"></span> Delete</div></section> */
.dhead {
  display: flex;
  flex-direction: column;
  gap: var(--sp2);
}

.dhead.has-accent {
  border-top: 4px solid var(--c, var(--brand));
}

.dh-top {
  display: flex;
  align-items: flex-start;
  gap: var(--sp2) var(--sp3);
  flex-wrap: wrap;
}

.dh-top h2 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  flex: 1 1 280px;
  min-width: 0;
  overflow-wrap: anywhere;
  margin: 0;
}

.dh-top > .stamp,
.dh-top > .dh-status {
  margin-left: auto;
  align-self: center;
}

.dh-meta {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.dh-actions {
  display: flex;
  align-items: center;
  gap: var(--sp2);
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: var(--sp3);
  margin-top: var(--sp1);
}

.dh-actions > .spacer {
  flex: 1;
}

.dh-actions .dh-hint {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 640px) {
  .dh-top h2 { font-size: 20px; flex-basis: 100%; }
  .dh-top > .stamp, .dh-top > .dh-status { margin-left: 0; }
}

/* Record fields: <dl class="kv"><dt>Due</dt><dd>9 Dec</dd>…</dl> (or div pairs) */
dl.kv {
  margin: 0;
}

dl.kv dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

dl.kv dd {
  margin: 0;
}

/* ---- Forms: <form class="card form"> fieldset.fsec + .formbar */
fieldset.fsec {
  margin: 0;
  min-width: 0;
}

fieldset.fsec > legend,
.fsec > .fsec-h {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 6px;
  margin-left: -6px;
}

form.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp4);
}

/* Required mark after a label's text: Title <span class="req" aria-hidden="true">*</span> */
.req {
  color: var(--bad);
  font-weight: 700;
  margin-left: 2px;
}

label .opt {
  font-weight: 400;
  color: var(--muted);
}

.formbar {
  display: flex;
  gap: var(--sp2);
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: var(--sp3);
}

.formbar > .danger-left,
.formbar > form.inline:first-child,
.formbar > .btn.danger:first-child {
  margin-right: auto;
}

@media (max-width: 640px) {
  /* The main action stays under the thumb */
  .formbar {
    position: sticky;
    bottom: 0;
    z-index: 4;
    background: var(--panel);
    margin: 0 calc(var(--pad) * -1) calc(var(--pad) * -1);
    padding: var(--sp2) var(--pad) max(var(--sp2), env(safe-area-inset-bottom, 0px));
    border-radius: 0 0 var(--r) var(--r);
    box-shadow: 0 -6px 14px -10px var(--scrollshade);
  }

  .formbar .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Inputs sized to their content */
input.w-xs, select.w-xs { max-width: 110px; }
input.w-s, select.w-s { max-width: 180px; }
input.w-m, select.w-m { max-width: 320px; }

/* Disabled and busy controls */
.btn:disabled,
.btn[aria-busy=true] {
  opacity: .6;
  cursor: not-allowed;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--panel2);
  color: var(--muted);
}

/* Error state on a control */
label.has-error > input,
label.has-error > select,
label.has-error > textarea,
.has-error > input,
.has-error > select,
.has-error > textarea,
input[aria-invalid=true],
select[aria-invalid=true],
textarea[aria-invalid=true] {
  border-color: var(--bad);
}

/* ---- Status stamps: the house status colours (see ARCHITECTURE.md) */
.stamp.st-bad {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 60%, transparent);
  background: var(--badbg);
}

.stamp.st-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 60%, transparent);
  background: var(--warnbg);
}

.stamp.st-ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 60%, transparent);
  background: var(--okbg);
}

.stamp.st-info {
  color: var(--brand);
  border-color: color-mix(in srgb, var(--brand) 60%, transparent);
  background: var(--brand2);
}

/* ---- WhatsApp: the emoji never sits on the dark green fill alone */
.btn.wa-soft {
  background: color-mix(in srgb, var(--wa) 12%, var(--panel));
  border-color: color-mix(in srgb, var(--wa) 45%, var(--line));
  color: var(--ink);
}

.btn.wa-soft:hover {
  border-color: var(--wa);
}

/* ---- Tables: scroll sideways inside their card, with a shadow hint at
   whichever edge has more to show (pure CSS, background-attachment). */
.tblwrap {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--panel) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--panel) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scrollshade), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scrollshade), transparent) right / 12px 100% no-repeat scroll;
}

.tblwrap > table.tbl {
  background: transparent;
}

/* ---- The page's main action under the thumb on phones:
   <span class="actionbar">…the main button(s)…</span>
   On wider screens it is display: contents, so its buttons sit in the
   surrounding action row as if the wrapper were not there; on phones it is
   a bar fixed to the bottom of the screen and the page gets room for it. */
.actionbar {
  display: contents;
}

@media (max-width: 640px) {
  .actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: flex;
    gap: var(--sp2);
    padding: var(--sp2) var(--sp3) max(var(--sp2), env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 20px -12px var(--scrollshade);
  }

  .actionbar > .btn,
  .actionbar > form > .btn {
    flex: 1;
    justify-content: center;
    min-height: 44px;
    font-weight: 700;
  }

  .actionbar > form { flex: 1; display: flex; }

  body:has(.actionbar) .main { padding-bottom: 96px; }
}

/* Inline links that are tap targets of their own (a task code in a sentence
   or a table cell): 32 px tall on touch screens without changing the text. */
.inlink {
  display: inline-block;
}

@media (pointer: coarse), (max-width: 760px) {
  .inlink {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
  }
}

.t-ok { color: var(--ok); font-weight: 600; }
.t-bad { color: var(--bad); font-weight: 600; }
.t-warn { color: var(--warn); font-weight: 600; }

/* Short inputs sit under their label, not beside the label text */
label > input.w-xs, label > input.w-s, label > input.w-m,
label > select.w-xs, label > select.w-s, label > select.w-m,
input.w-xs, input.w-s, input.w-m {
  display: block;
}

/* ---- Empty state: what goes here, and the action when allowed */
.empty {
  text-align: center;
  color: var(--muted);
  padding: var(--sp5) var(--sp4);
}

.empty .btn {
  margin-top: var(--sp3);
}

.empty .btn.sm {
  font-size: 13px;
  padding: 6px 12px;
}

/* =====================================================================
   33b. Top bar: the title truncates, search keeps a sensible width, and on
   phones search folds into an icon that opens it over the bar.
   ===================================================================== */
.ptop {
  flex: 0 1 auto;
  max-width: min(46%, 560px);
}

.ptop h1 {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sbox {
  flex: 1 1 240px;
  min-width: 200px;
  max-width: 380px;
}

.top .searchbtn,
.top .searchclose {
  display: none;
}

.top .search::placeholder {
  color: var(--muted);
  opacity: 1;
}

@media (max-width: 860px) {
  .ptop {
    display: flex;
    max-width: none;
    flex: 1 1 auto;
  }

  .ptop h1 { font-size: 17px; }

  .ptop > span { display: none; }
}

@media (max-width: 860px) and (min-width: 561px) {
  .sbox { flex: 0 1 260px; min-width: 180px; }
}

@media (max-width: 560px) {
  .top {
    position: sticky;
  }

  .top > .spacer { display: none; }

  .top .sbox {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 5;
    max-width: none;
    min-width: 0;
    padding: 6px 52px 6px 8px;
    background: var(--panel);
    border-radius: inherit;
    align-items: center;
  }

  .top.searching .sbox { display: flex; }

  .top .sbox .search { height: 40px; }

  .top .sbox .sres { left: 8px; right: 8px; }

  .top .searchbtn { display: grid; }

  .top.searching .searchclose {
    display: grid;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
  }

  /* the theme toggle comes back: search no longer needs the room */
  .top .iconbtn[title='Light / dark'],
  .top .iconbtn.themebtn {
    display: grid;
  }

  .top .iconbtn { width: 38px; height: 38px; flex: none; }
  .newbtn { min-height: 38px; }
}

/* =====================================================================
   33c. Phones and tablets (≤ 860 px): the sidebar is a strip of icons with
   short labels. It scrolls sideways with a fade at the edge that has more,
   the current page is scrolled into view (app.js), badges sit on the icon,
   and the strip scrolls away with the page so the top bar keeps the room.
   ===================================================================== */
.nav .nsl {
  display: none;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    min-width: 0;
    position: relative;
    top: auto;
    z-index: 5;
    overflow: visible;
    padding: 6px 0 6px 8px;
    gap: 2px;
    background: var(--side);
    border-bottom: 1px solid var(--side2);
  }

  .brand { padding: 0 4px 0 0; flex: none; }

  .nav {
    display: flex;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 0 8px 0 2px;
  }

  .nav::-webkit-scrollbar { display: none; }

  .nav a {
    position: relative;
    flex-direction: column;
    gap: 1px;
    padding: 5px 6px 4px;
    min-width: 58px;
    margin: 0;
    font-size: 10.5px;
    line-height: 1.2;
    font-weight: 600;
    white-space: nowrap;
    justify-content: center;
  }

  .nav .nic {
    width: auto;
    font-size: 18px;
    line-height: 22px;
  }

  /* every item shows a short label: icons alone are not self-explanatory.
     The full label stays for screen readers. */
  .nav a span.lbl,
  .nav a.on span.lbl {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .nav a .nsl {
    display: block;
    border: 0;
    padding: 0;
    color: inherit;
  }

  .nav a.on {
    box-shadow: 0 1px 3px rgba(20, 40, 80, .14);
  }

  /* the count rides on the icon's corner */
  .side .nav a .cnt {
    position: absolute;
    top: 1px;
    left: calc(50% + 6px);
    margin: 0;
    font-size: 10px;
    line-height: 15px;
    padding: 0 4px;
    min-width: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--side);
  }

  .nav a.on .cnt { box-shadow: 0 0 0 2px var(--sideon); }

  .top { top: 6px; }

  .banner.viewas { top: 70px; }
}

/* =====================================================================
   33d. Dark theme beyond contrast: calmer coloured blocks, visible
   borders, form controls and scrollbars that belong to the theme.
   ===================================================================== */
:root[data-theme=dark] {
  --line: #2c3340;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .25);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --line: #2c3340;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

:root[data-theme=dark] input,
:root[data-theme=dark] select,
:root[data-theme=dark] textarea {
  background: #11151c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) input,
  :root:not([data-theme=light]) select,
  :root:not([data-theme=light]) textarea {
    background: #11151c;
  }
}

:root[data-theme=dark] .btn.primary:disabled { opacity: .5; }

/* =====================================================================
   33e. Print: certificate, slip and report print on white in both themes,
   without the app's chrome.
   ===================================================================== */
@media print {
  :root,
  :root[data-theme=dark] {
    --bg: #fff;
    --panel: #fff;
    --panel2: #f6f6f6;
    --ink: #111;
    --muted: #555;
    --line: #d6d6d6;
    --brand: #1d4ed8;
    --brand2: #eef2fe;
    --ok: #137a38;
    --okbg: #e7f6ec;
    --warn: #b45309;
    --warnbg: #fff4dc;
    --bad: #c81e1e;
    --badbg: #fdeaea;
    --shadow: none;
    --review: #6d28d9;
    --self: #0f766e;
    color-scheme: light;
  }

  html, body { background: #fff !important; color: #111; }

  .side,
  .top,
  .banners,
  .toasts,
  .people-bar,
  .pbar,
  .back,
  .ph-actions,
  .dh-actions,
  .formbar,
  .actionbar,
  .noprint {
    display: none !important;
  }

  .shell { display: block; }
  .main { padding: 0 !important; }
  .card, .box { box-shadow: none !important; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* Brand link in the sidebar; a staff portal's logo takes its project colour */
a.brand {
  color: inherit;
  text-decoration: none;
}

.logo.proj {
  background: color-mix(in srgb, var(--c, var(--brandfill)) 62%, #000);
}

.chip.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--badbg); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: var(--warnbg); }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: var(--okbg); }

.empty .et { margin: 0 auto; max-width: 52ch; }
.empty .eh { margin: 4px auto 0; max-width: 52ch; font-size: 12px; }

/* Reduced motion: no slides, fades, wiggles or smooth scrolling anywhere */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Sideways-scrolling strips (the phone nav, the people bar's project tabs,
   tab rows): app.js sets data-scroll=start|middle|end|none and the edge that
   has more fades out, so it is clear the strip scrolls. */
[data-scroll=start] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
}

[data-scroll=middle] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 36px), transparent);
}

[data-scroll=end] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px);
  mask-image: linear-gradient(to right, transparent, #000 28px);
}

/* Initials avatars keep a visible edge on the pale sidebar and in the top bar */
.side span.av,
.top span.av {
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--side2);
}

.sidefoot .row > .small .muted {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Destructive confirm button (the app's own confirm dialog) */
.btn.danger.solid {
  background: var(--badfill);
  border-color: var(--badfill);
  color: #fff;
}

.btn.danger.solid:hover {
  filter: brightness(1.08);
}

/* Text on a project-coloured fill (style="--pc:#hex"): black or white,
   whichever reads better, so any colour an admin picks works — even yellow.
   Browsers without relative colours keep white. */
.on-pc {
  color: #fff;
  color: lch(from var(--pc, var(--c, #64748b)) calc((50 - l) * 1000) 0 0);
}

/* A project-coloured fill that carries text */
.pc-fill {
  background: var(--pc, var(--c, #64748b));
  color: #fff;
  color: lch(from var(--pc, var(--c, #64748b)) calc((50 - l) * 1000) 0 0);
}

/* Project-coloured fills in shared pieces pick black or white text (see .on-pc) */
.ptab2.open,
.ptab2.open b,
.ptab2.open .car {
  color: #fff;
  color: lch(from var(--pc) calc((50 - l) * 1000) 0 0);
}

.ptab2.open b {
  background: color-mix(in srgb, currentColor 18%, transparent);
}

.logo.proj {
  color: #fff;
  color: lch(from color-mix(in srgb, var(--c, var(--brandfill)) 62%, #000) calc((50 - l) * 1000) 0 0);
}

/* Top-bar title on phones: a short title (a task's code), and a long one
   wraps onto a second line instead of being cut off. */
.ptop h1 span {
  display: inline;
  font-size: inherit;
  color: inherit;
}

.ptop h1 .tshort { display: none; }

@media (max-width: 560px) {
  .ptop h1 {
    font-size: 16px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .ptop h1 .tfull {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .ptop h1 .tshort { display: inline; }
}


/* =====================================================================
   33f. Signed-out pages (layout_auth.php): sign in, and "not found" when
   signed out. Builds on section 28 (.lg2 …). Always dark.
   ===================================================================== */

/* Success note above the form ("You have been signed out.") */
.lg2-ok {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: #d1fae5;
  background: rgba(22, 163, 74, .16);
  border: 1px solid rgba(74, 222, 128, .35);
}

/* Error line: readable red on the glass card */
.lg2-err {
  color: #fecaca;
  font-weight: 600;
}

/* The secondary lines were too faint on the dark glass (≈3:1) */
.lg2-date {
  color: rgba(255, 255, 255, .72);
}

.lg2-note {
  color: rgba(255, 255, 255, .72);
}

.lg2-card > p {
  color: rgba(255, 255, 255, .78);
}

.lg2-top span {
  opacity: .82;
}

/* A link styled as the main button (signed-out 404) */
a.lg2-go.lg2-link {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* Single-column variant: no headline column (signed-out 404) */
.lg2.lg2-solo {
  grid-template-columns: 1fr;
}

.lg2.lg2-solo .lg2-panel {
  grid-row: 2;
}

/* "Not found" card for signed-in people (errors/404.php) */
.err-card {
  max-width: 620px;
  margin: 24px auto 0;
  padding: 32px 24px;
}

.err-card h2 {
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--ink);
}

.err-card .et {
  color: var(--ink);
}

.err-card .err-acts {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Avatar sizes as classes, for avatars not drawn by partials/avatar
   (group-chat circles): <span class="av gav s38">👥</span> */
.av.s32 { width: 32px; height: 32px; }
.av.s38 { width: 38px; height: 38px; }
.av.s40 { width: 40px; height: 40px; }

@media (max-width: 400px) {
  .top { gap: 4px; padding: 6px; }
  .top .iconbtn { width: 36px; height: 36px; }
  .newbtn { padding: 6px 8px; min-height: 36px; }
  .ptop h1 { font-size: 15px; }
}
.dot.pcdot { background: var(--pc, var(--muted)); }

/* Small dialogs (approve, return, alert, confirm) become bottom sheets on
   phones: full width, within reach of the thumb, the buttons pinned. */
@media (max-width: 560px) {
  #modal.center {
    align-items: flex-end;
    padding: 0;
  }

  #modal.center .mbox {
    max-width: none;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
  }

  #modal.center .mbox.anim {
    animation: sheetup .22s cubic-bezier(.2, .8, .2, 1);
  }

  #modal.center .mf .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 44px;
  }
}

@keyframes sheetup {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
