:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #657282;
  --line: #d8dee6;
  --panel: #ffffff;
  --panel-soft: #fbfcfd;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #edf2f5;
  --sidebar-bg: #111d27;
  --sidebar-panel: rgba(255, 255, 255, 0.035);
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --sidebar-text: #e7edf2;
  --sidebar-muted: #aeb9c4;
  --hero-start: #102833;
  --hero-mid: #163944;
  --hero-end: #1b4b45;
  --code-bg: #101820;
  --code-text: #edf7f6;
  --accent: #0b766f;
  --accent-soft: #e5f6f3;
  --accent-2: #b6562d;
  --danger: #b42318;
  --warn: #a15c00;
  --ok: #217a3c;
  --shadow: 0 16px 40px rgba(20, 32, 42, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf4f7;
  --muted: #a8b6c4;
  --line: #2b3b49;
  --panel: #14212c;
  --panel-soft: #182936;
  --bg: #0f1821;
  --surface: #101b25;
  --surface-2: #1f303d;
  --sidebar-bg: #071118;
  --sidebar-panel: rgba(255, 255, 255, 0.045);
  --sidebar-line: rgba(255, 255, 255, 0.11);
  --sidebar-text: #e9f2f5;
  --sidebar-muted: #8fa2b1;
  --hero-start: #08141d;
  --hero-mid: #12303a;
  --hero-end: #19423d;
  --code-bg: #071018;
  --code-text: #e6f4f3;
  --accent: #2fb5a7;
  --accent-soft: #123d3a;
  --accent-2: #e09b61;
  --danger: #ff7d73;
  --warn: #f4b24f;
  --ok: #62c783;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --ink: #e9eefc;
  --muted: #9ea9c8;
  --line: #263150;
  --panel: #11182d;
  --panel-soft: #151f38;
  --bg: #091020;
  --surface: #0d1528;
  --surface-2: #1b2744;
  --sidebar-bg: #050914;
  --sidebar-panel: rgba(122, 157, 255, 0.07);
  --sidebar-line: rgba(167, 190, 255, 0.12);
  --sidebar-text: #edf2ff;
  --sidebar-muted: #9daed8;
  --hero-start: #071026;
  --hero-mid: #102653;
  --hero-end: #173b4f;
  --code-bg: #050914;
  --code-text: #edf2ff;
  --accent: #6da7ff;
  --accent-soft: #142447;
  --accent-2: #66d5c2;
  --danger: #ff8e88;
  --warn: #f5c35b;
  --ok: #70d69b;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

:root[data-theme="contrast"] {
  color-scheme: light;
  --ink: #050505;
  --muted: #343434;
  --line: #050505;
  --panel: #ffffff;
  --panel-soft: #f4f4f4;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eeeeee;
  --sidebar-bg: #000000;
  --sidebar-panel: rgba(255, 255, 255, 0.08);
  --sidebar-line: rgba(255, 255, 255, 0.3);
  --sidebar-text: #ffffff;
  --sidebar-muted: #e0e0e0;
  --hero-start: #000000;
  --hero-mid: #202020;
  --hero-end: #003c38;
  --code-bg: #000000;
  --code-text: #ffffff;
  --accent: #005f58;
  --accent-soft: #dff8f4;
  --accent-2: #8a3600;
  --danger: #9b0000;
  --warn: #754000;
  --ok: #005f22;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 284px 1fr;
  background:
    linear-gradient(180deg, var(--surface-2) 0, var(--surface) 280px, var(--bg) 100%);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

body.sidebar-collapsed {
  grid-template-columns: 76px 1fr;
}

body.auth-loading .sidebar,
body.auth-loading header,
body.auth-loading .mobile-nav,
body.login-mode .sidebar,
body.login-mode header,
body.login-mode .mobile-nav {
  display: none;
}

body.customer-mode .sidebar,
body.customer-mode .sidebar-unhide,
body.customer-mode .mobile-nav {
  display: none;
}

body.customer-mode {
  display: block;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 20%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 88%, white), var(--surface));
}

body.captive-mode header {
  display: flex;
  padding: 18px 24px;
}

body.customer-mode header {
  display: flex;
  padding: 18px 24px;
}

body.customer-mode #refresh {
  display: none;
}

