/* ═══════════════════════════════════════════════════════
   GRAND TENT ERP — Design System v3.0
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette */
  --navy:     #0B1829;
  --navy2:    #112235;
  --navy3:    #1A3350;
  --amber:    #F59E0B;
  --amber-lt: rgba(245,158,11,.12);
  --blue:     #2563EB;
  --blue-lt:  rgba(37,99,235,.1);
  --green:    #10B981;
  --green-lt: rgba(16,185,129,.1);
  --red:      #EF4444;
  --red-lt:   rgba(239,68,68,.1);
  --purple:   #8B5CF6;
  --orange:   #F97316;

  /* Neutrals */
  --g50:  #F8FAFC;
  --g100: #F1F5F9;
  --g200: #E2E8F0;
  --g300: #CBD5E1;
  --g400: #94A3B8;
  --g500: #64748B;
  --g600: #475569;
  --g700: #334155;
  --g900: #0F172A;
  --white: #FFFFFF;

  /* Layout */
  --sidebar: 260px;
  --r:    8px;
  --r-lg: 14px;
  --sh:   0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --sh-lg: 0 8px 32px rgba(0,0,0,.14);

  /* Dept colors */
  --dept-mkt:  #EC4899;
  --dept-sale: #F59E0B;
  --dept-supp: #06B6D4;
  --dept-tech: #8B5CF6;
  --dept-proc: #F97316;
  --dept-prod: #10B981;
  --dept-wh:   #14B8A6;
  --dept-mnt:  #3B82F6;
  --dept-fin:  #22C55E;
  --dept-hr:   #A78BFA;
  --dept-mgmt: #F59E0B;
}

html { font-size: 14px; }
body { font-family: 'Inter','Segoe UI',system-ui,sans-serif; background: var(--g100); color: var(--g900); display: flex; min-height: 100vh; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--g300); border-radius: 4px; }

/* ══════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar); background: var(--navy);
  display: flex; flex-direction: column;
  position: fixed; top:0; left:0; bottom:0;
  overflow-y: auto; z-index: 100;
}
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }

/* Brand */
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--amber); display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: var(--navy); flex-shrink: 0;
}
.brand-name { color: var(--white); font-size: 13px; font-weight: 800; }
.brand-sub  { color: rgba(255,255,255,.35); font-size: 10px; text-transform: uppercase; letter-spacing: .6px; }

/* Mode switcher */
.mode-bar {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.mode-label { font-size: 9.5px; font-weight: 600; color: rgba(255,255,255,.3); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 6px; }
.mode-btns  { display: flex; gap: 4px; }
.mode-btn {
  flex: 1; padding: 6px 4px; border: none; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; cursor: pointer;
  background: rgba(255,255,255,.07); color: rgba(255,255,255,.5);
  transition: all .15s; text-align: center;
}
.mode-btn:hover { background: rgba(255,255,255,.12); color: var(--white); }
.mode-btn.active { background: var(--amber); color: var(--navy); }

/* Nav */
.nav { padding: 8px 8px 0; flex: 1; }
.nav-section { margin-bottom: 4px; }
.nav-section-label {
  font-size: 9px; font-weight: 700; color: rgba(255,255,255,.22);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 8px 3px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 9px; border: none;
  background: transparent; color: rgba(255,255,255,.5);
  border-radius: 7px; cursor: pointer; text-align: left;
  transition: all .13s; margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.88); }
.nav-item.active { background: var(--amber); color: var(--navy); }
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: .6; flex-shrink: 0;
}
.nav-item.active .nav-dot { opacity: 1; }
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-text { flex: 1; }
.nav-text strong { display: block; font-size: 12px; font-weight: 700; line-height: 1.2; }
.nav-text small  { font-size: 10px; opacity: .6; }

