/* Attorney workspace. Quiet and neutral: near-black ink on white and soft gray, one
   blue accent for links and the current place. Color is kept for meaning only: red for
   late, green for done. Case stages are steps of the accent, light to full, so a matter's
   place in the pipeline still reads at a glance without a rainbow. */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f6;
  --ink: #18181b;
  --muted: #63636b;
  --line: #e4e4e7;
  --accent: #3451b2;
  --accent-ink: #ffffff;
  --accent-soft: #eef1fa;
  --citrus: #a1a1aa;
  --citrus-soft: #f1f1f3;
  --citrus-ink: #3f3f46;
  --ok: #1f7a46;
  --ok-soft: #eef6f0;
  --warn-bg: #fbf5e6;
  --warn-ink: #7a4e0a;
  --hot: #b42318;
  --hot-soft: #fdf1f0;
  --danger: #b42318;
  --focus: #3451b2;
  --mark: #fdf0b3;
  --rail-bg: #ffffff;
  --rail-ink: #18181b;
  --rail-muted: #52525b;
  --rail-hover: #f4f4f5;
  --rail-active: #efeff1;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
  /* Stage steps: one hue, lighter early, full at the end; closed goes gray */
  --st-intake: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --st-review: color-mix(in srgb, var(--accent) 35%, var(--surface));
  --st-drafting: color-mix(in srgb, var(--accent) 48%, var(--surface));
  --st-filed: color-mix(in srgb, var(--accent) 60%, var(--surface));
  --st-served: color-mix(in srgb, var(--accent) 72%, var(--surface));
  --st-negotiation: color-mix(in srgb, var(--accent) 86%, var(--surface));
  --st-final: var(--accent);
  --st-closed: #a1a1aa;
  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f11; --surface: #18181b; --surface-2: #1f1f23; --ink: #ececee; --muted: #a1a1aa; --line: #2c2c31;
    --accent: #8ea2ef; --accent-ink: #0f0f11; --accent-soft: #1e2236;
    --citrus: #71717a; --citrus-soft: #26262b; --citrus-ink: #d4d4d8;
    --ok: #6cc28a; --ok-soft: #16231b; --warn-bg: #2a2310; --warn-ink: #e8c77a;
    --hot: #f2867b; --hot-soft: #2d1816; --danger: #f2867b; --focus: #8ea2ef; --mark: #e9d27a;
    --rail-bg: #141416; --rail-ink: #ececee; --rail-muted: #a1a1aa; --rail-hover: #1f1f23; --rail-active: #26262b;
    --st-closed: #63636b;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f11; --surface: #18181b; --surface-2: #1f1f23; --ink: #ececee; --muted: #a1a1aa; --line: #2c2c31;
  --accent: #8ea2ef; --accent-ink: #0f0f11; --accent-soft: #1e2236;
  --citrus: #71717a; --citrus-soft: #26262b; --citrus-ink: #d4d4d8;
  --ok: #6cc28a; --ok-soft: #16231b; --warn-bg: #2a2310; --warn-ink: #e8c77a;
  --hot: #f2867b; --hot-soft: #2d1816; --danger: #f2867b; --focus: #8ea2ef; --mark: #e9d27a;
  --rail-bg: #141416; --rail-ink: #ececee; --rail-muted: #a1a1aa; --rail-hover: #1f1f23; --rail-active: #26262b;
  --st-closed: #63636b;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
