/* ============================================================
   Sparke Helmore — Matter workspace
   Brand: charcoal #37424a · stone #c7c2ba · blue #0885be
          orange #E07E3C · teal #006980 · green #5B8F22
   Type:  Barlow Semi Condensed (Korolev stand-in) / Open Sans /
          IBM Plex Mono for refs, codes and units
   ============================================================ */

:root {
  /* Brand core */
  --charcoal: #37424a;
  --charcoal-deep: #2c353c;
  --charcoal-deeper: #232b31;
  --stone: #c7c2ba;
  --stone-mid: #dad6cf;
  --stone-soft: #e9e6df;
  --paper: #f4f2ee;
  --card: #ffffff;

  --blue: #0885be;
  --blue-deep: #076f9e;
  --blue-tint: #e8f3f9;
  --orange: #e07e3c;
  --orange-deep: #c85a2d;
  --orange-tint: #faeee3;
  --teal: #006980;
  --teal-tint: #e2eef1;
  --green: #5b8f22;
  --green-tint: #eef3e4;
  --maroon: #a71930;
  --maroon-tint: #f8e9ec;

  /* Text */
  --text: #37424a;
  --muted: #6f7178;
  --faint: #979a9e;
  --inverse: #ffffff;

  /* Lines */
  --line: #e5e1d8;
  --line-strong: #c7c2ba;

  /* Type */
  --display: 'Barlow Semi Condensed', 'Arial Narrow', Arial, sans-serif;
  --body: 'Open Sans', 'Segoe UI', Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  /* Shape & depth — the brand is squared-off */
  --r: 0;
  --r-ctl: 2px;
  --shadow-panel: -18px 0 48px rgba(44, 53, 60, .22);
  --shadow-toast: 0 10px 34px rgba(44, 53, 60, .28);
  --shadow-pop: 0 4px 18px rgba(44, 53, 60, .10);

  --rail-w: 236px;
  --focus: 0 0 0 3px rgba(8, 133, 190, .35);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--paper);
}
::selection { background: #bfe0f0; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--stone); }
::-webkit-scrollbar-track { background: transparent; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font-family: var(--body); font-size: 14px; color: var(--text); }
a { color: var(--blue-deep); }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ============ App shell ============ */
.app { display: flex; height: 100vh; overflow: hidden; }

.rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  background: var(--charcoal-deep);
  color: rgba(255, 255, 255, .78);
  display: flex; flex-direction: column;
  padding: 26px 0 18px;
}
.rail-brand { padding: 0 22px 22px; border-bottom: 1px solid rgba(255,255,255,.12); }
.rail-logo { display: block; width: 100%; max-width: 192px; height: auto; }
.rail-kicker {
  font-family: var(--display); font-size: 12px; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase; color: var(--orange);
  margin-top: 14px;
}
.rail-nav { padding: 16px 0; display: flex; flex-direction: column; }
.rail-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 22px; border-left: 3px solid transparent;
  font-size: 13.5px; color: rgba(255,255,255,.72);
  text-align: left; width: 100%;
  transition: background .15s ease, color .15s ease;
}
.rail-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.rail-item.is-active {
  border-left-color: var(--orange); background: rgba(255,255,255,.07);
  color: #fff; font-weight: 600;
}
.rail-item.is-quiet { color: rgba(255,255,255,.42); }
.rail-item.is-quiet:hover { color: rgba(255,255,255,.62); }
.rail-item svg { flex: 0 0 16px; opacity: .8; }