/* Dept nav items */
.nav-dept {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 9px; border: none;
  background: transparent; color: rgba(255,255,255,.5);
  border-radius: 7px; cursor: pointer; text-align: left;
  transition: all .13s; margin-bottom: 1px;
}
.nav-dept:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.88); }
.nav-dept.active { background: rgba(255,255,255,.1); color: var(--white); }
.dept-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; opacity: .85;
}
.nav-dept-name { font-size: 12px; font-weight: 600; }
.nav-dept-role-count { font-size: 10px; opacity: .45; margin-left: auto; }

.sidebar-footer {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.06);
  font-size: 10px; color: rgba(255,255,255,.22); line-height: 1.6; flex-shrink: 0;
}

/* ══════════════════════════════════════
   MAIN
   ══════════════════════════════════════ */
.main { flex: 1; margin-left: var(--sidebar); display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  height: 56px; background: var(--white);
  border-bottom: 1px solid var(--g200);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px; position: sticky; top: 0; z-index: 90;
}
.topbar-left { flex: 1; overflow: hidden; }
.topbar-eye   { font-size: 10px; font-weight: 600; color: var(--g400); text-transform: uppercase; letter-spacing: .6px; }
.topbar-title { font-size: 15px; font-weight: 800; color: var(--g900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-wrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--g100); border: 1.5px solid var(--g200);
  border-radius: 8px; padding: 0 10px;
}
.search-wrap:focus-within { border-color: var(--blue); background: var(--white); box-shadow: 0 0 0 3px var(--blue-lt); }
.search-input { border: none; background: transparent; padding: 7px 0; font-size: 12.5px; outline: none; width: 190px; color: var(--g900); }
.search-input::placeholder { color: var(--g400); }
.search-btn { border: none; background: none; cursor: pointer; color: var(--g400); font-size: 13px; }

/* Content */
.content { padding: 22px 24px; flex: 1; }

/* ══════════════════════════════════════
   METRICS ROW
   ══════════════════════════════════════ */
.kpi-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.kpi-card {
  background: var(--white); border-radius: var(--r); padding: 16px 18px;
  box-shadow: var(--sh); border-top: 3px solid transparent;
  display: flex; align-items: center; gap: 13px;
}
.kpi-card.c-amber { border-top-color: var(--amber); }
.kpi-card.c-blue  { border-top-color: var(--blue); }
.kpi-card.c-green { border-top-color: var(--green); }
.kpi-card.c-red   { border-top-color: var(--red); }
.kpi-card.c-navy  { border-top-color: var(--navy3); }
.kpi-icon { width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.c-amber .kpi-icon { background: var(--amber-lt); }
.c-blue  .kpi-icon { background: var(--blue-lt); }
.c-green .kpi-icon { background: var(--green-lt); }
.c-red   .kpi-icon { background: var(--red-lt); }
.c-navy  .kpi-icon { background: rgba(30,51,80,.1); }
.kpi-val  { font-size: 24px; font-weight: 900; color: var(--g900); line-height: 1; }
.kpi-lbl  { font-size: 11px; color: var(--g500); margin-top: 3px; font-weight: 500; }
.kpi-sub  { font-size: 10px; color: var(--g400); margin-top: 1px; }

/* ══════════════════════════════════════
   PANELS
   ══════════════════════════════════════ */
.panel { background: var(--white); border-radius: var(--r-lg); box-shadow: var(--sh); overflow: hidden; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; border-bottom: 1px solid var(--g100); }
.panel-head h2 { font-size: 14px; font-weight: 800; color: var(--g900); }
.eyebrow { font-size: 10px; font-weight: 700; color: var(--g400); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }

/* ══════════════════════════════════════
   PROCESS PIPELINE
   ══════════════════════════════════════ */
.pipeline-scroll { overflow-x: auto; padding: 18px 20px; }
.pipeline-row { display: flex; gap: 8px; min-width: max-content; }
.pip {
  flex-shrink: 0; width: 148px; padding: 12px 13px;
  background: var(--g50); border: 1.5px solid var(--g200);
  border-radius: var(--r); cursor: pointer; transition: all .13s;
  position: relative;
}
.pip:not(:last-child)::after {
  content: '→'; position: absolute; right: -14px; top: 50%;
  transform: translateY(-50%); color: var(--g300); font-size: 14px; font-weight: 700;
  z-index: 1;
}
.pip:hover { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-lt); }
.pip.sel  { border-color: var(--amber); background: var(--amber-lt); }
.pip-num { width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; margin-bottom: 8px; }
.pip.sel .pip-num { background: var(--amber); color: var(--navy); }
.pip-dept-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: middle; }
.pip-name { font-size: 11.5px; font-weight: 700; color: var(--g900); line-height: 1.3; margin-bottom: 4px; }
.pip-role { font-size: 10px; color: var(--g500); line-height: 1.3; }
.pip-sla  { font-size: 10px; color: var(--amber2,#D97706); font-weight: 700; margin-top: 4px; }

/* Stage detail */
.stage-detail {
  background: var(--navy); border-radius: var(--r);
  padding: 18px 20px; margin: 0 20px 18px; color: var(--white);
}
.stage-detail h3 { font-size: 15px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); gap: 14px; }
.sf label { font-size: 9.5px; color: rgba(255,255,255,.38); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 5px; }
.sf p     { font-size: 12.5px; color: var(--white); line-height: 1.4; }
.sla-pill { display: inline-block; background: var(--amber); color: var(--navy); font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 20px; }
.stage-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.stage-btn { border: 1.5px solid rgba(255,255,255,.2); background: rgba(255,255,255,.07); color: var(--white); font-size: 11.5px; font-weight: 700; padding: 5px 12px; border-radius: 6px; cursor: pointer; transition: all .13s; }
.stage-btn:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.4); }
.stage-btn.primary { background: var(--amber); border-color: var(--amber); color: var(--navy); }

