/* ============================================================
   SOP360 — Enterprise SOP Management Platform
   Design system & application styles
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --border: #e4e9f2;
  --border-2: #d5dcea;
  --text: #17203a;
  --text-2: #3d4a6b;
  --muted: #6b7690;
  --muted-2: #98a1b8;

  --primary: #2456e6;
  --primary-dark: #1a41b8;
  --primary-soft: #e8eefc;
  --primary-softer: #f0f4fe;

  --sidebar: #0e1830;
  --sidebar-2: #16224a;
  --sidebar-text: #aab6d8;
  --sidebar-active: #ffffff;

  --success: #16a34a;   --success-soft: #e6f6ec;
  --warn: #d97706;      --warn-soft: #fdf1e0;
  --danger: #dc2626;    --danger-soft: #fdeaea;
  --info: #0891b2;      --info-soft: #e3f5f9;
  --purple: #7c3aed;    --purple-soft: #f1eafd;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(23,32,58,.05), 0 1px 3px rgba(23,32,58,.06);
  --shadow-2: 0 4px 14px rgba(23,32,58,.08), 0 2px 4px rgba(23,32,58,.04);
  --shadow-3: 0 12px 40px rgba(10,18,46,.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { vertical-align: middle; }
::placeholder { color: var(--muted-2); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cdd5e4; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b4bfd6; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ App layout ============ */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; padding: 22px 26px 40px; max-width: 1560px; width: 100%; margin: 0 auto; }

