/* TransPro design system — tokens, layout and components. One file, no framework. */

:root {
    --brand: #1f5eff;
    --brand-strong: #1546c9;
    --brand-soft: #edf2ff;
    --brand-ring: rgba(31, 94, 255, .24);
    --accent: #f59e0b;

    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f4f9;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --subtle: #94a3b8;
    --border: #e4e8f0;
    --border-strong: #cdd5e1;

    --success: #047857; --success-soft: #ecfdf5; --success-line: #a7f3d0;
    --warning: #b45309; --warning-soft: #fffbeb; --warning-line: #fde68a;
    --danger: #c81e1e;  --danger-soft: #fef2f2;  --danger-line: #fecaca;
    --info: #1d4ed8;    --info-soft: #eff6ff;    --info-line: #bfdbfe;

    /* Tones for KPI chips and avatars (identity only, never status) */
    --tone-blue: #1f5eff;   --tone-blue-soft: #e8efff;
    --tone-teal: #0f8a7e;   --tone-teal-soft: #e3f5f2;
    --tone-violet: #6d4ae8; --tone-violet-soft: #efebff;
    --tone-amber: #b7700b;  --tone-amber-soft: #fdf3e1;
    --tone-slate: #475569;  --tone-slate-soft: #eef1f6;

    --sidebar: #0a1222;
    --sidebar-2: #0e1a30;
    --sidebar-text: #9fabc2;
    --sidebar-line: #1a2740;

    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 7px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .05);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, .2);
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --sidebar-width: 256px;
    --topbar-height: 62px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.015em; }
p { margin: 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.icon { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 11.5px var(--mono); color: var(--text-2); text-align: center; }

/* ===== App shell ===== */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 26px 32px 56px; }

