/* ==========================================================================
   AHD Agent Portal — design system
   ========================================================================== */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #8391a7;
  --primary: #1f5eff;
  --primary-600: #1747cc;
  --primary-50: #eef3ff;
  --green: #0f9d63;  --green-50: #e7f7ef;
  --amber: #c27803;  --amber-50: #fdf4e3;
  --red: #d93849;    --red-50: #fdecee;
  --blue: #2463eb;   --blue-50: #eaf1fe;
  --gray-50: #f1f4f8;
  --side-bg: #0c1424;
  --side-text: #a9b4c7;
  --side-active: #ffffff;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 6px 16px -8px rgba(15, 23, 42, .12);
  --shadow-lg: 0 20px 50px -12px rgba(15, 23, 42, .28);
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: 'cv11', 'ss01'; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; z-index: 40; transition: transform .22s ease; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.06); color: #fff; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .02em; flex: none; }
.brand-sub { display: block; font-size: 11px; font-weight: 500; color: var(--side-text); letter-spacing: .02em; }
.sidebar-company { margin: 14px 12px 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255,255,255,.05); display: flex; align-items: center; gap: 10px; color: #fff; }
.sidebar-company .avatar { width: 30px; height: 30px; font-size: 11px; }
.sidebar-company small { display: block; color: var(--side-text); font-size: 11px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 24px; scrollbar-width: thin; scrollbar-color: #26324a transparent; }
.nav-label { margin: 16px 10px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #5f6d86; }
.nav a, .nav summary { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 7px; color: var(--side-text); font-weight: 500; cursor: pointer; list-style: none; user-select: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav a:hover, .nav summary:hover { background: rgba(255,255,255,.05); color: #e6ebf3; }
.nav a.active { background: rgba(31, 94, 255, .18); color: var(--side-active); }
.nav a.active i { color: #7ea2ff; }
.nav i { font-size: 16px; width: 18px; text-align: center; flex: none; }
.nav summary .chev { margin-left: auto; font-size: 11px; transition: transform .15s; }
.nav details[open] > summary .chev { transform: rotate(90deg); }
.nav details .sub { padding: 2px 0 6px 29px; }
.nav details .sub a { padding: 6px 10px; font-size: 13px; font-weight: 450; }
.nav .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.08); padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--side-text); font-weight: 500; }
.sidebar-foot a:hover { background: rgba(255,255,255,.05); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar .menu-btn { display: none; }
.topbar-search { flex: 1; max-width: 460px; position: relative; }
.topbar-search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; font: inherit; color: var(--text); }
.topbar-search input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-50); }
.topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 18px; }
.icon-btn:hover { background: var(--gray-50); color: var(--text); }
.icon-btn .dot { position: absolute; top: 5px; right: 4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 99px; border: 1px solid transparent; background: none; cursor: pointer; font: inherit; color: var(--text); }
.user-chip:hover { border-color: var(--border); }
.user-chip .who { text-align: left; line-height: 1.2; }
.user-chip .who small { display: block; color: var(--text-3); font-size: 11.5px; }