/* ============ Sidebar ============ */
.sidebar {
  width: 244px; flex-shrink: 0; background: linear-gradient(180deg, var(--sidebar) 0%, #0c1428 100%);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 60;
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-logo .logo-mark {
  width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2456e6, #5b7cf7);
  display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.side-logo .logo-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.side-logo .logo-sub { font-size: 10.5px; color: #8fa0c8; margin-top: 1px; }

.side-org { padding: 12px 18px; border-bottom: 1px solid rgba(255,255,255,.08); display:flex; align-items:center; gap:9px; }
.side-org .org-avatar { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.1); display:flex; align-items:center; justify-content:center; color:#cdd9f7; flex-shrink:0; }
.side-org .org-name { font-size: 12.5px; font-weight: 600; color: #e5ebfa; line-height: 1.25; }
.side-org .org-sub { font-size: 10.5px; color: #7d8cb4; }

.side-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border: 2px solid transparent; background-clip: content-box; }
.nav-group-label { font-size: 10.2px; text-transform: uppercase; letter-spacing: .9px; color: #5d6c95; padding: 14px 10px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-size: 13px; font-weight: 500; cursor: pointer; margin-bottom: 1px;
  border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e6ecfb; text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(36,86,230,.4); }
.nav-item .nav-ic { flex-shrink: 0; display: flex; opacity: .9; }
.nav-item .nav-count {
  margin-left: auto; background: rgba(255,255,255,.13); color: #e7edfb; font-size: 10.5px; font-weight: 700;
  border-radius: 20px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-item.active .nav-count { background: rgba(255,255,255,.25); }

.side-user { border-top: 1px solid rgba(255,255,255,.08); padding: 12px; position: relative; }
.side-user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 9px;
  background: none; border: none; cursor: pointer; text-align: left;
}
.side-user-btn:hover { background: rgba(255,255,255,.06); }
.side-user-name { font-size: 12.8px; font-weight: 650; color: #eef2fc; line-height: 1.2; }
.side-user-role { font-size: 10.8px; color: #8fa0c8; margin-top: 2px; }

/* ============ Topbar ============ */
.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 50;
}
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.crumbs b { color: var(--text); font-weight: 650; font-size: 14px; white-space: nowrap; }
.crumbs .sep { color: var(--muted-2); }
.topbar-spacer { flex: 1; }

.global-search { position: relative; width: 380px; max-width: 42vw; }
.global-search .search-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; }
.global-search .search-box:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(36,86,230,.12); }
.global-search input { border: none; outline: none; background: none; flex: 1; font-size: 13px; font-family: inherit; color: var(--text); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-3); max-height: 430px; overflow-y: auto; display: none; z-index: 80;
}
.search-results.open { display: block; }
.sr-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--surface-2); }
.sr-item:hover { background: var(--primary-softer); }
.sr-item:last-child { border-bottom: none; }
.sr-title { font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sr-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.sr-snippet { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.45; }
.sr-snippet mark { background: #fff3c2; padding: 0 1px; border-radius: 2px; }
.sr-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 12.5px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-2); position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.icon-btn .dot {
  position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
  border: 2px solid #fff;
}

/* Dropdown menus */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 8px); right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-3); min-width: 230px; z-index: 90; padding: 6px; display: none;
}
.dropdown-menu.open { display: block; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--text-2); border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.menu-item:hover { background: var(--primary-softer); color: var(--primary-dark); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
/* sidebar profile menu opens upward (footer is at the bottom of the viewport) */
.side-user .dropdown-menu { top: auto; bottom: calc(100% + 10px); }
.side-user .js-logout:hover { background: rgba(220, 38, 38, .18); color: #fca5a5; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 8px; }
.menu-head { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* Notification popover */
.notif-pop {
  position: absolute; top: calc(100% + 8px); right: 0; width: 400px; max-width: 92vw; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-3); z-index: 90; display: none; overflow: hidden;
}
.notif-pop.open { display: block; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-head b { font-size: 13.5px; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--surface-2); cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-softer); }
.notif-item.unread:hover { background: #e4ecfd; }
.notif-ic { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-title { font-size: 12.8px; font-weight: 600; line-height: 1.35; }
.notif-body { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--muted-2); margin-top: 4px; }
.notif-empty { padding: 34px; text-align: center; color: var(--muted); }

/* ============ Page scaffolding ============ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 750; letter-spacing: -.2px; display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; max-width: 720px; line-height: 1.5; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ============ Cards ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 18px; }
.card-body.p0 { padding: 0; }
.card-foot { padding: 11px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--muted); }

/* ============ KPI cards ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-1); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3.5px; background: var(--kcolor, var(--primary)); }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--ksoft, var(--primary-soft)); color: var(--kcolor, var(--primary)); flex-shrink: 0; }
.kpi-value { font-size: 26px; font-weight: 780; margin-top: 8px; letter-spacing: -.5px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.kpi-link { cursor: pointer; }
.kpi-link:hover { border-color: var(--primary); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 8px;
  font-size: 13px; font-weight: 600; padding: 8px 15px; cursor: pointer; border: 1px solid transparent;
  font-family: inherit; line-height: 1.2; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.secondary { background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
.btn.secondary:hover:not(:disabled) { border-color: #b9c4dc; background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: rgba(23,32,58,.06); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b91f1f; }
.btn.danger-o { background: var(--surface); border-color: #f3c1c1; color: var(--danger); }
.btn.danger-o:hover:not(:disabled) { background: var(--danger-soft); }
.btn.success { background: var(--success); color: #fff; }
.btn.success:hover:not(:disabled) { background: #12813b; }
.btn.warn-o { background: var(--surface); border-color: #f0d4a8; color: var(--warn); }
.btn.warn-o:hover:not(:disabled) { background: var(--warn-soft); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn.lg { padding: 11px 22px; font-size: 14px; }
.btn.icon-only { padding: 7px; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.3px; font-weight: 650; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap; line-height: 1.5;
}
.badge .sdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.b-draft { background: #eef1f6; color: #55627e; }
.badge.b-under_review { background: #e8eefc; color: #2456e6; }
.badge.b-changes_requested { background: var(--warn-soft); color: #b45d04; }
.badge.b-approved { background: var(--info-soft); color: #0e7490; }
.badge.b-published { background: var(--success-soft); color: #15803d; }
.badge.b-superseded { background: #f0f1f5; color: #77809a; }
.badge.b-expired { background: var(--danger-soft); color: #b91c1c; }
.badge.b-archived { background: #e8ebf1; color: #4b5568; }
.badge.b-neutral { background: #eef1f6; color: #55627e; }
.badge.b-blue { background: #e8eefc; color: #2456e6; }
.badge.b-green { background: var(--success-soft); color: #15803d; }
.badge.b-amber { background: var(--warn-soft); color: #b45d04; }
.badge.b-red { background: var(--danger-soft); color: #b91c1c; }
.badge.b-purple { background: var(--purple-soft); color: #6d28d9; }
.badge.b-cyan { background: var(--info-soft); color: #0e7490; }
.badge.b-dark { background: #2b3450; color: #e7ecf9; }

.traffic { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.traffic.green { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.traffic.amber { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.traffic.red { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11.3px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--primary-softer); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl .num { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.tbl .t-title { font-weight: 600; color: var(--text); }
.tbl .t-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 10px 15px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; border: none;
  background: none; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; font-family: inherit;
  display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .tab-count { background: var(--primary-soft); color: var(--primary-dark); border-radius: 20px; font-size: 10.5px; padding: 1px 7px; font-weight: 700; }

/* ============ Forms ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .col-1 { grid-column: 1 / -1; }
.form-grid .col-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; font-weight: 650; color: var(--text-2); display: flex; gap: 4px; align-items: center; }
.field .req { color: var(--danger); }
.field input, .field select, .field textarea, .input {
  border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 11px; font-size: 13px; font-family: inherit;
  color: var(--text); background: var(--surface); outline: none; width: 100%;
}
.field textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,86,230,.12);
}
.field .hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.1); }
.field .err-msg { font-size: 11.5px; color: var(--danger); font-weight: 600; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #cdd5e4; border-radius: 20px; cursor: pointer; transition: .15s; }
.switch .track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(16px); }

/* ============ Filter bar ============ */
.filter-bar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 15px; }
.filter-bar .search-box {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 8px; padding: 8px 12px; min-width: 260px; flex: 1; max-width: 420px;
}
.filter-bar .search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,86,230,.12); }
.filter-bar .search-box input { border: none; outline: none; flex: 1; font-size: 13px; font-family: inherit; background: none; color: var(--text); }
.filter-bar select { border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; font-family: inherit; background: var(--surface); color: var(--text-2); outline: none; max-width: 180px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: none; background: none; padding: 7px 11px; cursor: pointer; color: var(--muted); display: flex; align-items: center; font-family: inherit; }
.seg button.active { background: var(--primary); color: #fff; }

/* ============ Avatars ============ */
.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
  color: #fff; flex-shrink: 0; font-size: 12px; width: 32px; height: 32px; letter-spacing: .3px;
}
.avatar.sm { width: 25px; height: 25px; font-size: 10px; }
.avatar.lg { width: 42px; height: 42px; font-size: 15px; }
.avatar.sq { border-radius: 9px; }