code { font-size: 0.9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- app shell: plain sidebar on the left, stacks on top on small screens ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; background: var(--rail-bg); color: var(--rail-ink); border-right: 1px solid var(--line); }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 1rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; color: var(--rail-ink); text-decoration: none; padding: 0 6px; }
.brand-mark { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: var(--ink); color: var(--surface); font-size: 0.95rem; }
.rail-search input { width: 100%; padding: 8px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); color: var(--rail-ink); }
.rail-search input::placeholder { color: var(--rail-muted); }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--rail-muted); text-decoration: none; font-weight: 500; }
.rail-nav a:hover { background: var(--rail-hover); color: var(--rail-ink); }
.rail-nav a[aria-current] { background: var(--rail-active); color: var(--rail-ink); font-weight: 600; }
.ico { width: 20px; text-align: center; opacity: 0.6; }
.signout { margin: auto 0 0; padding: 0 10px; }
.rail .linklike { color: var(--rail-muted); }
.rail .linklike:hover { color: var(--rail-ink); }
.app-bare { grid-template-columns: 1fr; }
.app-bare .rail { position: static; height: auto; flex-direction: row; background: var(--rail-bg); }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { min-width: 0; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; }
  .rail-search { order: 3; flex: 1 1 100%; }
  .rail-nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 4; }
  .rail-nav a { white-space: nowrap; padding: 7px 10px; }
  .signout { margin: 0 0 0 auto; padding: 0; }
}

.page { max-width: 1280px; width: 100%; margin: 0 auto; padding: 24px 28px 72px; min-width: 0; }
@media (max-width: 600px) { .page { padding: 16px 16px 56px; } }
.page-title { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; margin: 4px 0 16px; letter-spacing: -0.02em; }
.lede { color: var(--muted); margin: -8px 0 20px; max-width: 70ch; }
.eyebrow { margin: 0; color: var(--muted); font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 600; }
.eyebrow a { color: inherit; }

.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); font-weight: 600; overflow-wrap: anywhere; }
.flash-error { background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- stage colors ---------- */
.stage-intake { --st: var(--st-intake); } .stage-review { --st: var(--st-review); } .stage-drafting { --st: var(--st-drafting); }
.stage-filed { --st: var(--st-filed); } .stage-served { --st: var(--st-served); } .stage-negotiation { --st: var(--st-negotiation); }
.stage-final { --st: var(--st-final); } .stage-closed { --st: var(--st-closed); }
.stage-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0; text-transform: none;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; font-weight: 600; }
.stage-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--st, var(--muted)); }

/* ---------- Today ---------- */
.hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px 32px; padding: 4px 0 20px; margin-bottom: 20px; color: var(--ink);
  border-bottom: 1px solid var(--line); }
