:root, [data-theme="light"] {
  color-scheme: light;
  --accent: #0F766E;
  --accent-hover: #115E59;
  --on-accent: #FFFFFF;
  --nav: #12312E;
  --nav-hover: #1B4743;
  --nav-text: #D5E3E0;
  --nav-muted: #9DB5B0;
  --nav-accent: #5EEAD4;
  --nav-strong: #FFFFFF;
  --page: #F3F5F4;
  --card: #FFFFFF;
  --soft: #EEF5F3;
  --line: #D8DEDC;
  --text: #1C2826;
  --muted: #5F6F6C;
  --good: #0F766E;
  --warn: #B45309;
  --chart-a: #0F766E;
  --chart-b: #C2410C;
  --chart-grid: #E3E8E6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --series-other: #9AA5A2;
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
  color-scheme: dark;
  --accent: #14B8A6;
  --accent-hover: #2DD4BF;
  --on-accent: #062421;
  --nav: #0C1F1D;
  --nav-hover: #16332F;
  --nav-text: #D5E3E0;
  --nav-muted: #9DB5B0;
  --nav-accent: #5EEAD4;
  --nav-strong: #FFFFFF;
  --page: #141918;
  --card: #1D2422;
  --soft: #22302D;
  --line: #34403D;
  --text: #E6ECEA;
  --muted: #9FB0AC;
  --good: #2DD4BF;
  --warn: #FBBF24;
  --chart-a: #2DD4BF;
  --chart-b: #FB923C;
  --chart-grid: #2C3735;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #7C8986;
}
}
[data-theme="dark"] {
  color-scheme: dark;
  --accent: #14B8A6;
  --accent-hover: #2DD4BF;
  --on-accent: #062421;
  --nav: #0C1F1D;
  --nav-hover: #16332F;
  --nav-text: #D5E3E0;
  --nav-muted: #9DB5B0;
  --nav-accent: #5EEAD4;
  --nav-strong: #FFFFFF;
  --page: #141918;
  --card: #1D2422;
  --soft: #22302D;
  --line: #34403D;
  --text: #E6ECEA;
  --muted: #9FB0AC;
  --good: #2DD4BF;
  --warn: #FBBF24;
  --chart-a: #2DD4BF;
  --chart-b: #FB923C;
  --chart-grid: #2C3735;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #7C8986;
}
[data-theme="lightmodern"] {
  color-scheme: light;
  --accent: #0F766E;
  --accent-hover: #115E59;
  --on-accent: #FFFFFF;
  --nav: #FFFFFF;
  --nav-hover: #E9F4F2;
  --nav-text: #3A4653;
  --nav-muted: #7A8594;
  --nav-accent: #0F766E;
  --nav-strong: #0F1720;
  --page: #F3F5F8;
  --card: #FFFFFF;
  --soft: #F0F4F6;
  --line: #E2E7ED;
  --text: #16202A;
  --muted: #5D6977;
  --good: #0F766E;
  --warn: #B45309;
  --chart-a: #0F766E;
  --chart-b: #C2410C;
  --chart-grid: #E8ECF0;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --series-other: #9AA5A2;
}
[data-theme="darkmodern"] {
  color-scheme: dark;
  --accent: #2DD4BF;
  --accent-hover: #5EEAD4;
  --on-accent: #04201D;
  --nav: #11161E;
  --nav-hover: #1B2230;
  --nav-text: #C9D2DE;
  --nav-muted: #7F8BA0;
  --nav-accent: #5EEAD4;
  --nav-strong: #FFFFFF;
  --page: #0D1117;
  --card: #151B24;
  --soft: #1A2230;
  --line: #252D3A;
  --text: #E8EDF4;
  --muted: #8E9AAE;
  --good: #34D399;
  --warn: #FBBF24;
  --chart-a: #2DD4BF;
  --chart-b: #FB923C;
  --chart-grid: #222A36;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #7C8794;
}
[data-theme="oled"] {
  color-scheme: dark;
  --accent: #2DD4BF;
  --accent-hover: #5EEAD4;
  --on-accent: #001A17;
  --nav: #000000;
  --nav-hover: #141416;
  --nav-text: #C7CAD1;
  --nav-muted: #80848E;
  --nav-accent: #5EEAD4;
  --nav-strong: #FFFFFF;
  --page: #000000;
  --card: #0B0B0C;
  --soft: #141416;
  --line: #1E1F22;
  --text: #F2F3F5;
  --muted: #949BA4;
  --good: #34D399;
  --warn: #FBBF24;
  --chart-a: #2DD4BF;
  --chart-b: #FB923C;
  --chart-grid: #1A1B1E;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #7C7F86;
  --lication-background: #000000;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif; font-size: 14px;
       background: var(--page); color: var(--text); }