body.login-mode,
body.auth-loading {
  display: block;
  background:
    linear-gradient(135deg, rgba(10, 36, 48, 0.94), rgba(11, 118, 111, 0.88)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cpath d='M0 80h160M80 0v160M24 24l112 112M136 24L24 136' stroke='%23ffffff' stroke-opacity='.08'/%3E%3C/svg%3E");
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 20px 14px;
  min-height: 100vh;
  max-height: 100vh;
  overflow: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  margin-bottom: 12px;
}

.tenant-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  vertical-align: middle;
}

.portal-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.portal-preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.portal-preview-hero {
  padding: 18px;
  background: linear-gradient(135deg, var(--portal-accent), color-mix(in srgb, var(--portal-accent) 48%, #08141d));
  background-size: cover;
  background-position: center;
  color: white;
}

.portal-preview-hero.center,
.captive-hero.center {
  text-align: center;
}

.portal-preview-hero h3 {
  margin: 10px 0 8px;
}

.portal-preview-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
}

.portal-preview-body {
  padding: 16px 18px 18px;
  display: grid;
  gap: 10px;
}

.portal-preview-body h4 {
  margin: 0;
  font-size: 18px;
}

.portal-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.portal-preview-tags span,
.captive-hero-points span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.captive-shell {
  padding: 24px;
  display: grid;
  gap: 20px;
}

.captive-hero {
  padding: 28px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(140deg, var(--portal-accent), color-mix(in srgb, var(--portal-accent) 48%, #08141d));
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
}

.captive-hero h1 {
  margin: 10px 0 10px;
  font-size: 38px;
}

.captive-hero p {
  max-width: 760px;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.captive-hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.captive-hero-points span {
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.25);
}

.captive-promo {
  margin-top: 18px;
  max-width: 540px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(6, 15, 22, 0.28);
  backdrop-filter: blur(6px);
}

.captive-hero.center .captive-promo {
  margin-left: auto;
  margin-right: auto;
}

.captive-promo strong {
  display: block;
  font-size: 18px;
  margin-bottom: 6px;
}

.captive-promo p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
}

.captive-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: start;
}

.captive-section {
  display: grid;
  gap: 18px;
}

.captive-package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.captive-package-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.captive-package-card.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

.captive-package-card input {
  display: none;
}

.captive-package-card strong {
  font-size: 18px;
}

.captive-package-card span {
  font-size: 22px;
  color: var(--accent);
  font-weight: 700;
}

.captive-package-card small {
  color: var(--muted);
}

.inline-result {
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.inline-result.ok {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
  background: color-mix(in srgb, var(--ok) 10%, var(--panel));
}

.inline-result p {
  margin: 6px 0 0;
}

.captive-actions {
  display: grid;
  gap: 12px;
}

.captive-repeat-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto;
  gap: 18px;
  align-items: center;
}

.captive-repeat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel-soft);
}

.brand div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.brand strong {
  font-size: 24px;
}

.sidebar-toggle {
  min-height: 30px;
  padding: 5px 9px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  font-size: 12px;
}

.brand span,
.eyebrow,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.sidebar .brand span {
  color: var(--sidebar-muted);
}

nav {
  display: grid;
  gap: 12px;
}

.nav-group {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--sidebar-line);
  border-radius: 10px;
  background: var(--sidebar-panel);
}

.nav-group.active {
  border-color: rgba(118, 196, 185, 0.45);
  background: rgba(8, 109, 103, 0.16);
}

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 7px;
  color: var(--sidebar-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.nav-group-title span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 800;
  text-transform: none;
}

nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}

