/* =====================================================================
   SIID design system — shared by every screen.
   Tokens are derived from the product mock-ups (light gray canvas,
   white cards with 12px radius, green primary, semantic badges).
   ===================================================================== */
:root{
  --bg:#F3F4F6; --surface:#FFFFFF; --surface-2:#F9FAFB; --surface-3:#F3F4F6;
  --border:#E5E7EB; --border-2:#EEF0F3; --border-strong:#D1D5DB;
  --text:#111827; --text-2:#374151; --muted:#6B7280; --muted-2:#9CA3AF;
  --primary:#159A6B; --primary-600:#12865D; --primary-700:#0F6E4C; --primary-50:#E7F6EE; --primary-100:#CDEEDD; --primary-200:#A6E1C6;
  --red:#D93B3B; --red-600:#C42F2F; --red-50:#FDECEC; --red-100:#FBD5D5;
  --orange:#D97706; --orange-50:#FFF4E5; --orange-100:#FFE4BF;
  --green:#157F55; --green-50:#E6F6EE;
  --blue:#2B5FD9; --blue-50:#E8F0FE; --blue-100:#D3E1FC;
  --purple:#7C3AED; --purple-50:#F1EAFE;
  --teal:#0E8A8A; --teal-50:#E3F5F5;
  --yellow-hl:#FFF3B0;
  --radius:12px; --radius-sm:8px; --radius-xs:6px; --radius-lg:16px;
  --shadow:0 1px 2px rgba(16,24,40,.04),0 1px 3px rgba(16,24,40,.06);
  --shadow-md:0 4px 12px rgba(16,24,40,.08),0 1px 3px rgba(16,24,40,.06);
  --shadow-lg:0 12px 32px rgba(16,24,40,.14);
  --sidebar-w:64px; --topbar-h:56px;
  --font:"Inter","SF Pro Text",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  --fs:13px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;font-family:var(--font);font-size:var(--fs);line-height:1.45;color:var(--text);background:var(--bg);-webkit-font-smoothing:antialiased;font-feature-settings:"tnum" 0}
a{color:var(--primary-600);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3,h4{margin:0;font-weight:600;line-height:1.25}
h1{font-size:22px}h2{font-size:16px}h3{font-size:14px}h4{font-size:13px}
p{margin:0 0 8px}
small{font-size:11px;color:var(--muted)}
code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;background:var(--surface-3);padding:1px 5px;border-radius:4px}
button{font-family:inherit;font-size:inherit;color:inherit}
img{max-width:100%}
[hidden]{display:none!important}
::selection{background:var(--primary-100)}
.ic{width:18px;height:18px;flex:none;stroke:currentColor;fill:none;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round;vertical-align:middle}
.ic-sm{width:14px;height:14px}.ic-xs{width:12px;height:12px}.ic-lg{width:22px;height:22px}.ic-xl{width:28px;height:28px}

