/* SubHub Engine console - design system. Brand colour: #00aaff */
:root {
  --brand: #00aaff;
  --primary: #00aaff;
  --primary-hover: #0099e6;
  --primary-press: #0088cc;
  --primary-ink: #0072a8;
  --primary-soft: #e6f7ff;
  --primary-ring: rgba(0, 170, 255, 0.28);

  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #0f1b2a;
  --text-2: #33445a;
  --muted: #6b7a90;

  --success: #067647;
  --success-soft: #e8f8ef;
  --warn: #b54708;
  --warn-soft: #fff5e0;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #0072a8;
  --info-soft: #e6f7ff;

  --shadow-xs: 0 1px 2px rgba(15, 27, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 27, 42, 0.07), 0 1px 2px rgba(15, 27, 42, 0.04);
  --shadow-md: 0 10px 28px rgba(15, 27, 42, 0.12);
  --shadow-lg: 0 28px 56px rgba(15, 27, 42, 0.24);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 262px;
  --sidebar-w-collapsed: 74px;
  --topbar-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
html.dark {
  --primary: #1ab3ff;
  --primary-hover: #4cc3ff;
  --primary-press: #7ad2ff;
  --primary-ink: #5cc8ff;
  --primary-soft: #0b2a3a;
  --primary-ring: rgba(26, 179, 255, 0.35);
  --bg: #0a1017;
  --surface: #111a24;
  --surface-2: #16212d;
  --surface-3: #1c2937;
  --border: #223142;
  --border-strong: #2f4258;
  --text: #edf2f8;
  --text-2: #c6d2e0;
  --muted: #8a9bb0;
  --success: #4ade80;
  --success-soft: #0f2a1d;
  --warn: #fbbf24;
  --warn-soft: #2d230b;
  --danger: #f87171;
  --danger-soft: #331414;
  --info: #5cc8ff;
  --info-soft: #0b2a3a;
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 28px 56px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
.hide { display: none !important; }
.muted { color: var(--muted); }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.lg { width: 20px; height: 20px; }
::selection { background: var(--primary-ring); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }

/* ============================================================ shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 50; transition: width 0.2s ease;
}
.sb-top { display: flex; align-items: center; gap: 8px; padding: 16px 14px 12px 16px; min-height: var(--topbar-h); }
.brand { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; color: var(--text); text-decoration: none !important; }
.brand-mark { width: 36px; height: 36px; flex: none; border-radius: 10px; background: linear-gradient(135deg, #33bbff 0%, #00aaff 55%, #0088cc 100%); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 14px rgba(0, 170, 255, 0.35); }
.brand-mark svg.i { width: 19px; height: 19px; stroke-width: 2.4; }
.brand-text { display: grid; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 16px; letter-spacing: -0.02em; }
.brand-text small { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.sb-close { display: none; }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.nav-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); padding: 18px 12px 7px; white-space: nowrap; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; margin-bottom: 2px;
  color: var(--text-2); font-weight: 550; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; text-decoration: none !important;
}
.nav-item svg.i { width: 18px; height: 18px; color: var(--muted); transition: color 0.12s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover svg.i { color: var(--text-2); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 650; }
.nav-item.active svg.i { color: var(--primary); }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--primary); }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sub { margin: 2px 0 8px 27px; padding-left: 12px; border-left: 1.5px solid var(--border); display: grid; gap: 1px; }
.nav-sub a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none !important; }
.nav-sub a:hover { background: var(--surface-2); color: var(--text); }
.nav-sub a.active { color: var(--primary-ink); font-weight: 650; background: var(--primary-soft); }
.nav-sub .count { font-size: 11px; background: var(--surface-3); border-radius: 999px; padding: 0 7px; line-height: 18px; color: var(--muted); font-weight: 600; }
.nav-sub a.active .count { background: var(--primary); color: #fff; }
.sb-foot { border-top: 1px solid var(--border); padding: 12px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: linear-gradient(135deg, #33bbff, #0088cc); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.uc-text { display: grid; line-height: 1.2; min-width: 0; flex: 1; }
.uc-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-text small { color: var(--muted); font-size: 11.5px; }
.sb-collapse { display: inline-flex; }

body.sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sb-collapsed .brand-text, body.sb-collapsed .nav-text, body.sb-collapsed .nav-sub, body.sb-collapsed .uc-text, body.sb-collapsed .nav-item .count { display: none; }
body.sb-collapsed .sb-top { flex-direction: column; padding: 14px 0 6px; gap: 10px; }
body.sb-collapsed .nav { padding: 4px 10px; }
body.sb-collapsed .nav-label { font-size: 0; padding: 10px 0 4px; border-bottom: 1px solid var(--border); margin: 6px 6px 8px; }
body.sb-collapsed .nav-item { justify-content: center; padding: 11px; }
body.sb-collapsed .nav-item.active::before { left: -10px; }
body.sb-collapsed .user-card { flex-direction: column; padding: 8px 4px; }
body.sb-collapsed .sb-collapse svg { transform: rotate(180deg); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-weight: 550; white-space: nowrap; overflow: hidden; }
.crumbs b { color: var(--text); font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.crumbs svg.i { width: 14px; height: 14px; opacity: 0.6; }
.grow { flex: 1; min-width: 0; }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1520px; width: 100%; margin: 0 auto; }
.scrim { position: fixed; inset: 0; background: rgba(8, 18, 30, 0.55); z-index: 45; display: none; backdrop-filter: blur(2px); }
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, #33bbff, #00aaff); z-index: 400; transition: width 0.25s ease, opacity 0.3s; opacity: 0; box-shadow: 0 0 8px var(--primary); }
.progress.on { opacity: 1; }

/* page header (sits in the content area, never in the top bar) */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; margin-bottom: 22px; flex-wrap: wrap; }
.ph-main { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 320px; }
.ph-icon { width: 46px; height: 46px; flex: none; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.ph-icon svg.i { width: 22px; height: 22px; }
.ph-text { min-width: 0; }
.ph-text h2 { font-size: 22px; line-height: 1.2; letter-spacing: -0.02em; }
.ph-text p { color: var(--muted); margin-top: 3px; max-width: 72ch; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ph-actions:empty { display: none; }

/* ============================================================ surfaces */
.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: 15px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; display: flex; align-items: center; gap: 9px; }
.card-head h3 svg.i { color: var(--primary); }
.card-body { padding: 20px; }
.stack { display: grid; gap: 18px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 18px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 18px 20px; display: flex; align-items: flex-start; gap: 14px; }
.kpi-ico { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi-ico svg.i { width: 20px; height: 20px; }
.kpi .label, .stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .value, .stat .value { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.kpi .delta, .stat .delta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.alert { display: flex; gap: 11px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13.5px; }
.alert svg.i { margin-top: 2px; }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn); }
.alert.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); color: var(--danger); }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); color: var(--info); }
.alert.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); color: var(--success); }
.alert a { font-weight: 650; }
.sep { height: 1px; background: var(--border); margin: 16px 0; }

