/* Kanoon automation — UI foundation.
   Identity comes from the bar association's emblem: its navy ground (#193344) and white line art.
   The navy shell (sidebar, portal band) is the one strong element; pages are quiet white paper.
   Tokens first, then base, layout shells, components, and screen-specific pieces.
   Breakpoint: 760px. Above it the desktop shell shows; below it the phone shell. */

/* ---------- font: Peyda (served locally, works without internet) ---------- */
@font-face{font-family:Peyda;src:url("../fonts/Peyda-Regular.woff2") format("woff2");font-weight:400;font-display:swap}
@font-face{font-family:Peyda;src:url("../fonts/Peyda-Medium.woff2") format("woff2");font-weight:500;font-display:swap}
@font-face{font-family:Peyda;src:url("../fonts/Peyda-SemiBold.woff2") format("woff2");font-weight:600;font-display:swap}
@font-face{font-family:Peyda;src:url("../fonts/Peyda-Bold.woff2") format("woff2");font-weight:700;font-display:swap}
@font-face{font-family:Peyda;src:url("../fonts/Peyda-ExtraBold.woff2") format("woff2");font-weight:800;font-display:swap}

/* ---------- tokens ---------- */
:root, [data-theme="light"] {
  --navy:#193344; --brass:#a3823f;
  --bg:#eef1f4; --surface:#ffffff; --sunk:#e7ebef; --line:#d8dee4; --line-strong:#a9b3bd;
  --fg:#15212c; --muted:#56636f;
  --accent:#193344; --accent-fg:#ffffff; --accent-soft:#e2e9ef;
  --ok:#256b3c; --ok-soft:#e0efe4; --warn:#875900; --warn-soft:#f7ecd5; --bad:#a12d2d; --bad-soft:#f6e1e0;
  --info:#28507f; --info-soft:#e1e9f3; --note:#f8f3e5; --note-line:#d8c48f;
  --teal:#1d6b68; --teal-soft:#dcefed; --violet:#5d4a8f; --violet-soft:#ebe6f5; --brass-ink:#7a5f22; --brass-soft:#f3ebd9;
  /* the navy shell */
  --shell:#193344; --shell-fg:#eef3f7; --shell-muted:#9db1c1; --shell-line:rgba(255,255,255,.12); --shell-hover:rgba(255,255,255,.06); --shell-active:rgba(255,255,255,.1);
  --r:6px; --r-lg:10px;
  --shadow:0 8px 24px rgba(21,33,44,.12);
  --font:Peyda,Tahoma,"Segoe UI",system-ui,sans-serif;
  color-scheme:light;
}
[data-theme="dark"] {
  --bg:#0f1a22; --surface:#16232d; --sunk:#1d2c38; --line:#293a47; --line-strong:#465a6b;
  --fg:#e3e9ee; --muted:#93a3b0;
  --accent:#a9c6dd; --accent-fg:#0f1a22; --accent-soft:#1d3344;
  --ok:#86cf9c; --ok-soft:#15301f; --warn:#e5bd68; --warn-soft:#33280f; --bad:#ee9b98; --bad-soft:#3a1c1c;
  --info:#a3c0ea; --info-soft:#1a283d; --note:#28241a; --note-line:#584a26;
  --teal:#7fd0c8; --teal-soft:#12302e; --violet:#c2b2ec; --violet-soft:#272040; --brass-ink:#e0c27e; --brass-soft:#2d2614;
  --shell:#0b141b; --shell-fg:#e3e9ee; --shell-muted:#8597a6; --shell-line:rgba(255,255,255,.08); --shell-hover:rgba(255,255,255,.04); --shell-active:rgba(255,255,255,.07);
  --shadow:0 8px 24px rgba(0,0,0,.45);
  color-scheme:dark;
}

/* ---------- base ---------- */
*{box-sizing:border-box}
html,body{margin:0}
body{background:var(--bg);color:var(--fg);font-family:var(--font);font-size:15px;line-height:1.7;-webkit-font-smoothing:antialiased;min-height:100vh;display:flex;flex-direction:column;font-feature-settings:"ss01"}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline;text-underline-offset:3px}
button,input,select,textarea{font-family:inherit}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
h1,h2,h3{margin:0}
p{margin:0}
b,strong{font-weight:600}
.num{font-variant-numeric:tabular-nums}

@media (min-width:761px){.phone-only{display:none!important}}
@media (max-width:760px){.desk-only{display:none!important}
  html,body{overflow-x:clip}}  /* nothing may push the phone page sideways */

/* ---------- utilities ---------- */
.stack{display:flex;flex-direction:column;gap:var(--gap,16px)}
.cluster{display:flex;flex-wrap:wrap;gap:var(--gap,8px);align-items:center}
.between{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap}
.grid-fit{display:grid;grid-template-columns:repeat(auto-fit,minmax(var(--min,240px),1fr));gap:var(--gap,16px);align-items:start}
.grid-fill{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--min,250px),1fr));gap:var(--gap,10px)}
.grow{flex:1}
.min0{min-width:0}
.muted{color:var(--muted)}
.t-13{font-size:13px}.t-135{font-size:13.5px}.t-14{font-size:14px}.t-145{font-size:14.5px}.t-15{font-size:15px}.t-16{font-size:16px}.t-17{font-size:17px}.t-18{font-size:18px}.t-19{font-size:19px}
.w-500{font-weight:500}.w-700{font-weight:700}
.c-ok{color:var(--ok)}.c-warn{color:var(--warn)}.c-bad{color:var(--bad)}.c-info{color:var(--info)}
.spacer{flex:1}