a { color: var(--accent); }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 14px; }
h2 { font-size: 14px; font-weight: 600; color: var(--accent); margin: 14px 0 8px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.good { color: var(--good); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.icon { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; flex: none; }
.logo { flex: none; }

/* ------------------------------------------------------------------ frame */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; padding: 18px 0 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 18px 20px; text-decoration: none; }
.brand span { display: flex; flex-direction: column; font-size: 22px; font-weight: 600; line-height: 1.1; }
.brand b { color: var(--nav-strong); font-weight: 600; display: inline; }
.brand i { color: var(--nav-accent); font-style: normal; }
.brand small { color: var(--nav-muted); font-size: 11px; font-weight: 400; margin-top: 2px; }
.nav-item { display: flex; gap: 12px; align-items: center; padding: 11px 18px; color: var(--nav-text); text-decoration: none; border-left: 3px solid transparent; font-size: 14px; }
.nav-item:hover { background: var(--nav-hover); }
.nav-item.active { background: var(--nav-hover); border-left-color: var(--nav-accent); color: var(--nav-strong); font-weight: 600; }
.nav-item.active .icon { color: var(--nav-accent); }
.nav-foot { margin-top: auto; padding: 14px 18px 0; display: flex; flex-direction: column; gap: 6px; }
.nav-foot .user { color: var(--nav-strong); font-weight: 600; font-size: 12px; }
.nav-foot .role { color: var(--nav-muted); font-size: 11px; }
.nav-btn { background: transparent !important; color: var(--nav-text) !important; border-color: var(--nav-hover) !important; justify-content: flex-start; }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; gap: 8px; align-items: center; justify-content: flex-end; background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 24px; position: sticky; top: 0; z-index: 5; }
.topbar label { color: var(--muted); margin-left: 16px; }
.topbar select { width: 240px; }
.content { padding: 20px 24px 28px; }
[data-theme="lightmodern"] .nav, [data-theme="darkmodern"] .nav, [data-theme="oled"] .nav { margin: 12px 0 12px 12px; border-radius: 18px; border: 1px solid var(--line); height: calc(100vh - 24px); top: 12px; }
[data-theme="lightmodern"] .nav-item, [data-theme="darkmodern"] .nav-item, [data-theme="oled"] .nav-item { margin: 2px 10px; border-radius: 12px; padding: 9px 12px; }
[data-theme="lightmodern"] .topbar, [data-theme="darkmodern"] .topbar, [data-theme="oled"] .topbar { margin: 12px 24px 0 20px; border-radius: 14px; border: 1px solid var(--line); }
[data-theme="lightmodern"] .card, [data-theme="darkmodern"] .card, [data-theme="oled"] .card { border-radius: 16px; }

/* ------------------------------------------------------------------ controls */
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: 32px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--accent); }
input[readonly] { background: var(--soft); }
textarea { min-height: 70px; resize: vertical; }
.btn { display: inline-flex; gap: 8px; align-items: center; justify-content: center; font: inherit; padding: 6px 14px; min-height: 32px; border-radius: 6px;
       border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--warn); }
.btn.small { padding: 2px 8px; min-height: 26px; font-size: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; min-width: 0; }
.field > span { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.row { display: flex; gap: 12px; align-items: flex-start; }
.row > * { flex: 1; min-width: 0; }
.status { margin: 8px 0; }

/* ------------------------------------------------------------------ cards, tiles, tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.tile .l { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 19px; font-weight: 600; margin-top: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: inherit; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.table-wrap { overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 6px; max-height: calc(100vh - 260px); }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th { position: sticky; top: 0; background: var(--soft); text-align: left; font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.data td.wrap { white-space: normal; }
table.data tr.sel td { background: color-mix(in srgb, var(--accent) 16%, transparent); }
table.data tr:hover td { background: var(--soft); }
table.data tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
table.data td input, table.data td select { min-height: 28px; padding: 3px 6px; }
table.data .r, table.data th.r { text-align: right; }
.list { border: 1px solid var(--line); border-radius: 6px; background: var(--card); max-height: 60vh; overflow: auto; }
.list div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.list div.on { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 600; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* ------------------------------------------------------------------ dialogs */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 4vh 16px; overflow: auto; }
.dialog { background: var(--page); color: var(--text); border-radius: 10px; width: min(var(--w, 720px), 100%); box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.dialog header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 600; }
.dialog .body { padding: 16px 20px; }
.dialog footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px 16px; }
.dialog footer .grow { flex: 1; }
.center-card { max-width: 420px; margin: 10vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.center-card h1 { margin-top: 14px; }

/* ------------------------------------------------------------------ charts and map */
.chart { width: 100%; height: 260px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .legend text { fill: var(--text); font-size: 12px; }
.map { height: 260px; border: 1px solid var(--line); border-radius: 6px; margin-top: 8px; }
.results div { padding: 5px 8px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; }
.results div:hover { background: var(--soft); }
.chart-tip { position: fixed; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; white-space: pre; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.2); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 8px; margin: 0 !important; border-radius: 0 !important; }
  .nav-foot { display: none; }
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* tenant subdomains */
.host-tenant { margin: 10px 0 0; font-weight: 600; color: var(--accent); }
.fixed-tenant { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.host-input { display: flex; align-items: center; gap: 4px; }
.host-input input { width: 14em; }