.content { padding: 24px; width: 100%; max-width: 1480px; margin: 0 auto; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); margin-bottom: 8px; }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--primary); }
.crumbs i { font-size: 10px; }
.footer { padding: 18px 24px; color: var(--text-3); font-size: 12px; text-align: center; }
.backdrop { display: none; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--gray-50); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.notif-menu { width: 360px; max-width: calc(100vw - 24px); padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex !important; gap: 10px; padding: 11px 14px !important; border-radius: 0 !important; border-bottom: 1px solid var(--border); align-items: flex-start !important; }
.notif-item.unread { background: #f7f9ff; }
.notif-item .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 14px; }
.notif-item b { display: block; font-weight: 600; font-size: 13px; }
.notif-item span { display: block; color: var(--text-2); font-size: 12.5px; line-height: 1.4; }
.notif-item time { color: var(--text-3); font-size: 11.5px; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 650; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 24px; } .mb { margin-bottom: 16px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; box-shadow: var(--shadow-sm); color: var(--text); transition: border-color .15s, box-shadow .15s; }
a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow); color: var(--text); }
.stat .ico { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-size: 17px; flex: none; }
.stat .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.stat .hint { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.tone-blue { background: var(--blue-50); color: var(--blue); }
.tone-green { background: var(--green-50); color: var(--green); }
.tone-amber { background: var(--amber-50); color: var(--amber); }
.tone-red { background: var(--red-50); color: var(--red); }
.tone-gray { background: var(--gray-50); color: var(--text-2); }
.tone-violet { background: #f1edfe; color: #6d3fe0; }
.tone-teal { background: #e4f6f5; color: #0d7f78; }

/* Section heading */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { font-size: 16px; font-weight: 650; }

/* Company cards */
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.company-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: box-shadow .18s, transform .18s, border-color .18s; }
.company-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-2px); }
.company-card .band { height: 4px; background: var(--cc); }
.company-card .top { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.company-card .avatar { width: 46px; height: 46px; font-size: 15px; border-radius: 11px; background: var(--cc); }
.company-card h3 { font-size: 16px; font-weight: 700; letter-spacing: .01em; text-transform: uppercase; }
.company-card .code { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }
.company-card .status { margin-left: auto; align-self: flex-start; }
.company-card .metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.company-card .metric { background: #fff; padding: 11px 18px; }
.company-card .metric b { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.company-card .metric span { font-size: 12px; color: var(--text-2); }
.company-card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px; margin-top: auto; }
.company-card .foot .last { font-size: 12px; color: var(--text-3); }
.company-card .active-bar { height: 5px; border-radius: 99px; background: var(--gray-50); overflow: hidden; margin: 0 18px 12px; }
.company-card .active-bar span { display: block; height: 100%; background: var(--cc); border-radius: 99px; }
.company-card .active-meta { display: flex; justify-content: space-between; padding: 12px 18px 6px; font-size: 12px; color: var(--text-2); }
.add-company { border: 1.5px dashed var(--border-strong); background: transparent; box-shadow: none; align-items: center; justify-content: center; min-height: 260px; color: var(--text-2); gap: 10px; }
.add-company:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); transform: none; }
.add-company i { font-size: 28px; }