/* ---------- App shell ---------- */
.app{display:flex;min-height:100vh}
.sidebar{position:fixed;left:0;top:0;bottom:0;width:var(--sidebar-w);background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;align-items:center;padding:12px 0;z-index:40}
.sidebar-logo{display:flex;width:36px;height:36px;margin-bottom:14px}
.sidebar-logo img{width:36px;height:36px;border-radius:9px}
.sidebar-nav{display:flex;flex-direction:column;gap:4px;flex:1;width:100%;align-items:center}
.sidebar-bottom{display:flex;flex-direction:column;gap:4px;align-items:center;padding-top:8px;border-top:1px solid var(--border-2);width:100%}
.nav-item{position:relative;display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:10px;color:var(--muted);border:0;background:transparent;cursor:pointer;transition:background .15s,color .15s}
.nav-item .ic{width:20px;height:20px}
.nav-item:hover{background:var(--surface-3);color:var(--text-2);text-decoration:none}
.nav-item.active{background:var(--primary-50);color:var(--primary-600)}
.nav-item.active::before{content:"";position:absolute;left:-12px;top:10px;bottom:10px;width:3px;border-radius:0 3px 3px 0;background:var(--primary)}
.nav-item[data-tip]::after{content:attr(data-tip);position:absolute;left:calc(100% + 10px);top:50%;transform:translateY(-50%);white-space:nowrap;background:#111827;color:#fff;font-size:12px;padding:5px 9px;border-radius:6px;opacity:0;pointer-events:none;transition:opacity .12s;z-index:50}
.nav-item[data-tip]:hover::after{opacity:1}
.nav-user{padding:0}
.main{flex:1;margin-left:var(--sidebar-w);display:flex;flex-direction:column;min-width:0;min-height:100vh}
.topbar{position:sticky;top:0;z-index:30;height:var(--topbar-h);background:var(--surface);border-bottom:1px solid var(--border);display:flex;align-items:center;gap:16px;padding:0 20px}
.topbar-left{display:flex;align-items:center;gap:8px}
.brand{font-weight:700;font-size:19px;letter-spacing:.2px;color:var(--text)}
.topbar-search{flex:1;max-width:560px;display:flex;align-items:center;gap:8px;height:36px;padding:0 10px 0 12px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface-2);margin:0 auto}
.topbar-search:focus-within{border-color:var(--primary-200);background:#fff;box-shadow:0 0 0 3px var(--primary-50)}
.topbar-search input{flex:1;border:0;background:transparent;outline:0;font:inherit;color:var(--text);min-width:0}
.topbar-search .search-ic{color:var(--muted-2)}
.topbar-search kbd{font:inherit;font-size:11px;color:var(--muted-2);border:1px solid var(--border);border-radius:4px;padding:0 5px;background:#fff}
.topbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}
.icon-btn{position:relative;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:var(--radius-sm);border:1px solid transparent;background:transparent;color:var(--text-2);cursor:pointer}
.icon-btn:hover{background:var(--surface-3);text-decoration:none}
.icon-btn.bordered{border-color:var(--border);background:#fff}
.icon-btn.sm{width:28px;height:28px}.icon-btn.sm .ic{width:16px;height:16px}
.badge-dot{position:absolute;top:2px;right:2px;min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:var(--primary);color:#fff;font-size:10px;font-weight:600;line-height:16px;text-align:center}
.user-chip{display:flex;align-items:center;gap:8px;padding:3px 6px 3px 3px;border:0;background:transparent;border-radius:var(--radius-sm);cursor:pointer;text-align:left}
.user-chip:hover{background:var(--surface-3)}
.user-chip-text{display:flex;flex-direction:column;line-height:1.15}
.user-chip-name{font-weight:600;font-size:12.5px}
.user-chip-title{font-size:11px;color:var(--muted)}
.content{flex:1;padding:20px 24px 32px;min-width:0}
.app.sidebar-collapsed .sidebar{display:none}
.app.sidebar-collapsed .main{margin-left:0}

/* ---------- Avatars ---------- */
.avatar{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;background:var(--primary-50);color:var(--primary-700);font-weight:600;overflow:hidden;flex:none;vertical-align:middle}
.avatar img{width:100%;height:100%;object-fit:cover;display:block}
.avatar-xs{width:22px;height:22px;font-size:9px}.avatar-sm{width:30px;height:30px;font-size:11px}.avatar-md{width:36px;height:36px;font-size:12px}.avatar-lg{width:44px;height:44px;font-size:14px}

/* ---------- Dropdown menus ---------- */
.dropdown{position:relative}
.menu{position:absolute;right:0;top:calc(100% + 6px);min-width:220px;background:#fff;border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow-lg);padding:6px;display:none;z-index:60}
.menu.left{right:auto;left:0}
.menu-wide{min-width:340px;max-height:420px;overflow:auto}
.dropdown.open .menu{display:block}
.menu-title{font-size:11px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;padding:6px 10px}
.menu-item{display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border-radius:7px;border:0;background:transparent;color:var(--text);cursor:pointer;text-align:left;font:inherit}
.menu-item:hover{background:var(--surface-3);text-decoration:none}
.menu-item.active{background:var(--primary-50);color:var(--primary-700)}
.menu-item .ic{color:var(--muted)}
.menu-item small{display:block;color:var(--muted);font-size:11px}
.menu-sep{height:1px;background:var(--border-2);margin:6px 0}
.menu-empty{padding:10px}

/* ---------- Page scaffolding ---------- */
.page{display:flex;flex-direction:column;gap:16px;max-width:1720px;margin:0 auto}
.page-head{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.page-title{display:flex;align-items:center;gap:8px;font-size:22px;font-weight:600}
.page-title .ic{color:var(--muted-2);width:18px;height:18px;cursor:pointer}
.page-title .ic:hover{color:var(--orange)}
.page-sub{color:var(--muted)}
.page-actions{margin-left:auto;display:flex;align-items:center;gap:8px}
.breadcrumbs{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:12px}
.breadcrumbs a{color:var(--muted)}
.breadcrumbs .ic{width:14px;height:14px;color:var(--muted-2)}

/* ---------- Cards ---------- */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow)}
.card-header{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--border-2)}
.card-title{font-size:14px;font-weight:600}
.card-header .card-actions{margin-left:auto;display:flex;align-items:center;gap:8px}
.card-body{padding:16px}
.card-body.tight{padding:12px 14px}
.card-footer{padding:12px 16px;border-top:1px solid var(--border-2);display:flex;align-items:center;gap:10px}
.card-link{font-size:12.5px;color:var(--primary-600);font-weight:500}

/* ---------- KPI tiles ---------- */
.kpi-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:12px 14px;box-shadow:var(--shadow);min-width:0}
.kpi-label{font-size:11.5px;color:var(--muted);margin-bottom:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kpi-value{font-size:22px;font-weight:600;line-height:1.1;display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;font-variant-numeric:tabular-nums}
.kpi-value.sm{font-size:17px}
.kpi-value .unit{font-size:14px;font-weight:500;color:var(--text-2)}
.kpi-delta,.delta{font-size:11.5px;font-weight:500;white-space:nowrap}
.delta-up,.kpi-delta.up{color:var(--green)}
.delta-down,.kpi-delta.down{color:var(--red)}
.delta-flat{color:var(--muted)}
.kpi-delta.warn{color:var(--orange)}
.kpi-delta.muted{color:var(--muted)}
.stat-strip{display:flex;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);box-shadow:var(--shadow);overflow:hidden}
.stat-strip .stat{flex:1;padding:12px 16px;border-right:1px solid var(--border-2);min-width:0}
.stat-strip .stat:last-child{border-right:0}
.stat .stat-label{font-size:11.5px;color:var(--muted);margin-bottom:4px;white-space:nowrap}
.stat .stat-value{font-size:20px;font-weight:600;font-variant-numeric:tabular-nums;display:flex;align-items:baseline;gap:6px}
.stat .stat-pct{font-size:12px;font-weight:500}

/* ---------- Badges & chips ---------- */
.badge{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:999px;font-size:11.5px;font-weight:500;line-height:1.5;white-space:nowrap;vertical-align:middle}
.badge-gray{background:var(--surface-3);color:var(--text-2)}
.badge-red{background:var(--red-50);color:var(--red)}
.badge-orange{background:var(--orange-50);color:var(--orange)}
.badge-green{background:var(--green-50);color:var(--green)}
.badge-blue{background:var(--blue-50);color:var(--blue)}
.badge-purple{background:var(--purple-50);color:var(--purple)}
.badge-teal{background:var(--teal-50);color:var(--teal)}
.badge-outline{background:#fff;border:1px solid var(--border);color:var(--text-2)}
.badge .ic{width:12px;height:12px}
.chip{display:inline-flex;align-items:center;gap:6px;padding:3px 9px;border-radius:999px;background:var(--surface-3);color:var(--text-2);font-size:11.5px;border:1px solid transparent}
.chip.count{background:var(--surface-3);color:var(--muted);font-variant-numeric:tabular-nums}
.pill-count{display:inline-flex;min-width:22px;height:22px;padding:0 7px;align-items:center;justify-content:center;border-radius:999px;font-size:11.5px;font-weight:600;background:var(--surface-3);color:var(--text-2)}
.pill-count.red{background:var(--red-50);color:var(--red)}.pill-count.orange{background:var(--orange-50);color:var(--orange)}.pill-count.green{background:var(--green-50);color:var(--green)}.pill-count.blue{background:var(--blue-50);color:var(--blue)}

/* ---------- Buttons ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:34px;padding:0 13px;border-radius:var(--radius-sm);border:1px solid var(--border);background:#fff;color:var(--text);font-weight:500;font-size:13px;cursor:pointer;white-space:nowrap;transition:background .12s,border-color .12s,box-shadow .12s;text-decoration:none}
.btn:hover{background:var(--surface-2);text-decoration:none}
.btn:active{transform:translateY(.5px)}
.btn:disabled,.btn.disabled{opacity:.5;cursor:not-allowed;pointer-events:none}
.btn .ic{width:16px;height:16px}
.btn-primary{background:var(--primary);border-color:var(--primary);color:#fff}
.btn-primary:hover{background:var(--primary-600);border-color:var(--primary-600)}
.btn-outline-primary{border-color:var(--primary-200);color:var(--primary-700);background:#fff}
.btn-outline-primary:hover{background:var(--primary-50)}
.btn-danger{background:var(--red);border-color:var(--red);color:#fff}
.btn-outline-danger{border-color:var(--red-100);color:var(--red);background:#fff}
.btn-outline-danger:hover{background:var(--red-50)}
.btn-ghost{border-color:transparent;background:transparent;color:var(--text-2)}
.btn-ghost:hover{background:var(--surface-3)}
.btn-sm{height:28px;padding:0 10px;font-size:12px}.btn-sm .ic{width:14px;height:14px}
.btn-lg{height:42px;padding:0 18px;font-size:14px}
.btn-block{width:100%}
.btn-icon{width:34px;padding:0}
.btn-group{display:inline-flex}
.btn-group .btn{border-radius:0}
.btn-group .btn:first-child{border-radius:var(--radius-sm) 0 0 var(--radius-sm)}
.btn-group .btn:last-child{border-radius:0 var(--radius-sm) var(--radius-sm) 0}
.btn-group .btn+.btn{margin-left:-1px}

/* ---------- Inputs / selects / toggles ---------- */
.input,.select,textarea.input{height:34px;padding:0 10px;border:1px solid var(--border);border-radius:var(--radius-sm);background:#fff;font:inherit;color:var(--text);outline:0;min-width:0}
textarea.input{height:auto;padding:8px 10px;resize:vertical}
.input:focus,.select:focus,textarea.input:focus{border-color:var(--primary-200);box-shadow:0 0 0 3px var(--primary-50)}
.select{appearance:none;padding-right:28px;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");background-repeat:no-repeat;background-position:right 8px center;cursor:pointer}
.field{display:flex;flex-direction:column;gap:4px}
.field-label{font-size:11.5px;color:var(--muted)}
.field .input,.field .select{width:100%}
.filter{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 10px;border:1px solid var(--border);border-radius:var(--radius-sm);background:#fff;font-size:12.5px;cursor:pointer;white-space:nowrap;color:var(--text)}
.filter:hover{background:var(--surface-2)}
.filter .ic{width:14px;height:14px;color:var(--muted)}
.filter b{font-weight:500}
.filter .filter-label{color:var(--muted)}
.filter.active{border-color:var(--primary-200);background:var(--primary-50);color:var(--primary-700)}
.filter select{border:0;background:transparent;font:inherit;outline:0;cursor:pointer;color:inherit;padding:0}
.labeled{display:flex;flex-direction:column;gap:3px}
.labeled .lbl{font-size:11px;color:var(--muted)}
.toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.toolbar .spacer{flex:1}
.toggle{display:inline-flex;align-items:center;gap:8px;cursor:pointer;user-select:none;font-size:12.5px}
.toggle input{position:absolute;opacity:0;width:0;height:0}
.toggle .track{width:32px;height:18px;border-radius:999px;background:var(--border-strong);position:relative;transition:background .15s;flex:none}
.toggle .track::after{content:"";position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px rgba(0,0,0,.2)}
.toggle input:checked+.track{background:var(--primary)}
.toggle input:checked+.track::after{left:16px}
.checkbox{width:15px;height:15px;accent-color:var(--primary);cursor:pointer;margin:0;vertical-align:middle}
.search-inline{display:flex;align-items:center;gap:6px;height:32px;padding:0 10px;border:1px solid var(--border);border-radius:var(--radius-sm);background:#fff}
.search-inline input{border:0;outline:0;font:inherit;background:transparent;min-width:120px}
.search-inline .ic{color:var(--muted-2);width:15px;height:15px}

/* ---------- Tabs ---------- */
.tabs{display:flex;gap:2px;border-bottom:1px solid var(--border-2)}
.tab{padding:9px 12px;border:0;background:transparent;color:var(--muted);font-weight:500;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;white-space:nowrap;font-size:13px}
.tab:hover{color:var(--text)}
.tab.active{color:var(--primary-700);border-bottom-color:var(--primary)}
.tab .count{margin-left:6px;font-size:11px;color:var(--muted);background:var(--surface-3);padding:1px 6px;border-radius:999px}
.seg{display:inline-flex;gap:4px;padding:3px;background:var(--surface-3);border-radius:999px}
.seg .seg-item{padding:4px 11px;border-radius:999px;border:0;background:transparent;font-size:12px;color:var(--text-2);cursor:pointer;white-space:nowrap}
.seg .seg-item.active{background:#fff;color:var(--primary-700);box-shadow:var(--shadow);font-weight:500}
.seg.outline{background:transparent;padding:0;gap:6px}
.seg.outline .seg-item{border:1px solid var(--border);background:#fff}
.seg.outline .seg-item.active{border-color:var(--primary-200);background:var(--primary-50)}

/* ---------- Tables ---------- */
.table-wrap{overflow:auto;border-radius:var(--radius)}
.table{width:100%;border-collapse:separate;border-spacing:0;font-size:12.5px}
.table th,.table td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--border-2);vertical-align:middle;white-space:nowrap}
.table th{position:sticky;top:0;z-index:2;background:var(--surface-2);color:var(--muted);font-weight:500;font-size:11.5px}
.table td.num,.table th.num{text-align:right;font-variant-numeric:tabular-nums}
.table td.center,.table th.center{text-align:center}
.table td.wrap{white-space:normal;min-width:180px}
.table tbody tr{transition:background .1s}
.table tbody tr:hover{background:var(--surface-2)}
.table tbody tr.selected{background:var(--primary-50)}
.table tbody tr.clickable{cursor:pointer}
.table tbody tr:last-child td{border-bottom:0}
.table .t-muted{color:var(--muted)}
.table .t-strong{font-weight:500;color:var(--text)}
.table .row-num{color:var(--muted);width:36px}
.table tr.group-row td{background:var(--surface-3);font-weight:600;color:var(--text-2);padding-top:8px;padding-bottom:8px}
.table tr.total-row td{font-weight:600;background:var(--surface-2);border-top:1px solid var(--border)}
.table.compact th,.table.compact td{padding:7px 10px}
.table.dense th,.table.dense td{padding:6px 8px;font-size:12px}
.table .th-sort{cursor:pointer;user-select:none}
.table .th-sort .ic{width:12px;height:12px;color:var(--muted-2);margin-left:3px}
.table-footer{display:flex;align-items:center;gap:12px;padding:10px 14px;border-top:1px solid var(--border-2);font-size:12px;color:var(--muted);flex-wrap:wrap}
.table-footer .spacer{flex:1}
.progress{display:inline-flex;align-items:center;gap:8px;min-width:90px}
.progress .bar{flex:1;height:6px;border-radius:999px;background:var(--border);overflow:hidden;min-width:48px}
.progress .bar>i{display:block;height:100%;background:var(--primary);border-radius:999px}
.progress .bar.thick{height:8px}
.progress .bar>i.red{background:var(--red)}.progress .bar>i.orange{background:var(--orange)}.progress .bar>i.blue{background:var(--blue)}
.progress .pct{font-variant-numeric:tabular-nums;color:var(--text-2);font-size:12px;min-width:32px;text-align:right}
.pager{display:inline-flex;align-items:center;gap:2px}
.pager .pg{min-width:28px;height:28px;padding:0 7px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--text-2);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;font-size:12.5px}
.pager .pg:hover{background:var(--surface-3)}
.pager .pg.active{border-color:var(--primary);color:var(--primary-700);font-weight:600}
.pager .pg:disabled{opacity:.4;cursor:default}
.pager .pg .ic{width:14px;height:14px}
.pager .dots{padding:0 4px;color:var(--muted)}

/* ---------- Key/value lists ---------- */
.kv{display:flex;flex-direction:column}
.kv-row{display:flex;justify-content:space-between;gap:12px;padding:7px 0;border-bottom:1px solid var(--border-2);font-size:12.5px}
.kv-row:last-child{border-bottom:0}
.kv-label{color:var(--muted);flex:0 0 auto}
.kv-value{text-align:right;font-weight:500;color:var(--text);font-variant-numeric:tabular-nums;min-width:0}
.kv.plain .kv-row{border:0;padding:4px 0}
.kv.stack .kv-row{flex-direction:column;gap:2px}
.kv.stack .kv-value{text-align:left}
.kv.wide .kv-label{flex:0 0 200px}
.kv.wide .kv-value{text-align:left;flex:1;font-weight:400}
.info-strip{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow)}
.info-strip .info{padding:12px 16px;border-right:1px solid var(--border-2);min-width:0}
.info-strip .info:last-child{border-right:0}
.info .info-label{font-size:11px;color:var(--muted);margin-bottom:3px}
.info .info-value{font-weight:500;font-size:13px}
.meta-grid{display:flex;gap:28px;flex-wrap:wrap}
.meta-grid .meta{display:flex;flex-direction:column;gap:2px}
.meta .meta-label{font-size:11px;color:var(--muted)}
.meta .meta-value{font-weight:500}

/* ---------- Side panel / drawer ---------- */
.split{display:grid;gap:16px;align-items:start}
.split.cols-2{grid-template-columns:1fr 1fr}
.split.main-side{grid-template-columns:minmax(0,1fr) 380px}
.split.side-main{grid-template-columns:320px minmax(0,1fr)}
.split.three{grid-template-columns:320px minmax(0,1fr) 360px}
.panel{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-md);position:sticky;top:calc(var(--topbar-h) + 16px);max-height:calc(100vh - var(--topbar-h) - 32px);display:flex;flex-direction:column;overflow:hidden}
.panel-header{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--border-2)}
.panel-title{font-size:15px;font-weight:600}
.panel-header .close{margin-left:auto}
.panel-body{padding:14px 16px;overflow:auto;flex:1}
.panel-footer{padding:12px 16px;border-top:1px solid var(--border-2)}
.section-title{font-size:13px;font-weight:600;margin:14px 0 8px}
.section-title:first-child{margin-top:0}
.section-title .link{float:right;font-weight:500;font-size:12px}
.drawer-close{margin-left:auto}

/* ---------- Stepper ---------- */
.stepper{display:flex;align-items:flex-start}
.stepper .step{display:flex;flex-direction:column;align-items:center;gap:6px;position:relative;flex:1;min-width:70px}
.stepper .step-dot{width:22px;height:22px;border-radius:50%;border:2px solid var(--border-strong);background:#fff;display:flex;align-items:center;justify-content:center;z-index:1}
.stepper .step-dot .ic{width:12px;height:12px;stroke-width:3}
.stepper .step.done .step-dot{background:var(--primary);border-color:var(--primary);color:#fff}
.stepper .step.current .step-dot{border-color:var(--primary);color:var(--primary)}
.stepper .step-label{font-size:11.5px;color:var(--muted);white-space:nowrap}
.stepper .step.done .step-label,.stepper .step.current .step-label{color:var(--text)}
.stepper .step::before{content:"";position:absolute;top:10px;left:50%;right:-50%;height:2px;background:var(--border)}
.stepper .step:last-child::before{display:none}
.stepper .step.done::before{background:var(--primary)}

/* ---------- Timeline / event feed ---------- */
.timeline{position:relative;padding-left:0;list-style:none;margin:0}
.timeline .tl-item{display:grid;grid-template-columns:24px 1fr;gap:10px;position:relative;padding-bottom:16px}
.timeline .tl-item::before{content:"";position:absolute;left:11px;top:24px;bottom:-2px;width:2px;background:var(--border-2)}
.timeline .tl-item:last-child::before{display:none}
.tl-dot{width:24px;height:24px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:var(--surface-3);color:var(--muted);border:1px solid var(--border)}
.tl-dot .ic{width:13px;height:13px}
.tl-dot.red{background:var(--red-50);color:var(--red);border-color:var(--red-100)}
.tl-dot.orange{background:var(--orange-50);color:var(--orange);border-color:var(--orange-100)}
.tl-dot.green{background:var(--green-50);color:var(--green);border-color:var(--primary-100)}
.tl-dot.blue{background:var(--blue-50);color:var(--blue);border-color:var(--blue-100)}
.tl-dot.plain{background:transparent;border:0;position:relative}
.tl-dot.plain::after{content:"";width:8px;height:8px;border-radius:50%;background:var(--blue)}
.tl-body{min-width:0}
.tl-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.tl-time{font-size:11.5px;color:var(--muted);font-variant-numeric:tabular-nums;white-space:nowrap}
.tl-title{font-weight:500}
.tl-sub{font-size:11.5px;color:var(--muted);margin-top:2px}
.tl-group{font-size:12px;font-weight:600;color:var(--text-2);margin:6px 0 10px}

/* ---------- Lists ---------- */
.list{display:flex;flex-direction:column;gap:8px}
.list-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--border);border-radius:var(--radius-sm);background:#fff}
.list-item.clickable{cursor:pointer}
.list-item.clickable:hover{border-color:var(--border-strong);background:var(--surface-2)}
.list-item .li-title{font-weight:500;min-width:0;flex:1}
.list-item .li-sub{font-size:11.5px;color:var(--muted)}
.list-item .li-right{margin-left:auto;display:flex;align-items:center;gap:8px;white-space:nowrap}
.list-item .file-ic{width:28px;height:28px;border-radius:6px;background:var(--surface-3);display:flex;align-items:center;justify-content:center;color:var(--muted);flex:none}
.list-item .file-ic.xlsx{color:var(--green)}.list-item .file-ic.pdf{color:var(--text-2)}.list-item .file-ic.eml{color:var(--green)}
.list.plain .list-item{border:0;padding:6px 0;border-bottom:1px solid var(--border-2);border-radius:0}
.list.plain .list-item:last-child{border-bottom:0}
.rows{display:flex;flex-direction:column}
.rows .row-line{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 0;border-bottom:1px solid var(--border-2);font-size:12.5px}
.rows .row-line:last-child{border-bottom:0}

/* ---------- Highlighted document viewer ---------- */
.doc-viewer{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface-2);overflow:hidden}
.doc-toolbar{display:flex;align-items:center;gap:6px;padding:8px 10px;border-bottom:1px solid var(--border-2);background:#fff}
.doc-toolbar .spacer{flex:1}
.doc-page{background:#fff;margin:14px auto;max-width:760px;padding:28px 36px;box-shadow:var(--shadow);font-family:Georgia,"Times New Roman",serif;font-size:13px;line-height:1.55;color:#1F2937}
.doc-page h4{text-align:center;font-family:inherit;font-size:13px;margin:14px 0 8px}
.doc-page p{margin:0 0 6px}
.doc-page .clause{display:grid;grid-template-columns:auto 1fr;gap:8px;position:relative}
.doc-page .clause .n{white-space:nowrap}
.doc-page .hl{background:var(--yellow-hl);padding:0 2px;border-radius:2px}
.doc-page .hl.red{background:var(--red-100)}
.doc-page .marker{position:absolute;left:-26px;top:1px;width:17px;height:17px;border-radius:50%;background:var(--red);color:#fff;font:600 10px/17px var(--font);text-align:center;cursor:pointer}
.doc-page .marker.orange{background:var(--orange)}

/* ---------- Chat ---------- */
.chat{display:flex;flex-direction:column;min-height:480px}
.chat-log{flex:1;overflow:auto;padding:16px;display:flex;flex-direction:column;gap:12px}
.msg{max-width:92%;display:flex;flex-direction:column;gap:4px}
.msg.user{align-self:flex-end;align-items:flex-end}
.msg .bubble{padding:10px 14px;border-radius:12px;background:#fff;border:1px solid var(--border);line-height:1.5}
.msg.user .bubble{background:var(--primary-50);border-color:var(--primary-100)}
.msg .msg-meta{font-size:11px;color:var(--muted);display:flex;align-items:center;gap:8px}
.msg.ai{align-self:flex-start}
.msg.ai .ai-head{display:flex;align-items:center;gap:8px;font-weight:600}
.msg.ai .ai-head .ai-ic{width:26px;height:26px;border-radius:50%;background:var(--primary-50);color:var(--primary-700);display:flex;align-items:center;justify-content:center}
.msg.ai .ai-ic .ic{width:15px;height:15px}
.ai-section{display:grid;grid-template-columns:22px 1fr;gap:8px;padding:8px 0;border-bottom:1px solid var(--border-2)}
.ai-section:last-child{border-bottom:0}
.ai-section .ic{color:var(--primary);width:17px;height:17px;margin-top:1px}
.ai-section b{display:block;margin-bottom:3px}
.ai-section ul,.ai-section ol{margin:0;padding-left:18px}
.ai-section li{margin:2px 0}
.ai-section li.warn{list-style:none;margin-left:-16px;display:flex;gap:6px;color:var(--text-2)}
.ai-section li.warn::before{content:"△";color:var(--red);font-size:11px}
.ai-section li.warn.soft::before{content:"•";color:var(--red)}
.chat-input{border-top:1px solid var(--border-2);padding:12px 16px;display:flex;flex-direction:column;gap:8px}
.chat-input .box{display:flex;align-items:flex-end;gap:8px;border:1px solid var(--border);border-radius:10px;padding:8px 8px 8px 12px;background:#fff}
.chat-input .box:focus-within{border-color:var(--primary-200);box-shadow:0 0 0 3px var(--primary-50)}
.chat-input textarea{flex:1;border:0;outline:0;resize:none;font:inherit;min-height:44px;max-height:160px;background:transparent}
.chat-input .send{width:36px;height:36px;border-radius:9px;background:var(--primary);color:#fff;border:0;display:flex;align-items:center;justify-content:center;cursor:pointer}
.chat-input .send:hover{background:var(--primary-600)}
.chat-disclaimer{font-size:11px;color:var(--muted-2);text-align:center}
.attachment{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:#fff}
.attachment .file-ic{width:30px;height:30px;border-radius:6px;background:var(--surface-3);display:flex;align-items:center;justify-content:center;color:var(--muted)}
.typing{display:inline-flex;gap:3px;align-items:center}
.typing i{width:5px;height:5px;border-radius:50%;background:var(--muted-2);animation:blink 1.2s infinite}
.typing i:nth-child(2){animation-delay:.2s}.typing i:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.3}40%{opacity:1}}
.suggest{display:flex;flex-wrap:wrap;gap:6px}
.suggest button{border:1px solid var(--border);background:#fff;border-radius:999px;padding:5px 11px;font-size:12px;cursor:pointer;color:var(--text-2)}
.suggest button:hover{border-color:var(--primary-200);color:var(--primary-700);background:var(--primary-50)}

/* ---------- Accordion (check results) ---------- */
.acc{display:flex;flex-direction:column;gap:8px}
.acc-item{border:1px solid var(--border);border-radius:var(--radius-sm);background:#fff;overflow:hidden}
.acc-head{display:flex;align-items:center;gap:10px;padding:11px 12px;cursor:pointer;user-select:none}
.acc-head:hover{background:var(--surface-2)}
.acc-head .acc-title{font-weight:500;flex:1;display:flex;align-items:center;gap:8px}
.acc-head .acc-title .ic{color:var(--muted)}
.acc-head .acc-count{color:var(--muted);font-variant-numeric:tabular-nums;min-width:40px;text-align:right}
.acc-head .chev{color:var(--muted);transition:transform .15s}
.acc-item.open .acc-head .chev{transform:rotate(180deg)}
.acc-body{display:none;border-top:1px solid var(--border-2);background:var(--surface-2);padding:4px 6px}
.acc-item.open .acc-body{display:block}
.check-row{display:grid;grid-template-columns:1fr auto auto;gap:12px;align-items:center;padding:8px 10px;border-radius:6px;font-size:12.5px;cursor:pointer}
.check-row:hover{background:#fff}
.check-row.active{background:var(--primary-50)}
.check-row .loc{color:var(--muted);white-space:nowrap}
.check-row .dot{display:inline-block;width:5px;height:5px;border-radius:50%;background:var(--text-2);margin-right:8px;vertical-align:middle}

/* ---------- Alerts / empty / skeleton ---------- */
.alert{padding:10px 12px;border-radius:var(--radius-sm);font-size:12.5px;border:1px solid transparent}
.alert-red{background:var(--red-50);color:var(--red-600);border-color:var(--red-100)}
.alert-orange{background:var(--orange-50);color:#92400E;border-color:var(--orange-100)}
.alert-green{background:var(--green-50);color:var(--green);border-color:var(--primary-100)}
.alert-blue{background:var(--blue-50);color:#1E40AF;border-color:var(--blue-100)}
.empty{padding:32px;text-align:center;color:var(--muted)}
.skeleton{background:linear-gradient(90deg,var(--surface-3) 25%,#EDEFF2 37%,var(--surface-3) 63%);background-size:400% 100%;animation:sk 1.2s infinite;border-radius:6px;min-height:14px}
@keyframes sk{0%{background-position:100% 0}100%{background-position:0 0}}
.toasts{position:fixed;right:20px;bottom:20px;display:flex;flex-direction:column;gap:8px;z-index:100}
.toast{background:#111827;color:#fff;padding:10px 14px;border-radius:10px;font-size:12.5px;box-shadow:var(--shadow-lg);display:flex;align-items:center;gap:8px;animation:toast-in .2s ease-out}
.toast.success{background:var(--primary-700)}.toast.error{background:var(--red-600)}
@keyframes toast-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.modal-backdrop{position:fixed;inset:0;background:rgba(17,24,39,.45);display:none;align-items:center;justify-content:center;z-index:90}
.modal-backdrop.open{display:flex}
.modal{background:#fff;border-radius:var(--radius-lg);width:min(560px,92vw);max-height:88vh;overflow:auto;box-shadow:var(--shadow-lg)}
.modal-header{display:flex;align-items:center;gap:10px;padding:16px 20px;border-bottom:1px solid var(--border-2)}
.modal-header h3{flex:1}
.modal-body{padding:18px 20px}
.modal-footer{padding:14px 20px;border-top:1px solid var(--border-2);display:flex;justify-content:flex-end;gap:8px}

/* ---------- Utilities ---------- */
.row{display:flex;align-items:center;gap:8px}
.row.between{justify-content:space-between}
.row.wrap{flex-wrap:wrap}
.col{display:flex;flex-direction:column;gap:8px}
.grid{display:grid;gap:16px}
.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.gap-4{gap:4px}.gap-6{gap:6px}.gap-8{gap:8px}.gap-12{gap:12px}.gap-16{gap:16px}.gap-24{gap:24px}
.mt-4{margin-top:4px}.mt-8{margin-top:8px}.mt-12{margin-top:12px}.mt-16{margin-top:16px}.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}
.ml-auto{margin-left:auto}
.flex-1{flex:1;min-width:0}
.text-muted{color:var(--muted)}.text-muted-2{color:var(--muted-2)}.text-red{color:var(--red)}.text-green{color:var(--green)}.text-orange{color:var(--orange)}.text-blue{color:var(--blue)}.text-purple{color:var(--purple)}
.text-sm{font-size:12px}.text-xs{font-size:11px}.text-lg{font-size:15px}
.fw-500{font-weight:500}.fw-600{font-weight:600}
.num{font-variant-numeric:tabular-nums}
.nowrap{white-space:nowrap}
.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hidden{display:none!important}
.link{color:var(--primary-600);cursor:pointer;font-weight:500}
.link:hover{text-decoration:underline}
.divider{height:1px;background:var(--border-2);margin:12px 0}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.conf{display:inline-flex;align-items:center;gap:8px}
.conf .bar{width:110px;height:6px;border-radius:999px;background:var(--border);overflow:hidden}
.conf .bar>i{display:block;height:100%;background:var(--primary)}
.score{display:inline-flex;align-items:center;justify-content:center;min-width:40px;padding:2px 7px;border-radius:999px;font-size:11.5px;font-weight:600;background:var(--green-50);color:var(--green)}
.score.mid{background:var(--orange-50);color:var(--orange)}.score.low{background:var(--surface-3);color:var(--text-2)}
.tag-list{display:flex;flex-wrap:wrap;gap:4px}
.tag{padding:2px 8px;border-radius:999px;background:var(--surface-3);font-size:11.5px;color:var(--text-2)}
.legend-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px;vertical-align:middle}
.card.accent-green{border-color:var(--primary-200);background:linear-gradient(0deg,var(--primary-50),var(--primary-50))}

/* ---------- Login page ---------- */
.login-body{background:var(--bg)}
.login-wrap{min-height:100vh;display:grid;grid-template-columns:1.1fr 1fr;gap:0}
.login-hero{padding:56px 64px;display:flex;flex-direction:column;justify-content:center;gap:20px;background:linear-gradient(160deg,#F7FAF8,#EAF4EE 60%,#E3F1E9)}
.login-brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:22px}
.login-brand img{width:40px;height:40px;border-radius:10px}
.login-hero h1{font-size:34px;font-weight:700;line-height:1.15}
.login-hero p{font-size:15px;color:var(--text-2);max-width:520px}
.login-features{list-style:none;margin:8px 0 0;padding:0;display:grid;grid-template-columns:1fr 1fr;gap:12px;max-width:640px}
.login-features li{display:flex;gap:10px;padding:12px 14px;background:#fff;border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow)}
.login-features .ic{color:var(--primary);width:20px;height:20px;flex:none;margin-top:1px}
.login-features b{display:block;font-size:13px}
.login-features small{display:block;color:var(--muted);margin-top:2px}
.login-footer{margin-top:auto;color:var(--muted);font-size:12px}
.login-card{align-self:center;justify-self:center;width:min(440px,90vw);background:#fff;border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-md);padding:32px;display:flex;flex-direction:column;gap:14px;margin:32px 0}
.login-card h2{font-size:20px}
.login-users{display:flex;flex-direction:column;gap:6px}
.login-user{display:flex;align-items:center;gap:10px;padding:8px 10px;border:1px solid var(--border);border-radius:10px;cursor:pointer}
.login-user input{position:absolute;opacity:0}
.login-user.checked{border-color:var(--primary);background:var(--primary-50)}
.login-user-text{display:flex;flex-direction:column;flex:1}
.login-user-text b{font-size:13px}
.login-user-check{margin-left:auto;color:var(--primary);opacity:0}
.login-user.checked .login-user-check{opacity:1}
.login-hint{font-size:12px;text-align:center}
@media (max-width:900px){.login-wrap{grid-template-columns:1fr}.login-hero{padding:32px 24px}.login-features{grid-template-columns:1fr}}

/* ---------- Responsive ---------- */
@media (max-width:1280px){
  .split.three{grid-template-columns:280px minmax(0,1fr)}
  .split.three>*:nth-child(3){grid-column:1/-1}
  .split.main-side{grid-template-columns:minmax(0,1fr) 340px}
}
@media (max-width:1024px){
  .split.main-side,.split.side-main,.split.three,.split.cols-2{grid-template-columns:1fr}
  .panel{position:static;max-height:none}
  .user-chip-text{display:none}
  .topbar-search{max-width:none}
  .info-strip{grid-auto-flow:row;grid-template-columns:repeat(2,1fr)}
  .info-strip .info{border-bottom:1px solid var(--border-2)}
}
@media (max-width:720px){
  .content{padding:14px 12px 24px}
  .sidebar{display:none}.main{margin-left:0}
  .topbar{padding:0 12px;gap:8px}
  .kpi-row{grid-template-columns:repeat(2,1fr)}
  .grid-2,.grid-3,.grid-4{grid-template-columns:1fr}
}
@media print{.sidebar,.topbar{display:none}.main{margin:0}}
