/* ==========================================================================
   Legal AI Workspace — v2.8 redesign
   Public Sans + Source Serif 4 · navy & gold brand · red / amber / green for status only
   ========================================================================== */

@font-face { font-family: "Public Sans"; src: url("/assets/fonts/public-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("/assets/fonts/source-serif-4.woff2") format("woff2"); font-weight: 500 600; font-display: swap; }

:root {
  --paper: #ECEEF2;
  --surface: #FFFFFF;
  --sunk: #F3F4F7;
  --ink: #0F1522;
  --ink-2: #333C4D;
  --muted: #5A6375;
  --rule: #DCDFE6;
  --rule-hard: #C3C8D2;
  --navy: #1E2A4A;
  --navy-2: #2C3B62;
  --gold: #A67C21;
  --gold-bright: #D8AE55;
  --gold-soft: #F4EBD7;
  --overdue: #A8322A;
  --overdue-bg: #FAEDEB;
  --soon: #8A5E12;
  --soon-bg: #F8F0DF;
  --clear: #2B6A50;
  --clear-bg: #E9F2ED;
  --focus: #3A5BA8;
  --tab-line: var(--navy);
  --shadow: 0 1px 1px rgba(19, 23, 30, 0.04), 0 6px 18px -12px rgba(19, 23, 30, 0.3);
  --shadow-pop: 0 22px 50px -18px rgba(19, 23, 30, 0.45);

  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --doc: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: light;
  --r: 7px;
  --r-sm: 5px;
  --topbar-h: 68px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* Each desk gets its own colour so RERA, Income Tax and the Library are told apart at a glance */
:root, [data-area="rera"] { --area: #1D4ED8; --area-deep: #1E3A8A; --area-ink: #1E3A8A; --area-soft: #E8EEFD; --area-line: #BFD0F7; }
[data-area="income_tax"] { --area: #0F766E; --area-deep: #134E4A; --area-ink: #0F5F58; --area-soft: #E2F4F1; --area-line: #A9DCD4; }
[data-area="knowledge_library"] { --area: #9F1239; --area-deep: #6B1030; --area-ink: #881337; --area-soft: #FCE8EE; --area-line: #F3BCCB; }

:root[data-theme="dark"] {
  --paper: #0E1116; --surface: #161A21; --sunk: #1C212A; --ink: #E8EAEE; --ink-2: #B4BAC6;
  --muted: #868E9D; --rule: #272D37; --rule-hard: #333B47; --navy: #18202F; --navy-2: #28344F;
  --gold: #D3A94F; --gold-bright: #E2BE6C; --gold-soft: #2A2317; --overdue: #E0796C; --overdue-bg: #2A1816;
  --soon: #D2A455; --soon-bg: #271F13; --clear: #6CBB95; --clear-bg: #152119; --focus: #7E9BE0;
  --tab-line: var(--gold);
  color-scheme: dark;
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.4), 0 6px 18px -12px rgba(0, 0, 0, 0.9);
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--gold-soft); }

svg:has(> use) { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.35s var(--spring); }

.hidden { display: none !important; }
.grow { flex: 1 1 auto; }
.muted, .subtle { color: var(--muted); }
.mini { font-size: 13px; }
.span-2 { grid-column: 1 / -1; }
.warn-text { color: var(--soon); font-weight: 600; }
.note { font-size: 14px; color: var(--muted); }
.card-sub { font-size: 15px; color: var(--ink-2); }
.gap { height: 10px; }
.link { appearance: none; border: 0; padding: 0; background: none; color: inherit; font-weight: 600; cursor: pointer; border-bottom: 1px solid currentColor; }

/* ---------------------------------------------------------------- motion */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes kenburns { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.12) translate(-1.5%, -1%); } }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-from-right { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes slide-from-left { from { opacity: 0; transform: translateX(-26px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); } 40% { transform: scale(1.25) rotate(12deg); } 70% { transform: scale(0.95) rotate(-6deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(10deg); } }
@keyframes nudge-down { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes nudge-up { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes shimmer { from { background-position: -500px 0, 0 0; } to { background-position: 500px 0, 0 0; } }
@keyframes progress { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }
@keyframes check-pop { 0% { transform: translateY(-2px) rotate(-45deg) scale(0); } 70% { transform: translateY(-2px) rotate(-45deg) scale(1.25); } 100% { transform: translateY(-2px) rotate(-45deg) scale(1); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.view.active-view > * { animation: rise 0.45s var(--ease) both; }
.view.active-view > *:nth-child(2) { animation-delay: 0.05s; }
.view.active-view > *:nth-child(3) { animation-delay: 0.1s; }
.view.active-view > *:nth-child(4) { animation-delay: 0.15s; }
.detail-section.active-section { animation: rise 0.35s var(--ease) both; }

/* Icon micro-animations */
.btn:hover svg:has(> use[href="#i-plus"]) { transform: rotate(90deg); }
.btn:hover svg:has(> use[href="#i-arrow-right"]), .details-teaser:hover .teaser-go { transform: translateX(4px); }
.btn:hover svg:has(> use[href="#i-arrow-left"]), .crumb-back:hover svg:has(> use) { transform: translateX(-4px); }
.btn:hover svg:has(> use[href="#i-download"]) { animation: nudge-down 0.7s ease-in-out infinite; }
.btn:hover svg:has(> use[href="#i-upload"]) { animation: nudge-up 0.7s ease-in-out infinite; }
.btn:hover svg:has(> use[href="#i-sparkle"]), .composer .sec-head h3 svg:has(> use) { animation: twinkle 1.8s ease-in-out infinite; }
.btn:hover svg:has(> use[href="#i-trash"]), .btn:hover svg:has(> use[href="#i-lock"]), .user-dropdown button:hover svg:has(> use[href="#i-lock"]) { animation: wiggle 0.5s ease-in-out; }
.btn:hover svg:has(> use[href="#i-pen"]) { transform: rotate(-14deg) translateY(-1px); }
.nav-item:hover svg:has(> use) { transform: translateY(-2px) scale(1.08); }
.nav-item:hover svg:has(> use[href="#i-settings"]) { transform: rotate(60deg); }
.kpi:hover .lbl svg:has(> use) { transform: scale(1.2) rotate(-8deg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- controls */

input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid var(--rule-hard);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 15.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { line-height: 1.6; resize: vertical; }
select { appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237B8393' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--navy-2); cursor: pointer; }

.field { display: grid; gap: 6px; }
.field > span, .field-label, .extra-fields-grid label > span { font-size: 14px; font-weight: 600; color: var(--ink-2); transition: color 0.15s; }
.field:focus-within > span, .extra-fields-grid label:focus-within > span { color: var(--focus); }
.field-label { display: block; margin: 14px 0 6px; }
.optional { margin-left: 4px; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.form-stack { display: grid; gap: 14px; }
.form-stack.sub { padding-top: 14px; border-top: 1px solid var(--rule); }
.form-error { min-height: 18px; font-size: 14px; font-weight: 600; color: var(--overdue); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.inline-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }

.btn {
  position: relative;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--rule-hard);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s var(--ease), box-shadow 0.2s;
}
.btn svg:has(> use) { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { background: var(--sunk); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.sm, .btn.small { min-height: 34px; padding: 0 11px; font-size: 14px; }
.btn.lg { min-height: 46px; font-size: 16px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--navy-2); border-color: var(--navy-2); box-shadow: 0 8px 18px -10px rgba(30, 42, 74, 0.7); }
.btn.primary svg:has(> use) { color: var(--gold-bright); }
.btn.gold { background: var(--gold-bright); border-color: var(--gold-bright); color: #1B1405; font-weight: 600; }
.btn.gold:hover:not(:disabled) { background: #E6C271; border-color: #E6C271; box-shadow: 0 8px 20px -10px rgba(216, 174, 85, 0.9); }
.btn.on-photo { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.35); color: #fff; backdrop-filter: blur(6px); }
.btn.on-photo:hover:not(:disabled) { background: rgba(255, 255, 255, 0.2); }
.btn.quiet, .btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover:not(:disabled), .btn.ghost:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.btn.primary-alt { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 35%, transparent); color: var(--ink); }
.btn.danger { color: var(--overdue); border-color: color-mix(in srgb, var(--overdue) 35%, transparent); }
.btn.danger:hover:not(:disabled) { background: var(--overdue-bg); color: var(--overdue); }
.btn.quiet.danger { border-color: transparent; }
.btn.danger-solid { background: var(--overdue); border-color: var(--overdue); color: #fff; }
.btn.danger-solid:hover:not(:disabled) { background: color-mix(in srgb, var(--overdue) 88%, #000); }
.btn.icon-only { width: 34px; padding: 0; }
.actions, .action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.action-row.compact, .action-row.compact-left { gap: 6px; }

.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); font-size: 22px; line-height: 1; cursor: pointer; transition: background 0.15s, transform 0.3s var(--spring); }
.icon-btn:hover { background: var(--sunk); transform: rotate(90deg); }

.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.tiny-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none; }
.select-sm { width: auto; min-height: 34px; padding: 3px 32px 3px 10px; font-size: 14px; max-width: 190px; background-position: right 10px center; }

.search { position: relative; display: flex; align-items: center; min-width: 280px; }
.search > svg:has(> use) { position: absolute; left: 12px; z-index: 1; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }
.search-with-voice { position: relative; display: flex; flex: 1; align-items: center; }
.search-with-voice input { padding-right: 40px; }
.voice-search-btn { position: absolute; right: 6px; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer; transition: background 0.15s, color 0.15s; }
.voice-search-btn:hover { background: var(--sunk); color: var(--ink); }
.voice-search-btn.listening { background: var(--overdue-bg); color: var(--overdue); animation: pulse 1.4s infinite; }
.voice-search-btn.processing { color: var(--gold); }
.voice-search-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.count { display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 6px; border-radius: 3px; background: var(--sunk); color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.count.gold { background: var(--gold-soft); color: var(--gold); cursor: help; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 4px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--sunk); color: var(--ink-2); }
.badge.orange { background: var(--soon-bg); color: var(--soon); }
.badge.blue { background: var(--sunk); color: var(--ink-2); }

/* State pill: the only place red / amber / green appear */
.state { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 4px; font-size: 13.5px; font-weight: 600; white-space: nowrap; font-family: var(--font); letter-spacing: 0; }
.state.overdue { background: var(--overdue-bg); color: var(--overdue); }
.state.soon { background: var(--soon-bg); color: var(--soon); }
.state.clear { background: var(--clear-bg); color: var(--clear); }
.state.idle { background: var(--sunk); color: var(--ink-2); }
.unconfirmed { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 1px 6px; border: 1px dashed color-mix(in srgb, var(--soon) 55%, transparent); border-radius: 3px; background: var(--soon-bg); color: var(--soon); font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 1px; }

.alert { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 18px; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--overdue) 28%, transparent); border-left: 3px solid var(--overdue); border-radius: var(--r-sm); background: var(--overdue-bg); }
.alert .ic { flex: none; color: var(--overdue); padding-top: 2px; }
.alert .ic svg:has(> use) { animation: wiggle 0.6s ease-in-out 0.5s 2; }
.alert p { margin: 0; font-size: 15.5px; color: var(--ink-2); }
.alert b { color: var(--ink); }
.alert .link { color: var(--overdue); }
.alert.slim { margin: 0; padding: 9px 13px; font-size: 14.5px; color: var(--ink-2); border-color: color-mix(in srgb, var(--soon) 30%, transparent); border-left-color: var(--soon); background: var(--soon-bg); }

/* ---------------------------------------------------------------- sign in */

.lock { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 40px 28px; overflow: hidden; color: #fff; background: #0B0F18; }
.lock-photo { position: absolute; inset: -4%; background: url("/assets/images/signin.jpg") center / cover no-repeat; animation: kenburns 28s ease-in-out infinite alternate; }
.lock-shade { position: absolute; inset: 0; background: linear-gradient(100deg, rgba(14, 18, 30, 0.93) 0%, rgba(20, 28, 50, 0.8) 45%, rgba(14, 18, 30, 0.5) 100%); }
.lock-inner { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 440px); gap: 64px; align-items: center; width: min(1140px, 100%); }
.lock-hero { animation: rise 0.7s var(--ease) both; }
.lock-hero h1 { margin-top: 30px; color: #fff; font-size: 54px; line-height: 1.08; }
.lock-hero h1 em { font-style: italic; color: var(--gold-bright); }
.lock-lede { margin-top: 16px; max-width: 520px; font-size: 18px; line-height: 1.6; color: rgba(255, 255, 255, 0.78); }
.lock-points { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 10px; }
.lock-points li { display: flex; align-items: center; gap: 10px; font-size: 16px; color: rgba(255, 255, 255, 0.86); animation: rise 0.6s var(--ease) both; }
.lock-points li:nth-child(1) { animation-delay: 0.25s; }
.lock-points li:nth-child(2) { animation-delay: 0.35s; }
.lock-points li:nth-child(3) { animation-delay: 0.45s; }
.lock-points li:nth-child(4) { animation-delay: 0.55s; }
.lock-points svg:has(> use) { color: var(--gold-bright); }
.lock-card { padding: 34px; border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.7); animation: pop 0.6s 0.1s var(--ease) both; }
.lock-card h2 { font-size: 30px; }
.lock-card-sub { margin: 4px 0 20px; font-size: 15px; color: var(--muted); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; margin-bottom: 18px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sunk); }
.segmented .tab { min-height: 36px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); font-size: 15px; font-weight: 500; cursor: pointer; transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.segmented .tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.lock-note { display: flex; gap: 8px; margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.lock-note svg:has(> use) { width: 16px; height: 16px; color: var(--clear); margin-top: 2px; }

.mark { display: flex; align-items: center; gap: 10px; }
.mark .glyph { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 6px; background: var(--gold-bright); color: #1B1405; flex: none; }
.mark .glyph svg:has(> use) { width: 22px; height: 22px; }
.mark b { display: block; color: #fff; font-size: 18px; font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; white-space: nowrap; }
.mark span { color: rgba(255, 255, 255, 0.72); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; white-space: nowrap; }
.mark-lg .glyph { width: 46px; height: 46px; border-radius: 8px; }
.mark-lg .glyph svg:has(> use) { width: 27px; height: 27px; }
.mark-lg b { font-size: 21px; }
.mark-lg span { font-size: 11px; }

/* ---------------------------------------------------------------- top bar */

.app { min-height: 100vh; background: var(--paper); }
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 28px; height: 68px; padding: 0 24px; background: linear-gradient(180deg, #1F2C4F 0%, #172241 100%); border-bottom: 3px solid #D8AE55; box-shadow: 0 10px 24px -16px rgba(0, 0, 0, 0.8); }
.appnav { position: relative; display: flex; flex: 1; align-items: center; gap: 6px; height: 100%; }
.nav-item { position: relative; display: flex; align-items: center; gap: 9px; height: 44px; padding: 0 18px; border: 0; border-radius: 9px; background: transparent; color: #E6EAF3; font-size: 16.5px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: color 0.15s, background 0.2s, box-shadow 0.2s; }
.nav-item svg:has(> use) { width: 20px; height: 20px; color: #AFC0E4; transition: transform 0.35s var(--spring), color 0.2s; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.nav-item:hover svg:has(> use) { color: #fff; }
.nav-item.active { background: #D8AE55; color: #1B1405; box-shadow: 0 8px 18px -10px rgba(216, 174, 85, 0.95); }
.nav-item.active svg:has(> use) { color: #1B1405; }
.nav-indicator { display: none; }
.ai-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 999px; color: #fff; font-size: 14.5px; font-weight: 600; font-weight: 500; white-space: nowrap; }
.ai-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #8a93a8; color: rgba(138, 147, 168, 0.5); flex: none; }
.ai-chip.online { border-color: rgba(108, 187, 149, 0.45); color: #A9DDC3; }
.ai-chip.online .dot { background: #6CBB95; color: rgba(108, 187, 149, 0.5); animation: pulse 2.2s infinite; }
.ai-chip.offline { background: rgba(168, 50, 42, 0.18); border-color: rgba(224, 121, 108, 0.42); color: #F0A79D; }
.ai-chip.offline .dot { background: #E0796C; color: rgba(224, 121, 108, 0.55); animation: pulse 1.6s infinite; }

.user-menu { position: relative; }
.who { position: relative; display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: #fff; font-size: 15px; font-weight: 600; font-weight: 500; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.who:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.14); }
.who .av { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #D8AE55; color: #1B1405; font-size: 12px; font-weight: 700; flex: none; }
.who .chev { width: 14px; height: 14px; color: rgba(255, 255, 255, 0.6); transition: transform 0.25s var(--ease); }
.who[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu-dot { position: absolute; top: 2px; left: 30px; width: 9px; height: 9px; border: 2px solid #1E2A4A; border-radius: 50%; background: #E3A33B; color: rgba(227, 163, 59, 0.6); animation: pulse 2s infinite; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 8px); display: grid; min-width: 240px; padding: 6px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-pop); opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity 0.15s, transform 0.25s var(--ease), visibility 0.15s; }
.user-dropdown.open { opacity: 1; visibility: visible; transform: none; }
.user-dropdown button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); font-size: 15px; text-align: left; cursor: pointer; }
.user-dropdown button:hover { background: var(--sunk); color: var(--ink); }
.user-dropdown button svg:has(> use) { width: 16px; height: 16px; color: var(--muted); }
.user-dropdown button.danger, .user-dropdown button.danger svg:has(> use) { color: var(--overdue); }
.user-dropdown .menu-backup { align-items: flex-start; }
.user-dropdown .menu-backup span { display: grid; }
.user-dropdown .menu-backup small { font-size: 12.5px; color: var(--soon); }
.menu-sep { height: 1px; margin: 4px; background: var(--rule); }

/* ---------------------------------------------------------------- stage & headers */

.stage { max-width: 1480px; margin: 0 auto; padding: 24px 28px 64px; }
.view { display: none; }
.view.active-view { display: block; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.where { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.head h1 { font-size: 30px; }
.when { margin-top: 4px; font-size: 15px; color: var(--muted); }

/* Photographic header — real photos under a dark shade, slow Ken Burns drift */
.photo-head { position: relative; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px; min-height: 168px; margin-bottom: 18px; padding: 24px 26px; overflow: hidden; border-radius: 9px; color: #fff; background: #151B28; box-shadow: var(--shadow); isolation: isolate; }
.photo-head::before { content: ""; position: absolute; inset: 0; z-index: -2; background: var(--photo) center / cover no-repeat; animation: kenburns 26s ease-in-out infinite alternate; }
.photo-head::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(100deg, rgba(17, 22, 36, 0.94) 0%, rgba(22, 30, 52, 0.82) 42%, rgba(22, 30, 52, 0.3) 100%); }
.photo-head .where { color: #D8AE55; }
.photo-head h1 { color: #fff; font-size: 32px; }
.photo-head .when { color: rgba(255, 255, 255, 0.8); max-width: 720px; }
.desk-head { --photo: url("/assets/images/rera.jpg"); }
[data-area="income_tax"] .desk-head { --photo: url("/assets/images/tax.jpg"); }
[data-area="knowledge_library"] .desk-head { --photo: url("/assets/images/library.jpg"); }

.sec { margin-top: 26px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 16px; padding-bottom: 9px; border-bottom: 1px solid var(--rule-hard); }
.sec-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); }
.sec-head h3 svg:has(> use) { width: 16px; height: 16px; color: var(--gold); }
.sec-head .note { flex: 1; }
.sec-head .search { align-self: center; }
.sec-head.tight { padding-bottom: 6px; border-bottom: 0; }
.sec-head.wrap { align-items: flex-start; margin-bottom: 14px; }
.sec-head.wrap .note { display: block; margin-top: 4px; max-width: 760px; }
.empty-line { padding: 14px 0; font-size: 15px; color: var(--muted); }

/* ---------------------------------------------------------------- dashboard */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--rule); }
.kpi { display: flex; flex-direction: column; gap: 1px; padding: 15px 18px; background: var(--surface); transition: background 0.2s; }
.kpi:hover { background: color-mix(in srgb, var(--surface) 60%, var(--sunk)); }
.kpi .lbl { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi .lbl svg:has(> use) { width: 14px; height: 14px; color: var(--gold); }
.kpi .val { font-size: 31px; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .val.alarm { color: var(--overdue); }
.kpi .val.warn { color: var(--soon); }
.kpi .foot { font-size: 13.5px; color: var(--muted); }

.tbl-wrap { overflow-x: auto; }
table.matters { width: 100%; border-collapse: collapse; font-size: 15.5px; }
table.matters th { padding: 11px 13px; border-bottom: 1px solid var(--rule); font-size: 12.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); text-align: left; white-space: nowrap; }
table.matters td { padding: 13px; border-bottom: 1px solid var(--rule); vertical-align: top; transition: background 0.15s; }
table.matters tr:last-child td { border-bottom: 0; }
table.matters tbody tr:hover td { background: var(--sunk); }
.clickable-row { cursor: pointer; }
.clickable-row td:first-child { box-shadow: inset 0 0 0 var(--gold); transition: box-shadow 0.2s, background 0.15s; }
.clickable-row:hover td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.clickable-row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.caseno { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.client { font-weight: 600; }
.matter-sub { font-size: 14px; color: var(--muted); }
.date-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-match { margin-top: 2px; font-size: 13.5px; color: var(--gold); }
.empty-table { padding: 42px 14px !important; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- matters */

.workspace-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: start; }
.workspace-grid.detail-mode { grid-template-columns: minmax(0, 1fr); }
.workspace-grid.detail-mode .case-panel { display: none; }
#workspaceView.matter-open > .desk-head { display: none; }

.case-panel { position: sticky; top: calc(var(--topbar-h) + 18px); max-height: calc(100vh - var(--topbar-h) - 36px); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.case-panel-head { display: grid; gap: 8px; padding: 14px; border-bottom: 1px solid var(--rule); }
.case-panel .search { min-width: 0; }
.case-list { overflow-y: auto; }
.case-list > .subtle { padding: 22px 14px; text-align: center; }
.case-item { position: relative; display: grid; gap: 2px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; text-align: left; cursor: pointer; transition: background 0.15s, padding-left 0.25s var(--ease); }
.case-item:hover { background: var(--sunk); padding-left: 18px; }
.case-item strong { font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.case-item span { font-size: 13.5px; color: var(--muted); }
.case-item.active { background: var(--gold-soft); }
.case-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }
.case-deadline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.case-deadline::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.case-deadline.red { color: var(--overdue) !important; }
.case-deadline.red::before { background: var(--overdue); }
.case-deadline.orange { color: var(--soon) !important; }
.case-deadline.orange::before { background: var(--soon); }
.case-deadline.green { color: var(--clear) !important; }
.case-deadline.green::before { background: var(--clear); }
.inline-empty { display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center; }
.inline-empty h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; }

.case-main { min-width: 0; container-type: inline-size; }
.select-state { display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 340px; padding: 32px; text-align: center; border: 1px dashed var(--rule-hard); border-radius: var(--r); }
.select-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 6px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); animation: float 5s ease-in-out infinite; }
.select-icon svg:has(> use) { width: 26px; height: 26px; }
.select-state h2 { font-size: 22px; }
.select-state p { max-width: 360px; font-size: 15px; color: var(--muted); }
.select-state .btn { margin-top: 8px; }

.matter-bar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 18px; }
.matter-bar-main { min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; margin: 0 0 5px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.crumb-back { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px 2px 2px; margin-left: -2px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-2); font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.crumb-back:hover { background: var(--sunk); color: var(--ink); }
.crumb-back svg:has(> use) { width: 14px; height: 14px; }
.matter-id { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.matter-id h2 { font-size: 28px; font-variant-numeric: tabular-nums; }
.facts { display: flex; flex-wrap: wrap; row-gap: 4px; margin-top: 10px; font-size: 15px; color: var(--ink-2); }
.facts span { padding-right: 13px; margin-right: 13px; border-right: 1px solid var(--rule-hard); }
.facts span:last-child { padding-right: 0; margin-right: 0; border-right: 0; }
.facts b { color: var(--ink); font-weight: 600; }

.mtabs { position: relative; display: flex; gap: 2px; margin: 18px 0 0; overflow-x: auto; border-bottom: 1px solid var(--rule-hard); }
.mtabs .matter-tab { position: relative; appearance: none; padding: 10px 16px; border: 0; background: transparent; color: var(--muted); font-size: 15.5px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: color 0.15s; }
.mtabs .matter-tab:hover { color: var(--ink); }
.mtabs .matter-tab.active { color: var(--ink); font-weight: 600; }
.mtabs .matter-tab.active::after { content: ""; position: absolute; left: 11px; right: 11px; bottom: 0; height: 2px; background: var(--tab-line); transform-origin: left; animation: grow-x 0.35s var(--ease); }
.mtabs .matter-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.detail-section { display: none; padding-top: 22px; }
.detail-section.active-section { display: block; }

/* ---------------------------------------------------------------- overview */

.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.overview { display: grid; min-width: 0; }
.overview > .sec-head { margin-bottom: 12px; }
.strip { overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.strip-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--rule); animation: rise 0.4s var(--ease) both; }
.strip-row:nth-child(2) { animation-delay: 0.04s; }
.strip-row:nth-child(3) { animation-delay: 0.08s; }
.strip-row:nth-child(4) { animation-delay: 0.12s; }
.strip-row:last-child { border-bottom: 0; }
.strip-row.lead { background: var(--sunk); }
.strip .name { font-size: 15.5px; font-weight: 500; }
.strip .name em { display: block; font-size: 13.5px; font-style: normal; color: var(--muted); }
.strip .d { font-size: 15.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

.calc { margin-top: 24px; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.calc-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--rule); background: var(--sunk); }
.calc-head h4 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.tagline { padding: 2px 8px; border-radius: 3px; background: var(--gold-soft); color: var(--gold); font-size: 12px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; }
.headline { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--rule); }
.headline > div { padding: 17px 18px; background: var(--surface); }
.headline .lbl { font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.headline .big { margin-top: 1px; font-size: 33px; font-weight: 600; line-height: 1.2; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.headline .hint { font-size: 13.5px; color: var(--muted); }
dl.rows { margin: 0; border-top: 1px solid var(--rule); }
.setting dl.rows { border-top: 1px solid var(--rule); }
dl.rows > div { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 9px 18px; border-bottom: 1px solid var(--rule); font-size: 15.5px; }
dl.rows > div:last-child { border-bottom: 0; }
dl.rows dt { margin: 0; color: var(--ink-2); }
dl.rows dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-foot { padding: 12px 18px; border-top: 1px solid var(--rule); background: var(--sunk); font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.calc-foot b { color: var(--ink); }

.rail { display: flex; flex-direction: column; gap: 22px; }
.rail section > h4 { display: flex; justify-content: space-between; margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--rule-hard); font-size: 12.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); }
.rail section > h4 span { letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--muted); }
.progress { height: 5px; margin-bottom: 10px; overflow: hidden; border-radius: 3px; background: var(--sunk); }
.progress i { display: block; height: 100%; background: var(--gold); transform-origin: left; animation: grow-x 0.9s var(--ease); }
.slotlist { list-style: none; margin: 0; padding: 0; font-size: 14.5px; }
.slotlist li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.slotlist li:last-child { border-bottom: 0; }
.slotlist .miss { font-size: 13.5px; color: var(--muted); }
.slotlist .has { font-size: 13.5px; font-weight: 600; color: var(--clear); }
.tl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl li { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 6px 0; font-size: 14.5px; }
.tl li:not(:last-child)::before { content: ""; position: absolute; left: 3.5px; top: 20px; bottom: -8px; width: 1px; background: var(--rule-hard); }
.tl .pip { position: relative; width: 8px; height: 8px; margin-top: 7px; border: 1.5px solid var(--rule-hard); border-radius: 50%; background: var(--surface); }
.tl li.done .pip { border-color: var(--navy-2); background: var(--navy-2); }
.tl time { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tl span { font-size: 14px; color: var(--ink-2); }
.render-error { display: grid; gap: 6px; padding: 16px; border: 1px solid color-mix(in srgb, var(--overdue) 30%, transparent); border-radius: var(--r); background: var(--overdue-bg); }
.render-error h3 { color: var(--overdue); }

/* ---------------------------------------------------------------- documents */

.rera-slot-list { display: grid; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.rera-slot { border-bottom: 1px solid var(--rule); animation: rise 0.35s var(--ease) both; }
.rera-slot:last-child { border-bottom: 0; }
.slot-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; }
.slot-title { display: flex; align-items: center; gap: 10px; font-size: 15.5px; font-weight: 600; }
.slot-title span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; background: var(--sunk); color: var(--muted); font-size: 12.5px; font-weight: 700; flex: none; }
.slot-actions { display: flex; gap: 6px; }
.slot-actions .btn { min-height: 32px; padding: 0 11px; font-size: 14px; }
.slot-files { display: grid; padding: 0 14px 10px 48px; }
.slot-empty { font-size: 14px; color: var(--muted); }
.slot-pill { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 7px 0; border-top: 1px dashed var(--rule); }
.slot-pill:first-child { border-top: 0; }
.slot-pill.is-off .slot-file-name { opacity: 0.55; }
.slot-pill .btn { min-height: 30px; padding: 0 9px; font-size: 13.5px; }
.slot-file-name { flex: 1 1 220px; order: -1; display: grid; min-width: 0; }
.slot-file-name strong { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-file-name span { font-size: 13px; color: var(--muted); }

.tax-bench { display: grid; gap: 12px; }
.tax-bench-head, .tax-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.tax-head { display: grid; justify-items: start; gap: 6px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sunk); }
.tax-head.tax-client { border-top: 2px solid var(--gold); }
.tax-head.tax-department { border-top: 2px solid var(--navy-2); }
.tax-head .btn { min-height: 34px; font-size: 14px; }
.tax-badge { font-size: 12.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); }
.tax-badge.orange { color: var(--gold); }
.tax-rows { display: grid; gap: 12px; }
.tax-cell { display: grid; align-content: start; gap: 10px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.tax-cell > .btn { justify-self: start; }
.tax-cell .btn { min-height: 32px; padding: 0 10px; font-size: 13.5px; }
.tax-notice-title { font-size: 16px; font-weight: 600; word-break: break-word; }
.tax-notice-title span { margin-right: 4px; color: var(--muted); }
.meta-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-chip-row:empty { display: none; }
.meta-chip { padding: 2px 8px; border-radius: 4px; background: var(--sunk); font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.field-inline { display: grid; gap: 6px; }
.field-inline > span { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.date-note { font-size: 13px; font-weight: 600; }
.date-note.warn { color: var(--soon); }
.date-note.ok { color: var(--clear); }
.tax-annex-card { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--rule); }
.panel-title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 14.5px; }
.annexure-list { display: grid; }
.annexure-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; border-top: 1px dashed var(--rule); font-size: 14.5px; }
.annexure-item:first-child { border-top: 0; }
.annexure-item > span { flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.annexure-item .btn { min-height: 30px; padding: 0 9px; font-size: 13.5px; }
.tax-preview { min-height: 84px; font-size: 14px; color: var(--ink-2); background: var(--sunk); }
.tax-empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--rule-hard); border-radius: var(--r); }

@container (min-width: 760px) {
  .tax-bench-head, .tax-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (min-width: 1240px) {
  .outputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- AI drafting */

.composer { position: relative; display: grid; gap: 12px; padding: 16px 18px; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.composer .sec-head { padding-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .btn { min-height: 34px; padding: 0 12px; font-size: 14px; }
.chips .btn:hover:not(:disabled) { border-color: var(--gold); background: var(--gold-soft); }
.composer textarea { min-height: 110px; }
.composer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-progress { font-size: 14.5px; font-weight: 500; color: var(--ink-2); }
.composer-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; overflow: hidden; opacity: 0; transition: opacity 0.2s; }
.composer-bar::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%; background: linear-gradient(90deg, var(--navy-2), var(--gold-bright)); animation: progress 1.3s ease-in-out infinite; }
.composer.busy .composer-bar { opacity: 1; }

.outputs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.output { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.output-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px 9px 16px; border-bottom: 1px solid var(--rule); background: var(--sunk); }
.output-head h3 { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 600; }
.model-badge { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; color: #fff; font-size: 12.5px; font-weight: 700; background: var(--navy-2); }
.model-badge.model-claude { background: #1E2A4A; color: #D8AE55; }
.model-badge.model-openai { background: #464E5C; }
.output .alert.slim { margin: 10px 12px 0; }
.output-body { flex: 1; margin: 0; min-height: 220px; max-height: 640px; overflow: auto; padding: 16px 18px; white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 15.5px; line-height: 1.7; color: var(--ink-2); }
.output.provider-off { opacity: 0.55; }
.output.provider-off .output-body:empty::before { content: "This provider has no key on the server."; }
.output-body:empty::before { content: "No output yet — ask a question above."; color: var(--muted); }
.output-body.is-working { color: var(--muted); background-image: linear-gradient(90deg, transparent 0, color-mix(in srgb, var(--gold-bright) 20%, transparent) 50%, transparent 100%), repeating-linear-gradient(180deg, transparent 0 44px, var(--sunk) 44px 54px, transparent 54px 66px); background-size: 500px 100%, 100% 100%; background-repeat: no-repeat, repeat; animation: shimmer 1.3s linear infinite; }

/* ---------------------------------------------------------------- final draft */

.editor-bar { position: sticky; top: calc(var(--topbar-h) + 10px); z-index: 10; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); }
.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--clear); }
.save-status:not(:empty)::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.save-status[data-tone="pending"] { color: var(--muted); }
.save-status[data-tone="error"] { color: var(--overdue); }
.desk { display: flex; justify-content: center; padding: 28px 16px; border-radius: var(--r); background: var(--sunk); }
.paper { width: min(820px, 100%); min-height: 1000px; padding: 64px 72px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; box-shadow: var(--shadow); font-family: var(--doc); font-size: 17px; line-height: 1.8; color: #161616; resize: none; }
.paper:hover { border-color: var(--rule); }
.paper:focus { border-color: var(--rule-hard); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent), var(--shadow); }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary svg:has(> use) { transform: rotate(180deg); }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; min-width: 230px; padding: 5px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-pop); animation: pop 0.2s var(--ease); }
.menu-list button { padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font-size: 15px; text-align: left; cursor: pointer; }
.menu-list button:hover { background: var(--sunk); }

/* ---------------------------------------------------------------- library */

/* One strong colour per library section */
[data-cat] { --cat: #1D4ED8; --cat-deep: #1E3A8A; --cat-soft: #E8EEFD; --cat-line: #BFD0F7; }
[data-cat="prompts"] { --cat: #6D28D9; --cat-deep: #4C1D95; --cat-soft: #F0EAFE; --cat-line: #D3C2FB; }
[data-cat="skills"] { --cat: #1D4ED8; --cat-deep: #1E3A8A; --cat-soft: #E8EEFD; --cat-line: #BFD0F7; }
[data-cat="drafts"] { --cat: #0F766E; --cat-deep: #134E4A; --cat-soft: #E2F4F1; --cat-line: #A9DCD4; }
[data-cat="notices"] { --cat: #C2410C; --cat-deep: #9A3412; --cat-soft: #FFEDE3; --cat-line: #FBC7AA; }
[data-cat="checklists"] { --cat: #15803D; --cat-deep: #14532D; --cat-soft: #E4F5E9; --cat-line: #AEDDBC; }
[data-cat="clauses"] { --cat: #BE123C; --cat-deep: #881337; --cat-soft: #FDE8EE; --cat-line: #F6BACB; }
[data-cat="client_comm"] { --cat: #0369A1; --cat-deep: #0C4A6E; --cat-soft: #E0F2FE; --cat-line: #A5D8F5; }
[data-cat="sops"] { --cat: #4338CA; --cat-deep: #312E81; --cat-soft: #EAE9FD; --cat-line: #C7C4F6; }
[data-cat="all"] { --cat: #0F1522; --cat-deep: #0F1522; --cat-soft: #E9ECF2; --cat-line: #C3C8D2; }

@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes star-pop { 0% { transform: scale(1); } 40% { transform: scale(1.5) rotate(20deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes bar-slide { from { background-position: 0 0; } to { background-position: 200% 0; } }

.library { display: grid; gap: 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar #libraryCategoryFilter { display: none; }
.toolbar .search input { min-height: 46px; border-radius: 9px; font-size: 16px; box-shadow: var(--shadow-card); }
.toolbar .btn { min-height: 46px; border-radius: 9px; }
#libraryFavoriteFilter { font-weight: 600; }
#libraryFavoriteFilter[aria-pressed="true"], .toolbar .btn.active-filter { background: #FEF3C7; border-color: #F59E0B; color: #92400E; }

.library-summary { display: grid; gap: 8px; }
.lib-chips { display: flex; gap: 4px; padding: 5px; overflow-x: auto; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-card); scrollbar-width: none; }
.lib-chip { position: relative; display: inline-flex; flex: 1 0 auto; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 15.5px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background 0.2s, color 0.2s, box-shadow 0.25s; }
.lib-chip svg:has(> use) { width: 18px; height: 18px; color: var(--muted); transition: transform 0.35s var(--spring), color 0.2s; }
.lib-chip b { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: #E9ECF2; color: var(--ink-2); font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; }
.lib-chip:hover { background: var(--cat-soft); color: var(--cat-deep); }
.lib-chip:hover svg:has(> use) { color: var(--cat); transform: translateY(-2px) scale(1.12); }
.lib-chip.active { background: var(--cat); color: #fff; box-shadow: 0 8px 18px -10px var(--cat); }
.lib-chip.active svg:has(> use) { color: #fff; }
.lib-chip.active b { background: rgba(255, 255, 255, 0.25); color: #fff; }
.selected-library-section { font-size: 14px; color: var(--muted); }

.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.library-item-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 20px 20px 16px; overflow: hidden; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-card); animation: card-in 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); transition: transform 0.3s var(--ease), box-shadow 0.3s, border-color 0.3s; }
.library-item-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, var(--cat), color-mix(in srgb, var(--cat) 35%, #fff), var(--cat)); background-size: 200% 100%; }
.library-item-card:hover { transform: translateY(-5px); border-color: var(--cat-line); box-shadow: 0 4px 8px rgba(15, 21, 34, 0.05), 0 24px 40px -22px var(--cat); }
.library-item-card:hover::before { animation: bar-slide 1.6s linear infinite; }

.library-item-head { display: flex; align-items: center; gap: 12px; }
.lib-icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 10px; background: var(--cat-soft); color: var(--cat); transition: transform 0.4s var(--spring), background 0.3s, color 0.3s; }
.lib-icon svg:has(> use) { width: 21px; height: 21px; }
.library-item-card:hover .lib-icon { transform: rotate(-8deg) scale(1.08); background: var(--cat); color: #fff; }
.lib-meta { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.library-type { margin: 0; font-size: 13.5px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--cat); }
.lib-kind { font-size: 13.5px; color: var(--muted); }
.library-item-card h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.3; color: var(--ink); }
.library-star { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: #C3C8D2; font-size: 21px; cursor: pointer; transition: transform 0.3s var(--spring), color 0.15s, background 0.15s; }
.library-star:hover { background: #FEF3C7; color: #F59E0B; transform: scale(1.12); }
.library-star.active { color: #F59E0B; animation: star-pop 0.45s var(--spring); }

.library-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.library-tags:empty { display: none; }
.library-tags span { padding: 2px 10px; border: 1px solid var(--cat-line); border-radius: 999px; background: var(--cat-soft); color: var(--cat-deep); font-size: 13px; font-weight: 600; }
.library-preview { flex: 1; margin: 0; max-height: 132px; overflow: hidden; padding: 12px 14px; border-left: 3px solid var(--cat); border-radius: 0 8px 8px 0; background: #F6F7FA; white-space: pre-wrap; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--ink-2); -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent); mask-image: linear-gradient(180deg, #000 72%, transparent); }

.library-actions { display: grid; gap: 10px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--rule); }
.lib-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.library-actions .btn { min-height: 36px; padding: 0 12px; font-size: 14.5px; border-radius: 8px; }
.btn.lib-copy { background: var(--cat); border-color: var(--cat); color: #fff; font-weight: 600; }
.btn.lib-copy:hover:not(:disabled) { background: var(--cat-deep); border-color: var(--cat-deep); color: #fff; box-shadow: 0 8px 16px -10px var(--cat); }
.btn.lib-copy svg:has(> use) { color: #fff; }
.lib-util { display: flex; gap: 2px; }
.lib-util .btn.icon-only { width: 36px; color: var(--ink-2); }
.lib-util .btn.icon-only:hover:not(:disabled) { background: var(--cat-soft); color: var(--cat-deep); }
.lib-util .btn.icon-only svg:has(> use) { width: 17px; height: 17px; }
.lib-util .lib-del:hover:not(:disabled) { background: var(--overdue-bg) !important; color: var(--overdue) !important; }
.lib-use { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lib-use > span { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.btn.lib-send { gap: 8px; border-color: var(--area-line); background: var(--surface); color: var(--area-ink); font-weight: 600; }
.btn.lib-send i { width: 8px; height: 8px; border-radius: 50%; background: var(--area); }
.btn.lib-send svg:has(> use) { width: 15px; height: 15px; }
.btn.lib-send:hover:not(:disabled) { background: var(--area); border-color: var(--area); color: #fff; }
.btn.lib-send:hover i { background: #fff; }
.btn.lib-send:hover { transform: translateY(-1px); }

.empty-library-card { grid-column: 1 / -1; padding: 40px; text-align: center; border: 1px dashed var(--rule-hard); border-radius: 12px; background: var(--surface); }

/* ---------------------------------------------------------------- settings */

/* Cards pack with no ragged gaps; a wide card (AI keys) spans the whole width. */
.settings-grid { column-count: 2; column-gap: 22px; }
.setting {
  display: block;
  break-inside: avoid;
  margin: 0 0 22px;
  padding: 18px 20px 20px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  animation: rise 0.4s var(--ease) both;
}
.setting > * + * { margin-top: 12px; }
.setting .sec-head { padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--rule); }
.setting.span-2 { column-span: all; }
.setting .form-stack, .setting .inline-fields { margin-top: 12px; }
.setting .setting-line { font-size: 15px; line-height: 1.5; }
.setting:nth-child(2) { animation-delay: 0.05s; }
.setting:nth-child(3) { animation-delay: 0.1s; }
.setting:nth-child(4) { animation-delay: 0.15s; }
.setting > .rows, .setting .status-list, .setting .trash-list { border: 1px solid var(--rule); border-radius: 9px; background: var(--paper); box-shadow: none; }
.setting > .rows > div:has(#storageUsageText) { grid-template-columns: minmax(130px, auto) 1fr; align-items: start; }
#storageUsageText { text-align: left; font-weight: 500; line-height: 1.55; }
.setting-line { font-size: 15px; color: var(--ink-2); }
.status-list { list-style: none; margin: 0; padding: 0; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.status-list li { position: relative; padding: 9px 14px 9px 40px; border-bottom: 1px solid var(--rule); font-size: 15px; color: var(--ink-2); }
.status-list li:last-child { border-bottom: 0; }
.status-list li::before { content: ""; position: absolute; left: 14px; top: 12px; width: 16px; height: 16px; border-radius: 4px; background: var(--sunk); }
.status-list li.ok::before { background: var(--clear-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B6A50' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 11px no-repeat; }
.status-list li.warn::before { background: var(--soon-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A5E12' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M12 6.5v7M12 17.5v.2'/%3E%3C/svg%3E") center / 11px no-repeat; }
.status-list li.warn { color: var(--ink); }
.trash-list { display: grid; overflow: hidden; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.trash-list > .subtle { padding: 12px 14px; }
.trash-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.trash-row:last-child { border-bottom: 0; }
.trash-row > div:first-child { display: grid; gap: 1px; }
.setting-danger .sec-head h3, .setting-danger .sec-head h3 svg:has(> use) { color: var(--overdue); }

/* ---------------------------------------------------------------- admin keys */

.admin-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 14px; }
.admin-key { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); }
.admin-key-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-key-head strong { font-size: 17px; }
.admin-key-fields { display: grid; gap: 10px; }
.model-picker { display: flex; gap: 6px; }
.model-picker select { min-width: 0; flex: 1; }
.model-picker .btn { flex: none; }
.admin-key-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-key-actions .note { flex: 1 1 100%; }
.admin-key .note { font-size: 13.5px; }
.admin-key .note:empty { display: none; }
.ok-note { color: var(--clear); font-weight: 600; }
.badge.muted { background: var(--sunk); color: var(--muted); }
.model-badge.model-gemini { background: #1D4ED8; }
.model-badge.model-groq { background: #C2410C; }


/* ---------------------------------------------------------------- dialogs */

.dialog { padding: 0; border: 0; background: transparent; color: var(--ink); max-width: none; max-height: none; }
.dialog::backdrop { background: rgba(10, 13, 20, 0.5); backdrop-filter: blur(3px); animation: fade 0.2s; }
.dialog-card { display: flex; flex-direction: column; max-height: 100%; margin: 0; background: var(--surface); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--rule); }
.dialog-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dialog-title h2 { font-size: 22px; }
.dialog-sub { margin-top: 1px; font-size: 14px; color: var(--muted); }
.dialog-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 8px; background: var(--gold-soft); color: var(--gold); }
.dialog-icon svg:has(> use) { width: 19px; height: 19px; }
.dialog-icon-danger { background: var(--overdue-bg); color: var(--overdue); }
.dialog-body { display: grid; gap: 14px; padding: 18px 22px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--rule); background: var(--sunk); }
.dialog.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border-radius: 9px; box-shadow: var(--shadow-pop); }
.dialog.modal .dialog-card { max-height: calc(100vh - 48px); overflow: hidden; border-radius: 9px; }
.dialog.modal.wide { width: min(1000px, calc(100vw - 32px)); }
.dialog.modal[open] { animation: pop 0.25s var(--spring); }
.dialog.drawer { margin: 0 0 0 auto; width: min(620px, 100vw); height: 100vh; max-height: 100vh; box-shadow: var(--shadow-pop); }
.dialog.drawer .dialog-card { height: 100%; }
.dialog.drawer .dialog-body { flex: 1; align-content: start; }
.dialog.drawer[open] { animation: drawer-in 0.35s var(--ease); }

/* New-matter wizard */
.stepper { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-bottom: 1px solid var(--rule); background: var(--sunk); }
.step { display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 15px; font-weight: 500; cursor: pointer; }
.step-dot { position: relative; display: grid; place-items: center; width: 26px; height: 26px; border: 1.5px solid var(--rule-hard); border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; transition: background 0.3s, border-color 0.3s, color 0.3s, transform 0.3s var(--spring); }
.step-name small { margin-left: 3px; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.step.active { color: var(--ink); font-weight: 600; }
.step.active .step-dot { background: var(--navy); border-color: var(--navy); color: #fff; transform: scale(1.1); }
.step.done .step-dot { background: var(--clear); border-color: var(--clear); color: transparent; }
.step.done .step-dot::after { content: ""; position: absolute; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateY(-2px) rotate(-45deg); animation: check-pop 0.35s var(--spring); }
.step-line { position: relative; flex: 1; height: 2px; overflow: hidden; border-radius: 2px; background: var(--rule); }
.step-line i { position: absolute; inset: 0; width: 0; background: var(--clear); transition: width 0.45s var(--ease); }
[data-step="2"] .step-line i { width: 100%; }
.form-step { display: none; gap: 14px; }
.form-step.active { display: grid; }
.form-step.active > * { animation: rise 0.35s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.form-step.from-forward { animation: slide-from-right 0.3s var(--ease); }
.form-step.from-back { animation: slide-from-left 0.3s var(--ease); }
.field-hero input { min-height: 48px; font-size: 18px; font-weight: 500; }
.field.shake { animation: shake 0.45s; }
.field.shake input { border-color: var(--overdue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--overdue) 18%, transparent); }
.details-teaser { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1px dashed var(--rule-hard); border-radius: var(--r); background: var(--sunk); color: var(--ink); text-align: left; cursor: pointer; transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease); }
.details-teaser:hover { border-style: solid; border-color: var(--gold); background: var(--gold-soft); transform: translateY(-1px); }
.details-teaser-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 6px; background: var(--surface); color: var(--gold); }
.details-teaser strong { display: block; font-size: 15.5px; font-weight: 600; }
.details-teaser small { font-size: 14px; color: var(--muted); }
.details-teaser .teaser-go { margin-left: auto; color: var(--gold); }
.fill-meter { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sunk); }
.fill-meter-text { font-size: 14px; color: var(--muted); }
.fill-meter-text strong { color: var(--ink); font-weight: 600; }
.fill-meter-bar { height: 5px; overflow: hidden; border-radius: 3px; background: var(--surface); }
.fill-meter-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.4s var(--ease); }
.extra-fields { display: grid; gap: 12px; }
.extra-fields:empty { display: none; }
.field-group { margin: 0; padding: 10px 14px 14px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); animation: rise 0.35s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
.field-group legend { display: flex; align-items: center; gap: 7px; margin-left: -6px; padding: 0 6px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); }
.field-group-icon { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; background: var(--gold-soft); color: var(--gold); }
.field-group-icon svg:has(> use) { width: 12px; height: 12px; }
.extra-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.extra-fields-grid label { position: relative; display: grid; align-content: start; gap: 5px; }
.extra-fields-grid label.is-filled > span::after { content: ""; display: inline-block; width: 7px; height: 4px; margin-left: 6px; border-left: 2px solid var(--clear); border-bottom: 2px solid var(--clear); transform: translateY(-2px) rotate(-45deg); animation: check-pop 0.3s var(--spring); }
.extra-fields-grid small { font-size: 13px; }

.code-block { margin: 0; max-height: 56vh; overflow: auto; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--sunk); white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.doc-frame { width: 100%; height: 56vh; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--sunk); }
.context-coverage { font-size: 15px; }
.coverage-list { display: grid; gap: 4px; max-height: 190px; margin: 8px 0 0; padding: 0; overflow: auto; list-style: none; }
.coverage-list li { position: relative; padding-left: 16px; }
.coverage-list li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--clear); }
.coverage-list li.missing { color: var(--overdue); }
.coverage-list li.missing::before { background: var(--overdue); }

/* ---------------------------------------------------------------- toasts */

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: grid; gap: 8px; width: min(380px, calc(100vw - 36px)); }
.toast { position: relative; padding: 11px 14px 11px 40px; overflow: hidden; border-radius: var(--r); background: #1B2336; color: #F3F4F6; font-size: 15px; line-height: 1.45; box-shadow: var(--shadow-pop); animation: toast-in 0.35s var(--spring); }
.toast::before { content: ""; position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: rgba(216, 174, 85, 0.25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23D8AE55' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 8v.2M12 11.5v5'/%3E%3C/svg%3E") center / 10px no-repeat; }
.toast.success::before { background: rgba(108, 187, 149, 0.25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236CBB95' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 10px no-repeat; }
.toast.error { background: #4A1814; }
.toast.error::before { background: rgba(224, 121, 108, 0.25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F0A79D' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7L7 17'/%3E%3C/svg%3E") center / 9px no-repeat; }

/* ---------------------------------------------------------------- clarity pass: strong contrast, desk colour, plain headings */

:root { --shadow-card: 0 1px 2px rgba(15, 21, 34, 0.06), 0 8px 22px -14px rgba(15, 21, 34, 0.28); }
:root[data-theme="dark"] { --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5); }

/* Cards: white on a cool grey page, clear border + soft shadow */
.strip, .calc, .rera-slot-list, .composer, .output, .case-panel,
.tax-cell, .tax-head, .select-state, .editor-bar, .rail, .tbl-wrap, .kpi, .matter-bar {
  border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-card);
}

/* Section headings: plain sentence case, bigger, darker, coloured icon */
.sec-head { align-items: center; padding-bottom: 12px; border-bottom: 0; }
.sec-head h3, .rail section > h4, .calc-head h4 { font-size: 18px; font-weight: 700; letter-spacing: -0.005em; text-transform: none; color: var(--ink); }
.sec-head h3 svg:has(> use) { box-sizing: content-box; width: 17px; height: 17px; padding: 6px; border-radius: 7px; background: var(--area-soft); color: var(--area); }
.sec-head .note, .sec-head.wrap .note { font-size: 14.5px; color: var(--muted); }
.where, .crumbs, .kpi .lbl, table.matters th, .headline .lbl, .field-group legend, .tax-badge, .selected-library-section strong { letter-spacing: 0.02em; text-transform: none; }

/* Page headers on photos: tinted with the desk colour */
.desk-head::after { background: linear-gradient(100deg, color-mix(in srgb, var(--area-deep) 96%, #000) 0%, color-mix(in srgb, var(--area-deep) 84%, transparent) 45%, color-mix(in srgb, var(--area) 62%, transparent) 100%); }
#workspaceView .btn.primary { background: var(--area); border-color: var(--area); }
#workspaceView .btn.primary:hover:not(:disabled) { background: var(--area-deep); border-color: var(--area-deep); }
#workspaceView .btn.primary svg:has(> use) { color: #fff; }
.photo-head .where { font-size: 14px; font-weight: 600; }
.desk-head .btn.gold { background: #fff; border-color: #fff; color: var(--area-ink); }
.desk-head .btn.gold:hover:not(:disabled) { background: var(--area-soft); border-color: var(--area-soft); }

/* KPI cards */
.kpis { gap: 14px; overflow: visible; border: 0; background: transparent; }
.kpi { position: relative; gap: 4px; padding: 16px 18px 15px; overflow: hidden; transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.kpi:hover { transform: translateY(-2px); background: var(--surface); box-shadow: 0 2px 4px rgba(15, 21, 34, 0.06), 0 16px 30px -16px rgba(15, 21, 34, 0.4); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #1D4ED8; }
.kpi .lbl { font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.kpi .lbl svg:has(> use) { box-sizing: content-box; width: 16px; height: 16px; padding: 6px; border-radius: 7px; background: #E8EEFD; color: #1D4ED8; }
.kpi .val { font-size: 34px; font-weight: 700; color: var(--ink); }
.kpi .foot { font-size: 14px; }
.kpi:has(.val.alarm)::before { background: var(--overdue); }
.kpi:has(.val.alarm) .lbl svg:has(> use) { background: var(--overdue-bg); color: var(--overdue); }
.kpi:has(.val.warn)::before { background: #D97706; }
.kpi:has(.val.warn) .lbl svg:has(> use) { background: var(--soon-bg); color: var(--soon); }

/* Tracker table */
.tbl-wrap { overflow-x: auto; }
table.matters th { background: #F3F5F9; border-bottom: 1px solid var(--rule-hard); font-size: 14px; color: var(--ink-2); }
table.matters td { border-bottom-color: var(--rule); }
table.matters tbody tr:hover td { background: #F5F8FF; }
.clickable-row:hover td:first-child { box-shadow: inset 4px 0 0 #1D4ED8; }
.caseno { font-weight: 700; }
.desk-tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--area-soft); color: var(--area-ink); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.state { padding: 4px 10px; border-radius: 999px; font-size: 13.5px; }

/* Matter list */
.case-item.active { background: var(--area-soft); }
.case-item.active::before { width: 4px; background: var(--area); }
.case-item.active strong { color: var(--area-ink); }
.select-icon { background: var(--area-soft); color: var(--area); }

/* Matter header card */
.matter-bar { position: relative; padding: 20px 24px 18px; overflow: hidden; }
.matter-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, var(--area), color-mix(in srgb, var(--area) 45%, #D8AE55)); }
.crumbs { font-size: 14px; color: var(--muted); }
.crumb-back { color: var(--area-ink); font-weight: 700; }
.crumb-back:hover { background: var(--area-soft); color: var(--area-ink); }
.matter-id h2, .matter-bar-main .matter-id h2 { font-size: 29px; color: var(--ink); }
.facts { margin-top: 12px; font-size: 15.5px; }
.facts span { color: var(--muted); }
.facts b { color: var(--ink); font-weight: 700; }
.matter-bar .btn.primary { background: var(--area); border-color: var(--area); }
.matter-bar .btn.primary:hover:not(:disabled) { background: var(--area-deep); border-color: var(--area-deep); }
.matter-bar .btn.primary svg:has(> use) { color: #fff; }

/* Tabs: clear pills, active one filled with the desk colour */
.mtabs { gap: 6px; margin-top: 16px; padding: 5px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-card); width: fit-content; max-width: 100%; }
.mtabs .matter-tab { padding: 9px 18px; border-radius: 7px; color: var(--ink-2); font-weight: 600; transition: background 0.2s, color 0.2s; }
.mtabs .matter-tab:hover { background: var(--sunk); color: var(--ink); }
.mtabs .matter-tab.active { background: var(--area); color: #fff; }
.mtabs .matter-tab.active::after { display: none; }
.mtabs .matter-tab .count { background: rgba(15, 21, 34, 0.08); color: inherit; }
.mtabs .matter-tab.active .count { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* Overview */
.overview > .sec-head { margin-bottom: 4px; }
.overview > .sec-head .btn { border: 1px solid var(--rule-hard); background: var(--surface); color: var(--ink); }
.strip-row { padding: 14px 18px; }
.strip-row.lead { background: var(--area-soft); box-shadow: inset 4px 0 0 var(--area); }
.strip .name { font-size: 16px; font-weight: 600; color: var(--ink); }
.strip .name em { font-size: 14px; color: var(--muted); }
.strip .d { font-size: 16px; font-weight: 700; color: var(--ink); }

.calc-head { padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.calc-head h4 { font-size: 18px; }
.tagline { padding: 3px 10px; border-radius: 999px; letter-spacing: 0.02em; text-transform: none; font-size: 13px; }
.headline { gap: 12px; padding: 14px; background: var(--surface); }
.headline > div { border-radius: 8px; background: var(--area-soft); border: 1px solid var(--area-line); }
.headline .lbl { font-size: 14px; color: var(--area-ink); }
.headline .big { font-size: 34px; font-weight: 700; color: var(--area-ink); }
.headline .hint { font-size: 14px; color: var(--ink-2); }
dl.rows > div { padding: 11px 18px; font-size: 16px; }
dl.rows dt { color: var(--ink-2); }
dl.rows dd { font-weight: 700; color: var(--ink); }
.calc-foot { font-size: 14.5px; color: var(--ink-2); background: var(--sunk); }

.rail { gap: 24px; padding: 18px 20px; }
.rail section > h4 { align-items: baseline; margin-bottom: 8px; padding-bottom: 0; border-bottom: 0; font-size: 17px; }
.rail section > h4 span { font-size: 14px; font-weight: 600; color: var(--area-ink); }
.progress { height: 8px; border-radius: 999px; background: var(--sunk); }
.progress i { border-radius: 999px; background: var(--area); }
.slotlist li { padding: 8px 0; font-size: 15px; color: var(--ink); }
.slotlist .miss { color: var(--muted); }
.slotlist .has { color: var(--clear); }
.tl .pip { width: 10px; height: 10px; margin-top: 6px; border-width: 2px; }
.tl li:not(:last-child)::before { left: 4.5px; }
.tl li.done .pip { border-color: var(--area); background: var(--area); }
.tl time { font-size: 15px; color: var(--ink); }

/* Documents / AI */
.slot-title span { background: var(--area-soft); color: var(--area-ink); }
.slot-title { color: var(--ink); }
.composer .sec-head h3 svg:has(> use) { animation: none; }
.btn.primary-alt { background: var(--area-soft); border-color: var(--area-line); color: var(--area-ink); font-weight: 600; }
.model-badge.model-claude { background: var(--area); color: #fff; }
.chips .btn { border-color: var(--rule-hard); }
.chips .btn:hover:not(:disabled) { border-color: var(--area); background: var(--area-soft); color: var(--area-ink); }
.tax-head.tax-department { border-top: 4px solid var(--area); }
.tax-head.tax-client { border-top: 4px solid #D8AE55; }
.tax-badge, .tax-badge.orange { font-size: 16px; font-weight: 700; color: var(--ink); }
input[type="checkbox"] { accent-color: var(--area); }
.btn.quiet { color: var(--ink-2); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .split { grid-template-columns: 1fr; gap: 22px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .case-panel { position: static; max-height: none; }
  .settings-grid { column-count: 1; }
}
@media (max-width: 1280px) {
  .topbar { gap: 14px; padding: 0 16px; }
  .appnav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav-item { padding: 0 13px; font-size: 15.5px; }
}
@media (max-width: 1120px) {
  .who-name { display: none; }
  .topbar .mark > div { display: none; }
}
@media (max-width: 960px) {
  .nav-item span { display: none; }
  .nav-item { padding: 0 12px; }
}
@media (max-width: 720px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .mark > div, .ai-chip span, .who .chev { display: none; }
  .appnav { min-width: 0; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .nav-item { height: 40px; padding: 0 10px; }
  .ai-chip { padding: 7px; }
  .mark .glyph { width: 34px; height: 34px; }
  .stage { padding: 14px 12px 48px; }
  .photo-head { padding: 18px; min-height: 0; }
  .photo-head h1 { font-size: 25px; }
  .headline, .field-grid, .extra-fields-grid { grid-template-columns: 1fr; }
  .paper { padding: 32px 20px; min-height: 70vh; }
  .desk { padding: 10px 6px; }
  .editor-bar { position: static; }
  .search { min-width: 0; width: 100%; }
  .lock { padding: 24px 14px; }
  .lock-inner { grid-template-columns: 1fr; gap: 24px; }
  .lock-hero h1 { margin-top: 18px; font-size: 36px; }
  .lock-points { display: none; }
  .lock-card { padding: 22px; }
  .library-grid { grid-template-columns: 1fr; }
  .step-name small { display: none; }
  .strip-row { grid-template-columns: 1fr auto; }
  .strip-row .state { grid-column: 1 / -1; justify-self: start; }
  .slot-files { padding-left: 14px; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  table.matters { min-width: 760px; }
  .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .facts span { padding-right: 0; margin-right: 0; border-right: 0; }
}