/* ============ Progress ============ */
.progress { height: 6px; background: #e9edf5; border-radius: 6px; overflow: hidden; min-width: 60px; }
.progress-bar { height: 100%; border-radius: 6px; background: var(--primary); transition: width .3s; }
.progress-bar.green { background: var(--success); }
.progress-bar.amber { background: var(--warn); }
.progress-bar.red { background: var(--danger); }

/* ============ Empty state ============ */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .empty-icon { width: 54px; height: 54px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--muted-2); margin-bottom: 12px; }
.empty b { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 4px; }
.empty p { font-size: 12.5px; max-width: 380px; margin: 0 auto; line-height: 1.5; }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(14,22,46,.5); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 200; padding: 5vh 16px 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-3); width: 540px; max-width: 100%; animation: pop .16s ease-out; }
.modal.wide { width: 780px; }
.modal.xl { width: 960px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-x { border: none; background: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; display: flex; }
.modal-x:hover { background: var(--surface-2); color: var(--text); }

/* ============ Toasts ============ */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: #101a35; color: #eef2fc; border-radius: 10px; padding: 11px 16px; font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow-3); display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px;
  animation: slideIn .2s ease-out; line-height: 1.4;
}
.toast.success { background: #0f6b37; }
.toast.error { background: #a02020; }
.toast.info { background: #1d4ea8; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Alerts ============ */
.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 12.8px; line-height: 1.5; display: flex; gap: 10px; border: 1px solid; }
.alert .al-ic { flex-shrink: 0; margin-top: 1px; display: flex; }
.alert.info { background: var(--primary-softer); border-color: #d4e0fa; color: #1d3d8f; }
.alert.warn { background: var(--warn-soft); border-color: #f3ddb4; color: #8a4b06; }
.alert.danger { background: var(--danger-soft); border-color: #f5caca; color: #991b1b; }
.alert.success { background: var(--success-soft); border-color: #bfe8cd; color: #166534; }

/* ============ Key-value grid ============ */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 13px 20px; }
.kv .kv-item { min-width: 0; }
.kv .kv-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.kv .kv-value { font-size: 13px; font-weight: 550; color: var(--text); line-height: 1.45; word-break: break-word; }

/* ============ Activity feed ============ */
.activity { display: flex; gap: 12px; position: relative; padding: 0 0 18px 0; }
.activity:last-child { padding-bottom: 2px; }
.activity .act-dot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; z-index: 1; }
.activity .act-line { position: absolute; left: 14px; top: 30px; bottom: 0; width: 1.5px; background: var(--border); }
.activity:last-child .act-line { display: none; }
.activity .act-text { font-size: 12.8px; line-height: 1.5; color: var(--text-2); }
.activity .act-text b { color: var(--text); }
.activity .act-time { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

/* ============ Timeline (approval) ============ */
.timeline { position: relative; padding-left: 4px; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 4px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.tl-dot {
  width: 30px; height: 30px; border-radius: 50%; background: #eef1f6; color: var(--muted-2);
  display: flex; align-items: center; justify-content: center; border: 2px solid #e2e7f1; z-index: 1; flex-shrink: 0;
}
.tl-item.done .tl-dot { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.tl-item.current .tl-dot { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); animation: pulse 2s infinite; }
.tl-item.rejected .tl-dot { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(36,86,230,.25); } 50% { box-shadow: 0 0 0 6px rgba(36,86,230,0); } }
.tl-line { width: 2px; flex: 1; background: var(--border); min-height: 14px; }
.tl-item.done .tl-line { background: var(--success); }
.tl-body { flex: 1; min-width: 0; padding-top: 2px; }
.tl-title { font-size: 13.5px; font-weight: 650; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tl-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.tl-actions { margin-top: 9px; display: flex; gap: 8px; flex-wrap: wrap; }
.tl-comment {
  margin-top: 8px; background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--border-2);
  border-radius: 7px; padding: 8px 11px; font-size: 12.3px; color: var(--text-2); line-height: 1.5;
}

/* ============ Wizard ============ */
.wizard-steps { display: flex; gap: 0; margin-bottom: 22px; overflow-x: auto; padding-bottom: 2px; }
.wz-step { display: flex; align-items: center; gap: 9px; flex-shrink: 0; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.wz-step .wz-num {
  width: 27px; height: 27px; border-radius: 50%; background: #e9edf5; color: var(--muted); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #e2e7f1;
}
.wz-step.done .wz-num { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.wz-step.active .wz-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.wz-step .wz-label { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.wz-step.active .wz-label { color: var(--primary-dark); }
.wz-step.done .wz-label { color: var(--text-2); }
.wz-arrow { color: var(--muted-2); margin: 0 8px; flex-shrink: 0; }
.wz-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ============ Login ============ */
.login-page { min-height: 100vh; display: flex; background: #0c1428; }
.login-brand {
  flex: 1.15; background: linear-gradient(160deg, #101c3f 0%, #0d1730 55%, #132b66 130%);
  color: #dfe7fa; padding: 54px 58px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.login-brand::after {
  content: ""; position: absolute; right: -180px; bottom: -180px; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(36,86,230,.35), transparent 65%);
}
.login-brand .lb-logo { display: flex; align-items: center; gap: 12px; }
.login-brand .lb-logo .logo-mark {
  width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #2456e6, #5b7cf7);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.login-brand h1 { font-size: 25px; font-weight: 800; color: #fff; letter-spacing: -.3px; margin-top: auto; line-height: 1.25; max-width: 520px; }
.login-brand .lb-sub { color: #9fb0d8; font-size: 14.5px; margin-top: 12px; max-width: 480px; line-height: 1.65; }
.lb-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 34px; max-width: 560px; }
.lb-feat { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09); border-radius: 12px; padding: 13px 15px; }
.lb-feat .lf-t { font-size: 13px; font-weight: 650; color: #eaf0fd; display: flex; gap: 8px; align-items: center; }
.lb-feat .lf-d { font-size: 11.8px; color: #8fa0c8; margin-top: 4px; line-height: 1.5; }
.lb-stats { display: flex; gap: 34px; margin-top: 40px; }
.lb-stat b { font-size: 23px; color: #fff; display: block; letter-spacing: -.4px; }
.lb-stat span { font-size: 11.5px; color: #8fa0c8; }

.login-panel { flex: 1; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 34px 26px; overflow-y: auto; }
.login-card { width: 480px; max-width: 100%; }
.login-card h2 { font-size: 21px; font-weight: 800; letter-spacing: -.3px; }
.login-card .lc-sub { color: var(--muted); font-size: 13px; margin: 6px 0 20px; line-height: 1.5; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.role-card {
  border: 1.5px solid var(--border); background: var(--surface); border-radius: 11px; padding: 11px 12px; cursor: pointer;
  display: flex; gap: 10px; align-items: center; transition: border-color .12s, box-shadow .12s;
}
.role-card:hover { border-color: #b9c8ee; }
.role-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,86,230,.13); background: var(--primary-softer); }
.role-card .rc-name { font-size: 12.8px; font-weight: 650; line-height: 1.2; }
.role-card .rc-role { font-size: 10.8px; margin-top: 2px; }
.demo-note {
  margin-top: 16px; font-size: 11.8px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-2);
  padding: 10px 13px; border-radius: 9px; line-height: 1.55;
}

/* ============ Library ============ */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; }
.sop-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px;
  cursor: pointer; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 10px; position: relative;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.sop-card:hover { border-color: #b9c8ee; box-shadow: var(--shadow-2); transform: translateY(-1px); }
.sop-card .sc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sop-card .sc-id { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 6px; }
.sop-card .sc-title { font-size: 14px; font-weight: 700; line-height: 1.4; }
.sop-card .sc-desc { font-size: 12px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sop-card .sc-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.sop-card .sc-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--surface-2); padding-top: 10px; margin-top: auto; }
.sop-card .sc-ack { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.doc-type-ic { width: 36px; height: 42px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 9.5px; font-weight: 800; letter-spacing: .5px; color: #fff; flex-shrink: 0; }

/* ============ SOP detail ============ */
.detail-head { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 18px 20px; margin-bottom: 16px; }
.dh-top { display: flex; gap: 14px; align-items: flex-start; }
.dh-title-wrap { flex: 1; min-width: 0; }
.dh-title { font-size: 18.5px; font-weight: 780; letter-spacing: -.25px; display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.dh-meta { display: flex; gap: 17px; flex-wrap: wrap; margin-top: 9px; font-size: 12.3px; color: var(--muted); align-items: center; }
.dh-meta .dm { display: flex; align-items: center; gap: 5.5px; }
.dh-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.ack-banner {
  display: flex; align-items: center; gap: 14px; background: linear-gradient(90deg, #f0f4fe, #e9f7ef);
  border: 1px solid #cfe0fb; border-radius: var(--radius); padding: 13px 17px; margin-bottom: 16px; flex-wrap: wrap;
}
.ack-banner.needed { background: linear-gradient(90deg, #fdf7e8, #fdefd8); border-color: #f0dcae; }

/* ============ Document render ============ */
.doc-render { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); max-width: 860px; margin: 0 auto; }
.doc-cover { padding: 34px 44px 22px; border-bottom: 3px double var(--border-2); text-align: center; }
.doc-cover .dc-org { font-size: 11.5px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); }
.doc-cover .dc-title { font-size: 22px; font-weight: 800; margin-top: 14px; letter-spacing: -.3px; }
.doc-cover .dc-id { font-family: var(--mono); color: var(--primary); font-weight: 700; font-size: 14px; margin-top: 7px; }
.doc-cover .dc-meta { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; margin-top: 18px; font-size: 12px; color: var(--muted); }
.doc-cover .dc-meta b { color: var(--text-2); }
.doc-body { padding: 26px 44px 40px; }
.doc-sec { margin-bottom: 22px; }
.doc-sec h4 { font-size: 14.5px; font-weight: 750; margin-bottom: 9px; padding-bottom: 5px; border-bottom: 1px solid var(--surface-2); display: flex; gap: 8px; }
.doc-sec h4 .sec-num { color: var(--primary); font-family: var(--mono); }
.doc-sec p { font-size: 13.3px; line-height: 1.75; color: var(--text-2); white-space: pre-wrap; }
.doc-toc { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 14px 18px; margin: 20px 0 24px; }
.doc-toc b { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.doc-toc ul { margin: 8px 0 0 18px; font-size: 12.6px; color: var(--text-2); line-height: 1.9; }

/* ============ Version compare ============ */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.compare-col { padding: 0; min-width: 0; }
.compare-col + .compare-col { border-left: 1px solid var(--border); }
.compare-col-head { padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.compare-col-body { padding: 14px 16px; font-size: 12.6px; line-height: 1.7; color: var(--text-2); }
.ins { background: #d5f3e0; color: #0f5132; text-decoration: none; border-radius: 3px; padding: 0 2px; }
.del { background: #fadcdc; color: #8f1d1d; border-radius: 3px; padding: 0 2px; text-decoration: line-through; }
.diff-same { color: var(--muted-2); font-style: italic; }
.diff-sec-block { margin-bottom: 16px; }
.diff-sec-block h5 { font-size: 12.8px; font-weight: 700; margin-bottom: 5px; display: flex; gap: 7px; align-items: center; }
.change-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; border-radius: 5px; padding: 1.5px 7px; }
.change-badge.added { background: var(--success-soft); color: #15803d; }
.change-badge.removed { background: var(--danger-soft); color: #b91c1c; }
.change-badge.modified { background: var(--warn-soft); color: #b45d04; }

/* ============ Chat / AI ============ */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; background: linear-gradient(90deg, #f6f4fe, #f0f4fe); }
.chat-head .ai-avatar { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.chat-msg { display: flex; gap: 11px; max-width: 82%; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg .cm-avatar { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; }
.chat-msg.assistant .cm-avatar { background: linear-gradient(135deg, #7c3aed, #4f46e5); }
.chat-msg .cm-bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 15px; font-size: 13.2px; line-height: 1.65; color: var(--text-2); }
.chat-msg.user .cm-bubble { background: var(--primary); border-color: var(--primary); color: #fff; }
.chat-msg .cm-bubble p + p { margin-top: 8px; }
.chat-msg .cm-bubble b { color: var(--text); }
.chat-msg.user .cm-bubble b { color: #fff; }
.citation {
  margin-top: 10px; border-top: 1px dashed var(--border-2); padding-top: 9px; display: flex; flex-direction: column; gap: 6px;
}
.citation .cite-row { display: flex; gap: 8px; align-items: flex-start; font-size: 11.8px; color: var(--muted); line-height: 1.5; }
.citation .cite-row .cid { font-family: var(--mono); font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 1px 7px; border-radius: 5px; font-size: 11px; white-space: nowrap; }
.chat-suggest { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 22px 12px; }
.suggest-chip { border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); font-size: 12px; padding: 6px 12px; border-radius: 20px; cursor: pointer; font-family: inherit; }
.suggest-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-softer); }
.chat-input-bar { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.chat-input-bar input { flex: 1; border: 1px solid var(--border-2); border-radius: 10px; padding: 11px 15px; font-size: 13.5px; font-family: inherit; outline: none; }
.chat-input-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,86,230,.12); }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #9aa6c4; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
.ai-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: #6d28d9; background: var(--purple-soft); padding: 3px 9px; border-radius: 20px; }

/* ============ Charts ============ */
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 16px; margin-bottom: 16px; }
.donut-wrap { display: flex; align-items: center; gap: 22px; justify-content: center; padding: 8px 0; flex-wrap: wrap; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center b { font-size: 23px; font-weight: 800; letter-spacing: -.5px; }
.donut-center span { font-size: 11px; color: var(--muted); font-weight: 600; }
.donut-box { position: relative; width: 148px; height: 148px; flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; min-width: 130px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.legend-item .lg-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-item .lg-val { margin-left: auto; font-weight: 700; font-size: 12.5px; }
.hbars { display: flex; flex-direction: column; gap: 11px; padding: 6px 0; }
.bar-row { display: grid; grid-template-columns: 108px 1fr 34px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .br-label { color: var(--text-2); font-weight: 550; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .br-track { height: 15px; background: #eef1f7; border-radius: 5px; overflow: hidden; }
.bar-row .br-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #3d6bf3, #2456e6); transition: width .4s; }
.bar-row .br-val { font-weight: 700; font-size: 12px; }
.cols-chart { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding: 8px 4px 0; }
.col-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.col-item .ci-val { font-size: 11.5px; font-weight: 700; }
.col-item .ci-bar { width: 68%; max-width: 46px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, #5b7cf7, #2456e6); min-height: 3px; }
.col-item .ci-label { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ============ Pagination ============ */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; flex-wrap: wrap; }
.pager { display: flex; gap: 5px; }
.pager-btn {
  min-width: 31px; height: 31px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0 8px; font-family: inherit;
}
.pager-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-btn:disabled { opacity: .4; cursor: default; }

/* ============ Org tree / departments ============ */
.org-tree { display: flex; flex-direction: column; gap: 4px; }
.tree-node { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.tree-node.child { margin-left: 26px; }
.tree-node.grandchild { margin-left: 52px; }
.tree-node .tn-ic { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ============ Permission matrix ============ */
.perm-matrix { overflow-x: auto; }
.perm-matrix table { border-collapse: collapse; width: 100%; }
.perm-matrix th, .perm-matrix td { border: 1px solid var(--border); padding: 8px 12px; font-size: 12.3px; text-align: center; }
.perm-matrix th { background: var(--surface-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; font-weight: 600; white-space: nowrap; }
.perm-yes { color: var(--success); font-weight: 700; }
.perm-no { color: #c3cad9; }

/* ============ Audit ============ */
.audit-hash { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); }
.mono { font-family: var(--mono); }

/* ============ Misc / utilities ============ */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.muted2 { color: var(--muted-2); }
.small { font-size: 12px; }
.xsmall { font-size: 11.3px; }
.bold { font-weight: 700; }
.semi { font-weight: 600; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.text-danger { color: var(--danger); } .text-success { color: var(--success); } .text-warn { color: var(--warn); } .text-primary { color: var(--primary); }
.text-purple { color: #6d28d9; }
.clickable { cursor: pointer; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.secure-note { display: flex; align-items: center; gap: 7px; font-size: 11.3px; color: var(--muted); }
.badge-soft { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 3.5px 11px; font-size: 12px; font-weight: 550; color: var(--text-2); }
.upload-zone {
  border: 2px dashed var(--border-2); border-radius: var(--radius); padding: 34px 20px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--primary); background: var(--primary-softer); }
.upload-zone .uz-icon { width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.file-pill { display: flex; align-items: center; gap: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 14px; }
.section-editor { border: 1px solid var(--border); border-radius: 9px; padding: 13px 15px; margin-bottom: 11px; background: var(--surface); }
.wordcloud-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.conf-badge { font-size: 10.6px; font-weight: 700; padding: 2px 8px; border-radius: 5px; }
.conf-high { background: var(--success-soft); color: #15803d; }
.conf-med { background: var(--warn-soft); color: #b45d04; }
.conf-low { background: var(--danger-soft); color: #b91c1c; }

/* ============ Demo guide ============ */
.demo-steps { counter-reset: dstep; display: flex; flex-direction: column; gap: 9px; }
.demo-step { display: flex; gap: 12px; align-items: flex-start; }
.demo-step::before {
  counter-increment: dstep; content: counter(dstep); width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft);
  color: var(--primary-dark); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;
}
.demo-step .ds-body { font-size: 12.8px; line-height: 1.55; color: var(--text-2); }
.demo-step .ds-role { display: inline-block; font-size: 10.5px; font-weight: 700; background: #2b3450; color: #e7ecf9; border-radius: 5px; padding: 1.5px 7px; margin-right: 6px; text-transform: uppercase; letter-spacing: .4px; }

/* ============ Responsive ============ */
.hamburger { display: none; }
@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .global-search { max-width: none; }
}
@media (max-width: 920px) {
  .sidebar { position: fixed; left: -260px; transition: left .2s ease; box-shadow: none; }
  .sidebar.open { left: 0; box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(10,16,34,.45); z-index: 55; display: none; }
  .sidebar-overlay.show { display: block; }
  .hamburger { display: flex; }
  .content { padding: 16px 14px 40px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .compare-grid { grid-template-columns: 1fr; }
  .compare-col + .compare-col { border-left: none; border-top: 1px solid var(--border); }
  .chat-msg { max-width: 95%; }
}
@media print {
  .sidebar, .topbar, .dh-actions, .tabs { display: none !important; }
  .doc-render { border: none; box-shadow: none; }
}