/* Sidebar */
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; background: radial-gradient(120% 60% at 0% 0%, #13254a 0%, transparent 60%), linear-gradient(180deg, var(--sidebar), var(--sidebar-2)); color: var(--sidebar-text); z-index: 40; scrollbar-width: thin; scrollbar-color: #24324f transparent; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #2f6bff 0%, #1849d6 100%); box-shadow: 0 8px 22px rgba(31, 94, 255, .45), inset 0 1px 0 rgba(255,255,255,.25); flex: none; }
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.02em; line-height: 1.1; }
.brand-name span { color: #ffb020; }
.brand-sub { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #6f7d99; }
.sidebar-company { margin: 2px 14px 10px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); }
.sidebar-company .logo-box { width: 34px; height: 34px; border-radius: 9px; }
.sidebar-company strong { display: block; color: #e6ebf5; font-size: 13px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-company small { color: #7d8aa6; font-size: 11.5px; }
.sidebar-company > div { min-width: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px 20px; }
.nav-label { padding: 16px 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #56637f; }
.nav-link { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--sidebar-text); font-size: 13.8px; font-weight: 500; transition: background .15s, color .15s; }
.nav-link .icon { width: 18px; height: 18px; opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,.05); color: #e8edf6; }
.nav-link.is-active { background: linear-gradient(90deg, rgba(47,107,255,.26), rgba(47,107,255,.08)); color: #fff; }
.nav-link.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #4d84ff; }
.nav-link.is-active .icon { opacity: 1; color: #8fb0ff; }
.sidebar-foot { margin-top: auto; padding: 14px 20px 18px; border-top: 1px solid var(--sidebar-line); font-size: 11.5px; color: #56637f; display: flex; justify-content: space-between; gap: 8px; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: var(--topbar-height); padding: 0 32px; background: rgba(255,255,255,.88); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border); }
.topbar-menu { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); min-width: 0; }
.crumbs strong { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .icon { width: 14px; height: 14px; color: var(--subtle); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.managing { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--warning-soft); border: 1px solid var(--warning-line); color: var(--warning); font-size: 12.5px; font-weight: 600; }
.managing form { margin: 0; }
.managing button { border: 0; border-radius: 999px; padding: 3px 10px; background: #fff; color: var(--warning); font-size: 12px; font-weight: 600; cursor: pointer; }
.user-menu { position: relative; }
.user-button { display: inline-flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 0; border-radius: 12px; background: none; cursor: pointer; }
.user-button:hover { background: var(--surface-3); }
.user-button .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; text-align: left; }
.user-button .who strong { font-size: 13px; }
.user-button .who small { color: var(--muted); font-size: 11.5px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #2f6bff, #6d4ae8); color: #fff; font-size: 12.5px; font-weight: 700; flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.t1 { background: linear-gradient(135deg, #0f8a7e, #22b8a5); }
.avatar.t2 { background: linear-gradient(135deg, #6d4ae8, #9b7bff); }
.avatar.t3 { background: linear-gradient(135deg, #b7700b, #e9a23b); }
.avatar.t4 { background: linear-gradient(135deg, #475569, #7c8aa0); }
.avatar.muted-av { background: #cbd3df; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg); display: none; z-index: 60; }
.menu.is-open { display: block; animation: pop .14s ease-out; }
.menu-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-head strong { display: block; font-size: 13.5px; }
.menu-head small { color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font-size: 13.5px; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu form { margin: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ===== Page header ===== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; }
.page-head p { margin-top: 4px; color: var(--muted); font-size: 14px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.back-link .icon { width: 16px; height: 16px; }
.back-link:hover { color: var(--brand); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 13.8px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, color .15s; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(31,94,255,.3), inset 0 1px 0 rgba(255,255,255,.14); }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: #b4bfd0; color: var(--text); background: var(--surface-2); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a91919; color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.btn.is-busy::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ===== Cards & KPIs ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 18px 20px; }
.grid { display: grid; gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 18px; overflow: hidden; color: inherit; }
a.kpi:hover { border-color: var(--border-strong); color: inherit; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(15,23,42,.08); }
a.kpi { transition: transform .15s, box-shadow .15s, border-color .15s; }
.kpi-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none; }
.kpi-icon .icon { width: 21px; height: 21px; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 27px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tone-blue { background: var(--tone-blue-soft); color: var(--tone-blue); }
.tone-teal { background: var(--tone-teal-soft); color: var(--tone-teal); }
.tone-violet { background: var(--tone-violet-soft); color: var(--tone-violet); }
.tone-amber { background: var(--tone-amber-soft); color: var(--tone-amber); }
.tone-slate { background: var(--tone-slate-soft); color: var(--tone-slate); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.badge-muted { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: #cfdcff; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; }

/* ===== Tables ===== */
.table-card { overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search { position: relative; flex: 1 1 260px; max-width: 380px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--subtle); pointer-events: none; }
.search input { width: 100%; height: 36px; padding: 0 38px 0 34px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); font-size: 13.5px; }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-3); border: 1px solid var(--border); }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.table-count { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.6px; }
.table th { position: sticky; top: 0; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; text-align: left; white-space: nowrap; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text-2); }
.table th[data-sort]::after { content: "↕"; margin-left: 6px; opacity: .35; font-size: 11px; }
.table th[aria-sort="ascending"]::after { content: "↑"; opacity: .9; }
.table th[aria-sort="descending"]::after { content: "↓"; opacity: .9; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table tr.is-inactive td { color: var(--muted); }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.table .actions form { display: inline; margin: 0; }
.cell-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-main strong { display: block; font-weight: 600; color: var(--text); }
.cell-main small { display: block; color: var(--muted); font-size: 12px; }
.table-empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.table-empty .icon { width: 40px; height: 40px; color: var(--subtle); margin-bottom: 8px; }
.table-empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.table-empty .btn { margin-top: 14px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.pager { display: flex; gap: 4px; }
.pager button, .pager a { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-grid; place-items: center; }
.pager button[disabled], .pager a.is-disabled { opacity: .45; pointer-events: none; }
.pager .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Row action menu */
.row-menu { position: relative; display: inline-block; }
.row-menu .menu { min-width: 200px; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.req { color: var(--danger); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.input.upper { text-transform: uppercase; }
.input.upper::placeholder { text-transform: none; }
.has-error .input, .has-error .select, .has-error .textarea, .has-error .combo-input, .has-error .check-list { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(200,30,30,.12); }
.form-section { padding: 22px 24px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; }
.form-section:last-of-type { border-bottom: 0; }
.form-section-intro h2 { font-size: 15px; }
.form-section-intro p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.form-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: rgba(255,255,255,.94); backdrop-filter: blur(6px); border-radius: 0 0 var(--radius) var(--radius); }
.form-footer .hint { margin-right: auto; align-self: center; font-size: 12px; color: var(--muted); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid; }
.alert .icon { margin-top: 1px; }
.alert-danger { background: var(--danger-soft); color: #9b1c1c; border-color: var(--danger-line); }
.alert-info { background: var(--info-soft); color: #1e40af; border-color: var(--info-line); }
.alert-warning { background: var(--warning-soft); color: #92400e; border-color: var(--warning-line); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #cbd3df; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--brand-ring); }

/* Choice pills (multi-select roles) */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; }
.pill span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; transition: all .15s; }
.pill span::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--border-strong); background: #fff; }
.pill input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.pill input:checked + span::before { background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/10px no-repeat; border-color: var(--brand); }
.pill input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }
.pill input:disabled + span { opacity: .5; cursor: not-allowed; }

/* Searchable checklist (locations) */
.check-list { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.check-list-search { border-bottom: 1px solid var(--border); padding: 8px; background: var(--surface-2); }
.check-list-search input { width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 7px; padding: 0 10px; font-size: 13px; }
.check-list-items { max-height: 230px; overflow-y: auto; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; }
.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: var(--surface-2); }
.check-row input { width: 16px; height: 16px; accent-color: var(--brand); }
.check-row small { margin-left: auto; color: var(--muted); font-size: 12px; }
.check-list.is-disabled { opacity: .5; pointer-events: none; }

/* Combobox (searchable select / creatable autocomplete) */
.combo { position: relative; }
.combo-input { width: 100%; min-height: 40px; padding: 8px 34px 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; font-size: 14px; }
.combo-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); max-height: 240px; overflow-y: auto; padding: 4px; margin: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 80; }
.combo-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 7px; font-size: 13.5px; cursor: pointer; }
.combo-list li small { color: var(--muted); }
.combo-list li.is-active { background: var(--brand-soft); color: var(--brand-strong); }
.combo-list li.is-new { color: var(--brand); font-weight: 600; }
.combo-list li.is-empty { color: var(--muted); cursor: default; }

/* Logo upload */
.logo-box { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--border); overflow: hidden; flex: none; color: var(--muted); font-weight: 800; font-size: 13px; }
.logo-box { position: relative; }
.logo-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.logo-box.lg { width: 96px; height: 96px; border-radius: 18px; font-size: 26px; }
.logo-box.brand-tint { background: linear-gradient(135deg, #e8efff, #f3ecff); color: var(--brand); border-color: #d9e3ff; }
.upload { display: flex; align-items: center; gap: 18px; }
.upload-drop { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.upload-drop:hover, .upload-drop.is-over { border-color: var(--brand); background: var(--brand-soft); }
.upload-drop strong { font-size: 13.5px; }
.upload-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* ===== Modal dialogs ===== */
dialog.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
dialog.modal[open] { animation: modal-in .18s ease-out; display: flex; flex-direction: column; }
dialog.modal > form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 48px); }
dialog.modal::backdrop { background: rgba(10, 18, 34, .5); backdrop-filter: blur(3px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px 14px; }
.modal-header h2 { font-size: 17px; }
.modal-header p { margin-top: 3px; color: var(--muted); font-size: 13.5px; }
.modal-header .icon-btn { margin-left: auto; margin-top: -4px; }
.modal-body { padding: 6px 22px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-footer .hint { margin-right: auto; align-self: center; font-size: 12px; color: var(--muted); }
.reveal-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.reveal-item span { font-size: 12px; color: var(--muted); min-width: 130px; }
.reveal-item code { font: 600 15px var(--mono); color: var(--text); letter-spacing: .02em; word-break: break-all; }
.reveal-item .icon-btn { margin-left: auto; }

/* ===== Toasts ===== */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid; box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out; }
.toast strong { display: block; font-size: 13.5px; }
.toast p { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.toast .icon-btn { width: 26px; height: 26px; margin-left: auto; }
.toast-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none; }
.toast-icon .icon { width: 15px; height: 15px; }
.toast-success { border-left-color: var(--success); } .toast-success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-info { border-left-color: var(--info); } .toast-info .toast-icon { background: var(--info-soft); color: var(--info); }
.toast.is-leaving { opacity: 0; transform: translateX(16px); transition: all .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== Dashboard ===== */
.hero { position: relative; display: flex; align-items: center; gap: 18px; padding: 22px 24px; margin-bottom: 18px; border-radius: 18px; color: #fff; overflow: hidden;
        background: radial-gradient(90% 140% at 100% 0%, rgba(255,176,32,.28) 0%, transparent 45%), linear-gradient(120deg, #0d1b38 0%, #15306a 55%, #1f5eff 130%); box-shadow: 0 14px 34px rgba(13,27,56,.25); }
.hero::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 360px; height: 180px; background: url("../img/route-lines.svg") no-repeat center / contain; opacity: .5; pointer-events: none; }
.hero h1 { font-size: 22px; }
.hero p { color: #c3cfea; margin-top: 4px; font-size: 14px; }
.hero .logo-box { width: 56px; height: 56px; border-radius: 14px; border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff; }
.hero-stats { margin-left: auto; display: flex; gap: 26px; position: relative; z-index: 1; }
.hero-stats div { text-align: right; }
.hero-stats strong { display: block; font-size: 20px; }
.hero-stats span { font-size: 12px; color: #aebbd8; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dash-col { display: grid; gap: 18px; min-width: 0; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--brand); transition: fill .12s; }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .bar-hit:hover + .bar, .chart g:hover .bar { fill: var(--brand-strong); }
.chart .gridline { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .value-label { fill: var(--text-2); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart-tip { position: absolute; pointer-events: none; padding: 7px 10px; border-radius: 8px; background: #0f172a; color: #fff; font-size: 12px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); box-shadow: var(--shadow-lg); z-index: 5; }
.chart-tip strong { font-size: 13px; }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr) 36px; align-items: center; gap: 12px; font-size: 13px; }
.hbar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--brand); min-width: 3px; }
.hbar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-table summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.chart-table table { margin-top: 8px; font-size: 12.5px; width: 100%; border-collapse: collapse; }
.chart-table td, .chart-table th { padding: 4px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.setup { display: flex; flex-direction: column; }
.setup-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.setup-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.setup-bar span { display: block; height: 100%; background: linear-gradient(90deg, #1f5eff, #6d4ae8); border-radius: 4px; }
.setup-step { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); color: inherit; }
.setup-step:last-child { border-bottom: 0; }
a.setup-step:hover { color: inherit; background: var(--surface-2); border-radius: 8px; }
.setup-step .icon { width: 22px; height: 22px; color: var(--subtle); }
.setup-step.is-done .icon { color: var(--success); }
.setup-step.is-done strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--subtle); }
.setup-step strong { display: block; font-size: 13.5px; }
.setup-step small { color: var(--muted); font-size: 12px; }
.setup-step .go { margin-left: auto; width: 16px; height: 16px; }
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.feed-dot .icon { width: 15px; height: 15px; }
.feed-item p { font-size: 13px; color: var(--text-2); }
.feed-item small { color: var(--muted); font-size: 11.5px; }

/* ===== Permission matrix ===== */
.matrix th, .matrix td { text-align: center; padding: 10px 8px; }
.matrix th:first-child, .matrix td:first-child { text-align: left; padding-left: 18px; }
.matrix td:first-child strong { display: block; font-size: 13.5px; }
.matrix td:first-child small { color: var(--muted); font-size: 12px; }
.matrix .module-row td { background: var(--surface-2); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-top: 9px; padding-bottom: 9px; }
.matrix input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.matrix .na { color: #d3d9e3; }
.matrix tbody tr:hover td { background: #f8faff; }

/* ===== Audit ===== */
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) auto; gap: 10px; align-items: end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .field-label { font-size: 12px; }
.filters .input, .filters .select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
.changes { margin-top: 6px; }
.changes summary { cursor: pointer; font-size: 12px; color: var(--brand); font-weight: 600; }
.changes table { margin-top: 6px; border-collapse: collapse; font-size: 12px; }
.changes td { padding: 3px 10px 3px 0; border: 0; vertical-align: top; }
.changes .from { color: var(--danger); text-decoration: line-through; text-decoration-color: rgba(200,30,30,.4); }
.changes .to { color: var(--success); }

/* ===== Auth pages ===== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: var(--surface); }
.auth-art { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; color: #fff;
            background: radial-gradient(80% 60% at 85% 10%, rgba(255,176,32,.32) 0%, transparent 55%), radial-gradient(70% 70% at 0% 100%, rgba(47,107,255,.55) 0%, transparent 60%), linear-gradient(150deg, #081226 0%, #0f2350 60%, #142e6b 100%); }
.auth-art .brand { padding: 0; }
.auth-art .route { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; pointer-events: none; }
.auth-copy { position: relative; z-index: 1; max-width: 480px; }
.auth-copy h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.025em; }
.auth-copy h2 span { color: #ffb020; }
.auth-copy p { margin-top: 14px; color: #b9c6e4; font-size: 15.5px; }
.auth-points { display: flex; gap: 22px; margin-top: 26px; flex-wrap: wrap; }
.auth-points div { display: flex; align-items: center; gap: 8px; color: #dbe4f7; font-size: 13.5px; font-weight: 500; }
.auth-points .icon { width: 18px; height: 18px; color: #ffb020; }
.auth-foot { position: relative; z-index: 1; font-size: 12.5px; color: #7f8db0; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 26px; }
.auth-card > p { margin-top: 6px; color: var(--muted); }
.auth-card form { margin-top: 26px; display: flex; flex-direction: column; gap: 16px; }
.auth-card .btn { height: 44px; width: 100%; font-size: 14.5px; }
.auth-card .input { min-height: 44px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.auth-mobile-brand { display: none; }
.auth-legal { margin-top: 28px; font-size: 12px; color: var(--subtle); text-align: center; }

/* ===== Error / empty pages ===== */
.state { max-width: 520px; margin: 8vh auto; text-align: center; }
.state .kpi-icon { margin: 0 auto 16px; width: 56px; height: 56px; border-radius: 16px; }
.state h1 { font-size: 22px; }
.state p { margin-top: 8px; color: var(--muted); }
.state .btn { margin-top: 20px; }

/* ===== Responsive ===== */
@media (max-width: 1180px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
    .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-section { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .hero-stats { display: none; }
}
@media (max-width: 900px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10,18,34,.45); z-index: 35; }
    .topbar { padding: 0 16px; }
    .topbar-menu { display: inline-grid; }
    .content { padding: 20px 16px 48px; }
    .user-button .who { display: none; }
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth-art { display: none; }
    .auth-mobile-brand { display: flex; margin-bottom: 26px; }
    .auth-mobile-brand .brand { padding: 0; color: var(--text); }
    .auth-mobile-brand .brand-sub { color: var(--muted); }
}
@media (max-width: 640px) {
    .kpis { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .kpi { padding: 14px; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-section { padding: 18px 16px; }
    .form-footer { padding: 12px 16px; }
    .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .page-head h1 { font-size: 20px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .search { max-width: none; }
    .search kbd { display: none; }
    .table-count { margin-left: 0; }
    .managing span.long { display: none; }
    .crumbs .crumb-parent, .crumbs > .icon { display: none; }
    .hero { padding: 18px; }
    .hero h1 { font-size: 18px; }
    /* Tables become stacked cards on phones */
    .table.stack thead { display: none; }
    .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
    .table.stack tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
    .table.stack td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
    .table.stack td.cell-first { display: block; text-align: left; margin-bottom: 6px; }
    .table.stack td.cell-first::before { display: none; }
    .table.stack td.actions { width: 100%; justify-content: flex-end; margin-top: 4px; }
    .table.stack td.actions::before { display: none; }
    .table.stack tbody tr:hover td { background: none; }
    .table-foot { flex-direction: column; align-items: stretch; }
    .upload { flex-direction: column; align-items: stretch; }
    .reveal-item { flex-wrap: wrap; }
    .reveal-item span { min-width: 0; width: 100%; }
    .hbar { grid-template-columns: 96px minmax(0, 1fr) 30px; }
}
@media print { .sidebar, .topbar, .page-actions, .toast-stack { display: none !important; } .app { display: block; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
/* Forms inside row menus stack as menu items (the inline rule for table action forms must not apply). */
.table .actions .menu form { display: block; }
/* The menu button only exists on narrow screens (must beat the generic .icon-btn display rule). */
.topbar .topbar-menu { display: none; }
@media (max-width: 900px) { .topbar .topbar-menu { display: inline-grid; } }
/* Hero decoration sits behind the greeting, clear of the figures on the right. */
.hero::after { right: auto; left: 38%; bottom: -96px; width: 300px; opacity: .35; }
.hero > * { position: relative; z-index: 1; }