/* ══════════════════════════════════════
   DEPARTMENTS
   ══════════════════════════════════════ */
.depts-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(270px,1fr)); gap: 14px; padding: 16px 20px; }
.dept-card {
  border: 1.5px solid var(--g200); border-radius: var(--r);
  padding: 16px; cursor: pointer; transition: all .13s;
  background: var(--g50); position: relative; overflow: hidden;
}
.dept-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--dept-color, var(--g300));
}
.dept-card:hover { border-color: var(--dept-color, var(--blue)); box-shadow: var(--sh); background: var(--white); }
.dept-icon { font-size: 24px; margin-bottom: 8px; }
.dept-name { font-size: 14px; font-weight: 800; color: var(--g900); margin-bottom: 4px; }
.dept-head { font-size: 11px; color: var(--g500); margin-bottom: 10px; }
.dept-roles { display: flex; flex-wrap: wrap; gap: 5px; }
.dept-role-pill { font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: var(--g200); color: var(--g600); cursor: pointer; transition: all .12s; }
.dept-role-pill:hover { background: var(--blue-lt); color: var(--blue); }
.dept-stages { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.dept-stage-num { width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: var(--white); font-size: 9px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

/* Full dept view */
.dept-view-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy3) 100%);
  color: var(--white); margin: -22px -24px 20px;
}
.dept-view-title { font-size: 22px; font-weight: 900; display: flex; align-items: center; gap: 12px; }
.dept-view-sub   { font-size: 13px; color: rgba(255,255,255,.55); margin-top: 4px; }
.dept-color-bar  { width: 40px; height: 4px; border-radius: 4px; margin-bottom: 8px; }

/* ══════════════════════════════════════
   ROLE CARDS
   ══════════════════════════════════════ */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 13px; padding: 16px 20px; }
