:root {
  --navy: #0E2A47; --blue: #1D4F86; --blue2: #3C6EA6; --sky: #8FC1EC; --red: #D0232B; --green: #147A6B;
  --bg: #F5F7FA; --card: #fff; --line: #E3E9F0; --line2: #D2DCE7; --muted: #5F6F82; --soft: #EEF3F8; --ink: #1F2D3D;
  --radius: 16px; --shadow: 0 1px 2px rgba(14,42,71,.04), 0 6px 20px -12px rgba(14,42,71,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 80px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand img { width: 38px; height: 38px; }
.brand b { display: block; font-size: 16px; color: var(--navy); letter-spacing: -.01em; }
.brand span { font-size: 12.5px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav button.group { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14.5px; background: none; border: 0; cursor: pointer; text-align: left; }
.nav a:hover, .nav button.group:hover { background: var(--soft); }
.nav a.on { background: var(--navy); color: #fff; }
.nav .ico { width: 20px; height: 20px; flex: none; color: var(--blue2); }
.nav a.on .ico { color: var(--sky); }
.nav .chev { margin-left: auto; width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.nav .group[aria-expanded="true"] .chev { transform: rotate(90deg); }
.nav .sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 30px; }
.nav .sub a { font-weight: 500; font-size: 14px; padding: 7px 12px; }
.nav .sub a.on { background: var(--soft); color: var(--navy); font-weight: 700; }
.side-foot { margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid var(--line); font-size: 13px; }
.side-foot b { display: block; color: var(--navy); }
.side-foot .role { display: inline-block; margin-top: 4px; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--blue); font-weight: 700; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }
.side-foot button { margin-top: 10px; }
.main { min-width: 0; padding: 28px 32px 60px; }
.topbar { display: none; }

.head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.head h1 { margin: 0; font-size: 28px; line-height: 1.15; color: var(--navy); letter-spacing: -.02em; }
.head p { margin: 6px 0 0; color: var(--muted); }
.head .sp { flex: 1; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent; background: var(--blue); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #173F6C; }
.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line2); }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: #fff; color: #B51F27; border-color: #F1C4C6; }
.btn.danger:hover { background: #FDECEC; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; cursor: pointer; color: var(--navy); }
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 18px; height: 18px; }
.seg { display: inline-flex; gap: 6px; }
.seg button { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line2); background: #fff; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.input, .select { width: 100%; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 10px; background: #fff; min-height: 40px; }
.input:focus, .select:focus, .btn:focus-visible, .seg button:focus-visible, .nav a:focus-visible { outline: 2px solid var(--sky); outline-offset: 1px; }
label.lbl { display: block; font-size: 12.5px; font-weight: 700; color: var(--navy); margin-bottom: 5px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px 22px; }
.card h2 { margin: 0 0 14px; font-size: 16px; color: var(--navy); }
.card h2 .muted { font-weight: 500; font-size: 13.5px; margin-left: 6px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi .t { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.kpi .v { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.kpi .v b { font-size: 28px; color: var(--navy); letter-spacing: -.02em; line-height: 1.1; }
.delta { font-size: 13px; font-weight: 700; }
.delta.up { color: var(--green); } .delta.down { color: var(--red); } .delta.flat { color: var(--muted); }
.kpi .s { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.kpi svg.spark { display: block; width: 100%; height: 34px; margin-top: 8px; }
.live { display: flex; align-items: center; gap: 10px; padding: 12px 18px; margin-bottom: 16px; }
.live .dot { width: 12px; height: 12px; border-radius: 50%; background: #1FA36B; box-shadow: 0 0 0 5px rgba(31,163,107,.18); }
.live a { margin-left: auto; font-weight: 700; text-decoration: none; }
.section { margin-top: 16px; }

/* ---------- charts ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; padding: 8px 11px; border-radius: 9px; font-size: 12.5px; line-height: 1.45; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: 0 10px 24px -10px rgba(14,42,71,.6); }
.chart .tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.legend button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 0; cursor: pointer; color: var(--ink); font-weight: 600; }
.legend button.off { opacity: .4; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; font-size: 14px; }
.bar-row .n { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; height: 7px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 99px; background: var(--blue2); }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 14px; }
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 36px; }
.cmp div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.cmp b { color: var(--navy); }

/* ---------- tables ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs button { display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line2); background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.tabs button span { min-width: 22px; padding: 0 7px; border-radius: 99px; background: var(--soft); font-size: 12px; line-height: 20px; text-align: center; }
.tabs button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.tabs button.on span { background: rgba(255,255,255,.18); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1; min-width: 220px; max-width: 420px; position: relative; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 34px; }
.toolbar .sp { flex: 1; }
.filters { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); padding: 16px; border-bottom: 1px solid var(--line); background: #FAFCFE; }
.filters .wide { grid-column: span 2; }
.filters .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line2); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.filters .actions { display: flex; align-items: flex-end; gap: 8px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.active-filters .chip { cursor: pointer; background: var(--soft); border-color: transparent; color: var(--navy); }
.active-filters .chip::after { content: " ✕"; color: var(--muted); }
.bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; background: #EAF2FB; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--navy); }
.bulk .select { width: auto; min-height: 34px; padding: 5px 10px; }
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; min-width: 900px; }
.dt th { text-align: left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: #FAFCFE; white-space: nowrap; user-select: none; }
.dt th.sort { cursor: pointer; }
.dt th.sort:hover { color: var(--navy); }
.dt th .ar { display: inline-block; width: 12px; margin-left: 4px; color: var(--blue); }
.dt td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
.dt tbody tr { cursor: pointer; }
.dt tbody tr:hover td { background: #F7FAFD; }
.dt tbody tr.sel td { background: #EEF5FC; }
.dt td.chk, .dt th.chk { width: 40px; padding-right: 0; cursor: default; }
.dt input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.dt .strong { font-weight: 700; color: var(--navy); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.p-new { background: #FDE7E8; color: #B51F27; } .p-reviewing, .p-contacted { background: #E6EEF8; color: var(--blue); }
.p-shortlisted, .p-qualified { background: #DDF1EC; color: #0F6B5A; } .p-rejected, .p-closed { background: #EEF0F3; color: var(--muted); }
.p-partner { background: #DDF1EC; color: #0F6B5A; } .p-contact { background: #E6EEF8; color: var(--blue); }
.p-admin { background: #E6EEF8; color: var(--navy); } .p-hr { background: #FFF1DD; color: #8A5300; } .p-sales { background: #DDF1EC; color: #0F6B5A; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; font-size: 14px; color: var(--muted); }
.pager .sp { flex: 1; }
.pager .select { width: auto; min-height: 34px; padding: 5px 10px; }

/* ---------- drawer, dialogs, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(14,42,71,.45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; z-index: 41; display: flex; flex-direction: column; box-shadow: -20px 0 50px -20px rgba(14,42,71,.4); }
.drawer header { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer header h2 { margin: 0; font-size: 20px; color: var(--navy); }
.drawer header p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.drawer .body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.drawer footer { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; margin: 0; }
.dl dt { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.dl dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.modal { position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 24px)); background: #fff; border-radius: 18px; padding: 22px; box-shadow: 0 30px 70px -20px rgba(14,42,71,.55); }
.modal h2 { margin: 0 0 6px; color: var(--navy); font-size: 19px; }
.modal .row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.secret { display: flex; gap: 8px; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--soft); font-family: Consolas, "Courier New", monospace; font-size: 16px; color: var(--navy); }
.secret code { flex: 1; overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 16px 40px -14px rgba(14,42,71,.7); }
.toast.err { background: #B51F27; }

/* ---------- sign in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #0E2A47 0%, #163556 55%, #1D4F86 100%); }
.auth .card { width: 100%; max-width: 410px; padding: 32px 30px; }
.auth h1 { margin: 16px 0 4px; font-size: 22px; color: var(--navy); }
.auth p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.auth .field { margin-bottom: 14px; }
.auth .btn { width: 100%; padding: 12px; margin-top: 6px; }
.form-err { color: #B51F27; font-size: 14px; font-weight: 600; min-height: 20px; margin-top: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 45; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 20px 0 50px -20px rgba(14,42,71,.4); }
  .shell.menu-open .side { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 14px; }
  .topbar img { width: 30px; height: 30px; }
  .topbar b { color: var(--navy); }
  .main { padding: 20px 16px 50px; }
  .g2, .g3, .cmp { grid-template-columns: 1fr; }
  .head h1 { font-size: 23px; }
  .filters .wide { grid-column: auto; }
  .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- layout v2 ---------- */
.main { width: 100%; max-width: 1600px; margin: 0 auto; }
.grid { gap: 16px; align-items: stretch; }
.g1 { grid-template-columns: minmax(0, 1fr); }
.section { margin-top: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; min-height: 132px; }
.kpi .s { min-height: 18px; }
.kpi svg.spark, .kpi .spark-gap { margin-top: auto; padding-top: 8px; height: 42px; }
.card.pad, .panel { padding: 18px 20px; }
.panel { display: flex; flex-direction: column; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2, .card.pad > h2, .card .pad > h2 { margin: 0; font-size: 16px; font-weight: 700; color: var(--navy); }
.card.pad > h2 { margin-bottom: 14px; }
.panel-head h2 .muted { font-weight: 500; font-size: 13px; margin-left: 6px; }
.panel-link { font-size: 13.5px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.panel-link:hover { text-decoration: underline; }
.panel-body { flex: 1; min-width: 0; }
.card .pad { padding: 18px 20px 6px; }
.dash-main { grid-template-columns: minmax(0, 2.3fr) minmax(280px, 1fr); }
.chart-wrap { min-width: 0; }
.chart { width: 100%; min-width: 0; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart svg .ax { font-size: 11.5px; fill: #5F6F82; }
.chart .tip { z-index: 5; }
.dt.plain tbody tr { cursor: default; }
.dt.plain tbody tr:hover td { background: none; }
table.mini { width: 100%; border-collapse: collapse; }
table.mini td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini td:first-child { padding-left: 0; width: 45%; }
table.mini td:last-child { padding-right: 0; }
.strong { font-weight: 700; color: var(--navy); }
.bars { gap: 11px; }

@media (max-width: 1280px) {
  .dash-main { grid-template-columns: minmax(0, 1fr); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .head { flex-wrap: wrap; align-items: center; gap: 12px; }
  .head > div:first-child { flex-basis: 100%; }
  .head .sp { display: none; }
  .head .seg { overflow-x: auto; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .tabs button { flex: none; }
  .toolbar .search { min-width: 100%; max-width: none; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .drawer { width: 100vw; }
  .g3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.dt.stack { min-width: 0; }
  table.stack thead { display: none; }
  .table-wrap { padding: 4px 12px 8px; }
  table.dt.stack tr { border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; padding: 4px 12px; background: #fff; }
  table.dt.stack tr.sel { border-color: var(--sky); }
  table.dt.stack td { border: 0; padding: 7px 0; background: none !important; }
  table.stack td[data-label]:not([data-label=""]) { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; text-align: right; }
  table.stack td[data-label]:not([data-label=""])::before { content: attr(data-label); flex: none; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; padding-top: 2px; }
  table.dt.stack td.chk { padding-top: 10px; }
  table.mini.stack tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.mini.stack tr:last-child { border-bottom: 0; }
  table.mini.stack td { border: 0; padding: 3px 0; width: 100% !important; }
  .pager { justify-content: center; }
}
@media (max-width: 480px) {
  .main { padding: 16px 12px 40px; }
  .card.pad, .panel { padding: 14px 14px; }
  .kpi { padding: 14px; min-height: 120px; }
  .kpi .v b { font-size: 23px; }
  .head h1 { font-size: 21px; }
  .seg button { padding: 7px 12px; font-size: 13px; }
}