/* ---------- shells ---------- */
/* emblem: the bar association's seal, white line art on the navy shell */
.emblem{display:block;flex:none;height:44px;width:auto}
.emblem.sm{height:34px}
.emblem.lg{height:64px}
.avatar{width:34px;height:34px;border-radius:50%;background:var(--sunk);display:grid;place-items:center;font-weight:600;font-size:14px;flex:none;color:var(--fg)}
.avatar.md{width:36px;height:36px}
.avatar.lg{width:40px;height:40px}
.avatar.xl{width:72px;height:72px;font-size:26px;font-weight:700}
.badge{min-width:22px;height:20px;border-radius:4px;background:var(--brass);color:#fff;font-size:12.5px;font-weight:600;display:grid;place-items:center;padding:0 6px;line-height:1}

/* things that sit on the navy shell */
.on-shell{background:var(--shell);color:var(--shell-fg)}
.on-shell .avatar{background:var(--shell-active);color:var(--shell-fg)}
.on-shell .logout,.on-shell .theme-btn{color:var(--shell-muted);border-color:transparent}
.on-shell .logout:hover,.on-shell .theme-btn:hover{color:var(--shell-fg)}

/* portal (lawyers, trainees) */
.portal-header{flex:none}
.portal-header .inner{max-width:1120px;margin:0 auto;padding:0 32px;height:64px;display:flex;align-items:center;gap:32px}
.brand{display:flex;align-items:center;gap:12px;color:inherit}
.brand b{font-size:15px;font-weight:600;line-height:1.5}
.brand small{display:block;font-size:12.5px;color:var(--shell-muted);font-weight:400}
.topnav{display:flex;gap:2px;flex:1;align-self:stretch}
.topnav a{display:flex;align-items:center;gap:6px;padding:3px 12px 0;color:var(--shell-muted);font-size:14.5px;text-decoration:none;border-bottom:3px solid transparent}
.topnav a:hover{color:var(--shell-fg)}
.topnav a.active{color:var(--shell-fg);font-weight:600;border-bottom-color:var(--brass)}
.user-btn{min-height:40px;display:flex;align-items:center;gap:8px;padding:0 4px;border:0;background:none;color:inherit;font-size:14.5px}

.phone-header{height:56px;padding:0 16px;display:flex;align-items:center;gap:10px;flex:none;position:sticky;top:0;z-index:6}
.phone-header .title{font-size:16px;flex:1;font-weight:600}
.phone-header .avatar{width:32px;height:32px;font-size:13px}
.phone-header .btn{background:transparent;color:var(--shell-fg);border-color:var(--shell-line)}

.bottom-nav{position:sticky;bottom:0;background:color-mix(in srgb,var(--surface) 92%,transparent);-webkit-backdrop-filter:saturate(1.4) blur(12px);backdrop-filter:saturate(1.4) blur(12px);border-top:1px solid var(--line);display:flex;padding:6px 6px calc(6px + env(safe-area-inset-bottom,0px));z-index:5}
.bottom-nav a{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:2px 0;color:var(--muted);font-size:11.5px;line-height:1.3;text-decoration:none;-webkit-tap-highlight-color:transparent}
.bottom-nav a span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.bottom-nav .ico{width:22px;height:22px;box-sizing:content-box;padding:4px 16px;border-radius:999px;transition:background-color .15s}
.bottom-nav a:hover{text-decoration:none;color:var(--fg)}
.bottom-nav a.active{color:var(--accent);font-weight:600}
.bottom-nav a.active .ico{background:var(--accent-soft)}
.bottom-nav a.dot::before{width:8px;height:8px;border-radius:50%;background:var(--bad)}

/* staff and management workspace */
.workspace{flex:1;display:flex;min-height:100vh}
.sidebar{width:260px;flex:none;display:flex;flex-direction:column;position:sticky;top:0;height:100vh;overflow-y:auto}
.sidebar .head{padding:18px 20px 16px;display:flex;align-items:center;gap:12px;border-bottom:1px solid var(--shell-line)}
.sidebar .head .emblem{height:46px}
.sidebar .head div{display:flex;flex-direction:column;line-height:1.5}
.sidebar .head b{font-size:15px;font-weight:600}
.sidebar .head span{font-size:12.5px;color:var(--shell-muted)}
.sidebar .new{padding:12px 16px 6px}
.sidebar .new .btn{width:100%;min-height:36px;font-size:14px;background:transparent;color:var(--shell-fg);border-color:var(--shell-line);font-weight:500}
.sidebar .new .btn:hover{background:var(--shell-hover);border-color:var(--shell-muted)}
.sidenav{display:flex;flex-direction:column;gap:1px;padding:4px 0}
.sidenav a{display:flex;align-items:center;justify-content:space-between;min-height:34px;padding:0 20px;color:var(--shell-fg);text-decoration:none;font-size:15px;border-inline-start:3px solid transparent;opacity:.88}
.sidenav a:hover{background:var(--shell-hover);opacity:1}
.sidenav a.active{background:var(--shell-active);border-inline-start-color:var(--brass);font-weight:600;opacity:1}
.sidenav .group{font-size:12px;color:var(--shell-muted);padding:10px 23px 2px}
.sidebar .foot{margin-top:auto;padding:8px 0 6px;display:flex;flex-direction:column;gap:4px}
.sidebar .foot .later{display:flex;align-items:center;justify-content:space-between;min-height:34px;padding:0 23px;color:var(--shell-muted);text-decoration:none;font-size:14px}
.sidebar .foot .me{border-top:1px solid var(--shell-line);padding:10px 20px 4px;display:flex;align-items:center;gap:10px}
.sidebar .foot .me div{display:flex;flex-direction:column;line-height:1.5;min-width:0}
.sidebar .foot .me b{font-size:14px}
.sidebar .foot .me span{font-size:12.5px;color:var(--shell-muted)}
.ws-body{flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{height:56px;flex:none;display:flex;align-items:center;gap:12px;padding:0 32px;border-bottom:1px solid var(--line);background:var(--surface)}
.search{flex:1;max-width:520px;min-height:40px;border-radius:var(--r);border:1px solid var(--line);background:var(--bg);display:flex;align-items:center;padding:0 14px;color:var(--fg);font-size:15px;width:100%}
.search::placeholder{color:var(--muted)}
.search:focus{border-color:var(--accent);background:var(--surface);outline:none}
.notif-btn{min-height:40px;display:flex;align-items:center;gap:8px;padding:0 12px;border-radius:var(--r);border:1px solid var(--line);background:var(--surface);color:var(--fg);font-size:14.5px;cursor:pointer}
.notif-btn:hover{border-color:var(--line-strong);text-decoration:none}
.login .tools .icon-btn,.topbar .icon-btn{border:1px solid var(--line);background:var(--surface);color:var(--fg)}
.login .tools .icon-btn:hover,.topbar .icon-btn:hover{border-color:var(--line-strong);background:var(--surface)}

/* page containers */
.page{flex:1;width:100%;max-width:1120px;margin:0 auto;padding:20px 32px 20px;display:flex;flex-direction:column;gap:14px}
.page.wide{max-width:1180px}
.page.narrow{max-width:760px}
@media (max-width:760px){.page{padding:16px 16px 24px;gap:14px}}
.page-head{display:flex;flex-direction:column;gap:2px}
.h1{font-size:22px;font-weight:700;line-height:1.5}
@media (max-width:760px){.h1{font-size:20px}}
.h2{font-size:16.5px;font-weight:600}
.h2.lg{font-size:17px}
.h2.group{font-size:17px;color:var(--muted)}
.lead{color:var(--muted);font-size:14.5px;max-width:75ch}
.crumbs{font-size:14px;color:var(--muted)}
.back{align-self:flex-start;min-height:36px;display:flex;align-items:center;font-weight:500}

/* ---------- components ---------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:18px 20px;display:flex;flex-direction:column;gap:12px;min-width:0}
.card.pad-16{padding:16px}
.card.pad-18{padding:18px}
.card.gap-4{gap:4px}.card.gap-6{gap:6px}.card.gap-10{gap:10px}.card.gap-12{gap:12px}.card.gap-2{gap:2px}
.card.warn-edge{border-color:var(--line);border-inline-start:4px solid var(--warn)}
.card.accent-edge{border-color:var(--line);border-inline-start:4px solid var(--accent)}
.card.strong-edge{border:2px solid var(--line-strong)}
.plain-box{border:1px solid var(--line);border-radius:var(--r);padding:12px 16px;display:flex;flex-direction:column;gap:2px;font-size:15px}

.item-link{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:12px 18px;display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;color:var(--fg);text-decoration:none}
.item-link:hover{border-color:var(--accent);text-decoration:none}
.item-link .txt{display:flex;flex-direction:column}
.item-link .txt b{font-size:16px;font-weight:600}
.item-link .txt span{font-size:14px;color:var(--muted)}

.chip{display:inline-flex;align-items:center;gap:6px;padding:1px 10px;border-radius:4px;font-size:13px;font-weight:500;white-space:nowrap;line-height:1.7}
.chip.info{background:var(--info-soft);color:var(--info)}
.chip.ok{background:var(--ok-soft);color:var(--ok)}
.chip.warn{background:var(--warn-soft);color:var(--warn)}
.chip.bad{background:var(--bad-soft);color:var(--bad)}
.chip.neutral{background:var(--sunk);color:var(--muted)}
.chip.unassigned{border:1px dashed var(--line-strong);color:var(--muted)}
.tag{display:inline-flex;align-items:center;padding:0 8px;border-radius:4px;font-size:13px;font-weight:600;white-space:nowrap}
.tag.urgent{color:var(--bad);border:1px solid var(--bad)}
.tag.doc{font-size:12px;border:1px solid var(--line-strong);padding:0 6px}
.tag.internal{font-size:12px;background:var(--note);border:1px solid var(--note-line);color:var(--fg)}
.tag.secret{border:1px solid var(--fg)}

.btn{min-height:40px;padding:0 18px;border-radius:var(--r);background:var(--surface);color:var(--fg);border:1px solid var(--line-strong);font-size:15px;font-weight:500;transition:background-color .12s,border-color .12s;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;text-decoration:none}
.btn:hover{text-decoration:none;border-color:var(--fg)}
.btn.primary{background:var(--accent);color:var(--accent-fg);border-color:var(--accent);font-weight:600;padding:0 22px}
.btn.primary:hover{background:color-mix(in srgb,var(--accent) 86%,var(--fg))}
.btn.lg{min-height:44px;font-size:15.5px}
.btn.sm{min-height:36px;font-size:14px;padding:0 14px}
.btn.link{background:none;border:0;color:var(--accent);padding:0 8px}
.btn.link.muted{color:var(--muted)}
.btn.danger{color:var(--bad);border-color:var(--bad)}
.btn.self-start{align-self:flex-start}

.actionbar{display:flex;gap:8px;flex-wrap:wrap;padding:12px;border:1px solid var(--line);border-radius:var(--r-lg);background:var(--surface);position:sticky;bottom:0}
.actionbar .btn{flex:1 1 100px;min-height:48px;font-size:16px}
.btn.approve{background:var(--ok);color:var(--surface);border-color:var(--ok);font-weight:600}
.btn.return{color:var(--warn);border-color:var(--warn)}
.btn.reject{color:var(--bad);border-color:var(--bad)}

.dl{margin:0;display:grid;grid-template-columns:max-content 1fr;gap:8px 20px;font-size:15px}
.dl dt{color:var(--muted)}
.dl dd{margin:0}
.dl.tight{gap:6px 16px}

.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);overflow-x:auto}
.tabs button,.tabs a{min-height:42px;padding:0 14px;border:0;border-bottom:3px solid transparent;background:none;color:var(--muted);font-size:15px;font-weight:500;display:flex;align-items:center;gap:8px;white-space:nowrap;cursor:pointer;text-decoration:none}
.tabs.sm button{font-size:15px}
.tabs .active{border-bottom-color:var(--accent);color:var(--fg);font-weight:600}
.tabs .count{font-size:13px;background:var(--sunk);border-radius:4px;padding:0 8px;color:var(--fg);font-weight:500}

.filter{min-height:36px;display:inline-flex;align-items:center;padding:0 14px;border-radius:var(--r);font-size:14px;border:1px solid var(--line-strong);white-space:nowrap;background:none;color:var(--fg);cursor:pointer}
.filter.active{background:var(--accent);color:var(--accent-fg);font-weight:600;border-color:var(--accent)}
.filters{display:flex;gap:8px;overflow-x:auto;padding-bottom:2px;align-items:center}

.field{display:flex;flex-direction:column;gap:6px}
.field .label{font-weight:500;font-size:15px}
.input{min-height:40px;padding:7px 12px;border-radius:var(--r);border:1px solid var(--line-strong);background:var(--surface);color:var(--fg);display:flex;align-items:center;font-size:16px;width:100%}
.input.tall{min-height:44px}
/* The plain <select> looks exactly like the themed dropdown, so nothing flickers
   in the moment before select.js replaces it while a page loads. */
select.input{-webkit-appearance:none;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2356636f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:left 13px center;padding-inline-end:34px;cursor:pointer;color:var(--fg)}
[dir="ltr"] select.input{background-position:right 13px center}
[data-theme="dark"] select.input{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2393a3b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
.input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
.input.error{border:2px solid var(--bad)}
.input .aside{margin-inline-start:auto;color:var(--muted);font-size:14px}
.input .act{margin-inline-start:auto;font-size:14px;color:var(--accent);font-weight:500}
textarea.input{display:block;min-height:88px;padding:10px 14px;resize:vertical;line-height:1.7}
.err-text{font-size:14px;color:var(--bad);font-weight:500}
.hint{font-size:13.5px;color:var(--muted)}

.choices{display:flex;flex-wrap:wrap;gap:8px}
.choice{min-height:42px;display:inline-flex;align-items:center;padding:0 18px;border-radius:var(--r);font-size:15px;cursor:pointer;border:1px solid var(--line-strong);background:var(--surface);color:var(--fg)}
.choice.selected{border:2px solid var(--accent);background:var(--accent-soft);font-weight:600}

.dropzone{border:2px dashed var(--line-strong);border-radius:var(--r-lg);padding:18px;display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}
.dropzone.error{border-color:var(--bad)}

.alert-error{border:0;border-inline-start:4px solid var(--bad);background:var(--bad-soft);border-radius:var(--r);padding:14px 18px;display:flex;flex-direction:column;gap:4px}
.alert-error b{color:var(--bad);font-size:16px}
.alert-error a{color:var(--fg);text-decoration:underline;font-size:15px}
.info-box{background:var(--info-soft);border-radius:var(--r);padding:10px 16px;font-size:15px}
.info-box.lg{border-radius:var(--r);padding:12px 16px}
.quote{background:var(--warn-soft);border-radius:var(--r);padding:10px 14px;font-size:15px}
.quote.sm{border-radius:8px;padding:8px 12px}
.facts-box{background:var(--sunk);border-radius:var(--r);padding:12px 16px;display:flex;flex-wrap:wrap;gap:4px 24px;font-size:15px}

.note{background:var(--note);border:1px solid var(--note-line);border-radius:var(--r);padding:12px 14px;display:flex;flex-direction:column;gap:4px}
.note .meta{display:flex;justify-content:space-between;gap:8px;font-size:13px}
.note .meta span{color:var(--muted)}
.note .body{font-size:15px}

/* timeline */
.timeline{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.timeline li{display:grid;grid-template-columns:20px 1fr;gap:12px}
.timeline .rail{display:flex;flex-direction:column;align-items:center}
.timeline .dot{width:12px;height:12px;border-radius:50%;background:var(--accent);margin-top:8px;flex:none}
.timeline .dot.warn{background:var(--warn)}
.timeline .dot.note{background:var(--note-line)}
.timeline .dot.now{background:var(--surface);border:3px solid var(--accent)}
.timeline .dot.future{background:var(--surface);border:2px solid var(--line-strong)}
.timeline .line{flex:1;width:2px;background:var(--line)}
.timeline .line.dashed{background:repeating-linear-gradient(var(--line) 0 4px,transparent 4px 8px)}
.timeline .body{padding-bottom:16px;display:flex;flex-direction:column;gap:6px;min-width:0}
.timeline li:last-child .body{padding-bottom:0}
.timeline .what{font-weight:500;display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.timeline .what.now{font-weight:600}
.timeline .what.future{color:var(--muted)}
.timeline .when{font-size:13.5px;color:var(--muted)}

/* ---------- screen pieces ---------- */
/* status tiles (trainee home) */
.status-dot{width:10px;height:10px;border-radius:50%;background:var(--ok);flex:none}
.status-dot.accent{background:var(--accent)}

/* request picker */
.type-btn{text-align:right;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:14px 16px;display:flex;flex-direction:column;gap:2px;color:var(--fg);font-size:15px;cursor:pointer;min-height:0;text-decoration:none}
.type-btn:hover{border-color:var(--accent);text-decoration:none}
.type-btn b{font-size:15.5px;font-weight:600}
.type-btn span{font-size:13.5px;color:var(--muted);line-height:1.6}

/* staff inbox */
.list{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);overflow:hidden}
.list>.list-row:first-child{border-top:0}
.list-head{display:flex;gap:14px;padding:10px 18px;background:var(--sunk);font-size:13.5px;color:var(--muted)}
.list-row{border-top:1px solid var(--line);padding:12px 18px;display:flex;gap:14px;align-items:center;flex-wrap:wrap;color:var(--fg);text-decoration:none}
.list-row.selected{background:var(--accent-soft)}
.list-row .main{flex:1 1 260px;min-width:0;display:flex;flex-direction:column;gap:2px}
.list-row .main b{font-size:16px;font-weight:600}
.list-row .main span{font-size:14px;color:var(--muted)}
.list-row .holder{font-size:14px;min-width:120px}
a.list-row:hover b{text-decoration:underline}
.assign{border-top:1px solid var(--line);background:var(--surface);padding:16px 18px;display:flex;flex-direction:column;gap:12px}
.assign-opt{border:1px solid var(--line-strong);border-radius:var(--r);padding:10px 14px;display:flex;flex-direction:column;cursor:pointer}
.assign-opt b{font-size:15px}
.assign-opt span{font-size:13.5px;color:var(--muted)}
.assign-opt.selected{border:2px solid var(--accent);background:var(--accent-soft)}
.assign-opt.away{border-style:dashed;color:var(--muted);cursor:default}
.task-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:14px 16px;display:flex;flex-direction:column;gap:6px;color:var(--fg);text-decoration:none}
.task-card b{font-size:16px}
.task-card span.meta{font-size:14px;color:var(--muted)}

/* attachment */
.file-row{border:1px solid var(--line);border-radius:var(--r);padding:10px 14px;display:flex;align-items:center;gap:12px}
.file-icon{width:40px;height:40px;border-radius:var(--r);background:var(--sunk);display:grid;place-items:center;font-size:12px;font-weight:700;color:var(--muted);flex:none}

/* lawyer file */
.doc-row{border-top:1px solid var(--line);padding:12px 0;display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.doc-row .txt{flex:1 1 180px;display:flex;flex-direction:column}
.doc-row .txt b{font-size:15px}
.doc-row .txt span{font-size:13.5px;color:var(--muted)}
.view-row{border-top:1px solid var(--line);padding:10px 0;display:grid;grid-template-columns:minmax(120px,1fr) minmax(140px,1.4fr) auto;gap:4px 16px;font-size:14.5px;align-items:baseline}
.view-row .when{color:var(--muted);font-size:13.5px;white-space:nowrap}
@media (max-width:760px){
  .view-row{grid-template-columns:1fr auto}
  .view-row>span:nth-child(2){grid-column:1/-1;grid-row:2}
}
.grant-box{background:var(--warn-soft);border-radius:var(--r);padding:10px 14px;margin-top:8px;display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;font-size:14.5px}

/* outgoing letter */
.steps{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px}
.steps li{border-radius:var(--r-lg);padding:10px 14px;display:flex;gap:10px;align-items:center;background:var(--surface);border:1px solid var(--line)}
.steps li .n{width:28px;height:28px;border-radius:50%;flex:none;display:grid;place-items:center;font-size:14px;font-weight:700;border:1px solid var(--line-strong);color:var(--muted)}
.steps li div{display:flex;flex-direction:column;line-height:1.5}
.steps li b{font-size:15px;color:var(--muted);font-weight:500}
.steps li span{font-size:13px;color:var(--muted)}
.steps li.current{background:var(--accent-soft);border:2px solid var(--accent)}
.steps li.current .n{background:var(--surface);border:2px solid var(--accent);color:var(--fg)}
.steps li.current b{color:var(--fg);font-weight:700}
.letter-layout{display:grid;grid-template-columns:minmax(0,2fr) minmax(260px,1fr);gap:16px;align-items:start}
@media (max-width:1000px){.letter-layout{grid-template-columns:1fr}}
.editor{border:1px solid var(--line-strong);border-radius:var(--r);background:var(--surface)}
.editor .tools{display:flex;gap:4px;padding:6px;border-bottom:1px solid var(--line);font-size:14px;flex-wrap:wrap}
.editor .tools button{min-height:34px;display:inline-flex;align-items:center;padding:0 10px;border-radius:8px;color:var(--muted);background:none;border:0;font-size:14px;cursor:pointer}
.editor .text{padding:14px 16px;font-size:16px;line-height:2;min-height:180px;outline:none}
.token{min-height:36px;display:inline-flex;align-items:center;gap:8px;padding:0 12px;border-radius:var(--r);background:var(--sunk);font-size:14.5px}
.paper-snippet{background:#fff;color:#16211f;border:1px solid var(--line);border-radius:12px;padding:16px;font-size:15.5px;line-height:2}
.phone-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;position:sticky;bottom:0;background:var(--bg);padding:8px 0}
.phone-actions .wide{grid-column:1/-1}
.phone-actions .btn{min-height:48px}
.phone-actions .btn.approve{min-height:52px;font-size:17px}

/* print preview */
.print-bar{height:64px;background:var(--surface);border-bottom:1px solid var(--line);display:flex;align-items:center;gap:12px;padding:0 24px;flex:none}
.paper-desk{flex:1;background:var(--sunk);display:flex;justify-content:center;padding:32px 24px;overflow-x:auto}
.paper{width:794px;min-height:1123px;background:#ffffff;color:#16211f;box-shadow:0 4px 24px rgba(0,0,0,.25);padding:56px 64px;display:flex;flex-direction:column;gap:28px;font-size:16px;line-height:2.1;flex:none}
.paper .head{display:grid;grid-template-columns:1fr auto 1fr;align-items:start;gap:16px}
.paper .seal{width:auto;height:64px}
.paper .rule{border-top:2px solid #193344}
.paper .sign{align-self:flex-end;width:280px;text-align:center;display:flex;flex-direction:column;gap:6px;margin-top:12px}
.paper .sign-box{height:96px;border:1px dashed #a9b5b8;border-radius:8px;display:grid;place-items:center;font-size:13px;color:#5b6866}
.paper .foot{margin-top:auto;border-top:1px solid #d3dadd;padding-top:16px;display:flex;gap:18px;align-items:center}
.verified{background:var(--ok-soft);border:0;border-inline-start:4px solid var(--ok);border-radius:var(--r);padding:18px;display:flex;flex-direction:column;gap:4px}
@media print{.print-bar,.phone-only{display:none!important}.paper-desk{padding:0;background:#fff}.paper{box-shadow:none}}

/* activity log */
.log{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);overflow:hidden}
.log-grid{display:grid;grid-template-columns:56px minmax(160px,1fr) minmax(240px,2fr) minmax(180px,1.2fr);gap:16px;padding:7px 16px;font-size:14.5px;align-items:baseline}
.log-grid.head{padding:8px 16px;font-size:13px;color:var(--muted);background:var(--sunk)}
.log-grid.row{border-top:1px solid var(--line)}
.log-grid .t{color:var(--muted);font-variant-numeric:tabular-nums}
.log-grid .who b{font-weight:500}
.log-grid .who span{font-size:13.5px;color:var(--muted)}
.log-grid .what{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.log-grid a{font-size:14.5px}
.log-day{padding:6px 16px;border-top:1px solid var(--line);font-size:13.5px;font-weight:600;color:var(--muted)}
.log-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:12px 14px;display:flex;flex-direction:column;gap:2px}
.log-card .meta{display:flex;justify-content:space-between;gap:8px;font-size:13.5px;color:var(--muted)}
.log-card .what{font-size:15.5px}
.log-card a{font-size:14px}
/* phone: one list per day, one row per event */
.log-list{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);overflow:hidden}
.log-list-day{font-size:13.5px;font-weight:600;color:var(--muted);padding:8px 14px;background:var(--sunk);border-bottom:1px solid var(--line)}
.log-item{display:grid;grid-template-columns:1fr auto;gap:0 10px;padding:10px 14px;border-top:1px solid var(--line);color:var(--fg)}
.log-list-day+.log-item{border-top:0}
a.log-item:hover{text-decoration:none;background:var(--sunk)}
.log-item .what{font-size:15px;line-height:1.6}
.log-item .time{font-size:13px;color:var(--muted);font-variant-numeric:tabular-nums;padding-top:2px}
.log-item .sub{grid-column:1/-1;font-size:13px;color:var(--muted)}

/* dashboard */
.approve-row{border-top:1px solid var(--line);padding:14px 0;display:flex;gap:12px;align-items:center;flex-wrap:wrap;color:var(--fg);text-decoration:none}
.approve-row:hover{text-decoration:none}
.approve-row:hover b{text-decoration:underline}
.approve-row .txt{flex:1 1 240px;display:flex;flex-direction:column}
.approve-row .txt b{font-size:16px;font-weight:600}
.approve-row .txt span{font-size:14px;color:var(--muted)}
.approve-row .go{color:var(--accent);font-weight:500;font-size:15px}
.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:18px 20px;display:flex;flex-direction:column;gap:2px}
.stat .k{font-size:14px;color:var(--muted)}
.stat .v{font-size:28px;line-height:1.3;font-weight:600;font-variant-numeric:tabular-nums}
.stat .s{font-size:13.5px;color:var(--muted)}
.stat.warn{border-inline-start:4px solid var(--warn)}
.stat.warn .v{color:var(--warn)}
.legend{display:flex;gap:12px;font-size:13px;color:var(--muted)}
.legend span{display:flex;gap:6px;align-items:center}
.legend i{width:10px;height:10px;border-radius:2px;background:var(--accent)}
.legend i.w{background:var(--warn)}
.bar-row{display:grid;grid-template-columns:minmax(120px,170px) 1fr 70px;gap:12px;align-items:center;font-size:15px}
.bar{height:10px;border-radius:2px;background:var(--sunk);display:flex;overflow:hidden}
.bar i{background:var(--accent)}
.bar i.w{background:var(--warn)}
.bar-row .n{font-variant-numeric:tabular-nums;color:var(--muted);font-size:14px}
.late-row{border-top:1px solid var(--line);padding:10px 0;display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.late-row .txt{flex:1 1 200px;display:flex;flex-direction:column}
.late-row .txt b{font-size:15px;font-weight:500}
.late-row .txt span{font-size:13.5px;color:var(--muted)}
.people{display:grid;grid-template-columns:minmax(120px,1.4fr) minmax(110px,1.2fr) 70px 70px minmax(90px,1fr);gap:8px 16px;font-size:15px;min-width:520px}
.people .h{font-size:13.5px;color:var(--muted)}
.people .c{border-top:1px solid var(--line);padding-top:8px;font-variant-numeric:tabular-nums}
.people .late{color:var(--warn);font-weight:600}
.scroll-x{overflow-x:auto}

/* admin steps */
.flow{display:flex;flex-direction:column}
.flow-end{background:var(--sunk);border-radius:var(--r-lg);padding:14px 18px;display:flex;flex-direction:column;gap:2px}
.flow-end b{font-size:16px}
.flow-end span{font-size:14.5px;color:var(--muted)}
.flow-gap{display:flex;flex-direction:column;align-items:center;gap:6px;padding:4px 0}
.flow-gap i{width:2px;height:14px;background:var(--line-strong)}
.add-step{min-height:36px;padding:0 14px;border-radius:var(--r);border:1px dashed var(--line-strong);background:var(--bg);color:var(--muted);font-size:14px;cursor:pointer}
.step-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:16px 18px;display:flex;gap:14px;align-items:flex-start}
.step-card.selected{border:2px solid var(--accent)}
.step-card .n{width:32px;height:32px;border-radius:50%;background:var(--accent);color:var(--accent-fg);display:grid;place-items:center;font-weight:600;flex:none}
.step-card .txt{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}
.step-card .txt b{font-size:17px;font-weight:600}
.step-card .txt span{font-size:14px;color:var(--muted)}
.step-card .txt span.unit{font-size:15px;color:var(--fg)}
.select{min-height:42px;display:inline-flex;align-items:center;gap:10px;padding:0 14px;border-radius:var(--r);border:1px solid var(--line-strong);background:var(--surface);font-size:15.5px;color:var(--fg)}
.select::after{content:"▾";color:var(--muted);font-size:12px}
.radio{display:flex;gap:10px;align-items:center;min-height:40px;font-size:15.5px;cursor:pointer}
.radio input{appearance:none;width:20px;height:20px;border-radius:50%;border:2px solid var(--line-strong);margin:0;flex:none;cursor:pointer}
.radio input:checked{border:6px solid var(--accent)}
.switch{display:flex;gap:10px;align-items:center;min-height:36px;font-size:14.5px;cursor:pointer;user-select:none}
.switch input{appearance:none;box-sizing:border-box;width:36px;height:20px;border-radius:10px;background:var(--line-strong);border:0;position:relative;flex:none;margin:0;cursor:pointer;transition:background-color .15s}
.switch input::after{content:"";position:absolute;top:3px;inset-inline-start:3px;width:14px;height:14px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.25);transition:inset-inline-start .15s}
.switch input:checked{background:var(--accent)}
.switch input:checked::after{inset-inline-start:19px;background:var(--accent-fg)}
.switch input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.switch input,.switch input::after{transition:none}}
.num-box{min-height:42px;width:72px;display:inline-flex;align-items:center;justify-content:center;border-radius:var(--r);border:1px solid var(--line-strong);background:var(--surface);color:var(--fg);font-size:15.5px;text-align:center}

/* ---------- login ---------- */
.login{flex:1;display:grid;grid-template-columns:minmax(320px,5fr) 7fr;min-height:100vh}
.login .seal-side{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:22px;padding:48px 32px;text-align:center;border-inline-end:3px solid var(--brass)}
.login .seal-side .emblem{height:132px}
.login .seal-side .wordmark{height:34px;width:auto}
.login .seal-side p{color:var(--shell-muted);font-size:14px;max-width:30ch}
.login .form-side{display:flex;flex-direction:column;justify-content:center;align-items:center;padding:48px 24px;position:relative}
.login .form-side .inner{width:100%;max-width:380px;display:flex;flex-direction:column;gap:22px}
.login .form-side .tools{position:absolute;top:16px;inset-inline-end:20px}
@media (max-width:760px){
  .login{grid-template-columns:1fr;grid-template-rows:auto 1fr}
  .login .seal-side{flex-direction:column;padding:calc(24px + env(safe-area-inset-top,0px)) 20px 20px;gap:10px;border-inline-end:0;border-bottom:3px solid var(--brass);justify-content:center;text-align:center}
  .login .seal-side .emblem{height:76px}
  .login .seal-side .wordmark{height:40px}
  .login .seal-side p{font-size:13px}
  .login .form-side{justify-content:flex-start;padding:28px 16px}
  .login .form-side .tools{position:static;align-self:flex-end;margin-bottom:8px}
}

/* ---------- summary strip (key facts side by side, equal height) ---------- */
.facts{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg)}
.facts>div{padding:14px 20px;display:flex;flex-direction:column;gap:2px;min-width:0;border-inline-start:1px solid var(--line)}
.facts>div:first-child{border-inline-start:0}
.facts .k{font-size:13px;color:var(--muted)}
.facts .v{font-size:16px;font-weight:600;display:flex;align-items:center;gap:8px}
.facts .s{font-size:13px;color:var(--muted)}
@media (max-width:760px){.facts>div{border-inline-start:0;border-top:1px solid var(--line)}.facts>div:first-child{border-top:0}}
.empty{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:16px 20px;background:var(--surface);border:1px dashed var(--line-strong);border-radius:var(--r-lg)}
.empty .txt{display:flex;flex-direction:column}
.empty .txt span{font-size:13.5px;color:var(--muted)}

/* ---------- compact data table + pager (long lists stay within one screen) ---------- */
.tbl-wrap{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg)}
.tbl-wrap .tbl thead th:first-child{border-start-start-radius:var(--r-lg)}
.tbl-wrap .tbl thead th:last-child{border-start-end-radius:var(--r-lg)}
@media (max-width:760px){.tbl-wrap .scroll-x{overflow-x:auto}}
.tbl{width:100%;border-collapse:collapse;font-size:14.5px}
.tbl th{font-size:13px;font-weight:500;color:var(--muted);text-align:start;padding:8px 16px;background:var(--sunk);white-space:nowrap}
.tbl td{padding:8px 16px;border-top:1px solid var(--line);vertical-align:middle}
.tbl tr.clickable{cursor:pointer}
.tbl tr.clickable:hover td{background:color-mix(in srgb,var(--accent-soft) 55%,transparent)}
.tbl td.name a,.tbl td.name b{font-weight:600;color:var(--fg)}
.tbl td.name{min-width:150px}
.tbl td.num,.tbl td .num{font-variant-numeric:tabular-nums;white-space:nowrap}
.tbl td.actions{white-space:nowrap;text-align:end;width:1%}
.tbl .sub{display:block;font-size:13px;color:var(--muted)}
.tbl-empty{padding:18px 16px;color:var(--muted)}
.pager{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:8px 16px;border-top:1px solid var(--line);font-size:13.5px;color:var(--muted)}
.pager .nav{display:flex;gap:6px}
.pager span{white-space:nowrap}
.pager .goto{display:flex;align-items:center;gap:6px;margin:0 4px}
.pager .goto .input{width:52px;min-height:32px;padding:2px 4px;text-align:center;font-size:14px}
.pager .per{display:flex;align-items:center;gap:8px;margin-inline-start:auto}
.pager .per .kselect{width:78px}
.pager .per .input{min-height:32px;padding:3px 10px;font-size:14px}
@media (max-width:760px){
  .pager{padding:6px 10px;gap:4px 8px;font-size:12.5px;flex-wrap:wrap}
  .pager>span:first-child{flex-basis:100%;text-align:center;font-size:12px}
  .pager .per{font-size:0;gap:0;margin-inline-start:0}
  .pager .nav{flex:1;justify-content:flex-end}  /* phone: the size picker without its label */
  .pager .per .kselect{width:64px;font-size:14px}
  .pager .nav{gap:4px}
  .pager .goto{gap:4px;margin:0 2px}
  .pager .goto>span:first-of-type{display:none}
  .pager .goto .input{width:44px;min-height:30px;font-size:16px}
  .pager a,.pager span.off{min-height:30px;padding:0 10px}
}
.pager a,.pager span.off{min-height:32px;display:inline-flex;align-items:center;padding:0 12px;border:1px solid var(--line);border-radius:var(--r);color:var(--fg);text-decoration:none}
.pager span.off{color:var(--muted);opacity:.5}
.pager a:hover{border-color:var(--line-strong)}
@media (max-width:760px){.tbl .hide-sm{display:none}.tbl th,.tbl td{padding:8px 12px}
  .tbl td.name{min-width:120px}  /* names keep room; long role labels wrap instead */
  .tbl .role-chip{white-space:normal;text-align:start}
  /* people with roles: one block per person, roles under the name */
  .roles-tbl thead{display:none}
  .roles-tbl tr{display:grid;grid-template-columns:1fr auto;align-items:center;border-top:1px solid var(--line)}
  .roles-tbl tbody tr:first-child{border-top:0}
  .roles-tbl td{border-top:0}
  .roles-tbl td.name{grid-column:1;grid-row:1;padding-bottom:4px}
  .roles-tbl td.actions{grid-column:2;grid-row:1;width:auto}
  .roles-tbl td.roles{grid-column:1/-1;grid-row:2;padding-top:0;display:flex;flex-wrap:wrap;gap:6px}
  .roles-tbl td.roles:empty{display:none}}

/* toolbar: title and filters on one line */
.toolbar{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;flex-wrap:wrap}
.toolbar form{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.toolbar .input{width:auto;min-height:38px}
/* search + kind + button: the kind dropdown has a fixed width so choosing an option never moves anything */
.search-form>input[type=search]{width:260px}
.search-form .kselect{width:170px}
@media (max-width:760px){
  .toolbar .search-form{width:100%;display:grid;grid-template-columns:1fr auto;gap:8px}
  .search-form>input[type=search]{grid-column:1/-1;width:100%}
  .search-form .kselect{width:100%}
  .search-form .input,.search-form .btn{min-height:42px}
  .search-form .btn{padding:0 20px}
  .search-form .btn.link{grid-column:1/-1;justify-self:start}
}
/* a row of filter dropdowns: equal widths on the desktop, an even two-column grid on the phone */
.filter-bar{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;max-width:820px}
.filter-bar .kselect{width:100%}
/* custom date span: its own row under the dropdowns */
.filter-bar .range{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.filter-bar .range label{display:flex;align-items:center;gap:6px;font-size:14px;color:var(--muted)}
.filter-bar .range .input{width:130px;text-align:center;font-variant-numeric:tabular-nums}
@media (max-width:1100px){.filter-bar{grid-template-columns:1fr 1fr;max-width:440px}}
@media (max-width:760px){
  .filter-bar{max-width:none}
  .filter-bar .range{display:grid;grid-template-columns:1fr 1fr auto}
  .filter-bar .range[hidden]{display:none}
  .filter-bar .range .input{width:100%}
  .filter-bar .input{min-height:42px}
}

/* menu of secondary actions */
details.menu{position:relative;display:inline-block}
details.menu>summary{list-style:none;cursor:pointer;min-height:32px;display:inline-flex;align-items:center;padding:0 10px;border:1px solid var(--line);border-radius:var(--r);font-size:13.5px;color:var(--fg)}
details.menu>summary::-webkit-details-marker{display:none}
details.menu[open]>summary{border-color:var(--line-strong)}
details.menu .items{position:absolute;inset-inline-end:0;top:calc(100% + 4px);z-index:20;min-width:210px;background:var(--surface);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);padding:4px;display:flex;flex-direction:column}
details.menu .items button,details.menu .items a{all:unset;box-sizing:border-box;display:block;padding:7px 12px;border-radius:4px;font-size:14px;cursor:pointer;color:var(--fg);text-align:start}
details.menu .items button:hover,details.menu .items a:hover{background:var(--sunk)}
details.menu .items .danger{color:var(--bad)}
details.menu .items form{margin:0}

/* ---------- modal dialog ---------- */
dialog.modal{border:1px solid var(--line);border-radius:var(--r-lg);padding:0;background:var(--surface);color:var(--fg);width:min(560px,calc(100vw - 32px));box-shadow:var(--shadow)}
dialog.modal::backdrop{background:rgba(15,26,34,.45)}
dialog.modal form{padding:20px;display:flex;flex-direction:column;gap:14px}
dialog.modal .head{display:flex;justify-content:space-between;align-items:center;gap:12px}
dialog.modal .foot{display:flex;gap:8px;justify-content:flex-start;flex-wrap:wrap;padding-top:4px}

/* ---------- person picker (search the list, pick one) ---------- */
.picker{position:relative}
.picker .results{position:absolute;top:calc(100% + 4px);inset-inline:0;z-index:15;background:var(--surface);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);max-height:320px;overflow-y:auto}
.picker .results:empty{display:none}
.picker .results button{all:unset;box-sizing:border-box;display:flex;flex-direction:column;width:100%;padding:8px 12px;border-top:1px solid var(--line);cursor:pointer}
.picker .results button:first-child{border-top:0}
.picker .results button:hover,.picker .results button:focus-visible{background:var(--accent-soft)}
.picker .results b{font-size:14.5px}.picker .results span{font-size:12.5px;color:var(--muted)}
.picker .chosen{min-height:40px;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 6px 0 12px;border:1px solid var(--accent);background:var(--accent-soft);border-radius:var(--r);font-size:14.5px}
.picker .chosen b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* fields share the row and wrap by the space they actually have, not the window width */
.assign-row{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end}
.assign-row>.field{flex:1 1 170px;min-width:0}
.assign-row>.picker{flex:1.6 1 230px}
.assign-row>.switch,.assign-row>.btn{flex:none}
.assign-row .switch{min-height:40px;white-space:nowrap}
@media (max-width:560px){.assign-row>.btn{flex:1 1 100%}}
.role-chip{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;min-height:28px;padding:0 10px;border-radius:4px;background:var(--sunk);font-size:13.5px;cursor:pointer;margin:2px 0 2px 4px;white-space:nowrap}
.role-chip:hover{background:var(--accent-soft)}
.role-chip.head{background:var(--accent-soft);font-weight:600}

/* ---------- workflow editor: one row per step, fixed columns so rows line up ---------- */
.steps-edit{display:flex;flex-direction:column;gap:8px;--cols:52px minmax(180px,1.3fr) minmax(170px,1fr) 300px 32px}
.steps-edit.no-cond{--cols:52px minmax(180px,1.3fr) minmax(170px,1fr) 32px}
#steps{display:flex;flex-direction:column;gap:8px}
.step-row{display:grid;grid-template-columns:var(--cols);gap:10px;align-items:center;background:var(--surface);border-radius:var(--r)}
.step-row.head{font-size:13px;color:var(--muted)}
.step-row .n{width:26px;height:26px;border-radius:50%;background:var(--accent);color:var(--accent-fg);display:grid;place-items:center;font-size:13px;font-weight:600}
.step-row .cond{display:grid;grid-template-columns:1fr 112px;gap:8px;align-items:center}
.step-row .cond .days{display:flex;gap:6px;align-items:center}
.step-row .cond .days[hidden]{display:flex!important;visibility:hidden}
.step-row .num-box{width:64px}
.drag-handle{display:flex;align-items:center;gap:6px;height:40px;padding:0 4px;border:0;background:none;cursor:grab;touch-action:none;border-radius:var(--r);color:var(--muted)}
.drag-handle:hover,.drag-handle:focus-visible{background:var(--sunk)}
.drag-handle .grip{width:8px;height:16px;background-image:radial-gradient(currentColor 1.2px,transparent 1.3px);background-size:4px 4px}
.step-row.dragging{box-shadow:var(--shadow);position:relative;z-index:5;opacity:.95}
.step-row.dragging .drag-handle{cursor:grabbing}
body.is-dragging{user-select:none;cursor:grabbing}
.icon-btn{width:32px;height:32px;display:grid;place-items:center;border:1px solid var(--line);border-radius:var(--r);background:var(--surface);color:var(--fg);cursor:pointer;font-size:15px}
.icon-btn:hover{border-color:var(--line-strong)}
.icon-btn.danger{color:var(--bad)}
@media (max-width:900px){.step-row{grid-template-columns:52px 1fr 32px;padding:8px 0;border-bottom:1px solid var(--line);border-radius:0}.step-row>.input,.step-row>.kselect,.step-row>.cond{grid-column:2}.step-row>[data-remove]{grid-column:3;grid-row:1}.step-row.head{display:none}}

/* ---------- workflow view: horizontal pipeline ---------- */
.pipeline{display:flex;align-items:stretch;gap:0;overflow-x:auto;padding-bottom:2px}
.pipeline .stage{flex:1 1 0;min-width:150px;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);padding:12px 14px;display:flex;flex-direction:column;gap:2px}
.pipeline .stage.end{background:var(--sunk);border-color:transparent}
.pipeline .stage .n{font-size:12.5px;color:var(--muted)}
.pipeline .stage b{font-size:15px;font-weight:600;line-height:1.5}
.pipeline .stage span{font-size:13px;color:var(--muted)}
.pipeline .stage .when{color:var(--warn)}
.pipeline .arrow{flex:none;width:28px;display:grid;place-items:center;color:var(--line-strong);font-size:18px}
@media (max-width:760px){.pipeline{flex-direction:column}.pipeline .arrow{width:auto;height:22px;transform:rotate(-90deg)}}
.form-2col{display:grid;grid-template-columns:1fr 1fr;gap:28px;align-items:start}
@media (max-width:900px){.form-2col{grid-template-columns:1fr;gap:18px}}
.dropzone{padding:12px 14px}
.soon-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:6px}
.type-btn.soon{background:transparent;border-style:dashed;padding:8px 12px;cursor:default;color:var(--muted)}
.type-btn.soon b{font-size:14px;font-weight:500;color:var(--fg)}
.type-btn.soon span{font-size:12.5px}
.tbl td.ellipsis{max-width:0;width:45%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.btn.xs{min-height:28px;font-size:13px;padding:0 10px}
details.menu>summary{min-height:28px}
.tbl .role-chip{min-height:24px;margin:1px 0 1px 4px}

/* ---------- themed dropdown (js/select.js); the native select stays hidden underneath ---------- */
.kselect{position:relative;display:block;min-width:0}
.toolbar .kselect,.cluster .kselect{display:inline-block}
.kselect-native{position:absolute!important;inset:0;opacity:0;pointer-events:none;width:100%!important}
.kselect-btn{display:flex!important;align-items:center;justify-content:space-between;gap:10px;text-align:start;cursor:pointer;width:100%;font:inherit;font-size:15px;color:var(--fg)}
.kselect-btn::after{content:"";flex:none;width:7px;height:7px;border-right:1.5px solid var(--muted);border-bottom:1.5px solid var(--muted);transform:translateY(-2px) rotate(45deg);transition:transform .12s}
.kselect.open .kselect-btn{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
.kselect.open .kselect-btn::after{transform:translateY(2px) rotate(-135deg)}
.kselect-btn.placeholder .kselect-text{color:var(--muted)}
.kselect>.kselect-btn.input{width:100%}  /* fill the wrapper even where .input is set to auto */
.kselect-btn:disabled{opacity:.5;cursor:default}
.kselect-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.kselect-list{position:absolute;top:calc(100% + 4px);inset-inline-start:0;z-index:40;max-height:300px;overflow-y:auto;background:var(--surface);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);padding:4px;width:max-content;max-width:min(360px,calc(100vw - 32px))}
.kselect-list.up{top:auto;bottom:calc(100% + 4px)}
.kselect-list.flip{inset-inline-start:auto;inset-inline-end:0}
.kselect-list.searchable{max-height:none;padding:0;display:flex;flex-direction:column;overflow:hidden;width:min(320px,calc(100vw - 32px))}
.kselect-list.searchable:not([hidden]){display:flex}
.kselect-search{flex:none;margin:6px;min-height:36px;padding:0 10px;border:1px solid var(--line-strong);border-radius:var(--r);background:var(--bg);color:var(--fg);font:inherit;font-size:14.5px;outline:none}
.kselect-search:focus{border-color:var(--accent);background:var(--surface)}
.kselect-options{overflow-y:auto;overscroll-behavior:contain;padding:0 4px 4px;max-height:260px}
.kselect-note{padding:8px 10px;font-size:13px;color:var(--muted)}
@media (max-width:760px){.kselect-search{font-size:16px}}  /* below 16px iPhone zooms the page on focus */
.kselect-group{font-size:12px;color:var(--muted);padding:8px 10px 2px}
.kselect-opt{padding:7px 10px;border-radius:4px;font-size:14.5px;cursor:pointer;white-space:nowrap;display:flex;align-items:center;gap:8px}
.kselect-opt.active{background:var(--sunk)}
.kselect-opt[aria-selected="true"]{font-weight:600;color:var(--accent)}
.kselect-opt[aria-selected="true"]::after{content:"";margin-inline-start:auto;width:5px;height:9px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg) translateY(-2px)}
.kselect-opt[aria-disabled="true"]{opacity:.45;cursor:default}

/* ---------- phone shell: header buttons, menu sheet, installed app ---------- */
.phone-header{padding-top:env(safe-area-inset-top,0px);height:calc(56px + env(safe-area-inset-top,0px))}
.icon-btn{width:40px;height:40px;display:grid;place-items:center;border-radius:var(--r);border:0;background:none;color:inherit;font:inherit;font-size:16px;cursor:pointer;flex:none}
.on-shell .icon-btn{color:var(--shell-fg)}
.icon-btn:hover{background:var(--sunk);text-decoration:none}
.on-shell .icon-btn:hover{background:var(--shell-hover)}
.avatar-btn{border:0;background:none;padding:0;cursor:pointer;border-radius:50%;flex:none}
.on-shell .avatar-btn .avatar{background:var(--shell-active);color:var(--shell-fg);box-shadow:0 0 0 1px var(--shell-line)}
.bottom-nav a{cursor:pointer}

/* The dialog covers the whole screen (sized from the top, so the installed iPhone app has no gap at
   the bottom); the white panel sits at the bottom of it. */
dialog.sheet{position:fixed;inset:0 0 auto 0;margin:0;width:100%;max-width:none;height:100vh;height:100dvh;max-height:none;padding:0;border:0;background:rgba(8,15,21,.5);color:var(--fg);overscroll-behavior:contain}
dialog.sheet[open]{display:flex;flex-direction:column;justify-content:flex-end}
dialog.sheet::backdrop{background:transparent}
.sheet-panel{background:var(--surface);border-radius:16px 16px 0 0;max-height:88%;display:flex;flex-direction:column;overflow:hidden;box-shadow:var(--shadow)}
dialog.sheet[open] .sheet-panel{animation:sheet-up .2s ease-out}
@keyframes sheet-up{from{transform:translateY(40px);opacity:.5}to{transform:none;opacity:1}}
@media (prefers-reduced-motion:reduce){dialog.sheet[open] .sheet-panel{animation:none}}
.sheet-head{display:flex;align-items:center;gap:12px;padding:14px 16px 12px;flex:none;outline:none}
.sheet-head .who{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.45}
.sheet-head .who b{font-size:15.5px}
.sheet-head .who span{font-size:13px;color:var(--muted)}
.sheet-head .icon-btn{background:var(--sunk);border-radius:50%;width:36px;height:36px;font-size:14px;color:var(--muted)}
.sheet-nav{overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:2px 16px 12px;display:grid;grid-template-columns:1fr 1fr;gap:8px}
.sheet-nav a{display:flex;align-items:center;justify-content:space-between;gap:6px;min-height:46px;padding:6px 12px;border-radius:var(--r-lg);background:var(--bg);color:var(--fg);font-size:14.5px;line-height:1.4;border:1px solid transparent}
.sheet-nav a:hover{text-decoration:none;border-color:var(--line-strong)}
.sheet-nav a.active{background:var(--accent-soft);border-color:var(--accent);font-weight:600}
.sheet-nav .group{grid-column:1/-1;font-size:12.5px;color:var(--muted);padding:8px 4px 0}
.sheet-foot{border-top:1px solid var(--line);padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px));display:grid;grid-template-columns:1fr 1fr;gap:8px;flex:none}
.sheet-foot form{margin:0;display:flex}
.sheet-foot .btn{width:100%;justify-content:center}
.btn.danger-outline{color:var(--bad);border-color:var(--bad);background:none}