.rail-foot { margin-top: auto; padding: 18px 22px 0; border-top: 1px solid rgba(255,255,255,.12); }
.rail-label {
  font-family: var(--display); font-size: 11px; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase; color: rgba(255,255,255,.45);
  margin-bottom: 10px;
}
.rail-sys { display: flex; flex-direction: column; gap: 7px; font-size: 12px; }
.rail-sys div { display: flex; align-items: center; gap: 9px; }
.rail-dot { width: 7px; height: 7px; background: #7fb544; flex: 0 0 7px; }
.rail-demo { margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); }
.rail-demo button {
  font-size: 12px; color: var(--stone); text-decoration: underline;
  text-underline-offset: 3px;
}
.rail-demo button:hover { color: #fff; }

/* ============ Main column ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 62px; flex: 0 0 62px; background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 22px; padding: 0 30px;
}
.search { flex: 0 1 360px; position: relative; }
.search input {
  width: 100%; height: 36px; border: 1px solid var(--line);
  border-radius: var(--r-ctl); background: var(--paper);
  padding: 0 12px 0 34px; font-size: 13px;
}
.search input::placeholder { color: var(--faint); }
.search svg { position: absolute; left: 11px; top: 10px; color: var(--faint); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 20px; }
.units-today {
  display: flex; align-items: baseline; gap: 7px;
  padding-right: 20px; border-right: 1px solid var(--line);
}
.units-today .n {
  font-family: var(--display); font-weight: 600; font-size: 19px; color: var(--charcoal);
}
.units-today span { font-size: 12px; color: var(--muted); }

.roleswitch { display: flex; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); overflow: hidden; }
.roleswitch button {
  padding: 7px 13px; font-family: var(--display); font-weight: 600;
  font-size: 12.5px; letter-spacing: .08em; color: var(--muted);
  background: var(--card); transition: background .15s ease, color .15s ease;
}
.roleswitch button.is-on { background: var(--charcoal); color: #fff; }
.roleswitch button:not(.is-on):hover { background: var(--paper); }

.whoami { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 34px; height: 34px; background: var(--charcoal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: .05em;
}
.avatar.is-sfe { background: var(--teal); }
.whoami-name { font-size: 13px; font-weight: 600; line-height: 1.25; }
.whoami-role { font-size: 11.5px; color: var(--muted); }

.content { flex: 1; overflow-y: auto; }
.wrap { max-width: 1340px; margin: 0 auto; padding: 34px 38px 72px; min-width: 1080px; }

/* ============ Page head ============ */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 6px; }
.pagehead h1 {
  font-family: var(--display); font-weight: 500; font-size: 36px;
  letter-spacing: .01em; color: var(--charcoal); margin: 0; line-height: 1.1;
}
.pagehead .today { font-size: 13px; color: var(--muted); }
.headrule { width: 54px; height: 3px; background: var(--orange); margin: 12px 0 28px; }

/* ============ Cards ============ */
.card { background: var(--card); border: 1px solid var(--line); }
.card + .card { margin-top: 24px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.card-title {
  font-family: var(--display); font-weight: 600; font-size: 17px;
  letter-spacing: .02em; color: var(--charcoal);
}
.card-note { font-size: 12px; color: var(--muted); }
.card-foot { padding: 13px 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 26px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack > .card + .card { margin-top: 0; }

/* ============ Up next hero ============ */
.upnext {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue);
  padding: 20px 24px; display: flex; align-items: center; gap: 24px;
}
.upnext.is-waiting { border-left-color: var(--stone); }
.upnext.is-done { border-left-color: var(--green); }
.upnext-body { flex: 1; min-width: 0; }
.upnext-kicker {
  font-family: var(--display); font-size: 12px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--blue-deep);
  margin-bottom: 6px;
}
.upnext.is-waiting .upnext-kicker { color: var(--muted); }
.upnext.is-done .upnext-kicker { color: var(--green); }
.upnext-title {
  font-family: var(--display); font-weight: 600; font-size: 22px;
  color: var(--charcoal); line-height: 1.2;
}
.upnext-title .tid { font-family: var(--mono); font-weight: 500; font-size: 14px; color: var(--faint); margin-right: 8px; }
.upnext-sub { font-size: 13px; color: var(--muted); margin-top: 5px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--display); font-weight: 600; font-size: 13px;
  letter-spacing: .09em; text-transform: uppercase;
  padding: 0 22px; height: 42px; border-radius: var(--r-ctl);
  white-space: nowrap; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-sm { height: 34px; padding: 0 15px; font-size: 12px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); }
.btn-secondary { background: transparent; color: var(--charcoal); border: 1px solid var(--charcoal); }
.btn-secondary:hover { background: var(--charcoal); color: #fff; }
.btn-ghost { color: var(--muted); padding: 0 12px; }
.btn-ghost:hover { color: var(--charcoal); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--blue); }
.btn-secondary[disabled]:hover { background: transparent; color: var(--charcoal); }