nav button.active,
nav button:hover {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

.mobile-nav {
  display: none;
}

.sidebar-unhide {
  position: fixed;
  left: 14px;
  top: 14px;
  z-index: 50;
  min-height: 38px;
  padding: 8px 11px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.sidebar-unhide[hidden] {
  display: none;
}

body.sidebar-collapsed .sidebar {
  padding: 16px 10px;
}

body.sidebar-collapsed .brand {
  justify-content: center;
  padding: 6px 4px 14px;
}

body.sidebar-collapsed .brand div,
body.sidebar-collapsed .sidebar-toggle,
body.sidebar-collapsed nav button {
  display: none;
}

body.sidebar-collapsed .nav-group {
  padding: 8px 6px;
  justify-items: center;
}

body.sidebar-collapsed .nav-group-title {
  padding: 0;
}

body.sidebar-collapsed .nav-group-title strong {
  display: none;
}

body.sidebar-collapsed .nav-group-title span {
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.13);
}

body.sidebar-collapsed .nav-group.active .nav-group-title span {
  background: var(--accent);
}

body.sidebar-collapsed header {
  padding-left: 58px;
}

main {
  min-width: 0;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 30px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-control {
  display: flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.theme-control span {
  color: var(--muted);
  font-size: 12px;
}

.theme-control select {
  width: auto;
  min-height: 28px;
  padding: 3px 26px 3px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 700;
}

.theme-control select:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
  outline-offset: 1px;
}

.theme-control select option {
  background: var(--panel);
  color: var(--ink);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 48px;
  align-items: center;
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 28px;
}

.login-copy {
  display: grid;
  gap: 18px;
  color: #fff;
}

.login-copy .eyebrow {
  color: #b9d9d5;
  font-weight: 800;
  text-transform: uppercase;
}

.login-copy h2 {
  max-width: 680px;
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

.login-copy p {
  max-width: 580px;
  color: #d4e6e8;
  font-size: 18px;
  line-height: 1.6;
}

.login-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-points span {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #eef8f7;
  font-weight: 700;
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
}

.customer-auth-stack {
  display: grid;
  gap: 18px;
}

.customer-auth-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: stretch;
}

.login-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  align-self: start;
}

.login-switch button {
  min-height: 38px;
}

.login-switch button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.customer-login-screen {
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 480px);
}

.muted-card {
  opacity: 0.72;
}

.login-sidecard {
  align-content: start;
}

.login-side-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-side-points span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-card h2 {
  font-size: 28px;
}

.login-card button {
  min-height: 46px;
  font-weight: 800;
}

.login-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fae8e7;
  color: var(--danger);
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  margin-top: 4px;
}

#app {
  max-width: 1560px;
  padding: 24px 30px 40px;
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(20, 32, 42, 0.04);
}

.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.card {
  padding: 16px;
}

.stat {
  display: grid;
  gap: 8px;
}

.stat strong {
  font-size: 30px;
}

.toolbar,
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
  min-height: 38px;
}

button.secondary {
  background: var(--panel);
  color: var(--accent);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.secondary-link {
  background: var(--panel);
  color: var(--accent);
}

.command-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 90% 20%, rgba(58, 143, 133, 0.42), transparent 28%),
    linear-gradient(135deg, var(--hero-start) 0%, var(--hero-mid) 56%, var(--hero-end) 100%);
  color: #fff;
  border-radius: 12px;
  border: 1px solid #173b48;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.command-hero .muted {
  color: #b6c8cf;
  margin-top: 6px;
}

.command-hero h2 {
  font-size: 30px;
  letter-spacing: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.hero-status {
  min-width: 132px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
}

.hero-status span,
.hero-status small {
  color: #c3d6db;
  font-size: 12px;
}

.hero-status strong {
  font-size: 30px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.status-chip.online {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, var(--panel));
}

.status-chip.warning {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, var(--panel));
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 6px;
  min-height: 118px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.kpi-card span,
.kpi-card small {
  color: var(--muted);
}

.kpi-card strong {
  font-size: 26px;
}

.kpi-card.primary {
  border-color: #9fd1c9;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 16%, var(--panel)), var(--panel));
}

.kpi-card.danger-soft {
  border-color: #efb6b2;
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 13%, var(--panel)), var(--panel));
}

.kpi-card.danger-soft::before {
  background: var(--danger);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-head a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
  font-size: 13px;
}

.health-bars {
  display: grid;
  gap: 12px;
}

.health-bars > div {
  display: grid;
  grid-template-columns: 90px 54px 1fr;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--ok);
}

.bar.warn i {
  background: var(--warn);
}

.capacity-list,
.feed-list,
.quick-actions {
  display: grid;
  gap: 10px;
}

.capacity-item,
.feed-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: var(--panel-soft);
}

.capacity-item:hover,
.feed-item:hover,
.ops-metrics a:hover,
.quick-actions a:hover {
  border-color: #b9c9d1;
  background: var(--panel);
}

.capacity-item div,
.feed-item div {
  display: grid;
  gap: 4px;
}

.capacity-item span,
.capacity-item small,
.feed-item span {
  color: var(--muted);
  font-size: 12px;
}