@media (max-width:760px){
  .filters{flex-wrap:wrap;overflow:visible}
  .filters .spacer{display:none}
  .filter{min-height:34px;padding:0 12px;font-size:13.5px}
  .tabs a,.tabs button{padding:0 10px}
  .lead{font-size:14px}
  /* the bottom bar stays at the bottom of the screen even on short pages */
  .workspace,.ws-body{min-height:100dvh}
  .bottom-nav{position:sticky;bottom:0;margin-top:auto}
}

/* dashboard on the phone: stats two by two, the per-person table fits the width */
@media (max-width:760px){
  .stats{grid-template-columns:1fr 1fr}
  .stat{padding:12px 14px}
  .stat .v{font-size:22px}
  .stat .s{font-size:12.5px}
  .card{padding:14px 16px}
  .bar-row{grid-template-columns:minmax(90px,120px) 1fr 52px;gap:8px;font-size:14px}
  .people{grid-template-columns:1fr 44px 56px;min-width:0;gap:6px 12px;font-size:14px}
  .people>:nth-child(5n+2),.people>:nth-child(5n){display:none}
  .people>.muted{display:block!important}
}

/* ---------- events: one color per kind of action ---------- */
.ev-ok{--ev:var(--ok);--ev-soft:var(--ok-soft)}
.ev-warn{--ev:var(--warn);--ev-soft:var(--warn-soft)}
.ev-bad{--ev:var(--bad);--ev-soft:var(--bad-soft)}
.ev-info{--ev:var(--info);--ev-soft:var(--info-soft)}
.ev-note{--ev:var(--brass-ink);--ev-soft:var(--brass-soft)}
.ev-access{--ev:var(--teal);--ev-soft:var(--teal-soft)}
.ev-admin{--ev:var(--violet);--ev-soft:var(--violet-soft)}
.ev-login{--ev:var(--muted);--ev-soft:var(--sunk)}
.ev{box-shadow:inset -3px 0 0 var(--ev)}
[dir="ltr"] .ev{box-shadow:inset 3px 0 0 var(--ev)}
.ev-bad{background:color-mix(in srgb,var(--bad-soft) 45%,transparent)}
.ev-tag{display:inline-flex;align-items:center;flex:none;padding:0 8px;margin-inline-end:8px;border-radius:4px;font-size:12px;font-weight:600;line-height:20px;background:var(--ev-soft);color:var(--ev);white-space:nowrap;vertical-align:1px}
.ev-legend{display:flex;flex-wrap:wrap;gap:6px 14px;font-size:12.5px;color:var(--muted)}
.ev-legend span{display:inline-flex;align-items:center;gap:6px}
.ev-legend i{width:10px;height:10px;border-radius:3px;background:var(--ev)}
@media (max-width:760px){.ev-legend{gap:4px 12px;font-size:12px}}