.role-card {
  background: var(--g50); border: 1.5px solid var(--g200);
  border-radius: var(--r); padding: 15px;
  transition: all .13s; cursor: pointer;
  display: flex; flex-direction: column; gap: 9px;
}
.role-card:hover { border-color: var(--blue); background: var(--white); box-shadow: var(--sh); }
.role-card-top { display: flex; align-items: flex-start; gap: 10px; }
.role-avatar {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  background: var(--g200);
}
.role-dept-tag { font-size: 9.5px; font-weight: 700; color: var(--g400); text-transform: uppercase; letter-spacing: .4px; }
.role-name { font-size: 13.5px; font-weight: 800; color: var(--g900); }
.role-field { font-size: 11.5px; color: var(--g600); line-height: 1.45; }
.role-field strong { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--g400); font-weight: 700; margin-bottom: 2px; }
.role-stages { display: flex; gap: 4px; flex-wrap: wrap; }
.role-stage-badge { width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: var(--white); font-size: 9px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.role-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; background: var(--g200); color: var(--g600); }
.tag.t-kpi   { background: var(--amber-lt); color: #B45309; }
.tag.t-b24   { background: var(--blue-lt);  color: var(--blue); }
.tag.t-check { background: var(--green-lt); color: #047857; }

/* Full role view */
.role-full-header {
  background: var(--navy); color: var(--white);
  padding: 20px 24px; margin: -22px -24px 20px;
  display: flex; align-items: flex-start; gap: 16px;
}
.role-full-avatar { width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,.1); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.role-full-name { font-size: 20px; font-weight: 900; }
.role-full-dept { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 3px; }
.role-tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--g100); background: var(--white); }
.role-tab { padding: 10px 14px; border: none; background: none; font-size: 12px; font-weight: 700; color: var(--g500); cursor: pointer; border-bottom: 2.5px solid transparent; transition: all .13s; }
.role-tab:hover { color: var(--g900); }
.role-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.role-tab-content { padding: 18px 20px; }

/* ══════════════════════════════════════
   CHECKLIST
   ══════════════════════════════════════ */
.cl-wrap { padding: 14px 20px 18px; }
.cl-section { margin-bottom: 20px; }
.cl-title { font-size: 13px; font-weight: 800; color: var(--g900); padding: 9px 0 7px; border-bottom: 1.5px solid var(--g100); margin-bottom: 7px; }
.cl-item { display: flex; align-items: flex-start; gap: 9px; padding: 7px 2px; border-bottom: 1px solid var(--g50); }
.cl-item label { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; flex: 1; font-size: 12.5px; color: var(--g700); line-height: 1.45; }
.cl-item input[type=checkbox] { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; accent-color: var(--blue); cursor: pointer; }
.cl-item input:checked + span { text-decoration: line-through; color: var(--g300); }

/* ══════════════════════════════════════
   DOCS TABLE
   ══════════════════════════════════════ */
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th { text-align: left; padding: 8px 13px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--g500); background: var(--g50); border-bottom: 1.5px solid var(--g200); white-space: nowrap; }
.doc-table td { padding: 10px 13px; font-size: 12.5px; color: var(--g700); border-bottom: 1px solid var(--g100); vertical-align: top; }
.doc-table tr:hover td { background: var(--g50); cursor: pointer; }
.doc-name { font-weight: 700; color: var(--g900); }
.doc-path { font-size: 10px; color: var(--g400); margin-top: 2px; }
.cat-pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; background: var(--g100); color: var(--g600); white-space: nowrap; }

/* ══════════════════════════════════════
   KPI TABLE
   ══════════════════════════════════════ */