.ops-column {
  display: grid;
  gap: 16px;
  align-content: start;
}

.ops-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ops-metrics a,
.quick-actions a {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel-soft);
}

.ops-metrics a {
  display: grid;
  gap: 4px;
  text-align: center;
}

.ops-metrics strong {
  font-size: 24px;
}

.ops-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.quick-actions a {
  color: var(--accent);
  font-weight: 650;
}

.bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.topology-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.topology-node {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--muted);
  border-radius: 8px;
  padding: 13px;
  background: var(--panel-soft);
}

.topology-node.online,
.topology-node.up {
  border-left-color: var(--ok);
}

.topology-node.warning,
.topology-node.degraded {
  border-left-color: var(--warn);
}

.topology-node.offline,
.topology-node.down {
  border-left-color: var(--danger);
}

.topology-node span,
.topology-node small {
  color: var(--muted);
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--accent);
  background: var(--panel-soft);
  border-radius: 6px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.timeline-item span,
.timeline-item small {
  color: var(--muted);
  font-size: 12px;
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 650;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 650;
  background: var(--surface-2);
}

.online,
.success,
.active {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, var(--panel));
}

.warning,
.pending,
.running {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 16%, var(--panel));
}

.offline,
.failed,
.expired,
.disconnected {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, var(--panel));
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

pre {
  white-space: pre-wrap;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
}

.portal-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 24px;
  border: 1px solid #12313f;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--hero-start) 0%, var(--hero-mid) 52%, var(--hero-end) 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.portal-hero h2 {
  margin-top: 6px;
  font-size: 32px;
  letter-spacing: 0;
}

.portal-hero p,
.portal-hero .eyebrow {
  color: #c9d8db;
}

.portal-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.portal-hero-actions .secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.portal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.portal-stats > div {
  display: grid;
  gap: 5px;
  min-height: 108px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.portal-stats span,
.portal-stats small {
  color: var(--muted);
  font-size: 12px;
}

.portal-stats strong {
  font-size: 28px;
}

.portal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.portal-main,
.portal-side {
  display: grid;
  gap: 16px;
}

.portal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: grid;
  gap: 14px;
}

.profile-strip,
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.profile-card,
.device-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel-soft);
}

.profile-card.paused,
.device-card.paused {
  border-color: #efb6b2;
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
}

.profile-card > div:nth-child(2),
.device-card > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-card p,
.device-card span,
.device-card small {
  color: var(--muted);
  font-size: 12px;
}

.usage-list,
.alert-stack,
.mini-list,
.stack-form {
  display: grid;
  gap: 10px;
}

.usage-row {
  display: grid;
  grid-template-columns: 120px 1fr 82px;
  gap: 10px;
  align-items: center;
}

.usage-row div {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.usage-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.usage-row b {
  text-align: right;
  font-size: 13px;
}

.alert-stack article {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel-soft);
}

.alert-stack small {
  color: var(--muted);
}

.control-card h2 {
  font-size: 18px;
}

.stack-form.compact {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.stack-form label {
  font-size: 12px;
}

.mini-list span {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
}

.inline-package-cap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-package-cap input {
  min-width: 96px;
}

.share-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(240px, 0.95fr);
  gap: 14px;
  align-items: start;
}

.share-builder,
.share-preview {
  min-height: 100%;
}

.share-preview {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--panel-soft);
}

.share-preview textarea {
  min-height: 78px;
}