/* ---------- list pages: the page stays still, only the list scrolls ----------
   .page.fill (phone and desktop) or .page.fill-desk (desktop only) on <main>;
   .grow = a section that takes the remaining height, .grow-list = the box whose
   .scroll-x / .scroll child scrolls, with the pager below it always in view. */
.workspace:has(.page.fill){flex:none;height:100vh;height:100dvh;min-height:0}
@media (min-width:761px){.workspace:has(.page.fill-desk){flex:none;height:100vh;min-height:0}}
.workspace:has(.page.fill) .ws-body{min-height:0;height:100%}
@media (min-width:761px){.workspace:has(.page.fill-desk) .ws-body{min-height:0;height:100%}}
.page.fill{min-height:0;overflow:hidden}
@media (min-width:761px){.page.fill-desk{min-height:0;overflow:hidden}}
.page.fill .grow,.page.fill .grow-list{flex:1 1 auto;min-height:0;display:flex;flex-direction:column}
@media (min-width:761px){.page.fill-desk .grow,.page.fill-desk .grow-list{flex:1 1 auto;min-height:0;display:flex;flex-direction:column}}
.grow-list>.scroll-x,.grow-list>.scroll{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain}
.grow-list>.pager,.grow-list>.pager-box{flex:none}
.grow-list .tbl thead th{position:sticky;top:0;z-index:2}
.grow-list .log-grid.head{position:sticky;top:0;z-index:2}
.grow-list>.scroll>*{flex-shrink:0}
details.menu .items.floating{position:fixed;top:auto;inset-inline-end:auto;z-index:60}
.pager-box{flex:none}
.pager-box:not(:has(.pager)){display:none}
@media (max-width:760px){
  .workspace:has(.page.fill) .bottom-nav{position:static;margin-top:0}
  .page.fill .phone-only.grow-list{display:flex}
  .page.fill .page-head .lead{display:none}  /* more room for the list */
}