/* ============================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs); transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.05s; position: relative; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-2)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .nav-item:focus-visible, .tab:focus-visible, .nav-sub a:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; text-shadow: 0 1px 0 rgba(0, 60, 90, 0.18); box-shadow: 0 1px 2px rgba(0, 110, 160, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:active { background: var(--primary-press); }
html.dark .btn.primary { color: #04131c; text-shadow: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); background: var(--danger); }
html.dark .btn.danger { color: #1a0505; }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); }
.btn.soft:hover { background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary)); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.loading { color: transparent !important; text-shadow: none; pointer-events: none; }
.btn.loading::after, .spinner { content: ""; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn.loading::after { position: absolute; inset: 0; margin: auto; color: var(--text); }
.btn.primary.loading::after { color: #fff; }
.spinner { display: inline-block; color: var(--primary); }
.spinner.lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ forms */
.field { display: grid; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.field .req { color: var(--danger); }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; transition: border-color 0.12s, box-shadow 0.12s; }
select.input { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7a90' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
textarea.input { resize: vertical; min-height: 88px; line-height: 1.45; }
textarea.input.code { font-family: var(--mono); font-size: 12.5px; min-height: 120px; white-space: pre; tab-size: 2; }
.input::placeholder { color: var(--muted); opacity: 0.75; }
.input:hover { border-color: color-mix(in srgb, var(--border-strong) 55%, var(--text-2)); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.input:disabled { background: var(--surface-3); cursor: not-allowed; }
.field.invalid .input { border-color: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent); }
.field .err { color: var(--danger); font-size: 12.5px; display: none; align-items: center; gap: 6px; font-weight: 550; }
.field.invalid .err { display: flex; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { margin: 4px 0 0; padding-top: 18px; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section > h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; }
.form-error { margin-bottom: 14px; }
.form-error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 550; }
.check input[type=checkbox]:not([data-type=switch]) { width: 17px; height: 17px; accent-color: var(--primary); }
.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: 0.16s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.16s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px var(--primary-ring); }
.switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }
.kv-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; }
.kv-actions { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 6px; flex-wrap: wrap; }

