:root {
  color-scheme: dark;
  --bg: #0d1115;
  --surface: #121820;
  --surface-2: #17202a;
  --surface-3: #1f2a35;
  --text: #eef4f8;
  --muted: #8e9baa;
  --line: #25313d;
  --line-strong: #344452;
  --primary: #32d296;
  --primary-ink: #06130e;
  --info: #5ab7ff;
  --warn: #f2c96d;
  --danger: #ff627a;
  --shadow: 0 14px 40px rgba(0, 0, 0, .28);
  --radius: 8px;
  --sidebar: 280px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: currentColor; display: block; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px;
  background: #10161d;
  border-right: 1px solid var(--line);
}

.brand-block { padding: 4px 8px 14px; border-bottom: 1px solid var(--line); }
.brand {
  display: block;
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
}
.brand.compact { font-size: 16px; }
.brand-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.side-nav { display: grid; gap: 4px; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 620;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active {
  color: var(--primary);
  background: rgba(50, 210, 150, .1);
  box-shadow: inset 0 0 0 1px rgba(50, 210, 150, .24);
}

.service-card {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.service-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.service-row strong { color: var(--text); font-size: 12px; }
.logout-form { margin: 0; }

.content-shell {
  width: min(1440px, calc(100vw - var(--sidebar)));
  padding: 28px;
}

.mobile-bar {
  display: none;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.page-header h1 {
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.08;
}
.page-header p,
.panel p {
  margin: 0;
  color: var(--muted);
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}
.header-actions,
.toolbar-actions,
.row-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel,
.metric-card,
.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel {
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.accent-panel {
  border-color: rgba(50, 210, 150, .28);
  background: linear-gradient(180deg, rgba(50, 210, 150, .08), var(--surface) 58%);
}
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.panel-header h2 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.2;
}
.panel-header a,
.panel-header span {
  color: var(--muted);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric-grid.compact { grid-template-columns: repeat(5, minmax(130px, 1fr)); }
.metric-card {
  min-height: 112px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}
.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.metric-card strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 26px;
  line-height: 1.08;
}
.metric-card small { color: var(--muted); }

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

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.status-strip div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 9px;
  min-height: 64px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.status-strip small { grid-column: 2; color: var(--muted); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(142, 155, 170, .12);
}
.status-dot.online { background: var(--primary); box-shadow: 0 0 0 4px rgba(50, 210, 150, .14); }
.status-dot.muted { background: var(--warn); box-shadow: 0 0 0 4px rgba(242, 201, 109, .14); }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-2);
  font-weight: 680;
}
.button:hover { border-color: var(--primary); }
.button-primary { border-color: transparent; color: var(--primary-ink); background: var(--primary); }
.button-secondary { background: var(--surface-2); }
.button-ghost { background: transparent; }
.button-danger { border-color: rgba(255, 98, 122, .32); color: var(--danger); background: rgba(255, 98, 122, .09); }
.button-icon { width: 38px; padding: 0; flex: 0 0 auto; }
.full-width { width: 100%; }

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #0b1015;
  outline: none;
}
select { appearance: none; }
input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(50, 210, 150, .14);
}
label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.create-grid,
.filter-grid {
  display: grid;
  gap: 12px;
  align-items: end;
}
.create-grid { grid-template-columns: minmax(220px, 1fr) minmax(220px, 1.2fr) auto; }
.domain-create { grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 180px auto; }
.filter-grid { grid-template-columns: minmax(220px, 1.3fr) minmax(160px, .7fr) minmax(160px, .7fr) auto; }

.check-card {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1015;
}
.check-card input,
.switch-label input { width: auto; min-height: auto; }
.check-card span { margin: 0; color: var(--text); font-size: 13px; text-transform: none; }
.switch-label { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

.quick-filters,
.chip-cloud {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.chip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
}
.chip.selected { color: var(--primary); border-color: rgba(50, 210, 150, .35); background: rgba(50, 210, 150, .09); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}
.badge-success { color: var(--primary); border-color: rgba(50, 210, 150, .35); background: rgba(50, 210, 150, .1); }
.badge-info { color: var(--info); border-color: rgba(90, 183, 255, .35); background: rgba(90, 183, 255, .1); }
.badge-danger { color: var(--danger); border-color: rgba(255, 98, 122, .35); background: rgba(255, 98, 122, .1); }
.badge-muted { color: var(--muted); }

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.copy-field code {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #dce7ee;
  background: #0b1015;
  word-break: break-all;
}
.copy-field-compact code {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-filter { margin-bottom: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  padding: 11px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}
.data-table tr:hover td { background: rgba(255, 255, 255, .015); }
.number { text-align: right !important; font-variant-numeric: tabular-nums; }
.actions-col { width: 134px; }
.client-cell { min-width: 260px; }
.client-cell input + input { margin-top: 8px; }
.domain-cell {
  min-width: 230px;
  display: grid;
  gap: 4px;
}
.domain-cell small,
.number small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.empty-cell,
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.list-stack,
.event-list {
  display: grid;
  gap: 8px;
}
.list-row,
.event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .015);
}
.list-row div:first-child,
.event-row div:first-child { min-width: 0; }
.list-row strong,
.event-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row span,
.event-row span,
.event-row time {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.event-row > div:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.link-like {
  border: 0;
  padding: 0;
  color: var(--info);
  background: transparent;
  text-align: left;
}
.link-like:hover { color: var(--primary); }
.link-like.strong { font-weight: 720; color: var(--text); }

.notice {
  padding: 12px 14px;
  margin-bottom: 16px;
}
.notice.success {
  color: var(--primary);
  border-color: rgba(50, 210, 150, .32);
  background: rgba(50, 210, 150, .08);
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  gap: 8px;
}
.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .58); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 18px; }
.confirm-dialog p { color: var(--muted); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 25% 15%, rgba(50, 210, 150, .1), transparent 28%), var(--bg);
}
.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 18px;
  align-items: stretch;
}
.login-shell.compact-shell { width: min(860px, 100%); }
.login-copy,
.login-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-copy {
  display: grid;
  align-content: center;
  padding: 34px;
}
.login-copy h1 { margin: 0 0 10px; font-size: 36px; }
.login-copy p { color: var(--muted); max-width: 560px; }
.login-status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 28px;
}
.login-status-grid div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.login-status-grid small { color: var(--muted); }
.login-panel { padding: 24px; }
.stack { display: grid; gap: 14px; }
.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.form-error {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
}
.hidden { visibility: hidden; }

@media (max-width: 1100px) {
  .metric-grid,
  .metric-grid.compact,
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid,
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .mobile-bar { display: flex; position: sticky; top: 0; z-index: 30; }
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 35;
    width: min(300px, calc(100vw - 44px));
    transform: translateX(-105%);
    transition: transform .18s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .content-shell { width: 100%; padding: 18px 14px 42px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .create-grid,
  .domain-create,
  .filter-grid { grid-template-columns: 1fr; }
  .metric-grid,
  .metric-grid.compact,
  .status-strip { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-copy { padding: 24px; }
  .login-status-grid { grid-template-columns: 1fr; }
  .copy-field-compact code { max-width: 260px; }
}
