:root {
  --bg: #f5f3ee;
  --paper: #fffefa;
  --paper-2: #faf8f2;
  --ink: #1d1c19;
  --ink-2: #47443d;
  --muted: #625d54;
  --faint: #857f74;
  --line: #ddd8cc;
  --line-soft: #ebe7dd;
  --line-strong: #bdb6a6;
  --brand: #7c3529;
  --brand-dark: #5f281f;
  --ok: #2f654a;
  --warn: #92591b;
  --danger: #9a3430;
  --blue: #365d7c;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, "Liberation Mono", monospace;
  --r: 3px;
}
html[data-theme="plain"] {
  --bg: #f4f5f6; --paper: #ffffff; --paper-2: #fafbfc; --ink: #1b1e23; --ink-2: #3f454d;
  --muted: #5b626c; --faint: #7b828c; --line: #dfe3e8; --line-soft: #eceff2; --line-strong: #b9c0c8;
  --brand: #2f5d7c; --brand-dark: #234a63; --ok: #2f6b4f; --warn: #8a5b18; --danger: #a13b35; --blue: #2f5d7c;
}
html[data-theme="paper"] {
  --bg: #f5f3ee; --paper: #fffefa; --paper-2: #faf8f2; --ink: #1d1c19; --ink-2: #47443d;
  --muted: #625d54; --faint: #857f74; --line: #ddd8cc; --line-soft: #ebe7dd; --line-strong: #bdb6a6;
  --brand: #7c3529; --brand-dark: #5f281f; --ok: #2f654a; --warn: #92591b; --danger: #9a3430; --blue: #365d7c;
}
html[data-theme="sage"] {
  --bg: #eef1ec; --paper: #fbfcf8; --paper-2: #f4f7f1; --ink: #20251f; --ink-2: #3f473d;
  --muted: #5d675b; --faint: #7d877a; --line: #d8ded4; --line-soft: #e8ece4; --line-strong: #b8c2b2;
  --brand: #3f6242; --brand-dark: #304d33; --ok: #356b4b; --warn: #8a5b18; --danger: #9a3430; --blue: #3f5f74;
}
html[data-theme="slate"] {
  --bg: #eef1f4; --paper: #fbfcfd; --paper-2: #f5f7f9; --ink: #1b222b; --ink-2: #39434f;
  --muted: #59636f; --faint: #7b8591; --line: #d5dde4; --line-soft: #e6ebf0; --line-strong: #b5c0ca;
  --brand: #33556f; --brand-dark: #27465c; --ok: #2f654a; --warn: #8a5b18; --danger: #9a3430; --blue: #33556f;
}
html[data-theme="night"] {
  --bg: #17181b; --paper: #202227; --paper-2: #24262b; --ink: #ecebe7; --ink-2: #c9c7bf;
  --muted: #a9a69e; --faint: #827f77; --line: #35383e; --line-soft: #2c2f34; --line-strong: #555a63;
  --brand: #d08a74; --brand-dark: #e0a48f; --ok: #7fbf9a; --warn: #d9a25e; --danger: #e07a72; --blue: #8bb8d8;
}
html[data-theme="night"] .field input:focus, html[data-theme="night"] .field select:focus, html[data-theme="night"] .field textarea:focus { background: #262a30; }
html[data-theme="night"] .case-row:hover, html[data-theme="night"] .task:hover, html[data-theme="night"] .doc-row:hover { background: #262a30; }
html[data-theme="night"] .task.is-overdue { background: #302322; }
html[data-theme="night"] .inbox-related { background: #2b271f; border-color: #5a4a2a; }
html[data-theme="night"] .modal-foot { background: #1c1e22; }
html[data-theme="night"] .toast { background: #2a2d33; }
html[data-theme="night"] .mark { background: #ecebe7; color: #17181b; }
html[data-theme="night"] .sidebar { background: #1b1d21; }
html[data-theme="night"] .topbar { background: rgba(27,29,33,.96); }
html[data-theme="night"] .search { background: #24272c; }
html[data-theme="night"] .search:focus-within { background: #2a2e34; }
html[data-theme="night"] .nav-item:hover, html[data-theme="night"] .user-menu button:hover { background: #2a2d33; }
html[data-theme="night"] .nav-item.is-on { background: #30343b; }
html[data-theme="night"] .nav-count { background: #3a3e45; color: var(--ink-2); }
html[data-theme="night"] .nav-item.is-on .nav-count { background: #444952; }
html[data-theme="large"] {
  --bg: #f7f7f4; --paper: #ffffff; --paper-2: #f8f8f5; --ink: #141414; --ink-2: #333333;
  --muted: #4f4f4a; --faint: #6f6f68; --line: #d9d9d2; --line-soft: #e9e9e3; --line-strong: #b8b8ae;
  --brand: #2f5d7c; --brand-dark: #234a63; --ok: #2f654a; --warn: #8a5b18; --danger: #9a3430; --blue: #2f5d7c;
}
html[data-theme="large"] body { font-size: 15px; }
html[data-theme="large"] .page-title { font-size: 30px; }
html[data-theme="large"] .task-title, html[data-theme="large"] .case-name { font-size: 15.5px; }
html[data-theme="large"] .task-meta, html[data-theme="large"] .case-meta, html[data-theme="large"] .kpi-foot { font-size: 12px; }
.theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-card { text-align: left; border: 1px solid var(--line); background: var(--paper); padding: 10px; border-radius: var(--r); cursor: pointer; }
.theme-card:hover { border-color: var(--line-strong); }
.theme-card.is-on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.theme-swatch { display: flex; gap: 3px; height: 28px; border: 1px solid var(--line); padding: 3px; margin-bottom: 7px; }
.theme-swatch i { flex: 1; display: block; }
.theme-card b { display: block; font-size: 12px; font-weight: 600; }
.theme-card small { display: block; color: var(--faint); font-size: 10.5px; margin-top: 2px; line-height: 1.4; }
@media (max-width: 700px) { .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 13.5px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
::selection { background: #e6d3ca; }
:focus-visible { outline: 2px solid rgba(124,53,41,.28); outline-offset: 1px; }

/* ---------- shared ---------- */
.mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 2px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; line-height: 1;
}
.mark-sm { width: 22px; height: 22px; font-size: 12px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: #e9e4d9; color: var(--ink-2);
  font-size: 12px; font-weight: 600; flex: 0 0 auto;
}
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 11.5px; letter-spacing: -.01em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.hr { border: 0; border-top: 1px solid var(--line-soft); margin: 22px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 11px; border: 1px solid var(--line-strong);
  border-radius: var(--r); background: var(--paper); color: var(--ink);
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.btn:hover { background: #f7f4ec; border-color: #a9a191; text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #34312b; border-color: #34312b; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #d8bcb7; }
.btn-danger:hover { background: #fbf2f0; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #ebe7dd; border-color: transparent; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 11.5px; }
.btn-block { width: 100%; height: 34px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 0; background: transparent; border-radius: 50%; }
.icon-btn:hover { background: #eae5da; }
.icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.icon-sm { width: 13px; height: 13px; }
.nav-ico { width: 15px; height: 15px; display: inline-flex; margin-right: 9px; opacity: .72; }
.nav-ico svg, .search-ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.link { border: 0; background: transparent; padding: 0; color: var(--brand); font-size: 12px; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }
.kicker { font: 600 10.5px/1.4 var(--mono); letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line-soft); }
.empty b { display: block; color: var(--ink-2); font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 1.5px solid var(--line-strong); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: #f2efe7; }
.login-box { width: 100%; max-width: 360px; padding: 34px 34px 30px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 1px 0 rgba(29,28,25,.03); }
.login-brand { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.login-org { margin: 16px 0 0; color: var(--faint); font-size: 11.5px; letter-spacing: .04em; }
.login-title { margin: 28px 0 4px; font-size: 21px; font-weight: 600; letter-spacing: .02em; }
.login-note { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn-block { margin-top: 34px; }
.login-foot { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 11px; line-height: 1.7; }
.form-error { min-height: 18px; margin: -2px 0 8px; color: var(--danger); font-size: 11.5px; }

/* ---------- shell ---------- */
.app { min-height: 100dvh; }
.sidebar {
  position: fixed; z-index: 20; inset: 0 auto 0 0; width: 216px;
  display: flex; flex-direction: column; padding: 20px 14px 14px;
  background: #f0ede5; border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 6px 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text b { font-size: 12.5px; font-weight: 600; letter-spacing: .01em; }
.brand-text em { font-style: normal; color: var(--faint); font-size: 10.5px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  position: relative; display: flex; align-items: center; width: 100%; height: 32px;
  padding: 0 9px; border: 0; border-radius: 2px; background: transparent;
  color: var(--ink-2); font-size: 12.5px; text-align: left;
}
.nav-item:hover { background: #e8e4da; color: var(--ink); }
.nav-item.is-on { background: #e4dfd3; color: var(--ink); font-weight: 600; }
.nav-item.is-on::before { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 2px; background: var(--brand); }
.nav-item.is-on .nav-ico { opacity: 1; }
.nav-count { margin-left: auto; min-width: 17px; height: 16px; padding: 0 4px; border-radius: 8px; background: #d8d1c3; color: var(--ink-2); font: 10px/16px var(--mono); text-align: center; }
.nav-item.is-on .nav-count { background: #d0c7b6; }
.app > .main { min-height: 100dvh; margin-left: 216px; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; height: 52px; flex: 0 0 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 32px; background: rgba(255,254,250,.96); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.crumb { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 12px; color: var(--faint); white-space: nowrap; }
.crumb b { color: var(--ink-2); font-weight: 500; }
.crumb .sep { color: var(--line-strong); }
.crumb span:last-child { overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { display: flex; align-items: center; gap: 10px; }
.user-menu-wrap { position: relative; }
.user-menu { position: absolute; z-index: 45; top: calc(100% + 8px); right: 0; width: 196px; padding: 5px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 3px; box-shadow: 0 14px 36px rgba(20,19,17,.16); }
.user-menu-head { padding: 8px 10px 9px; margin-bottom: 4px; border-bottom: 1px solid var(--line-soft); }
.user-menu-head b { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-head span { display: block; margin-top: 2px; color: var(--faint); font-size: 10.5px; }
.user-menu button { display: block; width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: 2px; background: transparent; color: var(--ink-2); font-size: 12px; text-align: left; }
.user-menu button:hover { background: var(--paper-2); color: var(--ink); }
.user-menu button.danger { color: var(--danger); }
.search { position: relative; display: flex; align-items: center; width: 260px; height: 30px; border: 1px solid var(--line); border-radius: var(--r); background: #fbfaf6; color: var(--faint); }
.search:focus-within { background: var(--paper); border-color: var(--line-strong); }
.search-ico { position: absolute; left: 8px; display: inline-flex; }
.search input { width: 100%; height: 100%; padding: 0 42px 0 28px; border: 0; background: transparent; font-size: 11.5px; outline: 0; }
.search input::placeholder { color: var(--faint); }
.search kbd { position: absolute; right: 6px; padding: 1px 4px; border: 1px solid var(--line); border-radius: 2px; background: var(--paper); color: var(--faint); font: 9.5px/1.4 var(--mono); }
.content { width: 100%; max-width: 1220px; margin: 0 auto; padding: 30px 32px 80px; flex: 1; }
.mobile-nav { display: none; }

/* ---------- page ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.page-head-main { min-width: 0; }
.page-eyebrow { margin-bottom: 5px; color: var(--faint); font-size: 11px; letter-spacing: .02em; }
.page-title { margin: 0; font-size: 24px; line-height: 1.3; font-weight: 600; letter-spacing: .01em; }
.page-sub { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; max-width: 760px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; padding-bottom: 2px; }
.page-note { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 11px; }
.section { margin-top: 28px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 9px; border-bottom: 1px solid var(--line-strong); }
.section-title { font-size: 13.5px; font-weight: 600; letter-spacing: .01em; }
.section-title .count { margin-left: 6px; color: var(--faint); font: 11px var(--mono); }
.section-more { color: var(--muted); font-size: 11px; }
.section-more:hover { color: var(--brand); text-decoration: none; }

/* ---------- today ---------- */
.today-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: -4px 0 24px; color: var(--muted); font-size: 12px; }
.today-summary b { color: var(--ink); font-size: 20px; font-weight: 500; letter-spacing: -.02em; margin-right: 2px; }
.today-summary .warn { color: var(--danger); }
.today-grid { display: grid; grid-template-columns: minmax(0,1fr) 286px; gap: 44px; align-items: start; }
.rail { min-width: 0; }
.rail-block { padding: 0 0 18px; margin-bottom: 20px; border-bottom: 1px solid var(--line-soft); }
.rail-block:last-child { border-bottom: 0; }
.rail-title { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 8px; border-bottom: 1px solid var(--line-strong); margin-bottom: 2px; font-size: 12.5px; font-weight: 600; }
.rail-title a { color: var(--faint); font-weight: 400; font-size: 10.5px; }
.task { display: grid; grid-template-columns: 60px minmax(0,1fr) 74px 14px; gap: 12px; align-items: center; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; }
.task:hover { background: #faf8f2; }
.task:hover .task-title { color: var(--brand); }
.task.is-overdue .task-date b { color: var(--danger); }
.task-date { display: flex; flex-direction: column; line-height: 1.2; }
.task-date b { font: 500 14px/1.2 var(--mono); letter-spacing: -.02em; }
.task-date span { margin-top: 3px; color: var(--faint); font-size: 10px; }
.task-body { min-width: 0; }
.task-title { display: block; font-size: 14px; font-weight: 600; line-height: 1.55; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { display: flex; align-items: center; gap: 7px; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.task-meta .code { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.task-side { text-align: right; color: var(--muted); font-size: 11px; line-height: 1.4; }
.task-side b { display: block; color: var(--ink-2); font-weight: 600; font-size: 11.5px; }
.task-side.is-late b { color: var(--danger); }
.task-arrow { color: var(--line-strong); font-size: 14px; }
.task .kind { display: inline-block; padding: 0 4px; border: 1px solid var(--line); border-radius: 2px; color: var(--muted); font-size: 9.5px; line-height: 15px; }
.agenda-item { display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.agenda-item:last-child { border-bottom: 0; }
.agenda-date { font: 500 13px/1.3 var(--mono); color: var(--ink-2); }
.agenda-date span { display: block; color: var(--faint); font: 9.5px var(--sans); margin-top: 2px; }
.agenda-body { min-width: 0; font-size: 11px; line-height: 1.5; }
.agenda-body b { display: block; font-weight: 500; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-body span { display: block; color: var(--faint); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-line { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 11px; color: var(--ink-2); }
.status-line:last-child { border-bottom: 0; }
.status-line span:first-child { display: flex; align-items: center; gap: 7px; min-width: 0; }
.status-line b { font: 11px var(--mono); color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.recent { padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 10.5px; line-height: 1.55; color: var(--muted); }
.recent:last-child { border-bottom: 0; }
.recent b { color: var(--ink-2); font-weight: 500; }
.recent time { display: block; color: var(--faint); font-size: 9.5px; margin-top: 1px; }

/* ---------- cases ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.toolbar .search { width: 260px; }
.toolbar .select { height: 30px; }
.seg { display: inline-flex; align-items: center; gap: 1px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r); background: #efebe2; }
.seg button { height: 25px; padding: 0 10px; border: 0; border-radius: 2px; background: transparent; color: var(--muted); font-size: 11.5px; }
.seg button:hover { color: var(--ink); }
.seg button.is-on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 rgba(29,28,25,.06); font-weight: 500; }
.select { height: 30px; padding: 0 26px 0 8px; border: 1px solid var(--line); border-radius: var(--r); background: #fbfaf6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23777269' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 8px center; appearance: none; font-size: 11.5px; color: var(--ink-2); }
.select:focus { border-color: var(--line-strong); outline: 0; }
.case-table-head, .case-row { display: grid; grid-template-columns: minmax(250px,2.2fr) minmax(130px,1.05fr) 92px 100px minmax(160px,1.35fr) 58px 28px; gap: 12px; align-items: center; }
.case-table-head { padding: 7px 8px; border-bottom: 1px solid var(--line-strong); color: var(--faint); font-size: 10px; letter-spacing: .04em; }
.case-row { width: 100%; padding: 11px 8px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; }
.case-row:hover { background: #faf8f2; }
.case-summary { display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: baseline; margin: 14px 0 0; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.case-summary b { margin-right: 2px; color: var(--ink); font: 600 16px/1 var(--mono); }
.case-summary .is-warn b { color: var(--warn); }
.case-summary .is-danger b { color: var(--danger); }
.case-amount b { display: block; font-weight: 600; color: var(--ink); }
.case-amount small, .case-due small { display: block; color: var(--faint); font-size: 9.5px; font-weight: 400; line-height: 1.35; }
.case-row.is-overdue { border-left: 2px solid var(--danger); padding-left: 6px; }
.case-row.is-high .case-name { font-weight: 700; }
.case-row:hover .case-name { color: var(--brand); }
.case-main { min-width: 0; }
.case-name { display: block; font-size: 12.5px; font-weight: 500; line-height: 1.55; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-meta { display: block; margin-top: 2px; color: var(--faint); font-size: 10px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-meta .code { font-family: var(--mono); margin-right: 6px; }
.case-opp { min-width: 0; font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-opp small { display: block; color: var(--faint); font-size: 10px; }
.case-status { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.case-status .dot { background: var(--c, var(--faint)); }
.case-amount { font: 11.5px var(--mono); color: var(--ink-2); text-align: right; white-space: nowrap; }
.case-due { font-size: 10.5px; color: var(--muted); line-height: 1.45; }
.case-due b { display: block; color: var(--ink-2); font: 10.5px var(--mono); font-weight: 500; }
.case-due.is-late b { color: var(--danger); }
.case-risk { font-size: 10.5px; color: var(--muted); }
.case-risk.high { color: var(--danger); }
.case-risk.mid { color: var(--warn); }
.case-risk i { display: inline-block; width: 4px; height: 4px; margin-right: 5px; border-radius: 50%; background: currentColor; vertical-align: 2px; }
.case-arrow { color: var(--line-strong); text-align: right; }
.list-foot { padding: 12px 8px; color: var(--faint); font-size: 10.5px; }
.case-scope { margin-left: auto; color: var(--faint); font-size: 11px; }

/* ---------- detail ---------- */
.detail-top { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.back { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 14px; border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 11.5px; }
.back:hover { color: var(--ink); }
.detail-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--faint); font-size: 10.5px; }
.detail-kicker .code { font-family: var(--mono); color: var(--ink-2); }
.detail-title { margin: 7px 0 4px; font-size: 21px; font-weight: 600; line-height: 1.42; letter-spacing: .01em; }
.detail-sub { color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.detail-glance { display: flex; flex-wrap: wrap; gap: 10px 30px; padding: 12px 0 13px; border-bottom: 1px solid var(--line); margin-top: 2px; }
.detail-glance span { display: flex; flex-direction: column; gap: 3px; min-width: 82px; }
.detail-glance em { font-style: normal; color: var(--muted); font-size: 11px; }
.detail-glance b { font-weight: 600; font-size: 13px; }
.detail-glance .is-late b { color: var(--danger); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.stagebar { display: flex; align-items: stretch; gap: 0; margin: 18px 0 0; }
.stage { flex: 1; min-width: 0; padding: 7px 10px 0 0; border-top: 2px solid var(--line); color: var(--faint); font-size: 10.5px; }
.stage:last-child { padding-right: 0; }
.stage b { font-weight: 500; }
.stage.is-done { border-top-color: var(--line-strong); color: var(--muted); }
.stage.is-on { border-top-color: var(--ink); color: var(--ink); font-weight: 600; }
.tabs { display: flex; gap: 22px; margin-top: 22px; border-bottom: 1px solid var(--line); }
.tab { position: relative; height: 33px; border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 12px; }
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--ink); font-weight: 600; }
.tab.is-on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); }
.tab .n { margin-left: 4px; color: var(--faint); font: 10px var(--mono); }
.detail-grid { display: grid; grid-template-columns: minmax(0,1fr) 272px; gap: 40px; align-items: start; margin-top: 24px; }
.detail-main { min-width: 0; }
.detail-rail { min-width: 0; }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border-left: 2px solid var(--line-strong); background: #f7f4ec; margin-bottom: 20px; }
.alert.is-late { border-left-color: var(--danger); background: #fbf3f1; }
.alert.is-soon { border-left-color: var(--warn); background: #fbf7ed; }
.alert-date { flex: 0 0 74px; font: 11px var(--mono); color: var(--ink-2); line-height: 1.5; }
.alert-body { min-width: 0; font-size: 12px; line-height: 1.55; }
.alert-body b { display: block; font-weight: 500; }
.alert-body span { color: var(--muted); font-size: 10.5px; }
.alert-tag { margin-left: auto; flex: 0 0 auto; color: var(--danger); font-size: 10.5px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.fact { min-width: 0; padding: 9px 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact-label { display: block; color: var(--faint); font-size: 10px; line-height: 1.5; }
.fact-value { display: block; margin-top: 2px; color: var(--ink-2); font-size: 11.5px; line-height: 1.6; word-break: break-word; }
.fact-value.mono { font-size: 11px; }
.notes { margin-top: 20px; padding: 12px 14px; background: var(--paper-2); border-left: 2px solid var(--line); font-size: 11.5px; line-height: 1.8; color: var(--ink-2); white-space: pre-wrap; }
.subhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 11.5px; font-weight: 600; }
.subhead a, .subhead button { font-size: 10.5px; font-weight: 400; }
.subhead .count { margin-left: 5px; color: var(--faint); font: 10px var(--mono); font-weight: 400; }
.side-block { padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.side-block:last-child { border-bottom: 0; }
.side-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line-strong); margin-bottom: 4px; font-size: 11px; font-weight: 600; }
.side-title span { color: var(--faint); font-weight: 400; font-size: 10px; }
.side-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 10.5px; }
.side-row:last-child { border-bottom: 0; }
.side-row span { color: var(--faint); flex: 0 0 auto; }
.side-row b { font-weight: 500; color: var(--ink-2); text-align: right; line-height: 1.5; }
.side-row b.mono { font-weight: 400; }
.side-row.is-late b { color: var(--danger); }
.side-note { margin-top: 7px; color: var(--faint); font-size: 10px; line-height: 1.7; }
.auth-list { display: flex; flex-direction: column; }
.auth-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 10.5px; }
.auth-item:last-child { border-bottom: 0; }
.auth-item .dot { width: 5px; height: 5px; }
.auth-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-item em { margin-left: auto; font-style: normal; color: var(--faint); font-size: 9.5px; white-space: nowrap; }
.auth-item.done em { color: var(--ok); }
.progress-line { display: flex; align-items: center; gap: 8px; margin: 4px 0 7px; }
.progress-line .bar { flex: 1; height: 2px; background: var(--line); }
.progress-line .bar i { display: block; height: 2px; background: var(--ink-2); }
.progress-line b { font: 10px var(--mono); color: var(--muted); font-weight: 400; }
.timeline { position: relative; margin: 0; padding: 2px 0 0 17px; list-style: none; border-left: 1px solid var(--line); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before { content: ""; position: absolute; left: -21px; top: 5px; width: 6px; height: 6px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--bg); }
.tl-item.is-done::before { background: var(--ink-2); border-color: var(--ink-2); }
.tl-date { color: var(--faint); font: 10px var(--mono); }
.tl-title { margin-top: 2px; font-size: 11.5px; font-weight: 500; line-height: 1.55; }
.tl-meta { margin-top: 2px; color: var(--faint); font-size: 10px; line-height: 1.55; }
.tl-note { margin-top: 3px; color: var(--muted); font-size: 10.5px; line-height: 1.6; white-space: pre-wrap; }
.file-row, .doc-row { display: grid; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.file-row { grid-template-columns: 22px minmax(0,1fr) 76px 84px 96px; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; min-width: 0; white-space: nowrap; }
.file-row:last-child, .doc-row:last-child { border-bottom: 0; }
.file-ico { color: var(--faint); display: inline-flex; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name b { font-weight: 500; }
.file-name span { display: block; color: var(--faint); font-size: 9.5px; }
.file-size, .file-date { color: var(--faint); font-size: 9.5px; text-align: right; }
.doc-row { grid-template-columns: 22px minmax(0,1fr) 76px 58px; }
.icon-link { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); border-radius: 2px; }
.icon-link:hover { background: #ebe7dd; color: var(--ink); }
.strategy-box { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line); background: var(--paper-2); }
.strategy-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); font-size: 11.5px; }
.strategy-head b { font-weight: 600; }
.strategy-head span { color: var(--faint); font-size: 10px; }
.strategy-head .link { margin-left: auto; }
.strategy-body { margin-top: 10px; color: var(--ink-2); font-size: 11.5px; line-height: 1.9; }
.pay-strip { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; padding: 10px 12px; border: 1px solid var(--line); background: var(--paper-2); font-size: 11.5px; }
.pay-strip b { font-weight: 500; }
.pay-strip .mono { font-size: 13px; }
.pay-strip .link { margin-left: auto; }
.pay-strip .fee-parts { color: var(--muted); font-weight: 400; }
.side-row .fee-parts { font-size: 10.5px; line-height: 1.5; text-align: right; }
.material-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.material-cat { padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 11px; color: var(--ink-2); }
.material-cat b { font-weight: 500; }
.material-cat span { float: right; color: var(--faint); font: 10px var(--mono); }

/* ---------- inbox / payments ---------- */
.inbox-layout { display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 40px; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; border: 1px dashed var(--line-strong); background: var(--paper-2); text-align: center; cursor: pointer; }
.drop:hover, .drop.is-over { border-color: var(--ink-2); background: #f7f4ec; }
.drop b { font-size: 12.5px; font-weight: 500; }
.drop span { margin-top: 3px; color: var(--faint); font-size: 10.5px; }
.inbox-item { display: grid; grid-template-columns: 20px minmax(0,1fr) 100px; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.inbox-item:hover { background: #faf8f2; }
.inbox-file { color: var(--faint); padding-top: 1px; }
.inbox-name { font-size: 11.5px; font-weight: 500; line-height: 1.5; }
.inbox-name span { display: block; color: var(--faint); font-size: 9.5px; font-weight: 400; }
.inbox-state { text-align: right; font-size: 10px; color: var(--faint); }
.inbox-fields { grid-column: 2 / 3; display: flex; flex-wrap: wrap; gap: 2px 16px; color: var(--muted); font-size: 10.5px; }
.inbox-fields b { color: var(--ink-2); font-weight: 500; }
.inbox-actions { grid-column: 2 / 4; display: flex; align-items: center; gap: 7px; padding-top: 3px; }
.inbox-warn { grid-column: 2 / 4; color: var(--warn); font-size: 10px; line-height: 1.6; }
.inbox-related { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 3px 12px; padding: 6px 9px; border-left: 2px solid var(--warn); background: #fbf3df; color: var(--ink-2); font-size: 10.5px; }
.inbox-related b { color: var(--warn); font-weight: 600; }
.inbox-related span { color: var(--muted); }
.related-box { display: flex; flex-direction: column; gap: 6px; padding: 9px 10px; border: 1px solid var(--line); background: var(--paper-2); }
.related-box b { font-size: 11px; font-weight: 600; }
.related-box label { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 11.5px; }
.inbox-excerpt { grid-column: 2 / 4; margin-top: 2px; padding: 6px 8px; background: #f7f5ee; color: var(--muted); font-size: 10px; line-height: 1.7; max-height: 48px; overflow: hidden; }
.inbox-done { margin-top: 18px; border-top: 1px solid var(--line-strong); }
.inbox-done summary { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; color: var(--muted); font-size: 11px; cursor: pointer; list-style: none; }
.inbox-done summary::-webkit-details-marker { display: none; }
.inbox-done summary span { color: var(--faint); font-size: 10px; }
.inbox-done-list { opacity: .8; }
.inbox-done-list .inbox-item { padding: 9px 0; }
.inbox-done-list .inbox-item:hover { background: transparent; }
.badge { display: inline-block; padding: 0 4px; border: 1px solid var(--line); border-radius: 2px; color: var(--muted); font-size: 9px; line-height: 15px; vertical-align: 1px; }
.badge-warn { border-color: #dcc7a7; color: var(--warn); }
.badge-ok { border-color: #b9d0c0; color: var(--ok); }
.badge-danger { border-color: #d9b5b0; color: var(--danger); }
.pay-summary { display: flex; flex-wrap: wrap; gap: 24px; margin: -2px 0 18px; color: var(--muted); font-size: 11.5px; }
.pay-summary b { color: var(--ink); font: 15px var(--mono); font-weight: 500; margin-right: 4px; }
.table-wrap { width: 100%; overflow-x: auto; border-top: 1px solid var(--line-strong); }
table.data { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.data th { padding: 7px 8px; color: var(--faint); font-size: 10px; font-weight: 400; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:hover td { background: #faf8f2; }
table.data .t-r { text-align: right; }
table.data .main { font-weight: 500; color: var(--ink-2); }
table.data .sub { display: block; color: var(--faint); font-size: 9.5px; font-weight: 400; margin-top: 1px; }

/* ---------- studio / settings ---------- */
.studio-layout { display: grid; grid-template-columns: 238px minmax(0,1fr); gap: 36px; align-items: start; }
.studio-side { position: sticky; top: 76px; }
.kind-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.kind-item { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; color: var(--muted); font-size: 11.5px; text-align: left; }
.kind-item:hover { color: var(--ink); }
.kind-item.is-on { color: var(--ink); font-weight: 600; }
.kind-item.is-on::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--brand); }
.kind-item:not(.is-on)::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: transparent; }
.studio-preview { min-height: 540px; border: 1px solid var(--line); background: var(--paper); }
.studio-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--paper-2); font-size: 11px; }
.studio-bar b { font-weight: 500; }
.studio-body { padding: 20px 22px; }
.studio-body textarea { width: 100%; min-height: 430px; padding: 0; border: 0; background: transparent; resize: vertical; outline: 0; font: 12.5px/1.95 var(--sans); color: var(--ink-2); }
.studio-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 520px; padding: 40px; text-align: center; color: var(--muted); }
.studio-empty b { margin-top: 12px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.studio-empty span { margin-top: 5px; font-size: 11px; line-height: 1.7; }
.settings-section { padding: 0 0 26px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; }
.settings-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.settings-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.settings-head p { margin: 3px 0 0; color: var(--faint); font-size: 10.5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid .span2 { grid-column: 1 / -1; }
.field { display: block; min-width: 0; }
.field > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10.5px; }
.field input, .field select, .field textarea { width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); color: var(--ink); font-size: 12px; outline: 0; }
.field textarea { height: auto; min-height: 64px; padding: 7px 8px; line-height: 1.7; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--line-strong); background: #fff; }
.field input::placeholder, .field textarea::placeholder { color: #b0aa9d; }
.field-hint { margin-top: 4px; color: var(--faint); font-size: 9.5px; line-height: 1.6; }
.field > span .linkbtn { float: right; padding: 0; border: 0; background: none; color: var(--brand); font-size: 10.5px; cursor: pointer; }
.field > span .linkbtn:hover { text-decoration: underline; }
.inline-company { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; padding: 8px; border: 1px solid var(--line); background: var(--paper-2); }
.inline-company[hidden] { display: none; }
.inline-company input { flex: 1 1 110px; width: auto; min-width: 0; height: 28px; }
.inline-company [data-company-name] { flex: 1 1 100%; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.user-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.user-table th { padding: 6px 8px; border-bottom: 1px solid var(--line-strong); color: var(--faint); font-size: 10px; font-weight: 400; text-align: left; }
.user-table td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); }
.user-table .name { font-weight: 500; }
.user-table .uname { display: block; margin-top: 2px; color: var(--faint); font: 10px var(--mono); }
.user-table .ops { text-align: right; white-space: nowrap; }
.user-table .ops button { margin-left: 8px; }
@media (max-width: 700px) {
  .user-table-accounts th:nth-child(4), .user-table-accounts td:nth-child(4),
  .user-table-accounts th:nth-child(5), .user-table-accounts td:nth-child(5) { display: none; }
  .user-table-accounts th, .user-table-accounts td { padding-left: 4px; padding-right: 4px; }
  .user-table-accounts .ops { white-space: normal; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  .user-table-accounts .ops button { margin-left: 0; }
}
.state { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); }
.state .dot { background: var(--ok); }
.state.off .dot { background: var(--faint); }
.state.lock .dot { background: var(--danger); }
.status-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.status-edit { display: flex; align-items: center; gap: 7px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.status-edit .dot { background: var(--c); }
.status-edit b { font-weight: 500; }
.status-edit span { color: var(--faint); font-size: 9.5px; }
.status-edit button { margin-left: auto; }
.login-log { font-size: 10.5px; }
.login-log tr td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); }
.login-log .ok { color: var(--ok); }
.login-log .bad { color: var(--danger); }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; z-index: 60; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(24,23,20,.42); }
.modal { width: 100%; max-width: 620px; max-height: calc(100dvh - 48px); display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 3px; box-shadow: 0 24px 70px rgba(20,19,17,.22); }
.modal.modal-sm { max-width: 420px; }
.modal.modal-lg { max-width: 820px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 20px 13px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-sub { margin-top: 3px; color: var(--faint); font-size: 10.5px; line-height: 1.6; }
.modal-x { flex: 0 0 auto; width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--faint); font-size: 18px; line-height: 1; }
.modal-x:hover { color: var(--ink); }
.modal-body { overflow-y: auto; padding: 18px 20px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--paper-2); }
.modal-foot .left { margin-right: auto; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 28px; transform: translate(-50%, 10px); max-width: min(460px, calc(100vw - 32px)); padding: 9px 14px; border-radius: 3px; background: #26241f; color: #fff; font-size: 11.5px; line-height: 1.6; opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }
.toast.ok { background: #2f4e3e; }
.copy-line { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); background: var(--paper-2); font: 12px var(--mono); }
.copy-line b { flex: 1; font-weight: 500; letter-spacing: .06em; }
.session-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 10.5px; }
.session-row b { font-weight: 500; }
.session-row span { display: block; color: var(--faint); font-size: 9.5px; margin-top: 2px; }
.tabs-inline { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs-inline button { height: 30px; border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 11.5px; }
.tabs-inline button.is-on { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--ink); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.kv span { color: var(--faint); }
.kv b { font-weight: 500; color: var(--ink-2); text-align: right; }
.error-text { color: var(--danger); font-size: 10.5px; line-height: 1.6; }
.loading { padding: 80px 20px; text-align: center; color: var(--faint); font-size: 11.5px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .content { padding: 24px 24px 72px; }
  .topbar { padding: 0 24px; }
  .today-grid { grid-template-columns: minmax(0,1fr) 248px; gap: 30px; }
  .detail-grid { grid-template-columns: minmax(0,1fr) 235px; gap: 28px; }
  .case-table-head, .case-row { grid-template-columns: minmax(210px,2.1fr) minmax(105px,.95fr) 84px 96px minmax(130px,1.25fr) 50px 24px; gap: 10px; }
  .search { width: 220px; }
}
@media (max-width: 860px) {
  body { font-size: 13px; }
  .sidebar { display: none; }
  .app > .main { margin-left: 0; }
  .topbar { height: 48px; flex-basis: 48px; padding: 0 14px; gap: 8px; }
  .topbar .search { width: 30px; border-color: transparent; background: transparent; }
  .topbar .search input, .topbar .search kbd { display: none; }
  .topbar .search-ico { left: 8px; color: var(--ink-2); }
  .crumb { font-size: 11px; }
  .crumb .sep, .crumb span:last-child { display: none; }
  .topbar-tools { gap: 6px; }
  .topbar-tools > .btn-primary { height: 28px; font-size: 11px; padding: 0 9px; }
  .content { padding: 18px 14px 84px; }
  .mobile-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5,1fr); height: 56px; padding-bottom: env(safe-area-inset-bottom); background: rgba(255,254,250,.98); border-top: 1px solid var(--line); }
  .mobile-nav button { border: 0; background: transparent; color: var(--faint); font-size: 10.5px; }
  .mobile-nav button.is-on { color: var(--ink); font-weight: 600; }
  .page-head { align-items: flex-start; flex-direction: column; gap: 12px; padding-bottom: 14px; margin-bottom: 18px; }
  .page-title { font-size: 19px; }
  .page-actions { width: 100%; flex-wrap: wrap; }
  .today-grid, .inbox-layout, .detail-grid, .studio-layout { grid-template-columns: 1fr; gap: 24px; }
  .rail { border-top: 1px solid var(--line); padding-top: 20px; }
  .today-summary { gap: 5px 14px; margin-bottom: 18px; }
  .today-summary b { font-size: 17px; }
  .task { grid-template-columns: 50px minmax(0,1fr) 44px 10px; gap: 8px; padding: 11px 0; }
  .task-side { font-size: 9.5px; }
  .task-side b { font-size: 10px; }
  .task-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .task-meta { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .case-table-head { display: none; }
  .case-row { grid-template-columns: minmax(0,1fr) auto; gap: 2px 12px; padding: 12px 2px; }
  .case-main { grid-column: 1 / 2; }
  .case-opp, .case-amount, .case-risk { display: none; }
  .case-status { grid-column: 2 / 3; grid-row: 1; justify-self: end; }
  .case-due { grid-column: 1 / 2; padding-left: 0; }
  .case-arrow { display: none; }
  .case-scope { display: none; }
  .toolbar { gap: 6px; }
  .toolbar .search { width: 100%; order: -1; }
  .seg { overflow-x: auto; max-width: 100%; }
  .seg button { padding: 0 8px; }
  .detail-title { font-size: 18px; }
  .detail-actions { margin-top: 12px; }
  .stagebar { overflow-x: auto; }
  .stage { min-width: 74px; flex: 0 0 auto; }
  .facts { grid-template-columns: 1fr; }
  .fact { padding: 8px 10px; }
  .tabs { gap: 18px; overflow-x: auto; }
  .tab { flex: 0 0 auto; }
  .detail-rail { border-top: 1px solid var(--line); padding-top: 18px; }
  .file-row, .doc-row { grid-template-columns: 20px minmax(0,1fr) 30px; }
  .file-row.mat-row { grid-template-columns: 20px minmax(0,1fr) 84px; }
  .doc-row { grid-template-columns: 20px minmax(0,1fr) 56px; }
  .file-row.mat-row .row-actions { gap: 0; }
  .file-size, .file-date, .doc-row .file-date { display: none; }
  .inbox-item { grid-template-columns: 20px minmax(0,1fr); }
  .inbox-state { grid-column: 2; text-align: left; }
  .inbox-fields, .inbox-actions, .inbox-warn, .inbox-excerpt, .inbox-related { grid-column: 2; }
  .status-list, .form-grid, .material-cats { grid-template-columns: 1fr; }
  .studio-side { position: static; }
  .studio-layout { gap: 18px; }
  .studio-preview { min-height: 360px; }
  .studio-body textarea { min-height: 320px; }
  .table-wrap { margin-right: -14px; margin-left: -14px; width: calc(100% + 28px); }
  table.data th, table.data td { white-space: nowrap; }
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal { max-height: calc(100dvh - 24px); }
  .modal-body { padding: 14px 16px; }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .login-box { padding: 28px 22px 24px; }
  .toast { bottom: 70px; }
}
@media (max-width: 420px) {
  .topbar-tools > .btn-primary { padding: 0 7px; }
  .page-title { font-size: 18px; }
  .today-summary b { font-size: 16px; }
  .task { grid-template-columns: 44px minmax(0,1fr) 58px; gap: 8px; }
  .task-side { display: block; font-size: 9px; line-height: 1.35; }
  .task-side b { font-size: 9.5px; }
  .task-arrow { display: none; }
  .detail-kicker { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- v1.5 重点、看板、合并与预览 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); margin: 4px 0 20px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); background: var(--paper); }
.kpi { min-width: 0; padding: 15px 18px 13px; border-right: 1px solid var(--line-soft); }
.kpi:last-child { border-right: 0; }
.kpi-label { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.kpi-value { margin-top: 4px; font: 600 28px/1.15 var(--mono); letter-spacing: -.035em; color: var(--ink); }
.kpi-value span { margin-left: 3px; font: 500 11.5px var(--sans); letter-spacing: 0; color: var(--muted); }
.kpi-foot { margin-top: 5px; color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.kpi.is-money .kpi-value { font-size: 24px; }
.kpi.is-alert .kpi-value { color: var(--danger); }
.warn-text { color: var(--warn); }
.stage-panel { margin: 0 0 24px; padding: 0 0 13px; border-bottom: 1px solid var(--line); }
.stage-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; color: var(--ink); font-size: 12.5px; font-weight: 600; }
.stage-panel-head .muted { font-weight: 400; font-size: 11px; }
.pipeline { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 1px; margin-top: 9px; background: var(--line-soft); }
.pipe-step { display: flex; align-items: baseline; gap: 6px; min-width: 0; padding: 8px 10px; background: var(--paper-2); color: var(--muted); }
.pipe-step.is-filled { background: #eee6d8; color: var(--ink); }
.pipe-no { font: 9px var(--mono); color: var(--faint); }
.pipe-step b { font: 600 16px var(--mono); letter-spacing: -.02em; }
.pipe-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.group-label { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 0 5px; border-bottom: 1px solid var(--line-soft); color: var(--danger); font-size: 11.5px; font-weight: 600; }
.group-label:first-child { padding-top: 0; }
.group-label b { font: 500 11px var(--mono); }
.risk-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 1px 10px; width: 100%; padding: 9px 0; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; }
.risk-row:hover { background: var(--paper-2); }
.risk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12px; font-weight: 600; }
.risk-meta { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.risk-flag { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--danger); font-size: 11px; font-weight: 600; }
.merge-note { margin: 0 0 16px; padding: 10px 12px; border-left: 3px solid var(--warn); background: #fbf4e5; color: var(--ink-2); font-size: 12.5px; line-height: 1.7; }
.merge-note a { font-weight: 600; }
.preview-img { display: flex; justify-content: center; background: #f2efe7; }
.preview-img img { display: block; max-width: 100%; max-height: 72vh; object-fit: contain; }
.preview-frame { display: block; width: 100%; height: 72vh; border: 0; background: #fff; }
.preview-text { margin: 0; padding: 16px; max-height: 68vh; overflow: auto; background: var(--paper); color: var(--ink-2); font: 12px/1.8 var(--sans); white-space: pre-wrap; word-break: break-word; }
.company-list { border-top: 1px solid var(--line-soft); }
.company-item { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.company-item b { font-size: 13px; font-weight: 600; }
.company-item span { color: var(--muted); font-size: 11px; }
@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .kpi { border-bottom: 1px solid var(--line-soft); }
  .kpi:nth-child(2n) { border-right: 0; }
  .pipeline { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .company-item { grid-template-columns: minmax(0,1fr) auto; }
  .company-item button { grid-column: 2; }
}
@media (max-width: 420px) {
  .kpi { padding: 11px 12px 10px; }
  .kpi-value { font-size: 22px; }
  .kpi.is-money .kpi-value { font-size: 19px; }
  .pipe-label { font-size: 10px; }
}
