/* Employee console. One design system: tokens, layout, components. */
:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f9faf8;
  --sunken: #eff1ee;
  --ink: #17201b;
  --ink-2: #3d4a43;
  --muted: #6b7770;
  --faint: #98a39c;
  --line: #e3e7e3;
  --line-2: #d3d9d4;
  --accent: #0d6b4e;
  --accent-ink: #ffffff;
  --accent-hover: #0a5a41;
  --accent-soft: #e3f2ec;
  --accent-text: #0b5c43;
  --ai: #5a4bd6;
  --ai-soft: #efedfd;
  --ai-hover: #4a3cc0;
  --good: #187a4c; --good-soft: #e2f4ea;
  --warn: #9a6200; --warn-soft: #fdf1d9;
  --info: #2459b8; --info-soft: #e5edfb;
  --bad: #b3261e; --bad-soft: #fde8e6;
  --shadow-sm: 0 1px 2px rgba(20, 30, 25, .05);
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 6px 20px rgba(20, 30, 25, .06);
  --shadow-lg: 0 20px 60px rgba(20, 30, 25, .22);
  --r: 12px;
  --r-sm: 8px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --surface: #161d1a; --surface-2: #1a221e; --sunken: #121815; --ink: #e6ece8; --ink-2: #c3ccc6; --muted: #8e9a93; --faint: #66726b;
    --line: #26302b; --line-2: #34403a; --accent: #2fa77a; --accent-hover: #3bb889; --accent-soft: #163329; --accent-text: #6fd5aa; --accent-ink: #06150f;
    --ai: #9a8ffa; --ai-soft: #24204a; --ai-hover: #aea5ff;
    --good: #5fcf93; --good-soft: #15301f; --warn: #e6b450; --warn-soft: #33280f; --info: #82a9f5; --info-soft: #172440; --bad: #f2867c; --bad-soft: #3a1714;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); --shadow-lg: 0 20px 60px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1412; --surface: #161d1a; --surface-2: #1a221e; --sunken: #121815; --ink: #e6ece8; --ink-2: #c3ccc6; --muted: #8e9a93; --faint: #66726b;
  --line: #26302b; --line-2: #34403a; --accent: #2fa77a; --accent-hover: #3bb889; --accent-soft: #163329; --accent-text: #6fd5aa; --accent-ink: #06150f;
  --ai: #9a8ffa; --ai-soft: #24204a; --ai-hover: #aea5ff;
  --good: #5fcf93; --good-soft: #15301f; --warn: #e6b450; --warn-soft: #33280f; --info: #82a9f5; --info-soft: #172440; --bad: #f2867c; --bad-soft: #3a1714;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 8px; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.error-text { color: var(--bad); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--faint); }
