/* Theme-aware administration surfaces. All component colours below resolve
   through semantic tokens so master, tenant and authentication UIs switch as
   one system without inheriting public-page decoration. */
:root,
html[data-ui-theme="original"][data-theme="light"] {
  --admin-browser-color: #f4f7fb;
  --admin-page: #f4f7fb;
  --admin-page-accent: #e9eff8;
  --admin-surface: #ffffff;
  --admin-surface-soft: #f7f9fc;
  --admin-surface-raised: #ffffff;
  --admin-text: #172033;
  --admin-text-soft: #5e6b82;
  --admin-text-faint: #7d899c;
  --admin-border: #dfe6f0;
  --admin-border-strong: #c9d4e4;
  --admin-accent: #3268f3;
  --admin-accent-strong: #214fca;
  --admin-accent-soft: #edf3ff;
  --admin-accent-rgb: 50, 104, 243;
  --admin-on-accent: #ffffff;
  --admin-sidebar: #111b2c;
  --admin-sidebar-deep: #0c1524;
  --admin-sidebar-text: #aab8cd;
  --admin-sidebar-active: #ffffff;
  --admin-sidebar-wash: rgba(79, 126, 242, .18);
  --admin-success: #087556;
  --admin-success-soft: #e9f8f3;
  --admin-warning: #895a08;
  --admin-warning-soft: #fff5df;
  --admin-danger: #b92b46;
  --admin-danger-soft: #ffedf1;
  --admin-info: #285ccf;
  --admin-info-soft: #edf3ff;
  --admin-overlay: rgba(8, 18, 36, .54);
  --admin-shadow: 0 7px 24px rgba(24, 48, 88, .07);
  --admin-shadow-raised: 0 18px 48px rgba(17, 35, 68, .14);
  --admin-hero: linear-gradient(120deg, #152947, #244b86);
  --admin-hero-text: #f7faff;
  --admin-hero-muted: #b9c8df;
  --admin-radius-theme: 18px;
}

html[data-theme="dark"],
html[data-ui-theme="original"][data-theme="dark"] {
  --admin-browser-color: #0f1725;
  --admin-page: #0f1725;
  --admin-page-accent: #151f31;
  --admin-surface: #182335;
  --admin-surface-soft: #1d2a3f;
  --admin-surface-raised: #202d43;
  --admin-text: #f1f5fb;
  --admin-text-soft: #aebbd0;
  --admin-text-faint: #8392aa;
  --admin-border: #2b3a52;
  --admin-border-strong: #3a4d69;
  --admin-accent: #7aa2ff;
  --admin-accent-strong: #9ab8ff;
  --admin-accent-soft: rgba(90, 136, 244, .15);
  --admin-accent-rgb: 122, 162, 255;
  --admin-on-accent: #101827;
  --admin-sidebar: #0b1220;
  --admin-sidebar-deep: #080e19;
  --admin-sidebar-text: #98a8c0;
  --admin-sidebar-active: #ffffff;
  --admin-sidebar-wash: rgba(104, 145, 242, .2);
  --admin-success: #65d4ad;
  --admin-success-soft: rgba(46, 177, 132, .14);
  --admin-warning: #efc06e;
  --admin-warning-soft: rgba(221, 158, 47, .14);
  --admin-danger: #ff8095;
  --admin-danger-soft: rgba(224, 70, 97, .15);
  --admin-info: #8bb0ff;
  --admin-info-soft: rgba(78, 126, 235, .15);
  --admin-overlay: rgba(2, 7, 16, .72);
  --admin-shadow: 0 9px 26px rgba(0, 5, 15, .22);
  --admin-shadow-raised: 0 22px 60px rgba(0, 4, 14, .45);
  --admin-hero: linear-gradient(120deg, #17263b, #203c67);
  --admin-hero-text: #f7faff;
  --admin-hero-muted: #b6c5dc;
}

html[data-ui-theme="cosmic"] {
  --admin-browser-color: #f5f5ff;
  --admin-accent: #665adf;
  --admin-accent-strong: #5147c5;
  --admin-accent-soft: #eeedff;
  --admin-accent-rgb: 102, 90, 223;
  --admin-page: #f5f5ff;
  --admin-page-accent: #ececff;
  --admin-sidebar: #161733;
  --admin-sidebar-deep: #101126;
  --admin-sidebar-wash: rgba(111, 96, 232, .22);
  --admin-hero: linear-gradient(120deg, #232657, #3c438e);
}
html[data-ui-theme="cosmic"][data-theme="dark"] {
  --admin-browser-color: #101126;
  --admin-page: #101126;
  --admin-page-accent: #171936;
  --admin-surface: #1b1e40;
  --admin-surface-soft: #22264c;
  --admin-surface-raised: #272b54;
  --admin-border: #393e6b;
  --admin-border-strong: #4b5084;
  --admin-accent: #9b91ff;
  --admin-accent-strong: #b8b1ff;
  --admin-accent-soft: rgba(126, 113, 255, .17);
  --admin-accent-rgb: 155, 145, 255;
  --admin-text-soft: #bbbce0;
  --admin-info: #aaa4ff;
  --admin-info-soft: rgba(111, 98, 235, .17);
}

html[data-ui-theme="aurora"] {
  --admin-browser-color: #f1f9f7;
  --admin-accent: #169b89;
  --admin-accent-strong: #0c7d70;
  --admin-accent-soft: #e7f8f4;
  --admin-accent-rgb: 22, 155, 137;
  --admin-on-accent: #101827;
  --admin-page: #f1f9f7;
  --admin-page-accent: #e4f4f0;
  --admin-sidebar: #102c2d;
  --admin-sidebar-deep: #0b2022;
  --admin-sidebar-wash: rgba(42, 190, 165, .2);
  --admin-hero: linear-gradient(120deg, #144e4b, #346780);
  --admin-radius-theme: 22px;
}
html[data-ui-theme="aurora"][data-theme="dark"] {
  --admin-browser-color: #0b1e22;
  --admin-page: #0b1e22;
  --admin-page-accent: #102a2e;
  --admin-surface: #143236;
  --admin-surface-soft: #193b3f;
  --admin-surface-raised: #1d4447;
  --admin-border: #2e5354;
  --admin-border-strong: #3c6867;
  --admin-accent: #64d8c2;
  --admin-accent-strong: #8be5d4;
  --admin-accent-soft: rgba(50, 190, 166, .16);
  --admin-accent-rgb: 100, 216, 194;
  --admin-text-soft: #abcac5;
}

html[data-ui-theme="particles"] {
  --admin-browser-color: #f0f7fa;
  --admin-accent: #197db7;
  --admin-accent-strong: #0c659d;
  --admin-accent-soft: #e7f5fb;
  --admin-accent-rgb: 25, 125, 183;
  --admin-page: #f0f7fa;
  --admin-page-accent: #e2f0f5;
  --admin-sidebar: #102633;
  --admin-sidebar-deep: #0a1b25;
  --admin-sidebar-wash: rgba(40, 161, 211, .2);
  --admin-hero: linear-gradient(120deg, #153b52, #245f78);
  --admin-radius-theme: 12px;
}
html[data-ui-theme="particles"][data-theme="dark"] {
  --admin-browser-color: #081821;
  --admin-page: #081821;
  --admin-page-accent: #0d222d;
  --admin-surface: #102b38;
  --admin-surface-soft: #143542;
  --admin-surface-raised: #183d4b;
  --admin-border: #28505f;
  --admin-border-strong: #356577;
  --admin-accent: #58c7e9;
  --admin-accent-strong: #7bd7f1;
  --admin-accent-soft: rgba(45, 171, 215, .16);
  --admin-accent-rgb: 88, 199, 233;
  --admin-text-soft: #a7c5cf;
}

html[data-ui-theme="esports"] {
  --admin-browser-color: #faf4f7;
  --admin-accent: #d43866;
  --admin-accent-strong: #b72752;
  --admin-accent-soft: #fff0f4;
  --admin-accent-rgb: 212, 56, 102;
  --admin-page: #faf4f7;
  --admin-page-accent: #f4e8ee;
  --admin-sidebar: #291725;
  --admin-sidebar-deep: #1d111b;
  --admin-sidebar-wash: rgba(220, 61, 108, .2);
  --admin-hero: linear-gradient(120deg, #48243b, #63304a);
  --admin-radius-theme: 11px;
}
html[data-ui-theme="esports"][data-theme="dark"] {
  --admin-browser-color: #190f18;
  --admin-page: #190f18;
  --admin-page-accent: #241420;
  --admin-surface: #2b1927;
  --admin-surface-soft: #35202f;
  --admin-surface-raised: #3d2436;
  --admin-border: #573249;
  --admin-border-strong: #704158;
  --admin-accent: #f2769b;
  --admin-accent-strong: #ff9ab7;
  --admin-accent-soft: rgba(222, 66, 111, .16);
  --admin-accent-rgb: 242, 118, 155;
  --admin-text-soft: #d0b1c0;
}

html[data-ui-theme="arcade"] {
  --admin-browser-color: #f9f4fb;
  --admin-accent: #7650c8;
  --admin-accent-strong: #5d3baa;
  --admin-accent-soft: #f3edff;
  --admin-accent-rgb: 118, 80, 200;
  --admin-page: #f9f4fb;
  --admin-page-accent: #f0e8f5;
  --admin-sidebar: #281a35;
  --admin-sidebar-deep: #1d1328;
  --admin-sidebar-wash: rgba(133, 83, 210, .2);
  --admin-hero: linear-gradient(120deg, #422758, #68406d);
  --admin-radius-theme: 16px;
}
html[data-ui-theme="arcade"][data-theme="dark"] {
  --admin-browser-color: #1a1024;
  --admin-page: #1a1024;
  --admin-page-accent: #24162f;
  --admin-surface: #2d1c3a;
  --admin-surface-soft: #382448;
  --admin-surface-raised: #412951;
  --admin-border: #57396a;
  --admin-border-strong: #6e4984;
  --admin-accent: #b78af1;
  --admin-accent-strong: #cba8f7;
  --admin-accent-soft: rgba(147, 94, 220, .17);
  --admin-accent-rgb: 183, 138, 241;
  --admin-text-soft: #cdb8d6;
}

html[data-ui-theme="gold"] {
  --admin-browser-color: #f8f6f1;
  --admin-accent: #9a7138;
  --admin-accent-strong: #7f5928;
  --admin-accent-soft: #f8f1e4;
  --admin-accent-rgb: 154, 113, 56;
  --admin-on-accent: #000000;
  --admin-page: #f8f6f1;
  --admin-page-accent: #eee9df;
  --admin-sidebar: #2b251b;
  --admin-sidebar-deep: #1e1a13;
  --admin-sidebar-wash: rgba(186, 144, 76, .18);
  --admin-hero: linear-gradient(120deg, #413725, #685335);
  --admin-radius-theme: 14px;
}
html[data-ui-theme="gold"][data-theme="dark"] {
  --admin-browser-color: #18150f;
  --admin-page: #18150f;
  --admin-page-accent: #211d15;
  --admin-surface: #2a251c;
  --admin-surface-soft: #332d22;
  --admin-surface-raised: #3a3326;
  --admin-border: #504735;
  --admin-border-strong: #665b43;
  --admin-accent: #d7b777;
  --admin-accent-strong: #e7ca90;
  --admin-accent-soft: rgba(192, 150, 80, .16);
  --admin-accent-rgb: 215, 183, 119;
  --admin-text-soft: #c9bdab;
}

:root {
  --bg: var(--admin-page);
  --panel: var(--admin-surface);
  --panel-soft: var(--admin-surface-soft);
  --surface: var(--admin-surface);
  --ink: var(--admin-text);
  --muted: var(--admin-text-soft);
  --line: var(--admin-border);
  --blue: var(--admin-accent);
  --blue-dark: var(--admin-accent-strong);
  --blue-soft: var(--admin-accent-soft);
  --green: var(--admin-success);
  --green-soft: var(--admin-success-soft);
  --amber: var(--admin-warning);
  --amber-soft: var(--admin-warning-soft);
  --red: var(--admin-danger);
  --red-soft: var(--admin-danger-soft);
  --nav: var(--admin-sidebar);
  --nav-soft: var(--admin-sidebar-deep);
  --shadow: var(--admin-shadow);
  --radius: var(--admin-radius-theme);
}

html,
body { background: var(--admin-page); color: var(--admin-text); }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 92% 0, rgba(var(--admin-accent-rgb), .08), transparent 32%), linear-gradient(145deg, var(--admin-page), var(--admin-page-accent));
  pointer-events: none;
}
.sidebar { color: var(--admin-sidebar-active); background: linear-gradient(180deg, var(--admin-sidebar), var(--admin-sidebar-deep)); }
.brand { border-color: color-mix(in srgb, var(--admin-sidebar-text) 14%, transparent); }
.brand-mark,
.avatar,
.sidebar .side-group[open] .side-group-icon { color: var(--admin-on-accent); background: var(--admin-accent); box-shadow: none; }
.auth-brand-mark { color: var(--admin-on-accent); background: var(--admin-accent); box-shadow: 0 15px 32px rgba(var(--admin-accent-rgb), .24); }
.brand-copy span,
.side-caption,
.profile-copy span,
.side-logout,
.sidebar .side-group-copy small,
.sidebar .side-group-count { color: var(--admin-sidebar-text); }
.nav-item,
.sidebar .side-group-summary { color: var(--admin-sidebar-text); }
.nav-item:hover,
.nav-item.is-active,
.sidebar .side-group-summary:hover,
.sidebar .side-group[open] > .side-group-summary { color: var(--admin-sidebar-active); }
.nav-item:hover,
.sidebar .side-group-summary:hover { background: color-mix(in srgb, var(--admin-sidebar-wash) 48%, transparent); }
.nav-item.is-active,
.sidebar .side-group .nav-item.is-active { background: linear-gradient(90deg, var(--admin-sidebar-wash), transparent); box-shadow: inset 3px 0 var(--admin-accent); }
.sidebar .nav-item.is-active .nav-icon { color: var(--admin-on-accent); background: var(--admin-accent); }
.nav-icon,
.sidebar .side-group-icon,
.side-profile,
.side-logout,
.sidebar .side-group[open] { border-color: color-mix(in srgb, var(--admin-sidebar-text) 14%, transparent); background-color: color-mix(in srgb, var(--admin-sidebar-text) 7%, transparent); }
.topbar,
.modal-head,
.engagement-modal-head { border-color: var(--admin-border); background: color-mix(in srgb, var(--admin-surface) 91%, transparent); }
.panel,
.stat-card,
.site-card,
.domain-card,
.collector-card,
.settings-card,
.tenant-hero,
.auth-card,
.engagement-modal,
.theme-live-preview,
.telegram-inventory-tools,
.site-notification-card { border-color: var(--admin-border); background: var(--admin-surface); box-shadow: var(--admin-shadow); }
.panel-head,
.modal-foot,
.engagement-modal-foot,
.data-table th,
.data-table td,
.table-productivity-bar,
.long-form > .form-actions { border-color: var(--admin-border); }
.panel-head,
.modal-foot,
.engagement-modal-foot,
.table-productivity-bar,
.long-form > .form-actions { background: var(--admin-surface); }
.panel-body,
.modal-body,
.engagement-modal-body { background: var(--admin-surface); }
.button,
.inline-form select,
.field input,
.field select,
.field textarea,
.search-box,
.table-search,
.table-pager select,
.auth-form input,
.collector-rule-fields input,
.collector-rule-fields select { border-color: var(--admin-border); color: var(--admin-text); background: var(--admin-surface-raised); }
.button:hover { border-color: var(--admin-border-strong); box-shadow: 0 7px 18px rgba(var(--admin-accent-rgb), .1); }
.button.primary,
.auth-submit { border-color: var(--admin-accent); color: var(--admin-on-accent); background: var(--admin-accent); box-shadow: 0 8px 20px rgba(var(--admin-accent-rgb), .2); }
.button.soft { border-color: color-mix(in srgb, var(--admin-accent) 28%, var(--admin-border)); color: var(--admin-accent); background: var(--admin-accent-soft); }
.button.danger { border-color: color-mix(in srgb, var(--admin-danger) 25%, var(--admin-border)); color: var(--admin-danger); background: var(--admin-danger-soft); }
:where(.field input, .field select, .field textarea, .auth-form input)::placeholder { color: var(--admin-text-faint); }
:where(.field input, .field select, .field textarea, .search-box, .table-search, .auth-form input):focus-within { border-color: var(--admin-accent); box-shadow: 0 0 0 3px rgba(var(--admin-accent-rgb), .12); }
.hero-strip { color: var(--admin-hero-text); background: var(--admin-hero); box-shadow: var(--admin-shadow-raised); }
.hero-copy p:last-child,
.health-top span,
.health-meta { color: var(--admin-hero-muted); }
.quick-action,
.rank-row,
.operations-history,
.collector-settings-disclosure,
.engagement-summary > div,
.engagement-card-preview,
.engagement-risk-body,
.engagement-risk-visits li,
.site-notification-recipient,
.site-notification-empty,
.totp-action-grid form { border-color: var(--admin-border); color: var(--admin-text); background: var(--admin-surface-soft); }
.quick-action:hover { border-color: var(--admin-accent); background: var(--admin-accent-soft); }
.quick-action-icon,
.rank-row b,
.collector-settings-disclosure > summary b { color: var(--admin-accent); background: var(--admin-accent-soft); }
.data-table thead th { color: var(--admin-text-soft); background: var(--admin-surface-soft); }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--admin-accent) 5%, var(--admin-surface)); }
.data-table.admin-table-enhanced tr,
.site-summary-card,
.asset-thumb { border-color: var(--admin-border); background: var(--admin-surface-raised); box-shadow: none; }
.source-name,
.rank-row span,
.site-copy > strong,
.collector-settings-disclosure > summary strong,
.site-notification-recipient > div > strong,
.site-notification-empty > div > strong { color: var(--admin-text); }
.site-copy > span,
.stat-foot,
.chart-labels,
.engagement-summary span,
.engagement-table small,
.site-notification-recipient div > span,
.site-notification-empty div > span { color: var(--admin-text-soft); }
.mini-track,
.health-bar { background: color-mix(in srgb, var(--admin-border) 74%, transparent); }
.modal-backdrop,
.engagement-modal-backdrop { background: var(--admin-overlay); }
.modal,
.engagement-modal { color: var(--admin-text); background: var(--admin-surface); box-shadow: var(--admin-shadow-raised); }
.modal-close,
.engagement-modal-head button { border-color: var(--admin-border); background-color: var(--admin-surface-raised); box-shadow: 0 7px 18px rgba(5, 10, 20, .14); }
.toast { border-color: var(--admin-border); color: var(--admin-text); background: var(--admin-surface-raised); box-shadow: var(--admin-shadow-raised); }
.status.healthy,
.status.running,
.status.ready,
.status.active { color: var(--admin-success); background: var(--admin-success-soft); }
.status.warning,
.status.maintenance,
.status.syncing { color: var(--admin-warning); background: var(--admin-warning-soft); }
.status.offline,
.status.disabled,
.status.danger { color: var(--admin-danger); background: var(--admin-danger-soft); }
.auth-page { background: var(--admin-page); }
.auth-shell { color: var(--admin-text); }
.auth-story { color: var(--admin-hero-text); background: var(--admin-hero); box-shadow: var(--admin-shadow-raised); }
.auth-story p,
.auth-features span { color: var(--admin-hero-muted); }
.auth-features span { border-color: color-mix(in srgb, var(--admin-hero-muted) 24%, transparent); background: color-mix(in srgb, var(--admin-sidebar-deep) 32%, transparent); }
.auth-role,
.captcha-question,
.auth-switch a { color: var(--admin-accent); }
.auth-role,
.captcha-question { border-color: color-mix(in srgb, var(--admin-accent) 24%, var(--admin-border)); background: var(--admin-accent-soft); }
.auth-card-head p,
.auth-switch { color: var(--admin-text-soft); }
.auth-error { color: var(--admin-danger); }
.totp-secret-row code,
.totp-recovery-codes { border-color: var(--admin-border); color: var(--admin-text); background: var(--admin-surface-soft); }
.engagement-risk-flags span,
.engagement-risk-tag { color: var(--admin-warning); background: var(--admin-warning-soft); }
.engagement-risk-clear { color: var(--admin-success); }

html[data-ui-theme="particles"] :is(.panel, .stat-card, .auth-card, .modal, .site-card) { border-left-width: 2px; }
html[data-ui-theme="esports"] :is(.panel, .stat-card, .auth-card, .modal, .site-card) { border-radius: 10px; }
html[data-ui-theme="aurora"] :is(.panel, .stat-card, .auth-card, .modal, .site-card) { border-radius: 22px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
