:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --line: #e3e8ef;
  --line-strong: #d3dae4;
  --text: #0e1726;
  --text-2: #475467;
  --muted: #8a94a6;
  --brand: #1b3a6b;
  --brand-hover: #15305a;
  --brand-soft: #eaf0fa;
  --brand-ink: #1b3a6b;
  --gold: #c39a3e;
  --gold-soft: #faf3e3;
  --sidebar: #0d1b33;
  --sidebar-2: #13264a;
  --sidebar-text: #a9b6cc;
  --ok: #157f3c;
  --ok-soft: #e7f6ec;
  --warn: #a15c07;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 6px 16px -6px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.22);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1220; --surface: #121a2b; --surface-2: #0f1727; --surface-3: #18233a; --line: #222e45; --line-strong: #2d3b57;
    --text: #e8edf6; --text-2: #b3bdd0; --muted: #7d89a0; --brand: #5b8def; --brand-hover: #74a0f5; --brand-soft: #172743; --brand-ink: #9dbcf7;
    --gold: #d8b25a; --gold-soft: #2a2414; --sidebar: #070d19; --sidebar-2: #111c33; --ok: #4cc27a; --ok-soft: #12291c;
    --warn: #e5a23a; --warn-soft: #2d2210; --danger: #f07167; --danger-soft: #2f1615;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.6); color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1220; --surface: #121a2b; --surface-2: #0f1727; --surface-3: #18233a; --line: #222e45; --line-strong: #2d3b57;
  --text: #e8edf6; --text-2: #b3bdd0; --muted: #7d89a0; --brand: #5b8def; --brand-hover: #74a0f5; --brand-soft: #172743; --brand-ink: #9dbcf7;
  --gold: #d8b25a; --gold-soft: #2a2414; --sidebar: #070d19; --sidebar-2: #111c33; --ok: #4cc27a; --ok-soft: #12291c;
  --warn: #e5a23a; --warn-soft: #2d2210; --danger: #f07167; --danger-soft: #2f1615;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.6); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.icon { flex-shrink: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; color: #fff; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #1a1305;
  background: linear-gradient(135deg, #e6c779, var(--gold)); box-shadow: 0 6px 16px -6px rgba(195, 154, 62, 0.7);
}
.brand strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand small { color: var(--sidebar-text); font-size: 11.5px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; color: #6e7d98; padding: 14px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8.5px 10px; border-radius: 9px; color: var(--sidebar-text);
  font-weight: 500; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255, 255, 255, 0.1); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-item .badge-count { margin-left: auto; background: var(--gold); color: #1a1305; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot strong { color: #fff; display: block; font-size: 13px; }
.sidebar-foot small { font-size: 11.5px; }
.sidebar-foot .icon-btn { color: var(--sidebar-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--surface) 85%, transparent);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
}
.topbar .menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search input { padding-left: 38px; background: var(--surface-2); }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 40;
}
.search-results a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--text); }
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.content { padding: 28px; max-width: 1480px; width: 100%; margin: 0 auto; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { margin: 4px 0 0; color: var(--text-2); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; font-weight: 650; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-weight: 550; font-size: 13px; }
.stat .stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.stat .stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .stat-foot { font-size: 12.5px; color: var(--muted); }
.stat.gold .stat-icon { background: var(--gold-soft); color: var(--gold); }

/* Bars (single series: one hue, direct labels) */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 36px; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .label { color: var(--text-2); }
.bar-track { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--brand); min-width: 4px; transition: width 0.4s; }
.bar-row:hover .bar-fill { background: var(--brand-hover); }
.bar-row .value { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type='checkbox'] { width: auto; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-all { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.form-section { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); grid-column: 1 / -1; margin-top: 8px; padding-bottom: 4px; border-bottom: 1px dashed var(--line); }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1); }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn.gold { background: linear-gradient(135deg, #e2c068, var(--gold)); color: #1d1503; }
.btn.gold:hover:not(:disabled) { filter: brightness(1.05); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
.icon-btn { background: transparent; border: 0; padding: 7px; border-radius: 8px; color: var(--text-2); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; display: inline-block; }
.spinner.lg { width: 28px; height: 28px; border-width: 3px; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.blue { background: #e8f0fe; color: #1d4ed8; }
.badge.violet { background: #f1ebfe; color: #6d28d9; }
.badge.amber { background: #fdf3e2; color: #a15c07; }
.badge.orange { background: #fdeee4; color: #c2410c; }
.badge.sky { background: #e3f4fb; color: #0369a1; }
.badge.teal { background: #e0f5f1; color: #0f766e; }
.badge.pink { background: #fce8f3; color: #be185d; }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.gold { background: var(--gold-soft); color: #8a6a1f; }
:root[data-theme='dark'] .badge:not(.neutral), .dark-badges .badge { filter: saturate(0.9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .badge.blue { background: #172a4d; color: #93b4f8; }
  :root:not([data-theme='light']) .badge.violet { background: #251a42; color: #c4a8fb; }
  :root:not([data-theme='light']) .badge.amber, :root:not([data-theme='light']) .badge.gold { background: #2d2210; color: #f0bf6a; }
  :root:not([data-theme='light']) .badge.orange { background: #2f1c10; color: #f6a26e; }
  :root:not([data-theme='light']) .badge.sky { background: #0f2735; color: #7cc8ef; }
  :root:not([data-theme='light']) .badge.teal { background: #0f2a27; color: #6fd6c6; }
  :root:not([data-theme='light']) .badge.pink { background: #2f1424; color: #f39ac9; }
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.1s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person strong { display: block; font-weight: 600; }
.person small { color: var(--muted); }
.avatar { border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; flex-shrink: 0; background: hsl(var(--h) 55% 92%); color: hsl(var(--h) 45% 32%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .avatar { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 60% 80%); } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; font: inherit; font-weight: 600; color: var(--text-2); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tabs .count { background: var(--surface-3); color: var(--text-2); border-radius: 99px; font-size: 11px; padding: 0 7px; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.column { background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 9px; transition: background 0.15s, box-shadow 0.15s; }
.column.drop { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.column-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px; font-weight: 650; font-size: 13px; }
.column-head .count { color: var(--muted); font-weight: 600; }
.column-head small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s, transform 0.15s; display: flex; flex-direction: column; gap: 8px; }
.kcard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kcard.dragging { opacity: 0.5; }
.kcard strong { font-weight: 650; }
.kcard .meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Modal & drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 18, 34, 0.45); backdrop-filter: blur(2px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop 0.18s; }
.modal.wide { width: min(880px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.modal header, .drawer header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal h3, .drawer h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.drawer-overlay { place-items: stretch end; padding: 0; }
.drawer { background: var(--surface); width: min(640px, 100vw); height: 100vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide 0.2s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer header p { margin: 2px 0 0; }
.drawer-body { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); margin-bottom: 8px; }
.empty p { margin: 0; color: var(--muted); max-width: 380px; }
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 550; max-width: 420px; animation: pop 0.2s; }
.toast.error { background: var(--danger); color: #fff; }
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 16px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-item .tdot { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); margin-top: 3px; }
.timeline-item.ia .tdot { border-color: var(--gold); }
.timeline-item p { margin: 0; }
.timeline-item small { color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }
.checklist { display: flex; flex-direction: column; gap: 6px; }
.checklist .item { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.checklist .tick { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.checklist .item.ok .tick { background: var(--ok-soft); color: var(--ok); }
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--text); }
.callout.gold { background: var(--gold-soft); }
.callout .icon { color: var(--brand-ink); margin-top: 2px; }
.callout.gold .icon { color: var(--gold); }
.dropzone { border: 2px dashed var(--line-strong); border-radius: 14px; padding: 22px; text-align: center; color: var(--text-2); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.doc { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; gap: 11px; background: var(--surface); }
.doc-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); flex-shrink: 0; overflow: hidden; }
.doc-icon img { width: 100%; height: 100%; object-fit: cover; }
.doc .doc-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.doc .doc-body select { padding: 4px 8px; font-size: 12px; }
.doc .doc-actions { display: flex; gap: 2px; }

/* Chat */
.chat-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; height: calc(100vh - 64px - 56px - 70px); min-height: 520px; }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-item { display: flex; gap: 11px; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--brand-soft); }
.chat-item .top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item strong { font-weight: 650; }
.chat-item .last { color: var(--muted); font-size: 13px; }
.chat-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 18px 18px; }
.bubble { max-width: 74%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm); font-size: 13.5px; }
.bubble.incoming { align-self: flex-start; background: var(--surface); border-top-left-radius: 4px; }
.bubble.outgoing { align-self: flex-end; background: #dbeafe; color: #0b1f44; border-top-right-radius: 4px; }
.bubble.bot { background: var(--gold-soft); color: var(--text); }
.bubble.private { align-self: flex-end; background: transparent; border: 1px dashed var(--line-strong); box-shadow: none; color: var(--text-2); font-size: 12.5px; }
.bubble.activity { align-self: center; background: transparent; box-shadow: none; color: var(--muted); font-size: 12px; padding: 2px; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.bubble img { max-width: 220px; border-radius: 8px; display: block; margin-top: 4px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .bubble.outgoing { background: #1b3561; color: #e6eefc; } }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.opt { border: 1px solid var(--line-strong); background: var(--surface); color: var(--brand-ink); border-radius: 99px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; }
.chat-compose { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-end; }
.chat-compose textarea { min-height: 42px; max-height: 140px; }
.chat-side { border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }

/* Document editor */
.editor-toolbar { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: 64px; z-index: 5; }
.paper { background: #fff; color: #111; max-width: 820px; margin: 24px auto; padding: 64px 72px; box-shadow: var(--shadow); border-radius: 4px; font-family: 'Times New Roman', Georgia, serif; font-size: 15px; line-height: 1.6; min-height: 900px; }
.paper:focus { outline: none; }
.paper h1, .paper h2, .paper h3 { font-family: inherit; text-align: center; margin: 0.6em 0; }
.paper h1 { font-size: 19px; } .paper h2 { font-size: 16px; } .paper h3 { font-size: 15px; }
.paper p { text-align: justify; margin: 0 0 0.8em; }
.paper table { border-collapse: collapse; width: 100%; } .paper td, .paper th { border: 1px solid #999; padding: 4px 8px; }
.ai-glow { background: linear-gradient(135deg, var(--brand), #3b5ea8 60%, var(--gold)); color: #fff; border-radius: var(--radius); padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; box-shadow: var(--shadow); }
.ai-glow h2 { font-size: 19px; }
.ai-glow p { margin: 4px 0 0; opacity: 0.88; max-width: 640px; }
.opp { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.opp h4 { font-size: 15px; font-weight: 650; }
.opp p { margin: 0; color: var(--text-2); font-size: 13.5px; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(circle at 20% 20%, #23467f 0, transparent 50%), linear-gradient(160deg, var(--sidebar), #183160); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 1px solid rgba(216, 178, 90, 0.35); box-shadow: 0 0 0 60px rgba(216, 178, 90, 0.05), 0 0 0 120px rgba(216, 178, 90, 0.03); }
.login-art h2 { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; max-width: 460px; line-height: 1.15; }
.login-art h2 em { font-style: normal; color: #e6c779; }
.login-art p { color: #b6c3da; max-width: 420px; font-size: 15px; }
.login-form { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.login-form form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-form h1 { font-size: 26px; font-weight: 700; }
.error-text { color: var(--danger); font-weight: 550; font-size: 13px; }

@media print {
  .sidebar, .topbar, .editor-toolbar, .no-print, .toasts { display: none !important; }
  .shell { display: block; } .content { padding: 0; } body { background: #fff; }
  .paper { box-shadow: none; margin: 0; padding: 0; max-width: none; min-height: 0; }
}

@media (max-width: 1100px) {
  .grid.split, .grid.cols-3 { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .chat-side { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 90; transform: translateX(-100%); transition: transform 0.2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { padding: 0 16px; } .topbar .menu-btn { display: inline-grid; }
  .content { padding: 18px 16px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 14px; }
  .stat .stat-value { font-size: 21px; }
  .login { grid-template-columns: 1fr; } .login-art { display: none; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-list { max-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .messages { min-height: 380px; }
  .paper { padding: 32px 22px; }
  .bar-row { grid-template-columns: 110px 1fr 30px; }
  .field.span-2 { grid-column: auto; }
}