/* ============================================================ toolbar / tabs / chips / badges */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar .input { width: auto; min-width: 140px; flex: 0 1 auto; min-height: 38px; }
.search { position: relative; flex: 1 1 260px; min-width: 200px; max-width: 420px; }
.search .input { padding-left: 38px; width: 100%; }
.search svg { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 11px 15px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 8px; align-items: center; border-radius: 8px 8px 0 0; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--primary-ink); border-bottom-color: var(--primary); }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--muted); border-radius: 999px; padding: 0 8px; line-height: 19px; font-weight: 700; }
.tab.active .count { background: var(--primary); color: #fff; }
.svc-tabs { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 8px; box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2); }
.chip.btn-like { cursor: pointer; text-transform: capitalize; padding: 5px 14px; }
.chip.btn-like:hover { border-color: var(--primary); }
.chip.btn-like.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; text-transform: capitalize; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { color: var(--success); background: var(--success-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.info { color: var(--info); background: var(--info-soft); }
.badge.neutral { color: var(--muted); background: var(--surface-3); }
.badge.plain::before { display: none; }

/* ============================================================ tables (become cards on small screens) */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; }
.tbl .actions { text-align: right; white-space: nowrap; }
.cell-main { font-weight: 650; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.pager .btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ============================================================ groups */
.group { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-xs); transition: box-shadow 0.15s, border-color 0.15s; }
.group + .group { margin-top: 12px; }
.group:hover { border-color: var(--border-strong); }
.group.open { box-shadow: var(--shadow-sm); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.group-head { display: grid; grid-template-columns: auto auto minmax(0, 1fr) 96px 96px 96px 96px auto; grid-template-areas: "chk id title cost price margin prov act"; gap: 14px; align-items: center; padding: 14px 18px; cursor: pointer; }
.group-head:hover { background: var(--surface-2); }
.gh-chk { grid-area: chk; } .gh-id { grid-area: id; } .gh-title { grid-area: title; min-width: 0; } .gh-cost { grid-area: cost; } .gh-price { grid-area: price; }
.gh-margin { grid-area: margin; } .gh-prov { grid-area: prov; } .gh-act { grid-area: act; display: flex; align-items: center; gap: 6px; }
.gid { font-family: var(--mono); font-weight: 700; color: var(--primary-ink); background: var(--primary-soft); border-radius: 7px; padding: 3px 9px; font-size: 12.5px; }
.metric small { display: block; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.metric b { font-weight: 700; }
.group-body { border-top: 1px solid var(--border); background: var(--surface-2); padding: 16px 18px 18px; }
.chevron { transition: transform 0.15s; color: var(--muted); }
.group.open .chevron { transform: rotate(90deg); color: var(--primary); }
.body-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.bulkbar { position: sticky; bottom: 18px; margin: 16px auto 0; width: fit-content; max-width: 100%; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 9px 14px; background: var(--text); color: var(--bg); border-radius: 999px; box-shadow: var(--shadow-md); z-index: 20; font-weight: 600; }
.bulkbar .btn { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); box-shadow: none; }
.bulkbar .btn:hover { background: color-mix(in srgb, var(--bg) 15%, transparent); }

/* provider members inside a group */
.members-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.members-title h4 { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.members { display: grid; gap: 8px; }
.member { display: grid; grid-template-columns: 72px minmax(0, 1.6fr) 120px minmax(0, 1.2fr) auto auto; grid-template-areas: "ord main cost meta sw act"; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 11px 14px; }
.member.off { opacity: 0.62; }
.m-ord { grid-area: ord; display: flex; align-items: center; gap: 4px; }
.m-main { grid-area: main; min-width: 0; display: flex; align-items: center; gap: 11px; }
.m-cost { grid-area: cost; } .m-meta { grid-area: meta; } .m-sw { grid-area: sw; } .m-act { grid-area: act; display: flex; gap: 4px; justify-content: flex-end; }
.order-badge { width: 26px; height: 26px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-weight: 750; font-size: 12.5px; flex: none; }
.order-btns { display: grid; gap: 2px; }
.order-btns .btn { width: 22px; height: 15px; padding: 0; border-radius: 5px; }
.order-btns svg.i { width: 12px; height: 12px; }
.prov-avatar { width: 36px; height: 36px; flex: none; border-radius: 10px; background: linear-gradient(135deg, #33bbff, #0088cc); color: #fff; display: grid; place-items: center; font-weight: 750; font-size: 12px; text-transform: uppercase; }
.m-text { min-width: 0; }
.m-text .cell-main, .m-text .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-cost small, .m-meta small { display: block; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-bottom: 1px; }
.m-meta .chips { gap: 5px; }
.members-note { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 12.5px; margin-top: 12px; }

/* ============================================================ overlays */
.overlay { position: fixed; inset: 0; background: rgba(8, 18, 30, 0.58); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade 0.12s ease; backdrop-filter: blur(2px); }
.overlay.right { justify-content: flex-end; padding: 0; align-items: stretch; }
.dialog { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 580px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop 0.15s ease; }
.dialog.lg { max-width: 780px; }
.dialog.xl { max-width: 1000px; }
.overlay.right .dialog { border-radius: 0; max-width: 720px; max-height: none; height: 100%; animation: slide 0.2s ease; }
.overlay.right .dialog.xl { max-width: 900px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.dialog-head h3 { font-size: 18px; }
.dialog-head p { color: var(--muted); margin-top: 2px; }
.dialog-body { padding: 18px 22px 22px; overflow-y: auto; flex: 1; }
.dialog-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.overlay.right .dialog-foot { border-radius: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
@keyframes slide { from { transform: translateX(36px); opacity: 0; } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 500; max-width: min(430px, calc(100vw - 40px)); }
.toast { display: flex; gap: 11px; align-items: flex-start; padding: 12px 16px; border-radius: 11px; background: #0f1b2a; color: #fff; box-shadow: var(--shadow-md); animation: pop 0.16s ease; font-weight: 550; border-left: 4px solid var(--primary); }
.toast.success { border-left-color: #22c55e; } .toast.success svg { color: #4ade80; }
.toast.error { border-left-color: #ef4444; } .toast.error svg { color: #f87171; }

/* ============================================================ states & misc */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 7px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-line { height: 14px; margin: 12px 0; }
.center-state { display: grid; place-items: center; gap: 10px; padding: 52px 20px; text-align: center; color: var(--muted); }
.center-state h3 { color: var(--text); font-size: 16px; }
.center-state p { max-width: 46ch; }
.center-state .ico { width: 52px; height: 52px; border-radius: 15px; background: var(--primary-soft); display: grid; place-items: center; color: var(--primary); }
.busy { opacity: 0.55; pointer-events: none; transition: opacity 0.15s; }
.json { background: #0c1520; color: #d6e4f0; border-radius: var(--radius-sm); padding: 14px 16px; overflow: auto; max-height: 420px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; margin: 0; }
.json .k { color: #5cc8ff; } .json .s { color: #a5e8a0; } .json .n { color: #ffb86b; } .json .b { color: #d8a5ff; } .json .z { color: #6c7f94; }
.copyable { cursor: pointer; border-bottom: 1px dashed var(--border-strong); }
.copyable:hover { color: var(--primary-ink); }
.callout-code { position: relative; }
.callout-code .btn { position: absolute; right: 8px; top: 8px; }
.dl { display: grid; grid-template-columns: minmax(130px, 210px) 1fr; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.dl > div { padding: 9px 14px; border-bottom: 1px solid var(--border); word-break: break-word; }
.dl > div:nth-last-child(-n + 2) { border-bottom: 0; }
.dl .k { background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.bar { flex: 1; min-width: 6px; display: flex; flex-direction: column-reverse; border-radius: 5px 5px 0 0; overflow: hidden; background: var(--surface-3); position: relative; }
.bar i { display: block; width: 100%; }
.bar .s { background: #12b76a; } .bar .f { background: #f04438; } .bar .u { background: #f79009; } .bar .o { background: var(--primary); }
.bar-labels { display: flex; gap: 6px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.bar-labels span { flex: 1; min-width: 6px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.timeline { display: grid; gap: 14px; }
.tl-item { display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); font-size: 11.5px; font-weight: 750; }
.tl-item.ok .tl-dot { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tl-item.bad .tl-dot { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tl-item.warn .tl-dot { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
details.fold { border: 1px solid var(--border); border-radius: var(--radius-sm); }
details.fold > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold[open] > summary { border-bottom: 1px solid var(--border); }
details.fold > .fold-body { padding: 14px; }

/* ============================================================ sign-in */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 520px); background: var(--surface); }
.auth-hero { background: radial-gradient(900px 520px at 15% 0%, #33bbff 0%, #00aaff 28%, #006fa6 62%, #04263a 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; width: 520px; height: 520px; right: -180px; bottom: -180px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }
.auth-hero .brand { color: #fff; }
.auth-hero .brand-mark { background: rgba(255, 255, 255, 0.2); box-shadow: none; backdrop-filter: blur(4px); }
.auth-hero .brand-text small { color: rgba(255, 255, 255, 0.8); }
.auth-hero h1 { font-size: 36px; line-height: 1.15; max-width: 520px; letter-spacing: -0.025em; }
.auth-hero p { color: rgba(255, 255, 255, 0.88); max-width: 460px; margin-top: 14px; font-size: 15.5px; }
.auth-hero ul { list-style: none; padding: 0; margin: 30px 0 0; display: grid; gap: 14px; }
.auth-hero li { display: flex; gap: 12px; align-items: center; font-weight: 550; }
.auth-hero li svg.i { background: rgba(255, 255, 255, 0.18); padding: 7px; width: 32px; height: 32px; border-radius: 10px; }
.auth-hero small { color: rgba(255, 255, 255, 0.75); position: relative; z-index: 1; }
.auth-panel { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-card { width: 100%; max-width: 390px; }
.auth-card .brand { display: none; margin-bottom: 26px; }
.auth-card h2 { font-size: 26px; margin-bottom: 4px; letter-spacing: -0.02em; }
.auth-card .stack { margin-top: 24px; }

/* ============================================================ responsive */
@media (max-width: 1280px) {
  .group-head { grid-template-columns: auto auto minmax(0, 1fr) 96px 96px auto; grid-template-areas: "chk id title margin prov act"; }
  .gh-cost, .gh-price { display: none; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .member { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "ord main act" "cost meta sw"; row-gap: 10px; }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); width: min(300px, 86vw); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  body.sb-collapsed .sidebar { width: min(300px, 86vw); }
  body.sb-collapsed .brand-text, body.sb-collapsed .nav-text, body.sb-collapsed .uc-text, body.sb-collapsed .nav-item .count { display: revert; }
  body.sb-collapsed .nav-sub { display: grid; }
  body.sb-collapsed .nav-item { justify-content: flex-start; padding: 9px 12px; }
  body.sb-collapsed .nav-label { font-size: 10.5px; padding: 18px 12px 7px; border: 0; margin: 0; }
  body.sb-collapsed .sb-top { flex-direction: row; padding: 16px 14px 12px 16px; }
  body.sb-collapsed .user-card { flex-direction: row; }
  .sb-collapse { display: none; }
  .sb-close { display: inline-flex; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .page-head { margin-bottom: 16px; }
  .ph-text h2 { font-size: 19px; }
  .ph-icon { width: 40px; height: 40px; border-radius: 11px; }
  .ph-actions { width: 100%; }
  .ph-actions .btn, .ph-actions .input { flex: 1 1 auto; }
  .grid.c2, .grid.c3, .grid.c4, .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .dl .k { border-bottom: 0; padding-bottom: 2px; }
  .dl > div:nth-last-child(2) { border-bottom: 1px solid var(--border); }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-card .brand { display: flex; }
  .overlay { padding: 0; align-items: flex-end; }
  .overlay:not(.right) .dialog { border-radius: 18px 18px 0 0; max-height: 92vh; max-width: 100%; }
  .overlay.right .dialog { max-width: 100%; }
  .dialog-head, .dialog-body, .dialog-foot { padding-left: 16px; padding-right: 16px; }
  .dialog-foot .btn { flex: 1 1 auto; }
  .toolbar { padding: 12px 14px; }
  .toolbar .input, .toolbar select.input { flex: 1 1 140px; min-width: 0; }
  .search { max-width: none; flex-basis: 100%; }
  .card-head, .card-body, .pager { padding-left: 14px; padding-right: 14px; }
  .kv-row { grid-template-columns: 1fr auto; }
  .kv-row [data-v] { grid-column: 1 / 2; grid-row: 2; }
  .kv-row [data-kv-del] { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

  /* tables turn into stacked cards, labels come from data-label */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .tbl tbody tr:last-child { border-bottom: 0; }
  .tbl td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right !important; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; text-align: left; flex: none; }
  .tbl td:empty { display: none; }
  .tbl td.actions { justify-content: flex-end; padding-top: 10px; }
  .tbl td.actions::before { display: none; }
  .tbl td > .chips { justify-content: flex-end; }

  .group-head { grid-template-columns: auto 1fr auto; grid-template-areas: "chk id act" "title title title" "margin prov prov"; gap: 10px 12px; padding: 14px; }
  .gh-prov { text-align: right; }
  .group-body { padding: 14px; }
  .member { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "ord main" "cost cost" "meta meta" "sw act"; gap: 10px 12px; }
  .m-act { justify-content: flex-end; }
  .m-cost, .m-meta { padding-left: 2px; }
  .bulkbar { border-radius: 16px; width: calc(100% - 8px); justify-content: center; }
}
@media (max-width: 520px) {
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 22px; }
}
@media print { .sidebar, .topbar, .btn { display: none !important; } }