/* ============ Task list (dashboard) ============ */
.group-label {
  padding: 9px 20px; background: var(--paper);
  border-bottom: 1px solid var(--line);
  font-family: var(--display); font-size: 12px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.group-label.is-hot { color: var(--orange-deep); }
.trow {
  display: grid; grid-template-columns: 10px minmax(0, 2.1fr) minmax(0, 1.2fr) 120px 110px;
  gap: 16px; align-items: center; padding: 14px 20px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: left;
  background: var(--card); transition: background .15s ease;
}
.trow:last-child { border-bottom: 0; }
.trow:hover { background: var(--blue-tint); }
.trow.is-context .trow-task { color: var(--muted); font-weight: 400; }
.trow-dot { width: 8px; height: 8px; border-radius: 50%; }
.trow-task { font-weight: 600; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow-matter { font-size: 12px; color: var(--muted); margin-top: 2px; }
.trow-stage { font-size: 12.5px; color: var(--muted); }
.trow-due { font-size: 12.5px; color: var(--muted); }
.trow-due.is-hot { color: var(--orange-deep); font-weight: 600; }
.sys-tag {
  font-family: var(--mono); font-size: 10.5px; color: var(--charcoal);
  background: var(--stone-soft); padding: 4px 8px; justify-self: end; white-space: nowrap;
}

/* ============ Matters list ============ */
.mrow {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.1fr) 1fr 110px;
  gap: 16px; align-items: center; padding: 15px 20px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: left;
  transition: background .15s ease;
}
.mrow:last-child { border-bottom: 0; }
.mrow:hover { background: var(--blue-tint); }
.mrow-name { font-weight: 600; color: var(--charcoal); font-size: 14px; }
.mrow.is-context .mrow-name { color: var(--muted); font-weight: 400; }
.mrow-ref { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.mrow-stage { font-size: 12.5px; color: var(--muted); }
.bar { height: 4px; background: var(--stone-soft); position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--blue); }
.bar-label { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.mrow-due { text-align: right; font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--muted); }
.mrow-due.is-hot { color: var(--orange-deep); }

/* ============ Advice clock (signature) ============ */
.clock { border-top: 3px solid var(--orange); padding: 20px; }
.clock-kicker {
  font-family: var(--display); font-size: 12px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--orange-deep);
}
.clock-num { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; }
.clock-num .n {
  font-family: var(--display); font-weight: 300; font-size: 64px;
  line-height: .95; letter-spacing: -.01em; color: var(--charcoal);
}
.clock-num span { font-size: 13px; color: var(--muted); }
.clock-what { font-size: 13px; color: var(--text); margin-top: 10px; }
.ruler { display: flex; gap: 2px; margin-top: 16px; }
.ruler i { flex: 1; height: 16px; background: var(--stone-mid); }
.ruler i.is-left { background: var(--orange-tint); border: 1px solid var(--orange); }
.ruler i.is-today { background: var(--orange); border-color: var(--orange); }
.ruler-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 7px; }
.ruler-legend b { color: var(--orange-deep); font-weight: 600; }