.share-preview-actions,
.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-qr {
  width: min(220px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
}

.invite-list {
  display: grid;
  gap: 10px;
}

.invite-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.invite-card.revoked {
  opacity: 0.72;
}

.invite-meta,
.invite-stats {
  display: grid;
  gap: 4px;
}

.invite-meta small,
.invite-stats small {
  color: var(--muted);
  word-break: break-all;
}

.invite-screen .customer-auth-stack {
  max-width: 720px;
}

@media (max-width: 860px) {
  body {
    display: block;
    padding-bottom: 96px;
  }

  .captive-shell {
    padding: 16px;
  }

  .captive-grid {
    grid-template-columns: 1fr;
  }

  .captive-repeat-card {
    grid-template-columns: 1fr;
  }

  .captive-repeat-actions {
    justify-content: flex-start;
  }

  .captive-hero {
    padding: 22px 18px;
  }

  .captive-hero h1 {
    font-size: 28px;
  }

  body.login-mode,
  body.auth-loading {
    padding-bottom: 0;
  }

  .login-screen {
    min-height: 100vh;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 34px 16px;
  }

  .login-copy h2 {
    font-size: 36px;
  }

  .login-copy p {
    font-size: 15px;
  }

  .login-card {
    padding: 20px;
  }

  .customer-auth-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .sidebar-unhide {
    display: none;
  }

  body.sidebar-collapsed {
    display: block;
  }

  header {
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: flex-start;
    padding: 14px 16px;
    gap: 10px;
    box-shadow: 0 8px 22px rgba(20, 32, 42, 0.08);
  }

  header .eyebrow {
    display: none;
  }

  h1 {
    font-size: 22px;
    line-height: 1.15;
  }

  .header-actions {
    justify-content: flex-end;
    gap: 6px;
  }

  #current-user {
    display: none;
  }

  .theme-control {
    padding: 3px 6px;
  }

  .theme-control span {
    display: none;
  }

  .theme-control select {
    max-width: 110px;
    font-size: 13px;
  }

  #refresh,
  #logout {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
  }

  #app {
    padding: 14px 12px 28px;
    gap: 14px;
  }

  .panel,
  .card,
  .portal-panel {
    border-radius: 8px;
    padding: 14px;
  }

  .grid,
  .toolbar,
  .form-grid,
  .profile-strip,
  .device-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    border-radius: 8px;
    max-width: calc(100vw - 24px);
  }

  table {
    min-width: 640px;
  }

  th,
  td {
    padding: 9px 10px;
    font-size: 13px;
  }

  button,
  input,
  select,
  textarea {
    min-height: 42px;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .command-hero,
  .portal-hero,
  .portal-layout,
  .dashboard-layout,
  .bottom-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .kpi-grid,
  .portal-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-actions,
  .portal-hero-actions {
    justify-content: flex-start;
  }

  .command-hero,
  .portal-hero {
    padding: 18px;
    border-radius: 10px;
  }

  .command-hero h2,
  .portal-hero h2 {
    font-size: 24px;
  }

  .portal-stats {
    gap: 10px;
  }

  .portal-stats > div,
  .kpi-card {
    min-height: 96px;
  }

  .portal-layout {
    gap: 12px;
  }

  .share-grid,
  .invite-card {
    grid-template-columns: 1fr;
  }

  .usage-row {
    grid-template-columns: 92px 1fr 64px;
  }

  .mobile-nav {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    pointer-events: none;
  }

  .mobile-dock {
    pointer-events: auto;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 96%, transparent);
    box-shadow: 0 -14px 34px rgba(20, 32, 42, 0.14);
    backdrop-filter: blur(12px);
  }

  .mobile-dock button {
    display: grid;
    justify-items: center;
    gap: 3px;
    min-width: 0;
    min-height: 58px;
    padding: 6px 2px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
  }

  .mobile-dock button span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--ink);
    font-weight: 800;
    font-size: 13px;
  }

  .mobile-dock button small {
    max-width: 100%;
    overflow: hidden;
    color: inherit;
    font-size: 10px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-dock button.active,
  .mobile-dock button:active {
    color: var(--accent);
    background: var(--accent-soft);
  }

  .mobile-dock button.active span,
  .mobile-dock button:active span {
    background: var(--accent);
    color: #fff;
  }

  .mobile-sheet {
    pointer-events: auto;
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 82px;
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 20px 60px rgba(20, 32, 42, 0.22);
  }

  .mobile-sheet[hidden] {
    display: none;
  }

  .mobile-sheet-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
  }

  .mobile-close {
    min-height: 32px;
    padding: 6px 10px;
    border-color: var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-sheet-grid button {
    min-height: 44px;
    padding: 9px 10px;
    border-color: var(--line);
    background: var(--panel-soft);
    color: var(--ink);
    text-align: left;
    font-size: 13px;
  }

  .mobile-sheet-grid button.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
  }
}

@media (max-width: 420px) {
  .kpi-grid,
  .portal-stats {
    grid-template-columns: 1fr;
  }

  .mobile-dock {
    gap: 2px;
    padding-left: 5px;
    padding-right: 5px;
  }

  .mobile-dock button small {
    font-size: 9px;
  }

  .mobile-sheet-grid {
    grid-template-columns: 1fr;
  }
}