.kpi-table { width: 100%; border-collapse: collapse; }
.kpi-table th { text-align: left; padding: 8px 13px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,.5); background: var(--navy); border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
.kpi-table td { padding: 10px 13px; font-size: 12.5px; border-bottom: 1px solid var(--g100); vertical-align: top; color: var(--g700); }
.kpi-table tr:hover td { background: var(--g50); }
.sla-chip  { display: inline-block; background: var(--amber-lt); color: #B45309; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.stop-chip { display: inline-block; background: var(--red-lt); color: var(--red); font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }

/* ══════════════════════════════════════
   RED FLAGS
   ══════════════════════════════════════ */
.flags-list { padding: 12px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.flag-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: var(--r);
  border: 1.5px solid transparent;
}
.flag-item.red    { background: var(--red-lt);   border-color: rgba(239,68,68,.25); }
.flag-item.amber  { background: var(--amber-lt);  border-color: rgba(245,158,11,.25); }
.flag-item.green  { background: var(--green-lt);  border-color: rgba(16,185,129,.25); }
.flag-icon { font-size: 18px; flex-shrink: 0; }
.flag-title { font-size: 12.5px; font-weight: 700; color: var(--g900); margin-bottom: 2px; }
.flag-text  { font-size: 11.5px; color: var(--g600); }

/* ══════════════════════════════════════
   DECISIONS
   ══════════════════════════════════════ */
.dec-list { padding: 12px 20px 18px; display: flex; flex-direction: column; gap: 9px; }
.dec-card { border: 1.5px solid var(--g200); border-radius: var(--r); padding: 13px 16px; background: var(--white); display: flex; gap: 13px; align-items: flex-start; }
.dec-card.ok   { border-left: 4px solid var(--green); }
.dec-card.todo { border-left: 4px solid var(--amber); }
.dec-num { width: 26px; height: 26px; flex-shrink: 0; background: var(--g100); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--g700); }
.dec-q { font-size: 13px; font-weight: 700; color: var(--g900); margin-bottom: 4px; }
.dec-r { font-size: 12px; color: var(--g600); line-height: 1.5; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; flex-shrink: 0; white-space: nowrap; }
.badge-green { background: var(--green-lt); color: #047857; }
.badge-amber { background: var(--amber-lt); color: #B45309; }

/* ══════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════ */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: var(--r); font-size: 12px; font-weight: 700; cursor: pointer; border: none; transition: all .13s; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: #1D4ED8; }
.btn-amber { background: var(--amber); color: var(--navy); }
.btn-amber:hover { background: #D97706; }
.btn-ghost { background: var(--g100); color: var(--g700); border: 1.5px solid var(--g200); }
.btn-ghost:hover { background: var(--g200); }
.link-btn { background: none; border: none; color: var(--blue); font-size: 12px; font-weight: 700; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ══════════════════════════════════════
   FILTER CHIPS
   ══════════════════════════════════════ */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 20px 0; }
.chip { border: 1.5px solid var(--g200); background: var(--g100); color: var(--g600); font-size: 11.5px; font-weight: 700; padding: 4px 11px; border-radius: 20px; cursor: pointer; transition: all .12s; }
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { background: var(--blue); color: var(--white); border-color: var(--blue); }

/* ══════════════════════════════════════
   DIALOG / DOCUMENT VIEWER
   ══════════════════════════════════════ */
/* color-scheme: light — принудительно светлый режим (fix для macOS Dark Mode) */
.doc-dialog {
  width: min(1320px, 92vw); max-height: 92vh;
  margin: auto;
  border: none; border-radius: var(--r-lg);
  box-shadow: 0 32px 80px rgba(0,0,0,.35);
  padding: 0; overflow: hidden;
  background: #ffffff;
  color-scheme: light;
}
.doc-dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(6px); }
.dialog-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 0;
  background: linear-gradient(135deg, #0B1829 0%, #1A3350 100%);
  position: sticky; top: 0; z-index: 10;
}
.dialog-head-inner { padding: 18px 22px 16px; flex: 1; min-width: 0; }
.dialog-eye { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: rgba(255,255,255,.45); margin-bottom: 5px; }
.dialog-head h2 { font-size: 18px; font-weight: 900; color: #ffffff !important; line-height: 1.25; margin: 0 !important; background: none !important; border: none !important; padding: 0 !important; }
.close-btn { background: rgba(255,255,255,.1); border: none; width: 34px; height: 34px; border-radius: 50%; font-size: 15px; cursor: pointer; color: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin: 16px 18px 0 0; transition: all .13s; }
.close-btn:hover { background: rgba(255,255,255,.22); color: #ffffff; }
.dialog-meta { font-size: 11px; color: #64748b; padding: 8px 22px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dialog-body { padding: 28px 32px; overflow-y: auto; max-height: calc(92vh - 115px); background: #ffffff; }

/* ══════════════════════════════════════
   MARKDOWN — Enhanced v4.0
   ══════════════════════════════════════ */

/* Typography */
.md h1 { font-size: 20px; font-weight: 900; color: #0b1829; padding-bottom: 12px; margin: 0 0 22px; line-height: 1.25; border-bottom: 3px solid #f59e0b; }
.md h2 { font-size: 14px; font-weight: 800; color: #1e293b; margin: 24px 0 10px; padding: 0 0 6px 14px; border-left: 4px solid #f59e0b; border-bottom: 1px solid #e2e8f0; background: none; }
.md h3 { font-size: 13px; font-weight: 800; color: #334155; margin: 16px 0 7px; padding-left: 10px; border-left: 2px solid #2563eb; }
.md h3::before { display: none; }
.md h4 { font-size: 12px; font-weight: 700; color: var(--g700); margin: 12px 0 5px; }
.md p  { font-size: 13px; color: var(--g700); margin-bottom: 10px; line-height: 1.7; }
.md strong { color: var(--g900); font-weight: 700; }
.md th strong, .md th em, .md th * { color: #ffffff !important; }
.md em { color: var(--g600); font-style: italic; }
.md code  { background: var(--g100); padding: 1px 6px; border-radius: 4px; font-size: 11.5px; font-family: 'Courier New',monospace; color: var(--navy3); border: 1px solid var(--g200); }
.md pre   { background: var(--g900); color: var(--g100); padding: 14px 18px; border-radius: var(--r); overflow-x: auto; margin-bottom: 13px; }
.md pre code { background: none; color: inherit; padding: 0; border: none; }
.md hr { border: none; height: 2px; background: linear-gradient(90deg, var(--amber) 0%, var(--g100) 60%); margin: 22px 0; border-radius: 2px; }

/* Lists */
.md ul { padding-left: 0; margin-bottom: 12px; list-style: none; }
.md ul li { font-size: 13px; color: var(--g700); margin-bottom: 5px; line-height: 1.6; padding-left: 18px; position: relative; }
.md ul li::before { content: ''; position: absolute; left: 4px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.md ol { padding-left: 0; margin-bottom: 12px; list-style: none; counter-reset: mdol; }
.md ol li { counter-increment: mdol; font-size: 13px; color: var(--g700); margin-bottom: 6px; line-height: 1.6; display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--g50); }
.md ol li:last-child { border-bottom: none; }
.md ol li::before { content: counter(mdol); min-width: 22px; height: 22px; background: var(--navy); color: var(--white); border-radius: 50%; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }

/* Definition-style list items (- **Label:** value) */
.md li.md-def { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; border-bottom: 1px solid var(--g50); padding-left: 0; }
.md li.md-def::before { display: none; }
.md li.md-def:last-child { border-bottom: none; }
.md-def-lbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--g400); min-width: 110px; padding-top: 3px; flex-shrink: 0; }
.md-def-val { font-size: 12.5px; color: var(--g800,#1e293b); line-height: 1.5; }

/* Tables */
.md table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1.5px solid #e2e8f0; border-radius: 10px; overflow: hidden; margin-bottom: 18px; font-size: 12.5px; box-shadow: 0 2px 8px rgba(0,0,0,.06); background: #ffffff; }
.md th { background: #0b1829; color: #ffffff !important; padding: 10px 14px; text-align: left; font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.md td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; color: #475569; vertical-align: top; background: #ffffff; }
.md tbody tr:nth-child(even) td { background: #f8fafc; }
.md tbody tr:last-child td { border-bottom: none; }
.md tbody tr:hover td { background: #eff6ff; }
.md td:first-child { font-weight: 600; color: #0f172a; }

/* Alert boxes (from blockquotes) */
.md-alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 17px; border-radius: 9px; margin-bottom: 14px; }
.md-alert-icon { font-size: 18px; flex-shrink: 0; line-height: 1.6; }
.md-alert-body { font-size: 12.5px; line-height: 1.7; flex: 1; color: #334155; }
.md-alert-body strong { font-weight: 700; color: #1e293b; }
.md-alert-warning { background: #fffbeb; border: 1.5px solid #fcd34d; }
.md-alert-danger  { background: #fff5f5; border: 1.5px solid #fca5a5; }
.md-alert-success { background: #f0fdf4; border: 1.5px solid #86efac; }
.md-alert-tip     { background: #eff6ff; border: 1.5px solid #93c5fd; }
.md-alert-source  { background: #f0f4ff; border: 1.5px solid #a5b4fc; }
.md-alert-info    { background: #f8fafc; border: 1.5px solid #e2e8f0; }

/* РАЗДЕЛ N. section headers */
.md-section { display: flex; align-items: center; gap: 12px; margin: 28px 0 16px; padding: 12px 18px; background: linear-gradient(135deg, #0B1829 0%, #1A3350 100%); border-radius: 10px; }
.md-section-num { width: 30px; height: 30px; background: #f59e0b; color: #0B1829; border-radius: 50%; font-weight: 900; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 2px 6px rgba(245,158,11,.4); }
.md-section-title { color: #ffffff; font-weight: 800; font-size: 13.5px; letter-spacing: .2px; }
/* Первый md-section сразу после meta-row — немного меньший отступ */
.md-meta-row + .md-section { margin-top: 8px; }

/* ЗАПРЕЩЕНО / СТОП blocks */
.md-forbidden { background: rgba(239,68,68,.07) !important; border: 1.5px solid rgba(239,68,68,.25) !important; border-radius: 8px !important; padding: 10px 14px !important; color: var(--red) !important; font-weight: 700 !important; }

/* Document meta badges */
.md-meta-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 2px solid var(--g100); }
.md-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.md-badge-ok      { background: rgba(16,185,129,.12); color: #047857; border: 1px solid rgba(16,185,129,.25); }
.md-badge-warn    { background: rgba(245,158,11,.12); color: #B45309; border: 1px solid rgba(245,158,11,.3); }
.md-badge-draft   { background: var(--g100); color: var(--g600); border: 1px solid var(--g200); }
.md-badge-version { background: var(--blue-lt); color: var(--blue); border: 1px solid rgba(37,99,235,.2); }
.md-badge-date    { background: var(--g100); color: var(--g500); border: 1px solid var(--g200); }

/* ══════════════════════════════════════
   MISC
   ══════════════════════════════════════ */
.empty-state { text-align: center; padding: 48px 24px; color: var(--g500); font-size: 13.5px; }
.loading { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--g500); font-size: 13px; gap: 10px; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--g200); border-top-color: var(--blue); border-radius: 50%; animation: spin .65s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-item { padding: 12px 20px; border-bottom: 1px solid var(--g100); cursor: pointer; transition: background .1s; }
.sr-item:hover { background: var(--g50); }
.sr-title   { font-size: 13px; font-weight: 700; color: var(--g900); margin-bottom: 2px; }
.sr-path    { font-size: 10.5px; color: var(--g400); margin-bottom: 5px; }
.sr-snippet { font-size: 11.5px; color: var(--g600); line-height: 1.5; }

/* Insight */
.insight-list { display: flex; flex-direction: column; gap: 9px; padding: 12px 20px 18px; }
.insight { display: flex; gap: 11px; align-items: flex-start; padding: 11px 13px; background: var(--g50); border-radius: var(--r); border: 1px solid var(--g100); }
.insight-icon  { font-size: 18px; flex-shrink: 0; }
.insight-title { font-size: 12px; font-weight: 700; color: var(--g900); margin-bottom: 2px; }
.insight-text  { font-size: 11.5px; color: var(--g500); line-height: 1.5; }

/* Quick docs */
.qdocs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 10px 20px 18px; }
.qdoc { display: flex; align-items: center; gap: 9px; padding: 9px 11px; background: var(--g50); border: 1.5px solid var(--g100); border-radius: var(--r); cursor: pointer; transition: all .13s; }
.qdoc:hover { border-color: var(--blue); background: var(--white); }
.qdoc-icon { font-size: 16px; flex-shrink: 0; }
.qdoc-name { font-size: 11.5px; font-weight: 700; color: var(--g900); }
.qdoc-cat  { font-size: 10px; color: var(--g500); }