.clock-mini { text-align: right; }
.clock-mini .clock-kicker { font-size: 11px; }
.clock-mini .row { display: flex; align-items: baseline; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.clock-mini .n {
  font-family: var(--display); font-weight: 300; font-size: 34px;
  line-height: 1; color: var(--orange-deep);
}
.clock-mini span { font-size: 12.5px; color: var(--muted); }
.clock-mini .ruler { width: 190px; margin: 10px 0 0 auto; }
.clock-mini .ruler i { height: 9px; }

/* ============ Side cards ============ */
.side-card { padding: 18px 20px; }
.side-title {
  font-family: var(--display); font-weight: 600; font-size: 15.5px;
  letter-spacing: .02em; color: var(--charcoal); margin-bottom: 10px;
}
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-of-type { border-bottom: 0; }
.kv .k { color: var(--text); }
.kv .v { font-weight: 600; white-space: nowrap; }
.kv .v.is-hot { color: var(--orange-deep); }
.kv .v.is-ok { color: var(--green); }
.kv .v.is-empty { color: var(--faint); font-weight: 400; }
.side-foot { font-size: 11.5px; color: var(--muted); margin-top: 12px; }

.time-card { background: #fbfaf8; }
.time-card .kv .v { font-family: var(--mono); font-weight: 500; font-size: 12px; }
.time-card .kv .k { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Matter header ============ */
.matterhead { background: var(--card); border-bottom: 1px solid var(--line); }
.matterhead-in { max-width: 1340px; margin: 0 auto; padding: 20px 38px 0; min-width: 1080px; }
.crumb { font-size: 12.5px; color: var(--blue-deep); margin-bottom: 10px; display: inline-flex; align-items: center; gap: 6px; }
.crumb:hover { text-decoration: underline; }
.matterhead-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 40px; }
.matterhead h1 {
  font-family: var(--display); font-weight: 500; font-size: 30px;
  color: var(--charcoal); margin: 0 0 7px; line-height: 1.1;
}
.matter-meta { display: flex; gap: 24px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.matter-meta b { color: var(--text); font-weight: 600; }
.matter-meta .ref { font-family: var(--mono); font-size: 11.5px; }

/* Stage band */
.stageband { display: flex; gap: 14px; padding: 22px 0 20px; }
.stage {
  flex: 1; border: 1px solid var(--line); padding: 13px 16px 15px;
  background: var(--card); text-align: left; transition: border-color .15s ease;
}
.stage:hover { border-color: var(--line-strong); }
.stage.is-current { border-color: var(--charcoal); box-shadow: inset 0 3px 0 var(--charcoal); }
.stage.is-done { background: var(--paper); }
.stage-top { display: flex; align-items: baseline; gap: 10px; }
.stage-num { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.stage-name { font-family: var(--display); font-weight: 600; font-size: 16px; color: var(--charcoal); }
.stage.is-done .stage-name { color: var(--muted); }
.stage-count { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.stage-count .tick { color: var(--green); font-weight: 700; }
.stage .bar { margin-top: 10px; }
.stage.is-done .bar i { background: var(--green); }

/* Tabs */
.tabs { display: flex; gap: 28px; border-top: 1px solid var(--line); }
.tab {
  padding: 13px 2px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s ease;
}
.tab:hover { color: var(--charcoal); }
.tab.is-active { color: var(--charcoal); border-bottom-color: var(--orange); }

/* ============ Workflow ledger ============ */
.ledger-stage {
  padding: 11px 20px; background: var(--paper); border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 10px;
}
.ledger-stage .num { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.ledger-stage .name {
  font-family: var(--display); font-weight: 600; font-size: 14px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--charcoal);
}
.ledger-stage .meta { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.wrow {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) 92px 140px 130px;
  gap: 16px; align-items: center; padding: 14px 20px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: left;
  background: var(--card); transition: background .15s ease;
}
.wrow:hover { background: var(--blue-tint); }
.wrow.is-locked { cursor: default; }
.wrow.is-locked:hover { background: var(--card); }
.wrow.is-ready { background: #f4fafd; box-shadow: inset 3px 0 0 var(--blue); }
.wrow.is-ready:hover { background: var(--blue-tint); }
.wrow.is-returned { box-shadow: inset 3px 0 0 var(--orange); }
.wrow-id { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.wrow-title { font-weight: 600; color: var(--charcoal); font-size: 14px; }
.wrow.is-locked .wrow-title { color: var(--muted); font-weight: 400; }
.wrow-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.wrow-sub.is-hot { color: var(--orange-deep); }
.wrow-due { font-size: 12px; color: var(--muted); }

.rolechip {
  font-family: var(--display); font-weight: 600; font-size: 11.5px;
  letter-spacing: .08em; padding: 4px 0; text-align: center;
}
.rolechip.is-bfe { background: var(--blue-tint); color: var(--blue-deep); }
.rolechip.is-sfe { background: var(--teal-tint); color: var(--teal); }
.wrow.is-locked .rolechip { opacity: .55; }

.status { justify-self: end; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; }
.status.is-done { color: var(--green); }
.status.is-ready { color: var(--blue-deep); }
.status.is-other { color: var(--teal); }
.status.is-locked { color: var(--faint); font-weight: 400; }
.status.is-returned { color: var(--orange-deep); }

/* ============ Documents / Time / Activity / Details ============ */
.drow {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 110px 110px 150px;
  gap: 16px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.drow:last-child { border-bottom: 0; }
.docicon {
  width: 34px; height: 40px; border: 1px solid var(--line-strong); background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 600; font-size: 9.5px; letter-spacing: .05em;
  color: var(--muted);
}
.docicon.is-word { color: var(--blue-deep); border-color: var(--blue); }
.docicon.is-msg { color: var(--teal); border-color: var(--teal); }
.drow-name { font-weight: 600; color: var(--charcoal); font-size: 14px; }
.drow-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drow-new {
  display: inline-block; font-family: var(--display); font-size: 10.5px; font-weight: 600;
  letter-spacing: .1em; color: var(--green); border: 1px solid var(--green);
  padding: 1px 6px; margin-left: 8px; vertical-align: 1px;
}
.drow-date { font-size: 12.5px; color: var(--muted); }

.timrow {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) 90px 110px 90px;
  gap: 16px; align-items: center; padding: 13px 20px; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.timrow:last-child { border-bottom: 0; }
.timrow-date { color: var(--muted); font-size: 12.5px; }
.timrow-units { font-family: var(--mono); font-weight: 500; font-size: 13px; }
.timrow-act { font-size: 12.5px; color: var(--muted); }
.state-tag {
  font-family: var(--display); font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: var(--green); background: var(--green-tint); padding: 4px 10px; justify-self: end;
}

.feed { padding: 6px 24px 10px; }
.feed-item { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 9px; }
.feed-dot { width: 9px; height: 9px; background: var(--blue); margin-top: 5px; }
.feed-item.is-first .feed-dot { background: var(--orange); }
.feed-text { font-size: 13.5px; color: var(--charcoal); }
.feed-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.feed-time { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 44px; padding: 22px 24px; }
.detail-item { border-bottom: 1px solid var(--line); padding-bottom: 11px; }
.detail-label {
  font-family: var(--display); font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.detail-value { font-size: 14px; color: var(--charcoal); margin-top: 5px; }
.detail-value.is-mono { font-family: var(--mono); font-size: 13px; }

/* ============ Task panel ============ */
.overlay { position: fixed; inset: 0; z-index: 40; }
.overlay-bg { position: absolute; inset: 0; background: rgba(35, 43, 49, .45); animation: fadein .25s ease both; }
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 580px;
  background: var(--card); box-shadow: var(--shadow-panel);
  display: flex; flex-direction: column;
  animation: slidein .3s cubic-bezier(.2, .7, .3, 1) both;
}
.overlay.no-anim .overlay-bg, .overlay.no-anim .panel { animation: none; }

.panel-head { padding: 22px 28px 18px; border-bottom: 1px solid var(--line); }
.panel-kicker-row { display: flex; align-items: center; justify-content: space-between; }
.panel-kicker {
  font-family: var(--display); font-size: 11.5px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.panel-kicker .tid { font-family: var(--mono); letter-spacing: 0; color: var(--charcoal); }
.panel-close { color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; }
.panel-close:hover { color: var(--charcoal); }
.panel-head h2 {
  font-family: var(--display); font-weight: 600; font-size: 24px;
  color: var(--charcoal); margin: 10px 0 8px; line-height: 1.15;
}
.panel-facts { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); }
.panel-facts b { color: var(--text); font-weight: 600; }

.panel-body { flex: 1; overflow-y: auto; padding: 22px 28px 30px; }
.panel-desc { font-size: 14px; line-height: 1.6; color: var(--text); margin: 0 0 22px; }

.mismatch {
  background: var(--orange-tint); border-left: 3px solid var(--orange);
  padding: 15px 17px; margin-bottom: 22px;
}
.mismatch-title { font-size: 13.5px; font-weight: 700; color: var(--orange-deep); margin-bottom: 4px; }
.mismatch p { font-size: 13px; color: var(--text); margin: 0 0 12px; }

.field { margin-bottom: 22px; }
.field-label-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.field-label { font-size: 13.5px; font-weight: 700; color: var(--charcoal); }
.prefill {
  font-family: var(--display); font-size: 10.5px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--teal); background: var(--teal-tint);
  padding: 2px 8px;
}
.field-help { font-size: 12.5px; color: var(--muted); margin-bottom: 9px; }
.field input[type="text"], .field input[type="email"] {
  width: 100%; height: 40px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); padding: 0 12px; background: #fff;
}
.field input[type="date"] {
  width: 220px; height: 40px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); padding: 0 12px; background: #fff;
}
.field textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  padding: 10px 12px; resize: vertical; min-height: 92px; background: #fff; line-height: 1.5;
}
.field input:focus, .field textarea:focus { border-color: var(--blue); }
.field.has-error input, .field.has-error textarea { border-color: var(--orange-deep); }
.field-error { display: none; font-size: 12.5px; color: var(--orange-deep); font-weight: 600; margin-top: 7px; }
.field.has-error .field-error { display: block; }

.choices { display: flex; flex-wrap: wrap; gap: 9px; }
.choice {
  padding: 10px 22px; border: 1px solid var(--line-strong); background: #fff;
  font-family: var(--display); font-weight: 600; font-size: 13.5px; letter-spacing: .04em;
  color: var(--text); border-radius: var(--r-ctl);
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.choice:hover { border-color: var(--charcoal); }
.choice.is-on { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }

.checklist { display: flex; flex-direction: column; gap: 4px; }
.check {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  border: 1px solid var(--line); background: #fff; font-size: 13.5px; text-align: left;
  transition: background .12s ease, border-color .12s ease;
}
.check:hover { border-color: var(--line-strong); }
.check.is-on { background: var(--blue-tint); border-color: var(--blue); }
.checkbox {
  width: 16px; height: 16px; flex: 0 0 16px; border: 1px solid var(--line-strong);
  background: #fff; color: #fff; font-size: 11px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.check.is-on .checkbox { background: var(--blue); border-color: var(--blue); }

.notebox {
  background: var(--paper); border-left: 3px solid var(--stone);
  padding: 13px 15px; font-size: 13.5px; line-height: 1.6; color: var(--text);
}
.notebox.is-doc { border-left-color: var(--blue); }

/* Precedent block */
.precedent { border: 1px solid var(--line); margin-bottom: 22px; }
.precedent-head { padding: 14px 17px; border-bottom: 1px solid var(--line); background: var(--paper); }
.precedent-kicker {
  font-family: var(--display); font-size: 11px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
.precedent-name { font-size: 14px; font-weight: 700; color: var(--charcoal); margin-top: 5px; }
.precedent-code { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.precedent-body { padding: 17px; }
.precedent-hint { font-size: 13px; color: var(--muted); margin-bottom: 13px; }
.working { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--text); }
.working i { width: 11px; height: 11px; background: var(--blue); animation: pulse 1.1s ease-in-out infinite; }
.genfile {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  border: 1px solid var(--line); padding: 12px 15px; margin-top: 12px;
}
.genfile-name { font-size: 13.5px; font-weight: 700; color: var(--charcoal); }
.genfile-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.donebar {
  display: flex; align-items: center; gap: 11px; padding: 12px 15px;
  background: var(--green-tint); font-size: 13px; color: var(--text);
}
.donebar b { color: var(--green); }

/* Time capture */
.timecap { border: 1px solid var(--stone-mid); background: #fbfaf8; padding: 17px; }
.timecap-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.timecap-kicker {
  font-family: var(--display); font-size: 11px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--charcoal);
}
.timecap-note { font-size: 11.5px; color: var(--muted); }
.timecap-grid { display: grid; grid-template-columns: minmax(0, 1fr) 118px 120px; gap: 10px; align-items: end; }
.timecap label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.timecap input {
  width: 100%; height: 38px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); padding: 0 10px; font-size: 13px; background: #fff;
}
.stepper {
  display: flex; align-items: center; height: 38px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: #fff;
}
.stepper button { width: 34px; height: 100%; color: var(--muted); font-size: 17px; }
.stepper button:hover { color: var(--charcoal); background: var(--paper); }
.stepper .val { flex: 1; text-align: center; font-family: var(--mono); font-weight: 500; font-size: 13px; }
.actbox {
  height: 38px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600; gap: 6px;
}
.actbox small { font-weight: 400; color: var(--muted); }
.timecap-foot { font-size: 11.5px; color: var(--muted); margin-top: 11px; }

/* Panel footer */
.panel-foot { border-top: 1px solid var(--line); padding: 15px 28px 17px; background: var(--card); }
.writeback { font-size: 12px; color: var(--muted); margin-bottom: 12px; display: flex; align-items: center; gap: 7px; }
.writeback svg { color: var(--faint); }
.writeback b { color: var(--text); font-weight: 600; }
.panel-actions { display: flex; gap: 10px; align-items: center; }
.panel-actions .spacer { margin-left: auto; }
.foot-hint { font-size: 12px; color: var(--orange-deep); font-weight: 600; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  z-index: 60; background: var(--charcoal-deeper); color: #fff;
  padding: 15px 22px; display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow-toast); max-width: 620px; min-width: 320px;
  animation: rise .3s cubic-bezier(.2, .7, .3, 1) both;
}
.toast.is-leaving { animation: sink .25s ease both; }
.toast-icon { color: #9fce6a; font-weight: 700; font-size: 15px; margin-top: 1px; }
.toast.is-info .toast-icon { color: var(--stone); }
.toast-title { font-size: 13.5px; font-weight: 700; }
.toast-body { font-size: 12.5px; color: rgba(255, 255, 255, .75); margin-top: 2px; }

/* ============ First-load reveal ============ */
.first-load .reveal { animation: fadeup .5s ease both; }
.first-load .reveal:nth-child(2) { animation-delay: .06s; }
.first-load .reveal:nth-child(3) { animation-delay: .12s; }

@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes sink { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, 12px); opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ============ Toolbar: in-page search + filter chips ============ */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.searchbox { position: relative; flex: 0 1 320px; }
.searchbox input {
  width: 100%; height: 38px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); background: #fff; padding: 0 12px 0 34px; font-size: 13px;
}
.searchbox svg { position: absolute; left: 11px; top: 11px; color: var(--faint); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 8px 14px; border: 1px solid var(--line-strong); background: #fff;
  font-family: var(--display); font-weight: 600; font-size: 12px;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
  border-radius: var(--r-ctl); transition: background .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--charcoal); color: var(--charcoal); }
.chip.is-on { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.chip small { font-weight: 400; letter-spacing: 0; text-transform: none; opacity: .75; margin-left: 4px; }

/* ============ Matters index ============ */
.mxrow {
  display: grid; grid-template-columns: minmax(0, 1.4fr) 105px minmax(0, 1.5fr) 130px;
  gap: 18px; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: left;
  transition: background .15s ease;
}
.mxrow:last-child { border-bottom: 0; }
.mxrow:hover { background: var(--blue-tint); }
.mxrow.is-live { box-shadow: inset 3px 0 0 var(--blue); }
.mxrow-name { font-weight: 700; color: var(--charcoal); font-size: 14.5px; }
.mxrow-ref { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.phase-tag {
  font-family: var(--display); font-weight: 600; font-size: 11.5px; letter-spacing: .06em;
  padding: 4px 0; text-align: center; background: var(--stone-soft); color: var(--charcoal);
}
.phase-tag.is-advice { background: var(--blue-tint); color: var(--blue-deep); }
.mxrow-progress { font-size: 12.5px; color: var(--muted); }
.mxrow-progress .bar { margin-top: 7px; }
.mxrow-due { text-align: right; font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--muted); }
.mxrow-due.is-hot { color: var(--orange-deep); }
.mxrow-due small { display: block; font-family: var(--body); font-weight: 400; font-size: 11.5px; color: var(--faint); margin-top: 2px; }

/* ============ Read-only matter banner ============ */
.banner-lite {
  display: flex; align-items: center; gap: 16px;
  background: var(--stone-soft); border: 1px solid var(--stone-mid);
  padding: 13px 18px; margin-bottom: 24px; font-size: 13px; color: var(--text);
}
.banner-lite b { font-weight: 700; }
.banner-lite .btn { margin-left: auto; }

/* ============ KPI tiles ============ */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 24px; }
.kpi { background: var(--card); border: 1px solid var(--line); padding: 18px 20px 16px; }
.kpi.is-lead { border-top: 3px solid var(--blue); }
.kpi-kicker {
  font-family: var(--display); font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.kpi-num {
  font-family: var(--display); font-weight: 300; font-size: 40px; line-height: 1.05;
  color: var(--charcoal); margin-top: 8px;
}
.kpi-num small { font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kpi-sub b { color: var(--green); font-weight: 700; }

/* ============ Charts ============ */
.chart-note { font-size: 12px; color: var(--muted); }
.vwrap { position: relative; margin: 22px 6px 0 0; }
.vgrid { position: absolute; inset: 0; pointer-events: none; }
.vgrid i {
  position: absolute; left: 0; right: 38px; border-top: 1px solid var(--line);
}
.vgrid span {
  position: absolute; right: 0; transform: translateY(-55%);
  font-family: var(--mono); font-size: 10px; color: var(--faint);
}
.vbars { display: flex; gap: 14px; height: 132px; align-items: flex-end; position: relative; margin-right: 38px; }
.vbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.vbar i {
  width: 100%; max-width: 44px; background: var(--blue);
  border-radius: 4px 4px 0 0; min-height: 2px;
  transition: opacity .12s ease;
}
.vbar:hover i { opacity: .85; }
.vbar.is-zero i { background: transparent; border-top: 2px solid var(--line-strong); border-radius: 0; }
.vbar.is-live i { background: var(--blue-deep); }
.vbar-val {
  font-family: var(--mono); font-size: 11px; color: var(--charcoal); font-weight: 500;
  margin-bottom: 5px;
}
.tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--charcoal-deeper); color: #fff; font-size: 11px; line-height: 1.35;
  padding: 6px 10px; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .12s ease; z-index: 5; box-shadow: var(--shadow-pop);
}
.tip b { font-family: var(--mono); font-weight: 500; }
.vbar:hover .tip, .hrow:hover .tip { opacity: 1; }
.vbars-x { display: flex; gap: 14px; margin: 8px 38px 0 0; }
.vbars-x span { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); }
.vbars-x span.is-live { color: var(--charcoal); font-weight: 700; }
.target-line { position: absolute; left: 0; right: 38px; border-top: 2px dashed var(--orange); pointer-events: none; }
.target-line em {
  position: absolute; right: 0; top: -9px; transform: translateY(-100%);
  font-style: normal; font-family: var(--display); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--orange-deep);
  background: var(--card); padding: 1px 5px;
}

.hrow { display: grid; grid-template-columns: 158px minmax(0, 1fr) 48px; gap: 14px; align-items: center; padding: 8px 0; position: relative; }
.hrow-label { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htrack { height: 15px; border-left: 1px solid var(--line-strong); position: relative; }
.htrack i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--blue); border-radius: 0 4px 4px 0; min-width: 2px; transition: opacity .12s ease; }
.hrow:hover .htrack i { opacity: .85; }
.hrow-val { font-family: var(--mono); font-size: 12px; color: var(--charcoal); text-align: right; }
.hrow .tip { left: auto; right: 0; transform: none; bottom: calc(100% - 2px); }

/* ============ Log time form ============ */
.logtime { padding: 18px 20px; }
.logtime-grid { display: grid; grid-template-columns: 132px minmax(0, 1fr) 112px 168px auto; gap: 12px; align-items: end; }
.logtime-grid.no-matter { grid-template-columns: minmax(0, 1fr) 112px 168px auto; }
.logtime label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.logtime input[type="text"] {
  width: 100%; height: 40px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); padding: 0 12px; font-size: 13.5px; background: #fff;
}
.logtime select {
  width: 100%; height: 40px; border: 1px solid var(--line-strong);
  border-radius: var(--r-ctl); padding: 0 10px; font-size: 13.5px; background: #fff;
  color: var(--text); appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236f7178' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.logtime .stepper { height: 40px; }
.logtime-error { font-size: 12.5px; color: var(--orange-deep); font-weight: 600; margin-top: 9px; display: none; }
.logtime.has-error .logtime-error { display: block; }
.logtime.has-error input[type="text"] { border-color: var(--orange-deep); }

/* Group label inside cards for time lists */
.entry-matter { font-family: var(--mono); font-size: 10.5px; color: var(--charcoal); background: var(--stone-soft); padding: 3px 7px; white-space: nowrap; justify-self: start; }

.timrow-g { display: grid; grid-template-columns: 76px minmax(0, 1fr) 110px 90px 130px 90px; gap: 14px; align-items: center; padding: 13px 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.timrow-g:last-child { border-bottom: 0; }

/* ============ First-load reveal (kept last) ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