.avatar { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; background: var(--primary); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.round { border-radius: 50%; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; color: var(--text); font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); color: var(--text); border-color: #b9c3d2; }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn i { font-size: 15px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(31,94,255,.25); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #bf2c3c; border-color: #bf2c3c; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--gray-50); border-color: transparent; }
.btn-soft { background: var(--primary-50); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: #dfe8ff; border-color: transparent; color: var(--primary-600); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .label { display: block; font-size: 13px; font-weight: 550; color: var(--text); margin-bottom: 6px; }
.field .req { color: var(--red); }
.field .help { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.field .err { font-size: 12px; color: var(--red); margin-top: 5px; }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; font: inherit; color: var(--text); transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
select.input { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M1.6 5.1a.6.6 0 0 1 .9 0L8 10.6l5.5-5.5a.6.6 0 1 1 .9.9l-6 6a.6.6 0 0 1-.9 0l-6-6a.6.6 0 0 1 0-.9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.input.is-invalid { border-color: var(--red); }
.input-sm { height: 32px; font-size: 13px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.color-input { width: 52px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; cursor: pointer; }

/* Filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.filters .input { width: auto; min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 12px 12px 11px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13.5px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .n { font-size: 11px; background: var(--gray-50); color: var(--text-2); padding: 1px 7px; border-radius: 99px; margin-left: 4px; }
.tabs a.active .n { background: var(--primary-50); color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: #fafbfd; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .who { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.table .who b { display: block; font-weight: 600; }
.table .who small { color: var(--text-3); font-size: 12px; }
.table.compact td, .table.compact th { padding: 8px 12px; }
.sort-link { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort-link i { font-size: 10px; opacity: .5; }
.sort-link.active { color: var(--primary); }
.sort-link.active i { opacity: 1; }
.col-toggle { max-height: 320px; overflow-y: auto; }
.col-toggle label { display: flex; gap: 8px; align-items: center; padding: 6px 10px; cursor: pointer; border-radius: 6px; }
.col-toggle label:hover { background: var(--gray-50); }
tr.row-invalid td { background: #fff8f8; }
.cell-err { color: var(--red); font-size: 12.5px; max-width: 420px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.pager .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager .pages a, .pager .pages span { min-width: 32px; height: 32px; padding: 0 8px; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--border); color: var(--text); font-weight: 550; }
.pager .pages a:hover { border-color: var(--border-strong); background: var(--surface-2); }
.pager .pages .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .pages .gap { border: 0; }

/* ---------- Badges, alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-green { background: var(--green-50); color: var(--green); }
.badge-amber { background: var(--amber-50); color: var(--amber); }
.badge-red { background: var(--red-50); color: var(--red); }
.badge-blue { background: var(--blue-50); color: var(--blue); }
.badge-gray { background: var(--gray-50); color: var(--text-2); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 5px; background: var(--gray-50); color: var(--text-2); font-size: 12px; font-weight: 550; margin: 1px 2px 1px 0; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13.5px; }
.alert i { font-size: 17px; line-height: 1.2; }
.alert-success { background: var(--green-50); border-color: #b6e6cf; color: #0a5c3b; }
.alert-warning { background: var(--amber-50); border-color: #f3d9a4; color: #7a4b02; }
.alert-danger { background: var(--red-50); border-color: #f5c2c8; color: #8f1d2b; }
.alert-info { background: var(--blue-50); border-color: #c5d8fb; color: #173f95; }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }

.toasts { position: fixed; top: 72px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: 380px; max-width: calc(100vw - 32px); }
.toast { box-shadow: var(--shadow-lg); animation: toast-in .25s ease; }
.toast .close { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; font-size: 16px; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Detail lists ---------- */
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 0; }
.dl dt, .dl dd { padding: 10px 0; border-bottom: 1px solid var(--border); margin: 0; }
.dl dt { color: var(--text-2); font-size: 13px; }
.dl dd { font-weight: 500; word-break: break-word; }
.dl > :nth-last-child(-n+2) { border-bottom: 0; }

.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.profile-head .avatar { width: 56px; height: 56px; font-size: 18px; border-radius: 14px; }
.profile-head h1 { font-size: 21px; }
.meta-row { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin-top: 4px; }
.meta-row span { display: inline-flex; gap: 5px; align-items: center; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: -2px; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .pt { position: absolute; left: 0; top: 4px; width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); }
.timeline b { font-weight: 600; }
.timeline small { display: block; color: var(--text-3); }

.empty { text-align: center; padding: 44px 20px; color: var(--text-2); }
.empty i { font-size: 34px; color: var(--text-3); display: block; margin-bottom: 8px; }
.empty h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }

.progress { height: 8px; background: var(--gray-50); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s ease; }
.progress.lg { height: 12px; }

/* Charts */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 210px; }
.legend-list { list-style: none; margin: 0; padding: 0; }
.legend-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.legend-list li:last-child { border: 0; }
.legend-list .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-list b { margin-left: auto; font-variant-numeric: tabular-nums; }
.bar-list li { display: block; }
.bar-list .bar { height: 6px; background: var(--gray-50); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.bar-list .bar span { display: block; height: 100%; border-radius: 99px; }

/* ---------- Upload wizard ---------- */
.stepper { display: flex; gap: 0; counter-reset: step; overflow-x: auto; padding: 4px 2px 2px; scrollbar-width: none; }
.stepper .step { flex: 1; min-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; font-size: 12px; color: var(--text-3); font-weight: 550; text-align: center; }
.stepper .step::before { counter-increment: step; content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--border-strong); color: var(--text-3); font-weight: 700; z-index: 1; }
.stepper .step::after { content: ''; position: absolute; top: 13px; left: calc(50% + 16px); right: calc(-50% + 16px); height: 2px; background: var(--border); }
.stepper .step:last-child::after { display: none; }
.stepper .step.done::before { content: '✓'; background: var(--green); border-color: var(--green); color: #fff; }
.stepper .step.done::after { background: var(--green); }
.stepper .step.current::before { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-50); }
.stepper .step.current { color: var(--text); }

.dropzone { display: block; border: 2px dashed var(--border-strong); border-radius: 12px; padding: 36px 20px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone i { font-size: 38px; color: var(--primary); }
.dropzone h3 { font-size: 16px; margin: 8px 0 4px; }
.dropzone input { display: none; }
.dropzone .file-chosen { margin-top: 12px; font-weight: 600; color: var(--text); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.choice { position: relative; display: flex; gap: 12px; align-items: center; padding: 14px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; background: #fff; transition: border-color .12s, background .12s; }
.choice:hover { border-color: var(--border-strong); }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 1px var(--primary); }
.choice b { display: block; font-weight: 650; }
.choice small { color: var(--text-2); font-size: 12px; }
.map-table td { vertical-align: middle; }
.map-table .sample { color: var(--text-3); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-table tr.unmapped-req td { background: #fff8f8; }
.map-table .auto { font-size: 11px; color: var(--green); font-weight: 600; }
.result-hero { text-align: center; padding: 28px 18px 8px; }
.result-hero .big-ico { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; font-size: 30px; }
.result-hero h2 { font-size: 20px; }
.result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.result-stats .rs { border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; }
.result-stats .rs b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.result-stats .rs span { font-size: 12px; color: var(--text-2); }

/* Staff home */
.welcome { background: linear-gradient(135deg, #0c1424 0%, #16284a 100%); color: #fff; border-radius: 14px; padding: 28px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.welcome h1 { font-size: 24px; }
.welcome p { color: #b8c3d8; margin: 6px 0 0; }
.welcome .btn { background: #fff; color: var(--text); border-color: #fff; }

/* Permission matrix */
.matrix th, .matrix td { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix .grp td { background: var(--surface-2); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }

/* Modal (native dialog) */
dialog.modal { border: 0; border-radius: 14px; padding: 0; width: 520px; max-width: calc(100vw - 24px); box-shadow: var(--shadow-lg); color: var(--text); }
dialog.modal::backdrop { background: rgba(12, 20, 36, .5); backdrop-filter: blur(2px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: #fff; }
.auth-art { position: relative; background: var(--side-bg); color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.auth-art::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 30% 40%, #000 30%, transparent 75%); }
.auth-art > * { position: relative; }
.auth-art .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; }
.auth-art h2 { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; max-width: 480px; }
.auth-art h2 span { color: #86a5ff; }
.auth-art p { color: #a9b4c7; max-width: 460px; font-size: 15px; margin-top: 14px; }
.auth-points { display: grid; gap: 14px; margin-top: 30px; max-width: 460px; }
.auth-points div { display: flex; gap: 12px; align-items: flex-start; color: #cfd7e5; }
.auth-points i { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.07); display: grid; place-items: center; color: #86a5ff; flex: none; }
.auth-points b { display: block; color: #fff; font-weight: 600; }
.auth-points small { color: #93a0b6; }
.auth-foot { color: #6d7a91; font-size: 12px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 390px; }
.auth-box h1 { font-size: 24px; font-weight: 700; }
.auth-box .sub { color: var(--text-2); margin: 6px 0 26px; }
.auth-box .field { margin-bottom: 16px; }
.auth-box .row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 20px; font-size: 13px; }
.auth-box .secure { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--text-3); font-size: 12px; margin-top: 22px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 30px; border: 0; background: none; color: var(--text-3); cursor: pointer; border-radius: 6px; }
.pw-toggle:hover { color: var(--text); }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 26px; }

.error-page { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.error-page .code { font-size: 64px; font-weight: 800; color: var(--primary); letter-spacing: -.04em; line-height: 1; }
.error-page h1 { font-size: 22px; margin: 10px 0 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(12,20,36,.45); z-index: 35; }
  .main { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .topbar .menu-btn { display: inline-grid; }
  .g-3 { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-mobile-brand { display: flex; }
}
@media (max-width: 720px) {
  .content { padding: 16px; }
  .g-2, .g-3, .g-4, .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; flex-direction: column; gap: 8px; }
  .stat .value { font-size: 19px; }
  .user-chip .who { display: none; }
  .topbar-search { display: none; }
  .topbar-search.show-mobile { display: block; }
  .page-head h1 { font-size: 19px; }
  .page-head { align-items: flex-start; }
  .filters .input, .filters .grow { width: 100%; min-width: 0; flex: 1 1 100%; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { border-bottom: 0; padding-bottom: 0; }
  /* Stacked "card" tables on phones */
  .table.stack-sm thead { display: none; }
  .table.stack-sm tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table.stack-sm td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 16px; text-align: right; }
  .table.stack-sm td::before { content: attr(data-label); font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: none; }
  .table.stack-sm td.actions { justify-content: flex-end; }
  .table.stack-sm td.actions::before { display: none; }
  .table.stack-sm .who { min-width: 0; text-align: left; }
  .company-grid { grid-template-columns: 1fr; }
  .toasts { right: 16px; top: 68px; }
}
@media print {
  .sidebar, .topbar, .page-actions, .filters, .pager { display: none !important; }
  .main { margin: 0; }
}