.hero-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 2.6vw, 2rem); margin: 6px 0 0; max-width: 28ch; line-height: 1.2; letter-spacing: -0.02em; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { display: grid; min-width: 104px; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; border: 1px solid var(--line); }
.stat:hover { border-color: var(--muted); }
.stat-n { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.stat-citrus .stat-n { color: var(--ink); }
.stat-hot .stat-n { color: var(--hot); }

.pipeline { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
@media (max-width: 1000px) { .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pipe { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: inset 0 3px 0 var(--st); text-decoration: none; color: var(--ink); }
.pipe:hover { background: var(--surface-2); }
.pipe-n { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; line-height: 1.1; }
.pipe-l { font-size: 0.78rem; color: var(--muted); font-weight: 600; }

.dash { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .dash { grid-template-columns: 1fr; } }
.dash-main, .dash-side { display: grid; gap: 16px; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.card-hot { border-color: color-mix(in srgb, var(--hot) 35%, var(--line)); }
.card-hot .card-title { color: var(--hot); }
.card-citrus { background: var(--surface); }
.count { display: inline-block; min-width: 22px; text-align: center; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font: 700 0.78rem var(--font-body); }

.items { list-style: none; margin: 0; padding: 0; }
.item { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item-main { flex: 1 1 200px; min-width: 0; }
.item > .due { margin-left: auto; }
.item-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.item-meta { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.item.is-done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.tick-form, .del-form, form.inline { margin: 0; display: inline; }
.tick { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface); color: #fff; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.tick-task { border-radius: 7px; }
.tick:hover { background: var(--accent-soft); }
.is-done .tick { background: var(--ok); border-color: var(--ok); }
.icon-button { border: 0; background: none; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.icon-button:hover { color: var(--danger); background: var(--hot-soft); }
.due { flex: none; font-size: 0.78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.due-overdue { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.due-today { background: var(--hot); color: var(--surface); border-color: transparent; }
.due-soon { background: var(--citrus-soft); color: var(--citrus-ink); border-color: transparent; }
.due-done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag { font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag-rule { background: var(--surface-2); color: var(--ink); cursor: help; }
.tag-hot { background: var(--hot-soft); color: var(--hot); }
.plain { list-style: none; margin: 0 0 10px; padding: 0; }
.plain li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.plain li:first-child { border-top: 0; }
.plain .when { margin-left: auto; }
.when { color: var(--muted); font-size: 0.82rem; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }

.timeline { list-style: none; margin: 12px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 12px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline li.tl-note::before { background: var(--muted); border-color: var(--muted); }
.timeline .tl-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li.tl-note .tl-text { background: var(--citrus-soft); padding: 8px 10px; border-radius: 8px; }
.timeline .when { margin: 2px 0 0; }
.timeline.compact li { padding-bottom: 8px; font-size: 0.88rem; }
.timeline.compact .tl-text { display: inline; white-space: normal; background: none; padding: 0; }
.timeline.compact a { font-weight: 700; }

/* ---------- matter header and section list ---------- */
.matter-head { margin: 4px 0 20px; }
.matter-title { font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; margin: 6px 0 4px; letter-spacing: -0.01em; }
.matter-meta { margin: 0; color: var(--muted); }

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1060px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout-overview > .sections { order: 2; }
}

.sections { position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
@media (max-width: 1060px) { .sections { position: static; } }
.side-link { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 700; }
.side-link:hover { background: var(--surface-2); }
.side-link.is-active { background: var(--accent); color: var(--accent-ink); }
.sections-label { margin: 12px 10px 6px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.sections ol { list-style: none; margin: 0; padding: 0; }
.sections ol a { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.sections ol a:hover { background: var(--surface-2); }
.sections ol a[aria-current] { background: var(--accent-soft); font-weight: 700; }
.mark { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); font-size: 0.72rem; font-weight: 700; color: var(--citrus-ink); background: var(--surface); }
.is-confirmed .mark { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.sec-title { flex: 1; min-width: 0; }
.progress-line { margin: 12px 8px 4px; color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; }

/* ---------- matter overview ---------- */
.overview { display: grid; gap: 16px; min-width: 0; }
.stepper { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
@media (max-width: 800px) { .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.step { display: grid; justify-items: start; gap: 6px; padding: 8px 8px 9px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.step:hover { background: var(--surface-2); color: var(--ink); }
.step-dot { width: 100%; height: 6px; border-radius: 3px; background: var(--line); }
.step.is-past .step-dot { background: color-mix(in srgb, var(--st) 55%, var(--line)); }
.step.is-current { background: color-mix(in srgb, var(--st) 14%, var(--surface)); color: var(--ink); }
.step.is-current .step-dot { background: var(--st); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st) 25%, transparent); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 4px; }
.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (max-width: 700px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { display: grid; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
a.tile:hover { border-color: var(--accent); }
.tile-l { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; color: var(--muted); }
.tile-n { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; line-height: 1.15; }
.tile-n small { font-size: 0.95rem; color: var(--muted); }
.tile-s { font-size: 0.8rem; color: var(--muted); }
.bar { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.bar-alt > span { background: var(--accent); }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1200px) { .cols { grid-template-columns: 1fr; } }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.add-row .input:first-of-type { grid-column: span 2; }
.note-form { display: grid; gap: 8px; justify-items: start; }
.sub-head { margin: 16px 0 0; font-weight: 700; }
.mini { margin-top: 8px; font-size: 0.85rem; }
.mini summary { cursor: pointer; color: var(--muted); }
.mini .plain li { justify-content: flex-start; }

.callout { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 16px; }
.callout p { margin: 0; }
.callout ul { margin: 8px 0 0; padding-left: 20px; columns: 2 220px; }
.callout .button { margin-top: 10px; }
.callout-warn { background: var(--warn-bg); color: var(--warn-ink); }
.callout-warn a { color: inherit; font-weight: 700; }
.callout-hot { background: var(--hot-soft); color: var(--hot); border: 1px solid color-mix(in srgb, var(--hot) 35%, transparent); margin: 0; }
.callout-hot ul { columns: 1; }
.callout-hot a { color: inherit; font-weight: 700; }
.callout-ok { background: var(--ok-soft); color: var(--ok); }
.callout.inline { margin: 0; padding: 8px 12px; }

/* ---------- panels and review forms ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px 24px; min-width: 0; box-shadow: var(--shadow); }
@media (max-width: 600px) { .panel { padding: 16px; } }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; margin-bottom: 16px; }
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; margin: 2px 0 0; }
.badge { margin: 0; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }

.group { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 16px 0 8px; min-width: 0; }
.group-title { padding: 0; font-weight: 700; font-size: 1rem; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.forms { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px 16px; margin-top: 10px; }
.w-full { grid-column: span 8; } .w-half { grid-column: span 4; } .w-quarter { grid-column: span 2; } .w-eighth { grid-column: span 1; }
@media (max-width: 600px) { .w-half, .w-quarter { grid-column: span 8; } .w-eighth { grid-column: span 4; } }
.field { min-width: 0; }
.field[hidden], .group[hidden] { display: none; }
.field-label { display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 4px; }
.sub-label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 3px; }
.optional { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.input { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 38px; }
textarea.input { resize: vertical; }
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.money { display: flex; align-items: center; gap: 6px; }
.money-freq { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; max-width: 520px; }
fieldset.address, fieldset.checklist { border: 0; padding: 0; margin: 0; min-width: 0; }
.checklist { display: grid; gap: 4px 16px; }
.checklist.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) { .checklist.cols-2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.computed { margin: 0; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; }
.computed .field-label { display: inline; margin-right: 6px; }
.client-said { margin: 4px 0 0; font-size: 0.8rem; color: var(--citrus-ink); }
.client-said::before { content: "Changed. "; font-weight: 700; }

.repeater .count { min-width: 20px; }
.rows { display: grid; gap: 10px; }
.row-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 14px; background: var(--surface-2); }
.row-head { display: flex; justify-content: space-between; align-items: center; }
.row-title { font-weight: 700; font-size: 0.9rem; }
.row-card .grid { margin-top: 6px; }
.empty-note { color: var(--muted); margin: 4px 0; }

.button { display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center; white-space: nowrap; }
.button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
.button.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.button:hover { filter: brightness(1.07); }
.button.secondary:hover { border-color: var(--accent); }
.link-button { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: none; }
.link-button.danger { color: var(--danger); }
.form-actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  margin: 16px -24px -24px; padding: 14px 24px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.form-actions .hint { margin: 0; flex: 1 1 260px; }
@media (max-width: 600px) { .form-actions { margin: 16px -16px -16px; padding: 12px 16px; } }
.pager { display: flex; gap: 16px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- matters list, board, search ---------- */
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.view-toggle { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.view-toggle a { padding: 5px 14px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 0.88rem; }
.view-toggle a[aria-current] { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.chip span:last-child { color: var(--muted); font-weight: 700; }
.chip:hover { border-color: var(--st, var(--accent)); }
.chip.is-on { background: color-mix(in srgb, var(--st, var(--accent)) 16%, var(--surface)); border-color: var(--st, var(--accent)); }

table.matters, table.tracker { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.matters th, .matters td, .tracker th, .tracker td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.matters tbody tr:last-child td, .tracker tbody tr:last-child th, .tracker tbody tr:last-child td { border-bottom: 0; }
.matters thead th, .tracker thead th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.matters tbody tr:hover { background: var(--surface-2); }
.matters td a { font-weight: 700; }
.matters .sub { display: block; color: var(--muted); font-size: 0.8rem; }
.matters .sub-strong { display: block; font-size: 0.86rem; font-weight: 600; margin-bottom: 3px; }
.matters tr.is-adverse td:first-child { box-shadow: inset 4px 0 0 var(--hot); }
@media (max-width: 760px) {
  table.matters, .matters tbody, .matters tr, .matters td { display: block; }
  .matters thead { display: none; }
  .matters tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .matters td { border: 0; padding: 4px 14px; }
}
.tracker tbody th { font-weight: 600; font-size: 0.9rem; }
.tracker td { width: 26%; }
.client-col { margin-top: 6px; font-size: 0.84rem; font-weight: 400; }
.client-status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 0.76rem; background: var(--surface-2); color: var(--muted); }
.client-status.client-have { background: var(--ok-soft); color: var(--ok); }
.client-status.client-later, .client-status.client-help { background: var(--citrus-soft); color: var(--citrus-ink); }
.client-file { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.client-note { margin: 4px 0 0; color: var(--muted); font-style: italic; }
.tracker select { min-height: 34px; font-size: 0.86rem; font-weight: 600; }
.tracker .status-served, .tracker .status-received { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tracker .status-requested { background: var(--citrus-soft); color: var(--citrus-ink); border-color: transparent; }
.tracker .status-incomplete { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.tracker .status-na { color: var(--muted); background: var(--surface-2); }
@media (max-width: 700px) {
  table.tracker, .tracker tbody, .tracker tr, .tracker th, .tracker td { display: block; width: auto; }
  .tracker thead { display: none; }
  .tracker tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .tracker th, .tracker td { border: 0; padding: 4px 14px; }
}

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.lane { background: color-mix(in srgb, var(--st) 7%, var(--bg)); border-radius: var(--radius); padding: 10px; border-top: 4px solid var(--st); min-height: 140px; }
.lane-title { margin: 2px 4px 10px; font-size: 0.88rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.lane-card { display: grid; gap: 4px; justify-items: start; padding: 10px 12px; margin-bottom: 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.lane-card:hover { border-color: var(--st); }
.lane-name { font-weight: 700; }
.lane-meta { font-size: 0.8rem; color: var(--muted); }
.lane-card .due { white-space: normal; }
.lane-empty { margin: 4px; color: var(--muted); font-size: 0.85rem; }

.search-big { display: flex; gap: 8px; max-width: 640px; margin-bottom: 18px; }
.search-big .input { flex: 1; min-height: 46px; font-size: 1.05rem; border-radius: 12px; }
.result-line { margin: 0 0 10px; }

.meter { display: inline-block; width: 64px; height: 6px; border-radius: 3px; vertical-align: middle; margin-right: 8px;
  background: linear-gradient(90deg, var(--ok) var(--done), var(--line) var(--done)); }
.empty { color: var(--muted); padding: 24px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.import { margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.import summary { cursor: pointer; font-weight: 700; }
.import-form { display: grid; gap: 8px; margin-top: 12px; }
.import-actions { display: flex; flex-wrap: wrap; gap: 16px; }
.file-pick input { width: 0; height: 0; opacity: 0; position: absolute; }
.sample-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.sample-form .hint { margin: 0; }

/* ---------- documents ---------- */
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px 24px; padding: 14px 0; border-top: 1px solid var(--line); }
.doc-main { flex: 1 1 320px; min-width: 0; }
.doc-title { margin: 0; font-weight: 700; }
.doc-meta, .doc-note { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.versions { margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.88rem; }
.versions li { padding: 2px 0; overflow-wrap: anywhere; }

.save-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; padding: 12px 16px; margin-bottom: 20px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.save-bar > div { flex: 1 1 320px; min-width: 0; }
.save-name { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

/* The document itself: always black on white, like the printed page. */
.preview-panel { background: var(--surface); }
.paper { max-width: 8.5in; margin: 0 auto; padding: 1in; background: #fff; color: #000; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08);
  font-family: "Times New Roman", Times, serif; font-size: 12pt; line-height: 1.2; overflow-wrap: break-word; }
@media (max-width: 700px) { .paper { padding: 0.5in 0.35in; font-size: 11pt; overflow-x: auto; } }
.paper p { margin: 0; }
.paper .tab { display: inline-block; width: 0.5in; }
.paper mark.blank { background: var(--mark); color: #000; }
.paper .doc-table { width: 100%; border-collapse: collapse; margin: 0 0 4pt; }
.paper .doc-table td { border: 1px solid #000; padding: 2pt 5pt; vertical-align: top; font-size: 11pt; }
.paper .doc-table tr:first-child td { font-weight: bold; }
.paper-footer { margin-top: 36pt !important; font-size: 9pt; color: #333; }

.settings-form .grid { margin-bottom: 16px; }
.login { max-width: 420px; margin: 48px auto; }
.login .field { margin-bottom: 16px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.linklike:hover { color: var(--ink); }

/* Related contacts */
.tag-own { background: var(--ok-soft); color: var(--ok); }
.add-person { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.add-person summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.add-person .button { margin-top: 12px; }
.tag-line { display: block; margin: 2px 0; }
.contacts-table td { vertical-align: top; }

/* ---------- workflow builder ---------- */
.wf-lane.stage-dates { --st: var(--accent); } .wf-lane.stage-events { --st: var(--muted); }
.timeline li.tl-auto::before { background: var(--accent-soft); border-color: var(--accent); }
.card-alerts { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.alert-bolt { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 0.8rem; }
.alert-email { margin-top: 6px; }
.alert-email-body { white-space: pre-wrap; margin: 6px 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.88rem; }
.alert-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.alert-actions .button { padding: 6px 12px; font-size: 0.85rem; }

.wf-howto { list-style: none; margin: 16px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.wf-howto li { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 0.9rem; }
.wf-howto-n, .wf-part-n { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 0.85rem; }
.wf-part-opt { background: var(--line); color: var(--muted); }
.wf-status { min-height: 1.4em; margin: 0 0 8px; font-size: 0.88rem; color: var(--muted); }
.wf-status.is-ok { color: var(--ok); font-weight: 600; }
.wf-status.is-error { color: var(--danger); font-weight: 600; }

.wf-flow { display: flex; flex-direction: column; gap: 0; position: relative; }
.wf-lane { position: relative; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px 18px; padding: 14px 0 14px 0; border-top: 1px dashed var(--line); }
.wf-lane:first-child { border-top: 0; }
.wf-lane.is-over { background: color-mix(in srgb, var(--st) 10%, transparent); border-radius: var(--radius); outline: 2px dashed var(--st); outline-offset: -2px; }
.wf-lane-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; align-content: flex-start; }
.wf-lane-dot { flex: none; width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; background: var(--st); box-shadow: 0 0 0 4px color-mix(in srgb, var(--st) 20%, transparent); }
.wf-lane-head > div { flex: 1 1 120px; min-width: 0; }
.wf-lane-eyebrow { margin: 0; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.wf-lane-title { margin: 0; font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; }
.wf-add { margin-left: 24px; }
.wf-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; align-items: start; }
.wf-lane-empty { margin: 0; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 0.88rem; }
.wf-card { position: relative; padding: 12px 14px 12px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); min-width: 0; }
.wf-card::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--st); }
.wf-card[draggable="true"] { cursor: grab; }
.wf-card.is-dragging { opacity: 0.5; }
.wf-card.is-off { background: var(--surface-2); box-shadow: none; }
.wf-card.is-off .wf-name, .wf-card.is-off .wf-steps { opacity: 0.55; }
.wf-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wf-when { margin: 0; font-size: 0.78rem; color: var(--muted); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.wf-name { margin: 4px 0 6px; font-size: 0.98rem; }
.wf-open { all: unset; cursor: pointer; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.wf-open:hover { color: var(--accent); text-decoration: underline; }
.wf-open:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.wf-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.86rem; }
.wf-steps li { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; min-width: 0; }
.wf-ico { flex: none; width: 18px; text-align: center; color: var(--st); font-weight: 700; }
.wf-if { margin: 8px 0 0; font-size: 0.78rem; color: var(--warn-ink); background: var(--warn-bg); padding: 3px 8px; border-radius: 6px; display: inline-block; }
.wf-empty { margin: 0; color: var(--muted); font-size: 0.85rem; }
.wf-switch { position: relative; flex: none; display: inline-flex; cursor: pointer; }
.wf-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.wf-switch-track { width: 36px; height: 20px; border-radius: 999px; background: var(--line); transition: background 0.15s; position: relative; }
.wf-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.wf-switch input:checked + .wf-switch-track { background: var(--ok); }
.wf-switch input:checked + .wf-switch-track::after { transform: translateX(16px); }
.wf-switch input:focus-visible + .wf-switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.wf-reset { margin-top: 24px; }
@media (max-width: 760px) {
  .wf-lane { grid-template-columns: minmax(0, 1fr); }
  .wf-add { margin-left: auto; }
}

.wf-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2); }
.wf-dialog::backdrop { background: rgba(24, 24, 27, 0.4); }
.wf-editor { padding: 18px 22px 20px; display: flex; flex-direction: column; gap: 14px; }
.wf-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wf-examples { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; border-radius: var(--radius); background: var(--accent-soft); }
.wf-examples .sub-head { flex: 1 1 100%; margin: 0 0 2px; font-size: 0.85rem; }
.wf-examples .chip { cursor: pointer; }
.wf-part { margin: 0; padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.wf-part legend { display: flex; align-items: center; gap: 8px; padding: 0 6px; font-weight: 700; font-size: 1rem; }
.wf-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.wf-choice { position: relative; display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 0.88rem; font-weight: 600; cursor: pointer; }
.wf-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.wf-choice.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wf-choice:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.wf-sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wf-sentence .input, .wf-step-body .input { width: auto; max-width: 100%; }
.wf-full { flex: 1 1 100%; margin: 0; }
.wf-num { width: 5.5em !important; }
.wf-text { flex: 1 1 260px; min-width: 0; width: 100% !important; }
.wf-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.wf-step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wf-step { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.wf-step-n { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-top: 8px; border-radius: 50%; background: var(--line); font-size: 0.78rem; font-weight: 700; }
.wf-step-body { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wf-step-tools { flex: none; display: flex; flex-direction: column; }
.wf-step-tools .icon-button:disabled { opacity: 0.3; cursor: default; background: none; color: var(--muted); }
.wf-modes { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.88rem; }
.wf-add-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.wf-add-steps .chip { cursor: pointer; }
.wf-add-steps .hint { margin: 0; }
.wf-summary { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--ok-soft); color: var(--ink); font-size: 0.9rem; }
.wf-summary::before { content: "In plain words: "; font-weight: 700; }
.wf-editor-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.wf-spacer { flex: 1 1 auto; }
@media (max-width: 600px) {
  .wf-editor { padding: 14px 14px 16px; }
  .wf-step { flex-wrap: wrap; }
  .wf-step-tools { flex-direction: row; margin-left: auto; }
}
.wf-inline .input { color: var(--ink); font-size: 0.95rem; }
.wf-inline.wf-full { display: flex; flex-wrap: nowrap; align-items: flex-start; }
.wf-inline.wf-full > :first-child { flex: none; width: 4.2em; padding-top: 8px; }
.wf-editor-head .card-title { font-size: 1.35rem; }