.btn.subtle { background: transparent; color: var(--ink-2); }
.btn.subtle:hover { background: var(--sunken); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.danger-ghost { background: var(--surface); color: var(--bad); border-color: var(--line-2); }
.btn.danger-ghost:hover { background: var(--bad-soft); }
.btn.ai { background: var(--ai); color: #fff; }
.btn.ai:hover { background: var(--ai-hover); }
.btn.ai-ghost { background: var(--ai-soft); color: var(--ai); border-color: transparent; }
.btn.ai-ghost:hover { border-color: var(--ai); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .7s linear infinite; }
.btn.primary.loading::after, .btn.ai.loading::after, .btn.danger.loading::after { border-color: #fff transparent #fff transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field > small { color: var(--muted); font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px 11px; min-height: 36px;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; }
input[type=color] { padding: 2px; height: 36px; width: 56px; }
input[type=file] { padding: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; padding: 2px 0; }
.check > span { line-height: 1.35; }
.check small { display: block; color: var(--muted); font-size: 12px; }
.input-group { display: flex; gap: 6px; }
.input-group > input { flex: 1; }
.search { position: relative; }
.search .ic { position: absolute; left: 10px; top: 9px; color: var(--faint); }
.search input { padding-left: 34px; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.app > [data-side] { background: var(--surface); border-right: 1px solid var(--line); }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--surface); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.brand strong { display: block; font-size: 14.5px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: -1px; }
.nav-group { margin-bottom: 14px; }
.nav-group > h6 { margin: 0 0 4px; padding: 0 10px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 650; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 550; text-decoration: none;
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-text); }
.nav a .count { margin-left: auto; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.who div { min-width: 0; }
.who strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid transparent;
}
.topbar .crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; min-width: 0; }
.topbar .crumbs a { color: var(--muted); }
.topbar .crumbs strong { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .search { width: min(320px, 40vw); margin-left: auto; }
.page { padding: 8px 28px 64px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 20px; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.menu-btn { display: none; }

/* ---------------------------------------------------------------- cards and grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card > header h2 { display: flex; align-items: center; gap: 8px; }
.card > header h2 .ic { color: var(--muted); }
.card > .body { padding: 16px 18px; }
.card > .body.flush { padding: 0; }
.card > footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card + .card { margin-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > * { margin-top: 0 !important; margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side-r { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid.side-l { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.grid > .card + .card { margin-top: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-sm); display: block; color: inherit; text-decoration: none !important; }
a.kpi:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.kpi .k { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .v { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi .v small { font-size: 15px; color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------------- lists and tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-2); border-bottom: 0; }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-person strong { display: block; font-weight: 600; }
.cell-person small { display: block; color: var(--muted); font-size: 12px; }
table input { min-height: 30px; padding: 4px 8px; }

.rows > * { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none !important; }
.rows > *:last-child { border-bottom: 0; }
.rows > a:hover, .rows > .click:hover { background: var(--surface-2); cursor: pointer; }
.rows .main-col { flex: 1; min-width: 0; }
.rows .main-col strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows .main-col small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.attention a { display: flex; align-items: center; gap: 12px; }
.attention .dot { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.attention .dot.warn { background: var(--warn-soft); color: var(--warn); }
.attention .dot.info { background: var(--info-soft); color: var(--info); }
.attention .dot.bad { background: var(--bad-soft); color: var(--bad); }
.attention .dot.ai { background: var(--ai-soft); color: var(--ai); }
.attention .n { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- bits */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 2px 9px; border-radius: 99px; white-space: nowrap; line-height: 1.6; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.muted { background: var(--sunken); color: var(--muted); }
.badge.ai { background: var(--ai-soft); color: var(--ai); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 12.5px; cursor: pointer; text-decoration: none !important; }
.chip:hover { border-color: var(--faint); }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .count { color: inherit; opacity: .65; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar { --h: 160; display: inline-grid; place-items: center; border-radius: 50%; font-weight: 700; flex: none;
  background: hsl(var(--h) 45% 90%); color: hsl(var(--h) 45% 28%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 50% 80%); } }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.md { width: 36px; height: 36px; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.progress { height: 6px; background: var(--sunken); border-radius: 99px; overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar-chart { display: flex; flex-direction: column; gap: 9px; }
.bar-chart .row { display: grid; grid-template-columns: 120px 1fr 32px; align-items: center; gap: 10px; font-size: 13px; }
.bar-chart .row span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.bar-chart .track { height: 10px; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.bar-chart .fill { height: 100%; background: var(--accent); border-radius: 99px; opacity: .85; }
.bar-chart .n { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--sunken) 0); }
.ring > span { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--r-sm); background: var(--info-soft); color: var(--ink); font-size: 13.5px; }
.callout .ic { color: var(--info); margin-top: 1px; }
.callout.warn { background: var(--warn-soft); } .callout.warn .ic { color: var(--warn); }
.callout.bad { background: var(--bad-soft); } .callout.bad .ic { color: var(--bad); }
.callout.good { background: var(--good-soft); } .callout.good .ic { color: var(--good); }
.callout.ai { background: var(--ai-soft); } .callout.ai .ic { color: var(--ai); }
.callout ul { margin: 4px 0 0; padding-left: 18px; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 34px 20px; color: var(--muted); }
.empty .ic { color: var(--faint); margin-bottom: 4px; }
.empty strong { color: var(--ink); font-weight: 650; }
.empty p { margin: 0 0 6px; max-width: 360px; }
.skeleton { height: 14px; border-radius: 6px; margin: 10px 0; background: linear-gradient(90deg, var(--sunken), var(--surface-2), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton.short { width: 60%; }
.skeleton.block { height: 120px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { background: var(--sunken); color: var(--muted); border-radius: 99px; font-size: 11px; padding: 0 7px; font-weight: 700; }

.steps { display: flex; list-style: none; padding: 0; margin: 0 0 18px; gap: 6px; flex-wrap: wrap; counter-reset: s; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.steps li + li::before { content: ""; width: 26px; height: 1px; background: var(--line-2); margin-right: 2px; }
.steps li > span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; border: 1.5px solid var(--line-2); background: var(--surface); }
.steps li.now { color: var(--ink); }
.steps li.now > span { border-color: var(--accent); color: var(--accent-text); }
.steps li.done > span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--accent); }
.timeline li.now::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.timeline li strong { display: block; font-size: 13px; font-weight: 600; }
.timeline li small { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- person header */
.person-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.person-head .info { flex: 1; min-width: 220px; }
.person-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.person-head .meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 4px; }
.person-head .meta span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------------------------------------------------------------- letters */
.letter-paper { background: #fff; color: #1d1d1d; border: 1px solid var(--line); border-radius: 6px; padding: 44px 52px; font: 14.5px/1.65 var(--serif); box-shadow: var(--shadow); min-height: 500px; }
.letter-paper h4 { font: 700 15px/1.4 var(--font); margin: 20px 0 8px; color: #222; }
.letter-paper p { margin: 0 0 12px; }
.letter-paper ul { margin: 0 0 12px; padding-left: 22px; }
.letter-paper mark.merge { background: #e7f0ff; color: #2459b8; border-radius: 4px; padding: 0 4px; font: 600 12px/1.6 var(--mono); }
.letter-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--lh, #1f3a5f); padding-bottom: 14px; margin-bottom: 22px; font-family: var(--font); }
.letter-head .org { display: flex; gap: 12px; align-items: center; }
.letter-head .org img { max-height: 44px; max-width: 140px; }
.letter-head strong { display: block; font-size: 20px; color: var(--lh, #1f3a5f); }
.letter-head small { display: block; color: #666; font-size: 11px; }
.letter-head .addr { text-align: right; font-size: 11px; color: #666; }
.editor { width: 100%; min-height: 560px; font: 13.5px/1.6 var(--mono); padding: 16px; }
.pdf-frame { width: 100%; height: 78vh; min-height: 560px; border: 1px solid var(--line); border-radius: var(--r); background: var(--sunken); }
.opt-section { border-top: 1px solid var(--line); padding: 14px 0; }
.opt-section:first-child { border-top: 0; padding-top: 0; }
.opt-section > .opt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.opt-section > .opt-head h3 { font-size: 13.5px; }
.list-editor { display: flex; flex-direction: column; gap: 6px; }
.list-editor .item { display: flex; gap: 6px; align-items: center; }
.list-editor .item input { flex: 1; }
.list-editor .item .handle { color: var(--faint); font-size: 12px; width: 16px; text-align: center; }
.clause-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.clause-row:last-child { border-bottom: 0; }
.clause-row .extra { display: flex; align-items: center; gap: 6px; }
.clause-row .extra input { width: 70px; min-height: 30px; padding: 4px 8px; }
.sticky-col { position: sticky; top: 72px; }

/* ---------------------------------------------------------------- AI */
.ai-box { border: 1px solid color-mix(in srgb, var(--ai) 30%, var(--line)); border-radius: var(--r); background: linear-gradient(180deg, var(--ai-soft), var(--surface) 70px); padding: 14px; }
.ai-head { display: flex; align-items: center; gap: 8px; color: var(--ai); font-weight: 650; font-size: 13px; margin-bottom: 10px; }
.ai-text { width: 100%; font: 13.5px/1.6 var(--font); }
.edit-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.edit-list li { display: flex; gap: 8px; align-items: center; }
.edit-list .txt { flex: 1; }

/* ---------------------------------------------------------------- modal, toast */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(12, 18, 15, .45); display: grid; place-items: center; padding: 20px; opacity: 0; transition: opacity .15s; }
.modal-wrap.in { opacity: 1; }
.modal-wrap.out { opacity: 0; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); transform: translateY(8px) scale(.98); transition: transform .15s; }
.modal.wide { width: min(820px, 100%); }
.modal-wrap.in .modal { transform: none; }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 6px; }
.modal-body { padding: 10px 20px 18px; overflow-y: auto; }
.modal > footer { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; gap: 9px; align-items: center; max-width: 440px; padding: 11px 15px; border-radius: 10px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-lg); font-weight: 550; animation: rise .18s ease-out; transition: opacity .3s, transform .3s; }
.toast.error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- sign-in */
.gate { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.gate .art { background: var(--accent); color: var(--accent-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.gate .art::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255,255,255,.07); }
.gate .art h2 { font-size: 30px; line-height: 1.2; max-width: 420px; letter-spacing: -.02em; font-weight: 700; }
.gate .art ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; opacity: .92; }
.gate .art li { display: flex; gap: 10px; align-items: center; }
.gate .form-side { display: grid; place-items: center; padding: 32px 20px; }
.gate form { width: min(380px, 100%); }
.gate h1 { font-size: 24px; margin: 18px 0 6px; }
.gate .lede { color: var(--muted); margin-bottom: 20px; }
.gate .btn { width: 100%; height: 42px; margin-top: 14px; }
.code-input { letter-spacing: .5em; font-size: 22px; text-align: center; font-weight: 700; font-family: var(--mono); }
.dev-list { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }
.dev-list .rows > * { padding: 8px 10px; border-radius: 8px; border: 0; }

/* ---------------------------------------------------------------- signature pad */
.sig-pad { width: 100%; height: 170px; border: 1.5px dashed var(--line-2); border-radius: var(--r); background: #fff; touch-action: none; cursor: crosshair; display: block; }
.sig-preview { max-height: 70px; max-width: 220px; background: #fff; border-radius: 6px; border: 1px solid var(--line); padding: 4px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side-r, .grid.side-l, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .sticky-col { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .app > [data-side] { border: 0; }
  .side { position: fixed; z-index: 90; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .app.nav-open .side { transform: none; }
  .menu-btn { display: inline-grid; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
  .topbar .search { display: none; }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .gate { grid-template-columns: 1fr; }
  .gate .art { display: none; }
  .letter-paper { padding: 24px 20px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}

@media (max-width: 1100px) { .attention-first > .stack:last-child { order: -1; } }
details.opt-section > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
details.opt-section > summary::-webkit-details-marker { display: none; }
details.opt-section > summary::after { content: "+"; margin-left: 8px; color: var(--muted); font-weight: 600; }
details.opt-section[open] > summary { margin-bottom: 8px; }
details.opt-section[open] > summary::after { content: "–"; }
details.opt-section > summary h3 { flex: none; }
details.opt-section > summary .small { flex: 1; text-align: right; }
.ai-prompt { width: 100%; font: 13.5px/1.5 var(--font); background: var(--surface); }
.sec { position: relative; border-radius: 6px; margin: 0 -10px; padding: 2px 10px; transition: background .12s; }
.sec:hover { background: color-mix(in srgb, var(--ai) 6%, transparent); outline: 1px dashed color-mix(in srgb, var(--ai) 35%, transparent); }
.sec .sec-tools { position: absolute; right: 6px; top: 16px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; font-family: var(--font); }
.sec:hover .sec-tools, .sec:focus-within .sec-tools { opacity: 1; }
.add-sec { margin-top: 18px; font-family: var(--font); }
.part-list > div { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.part-list > div:last-child { border-bottom: 0; }
@media (hover: none) { .sec .sec-tools { opacity: 1; } }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2::after { content: "+"; color: var(--muted); margin-left: 6px; font-weight: 600; }
details.card[open] > summary h2::after { content: "–"; }
