:root {
  --bg: #0b1020;
  --bg-body-start: #08101f;
  --bg-body-mid: #0f172a;
  --bg-body-end: #131c35;
  --panel: #121a2f;
  --panel-soft: #18233e;
  --border: rgba(148, 163, 184, 0.18);
  --text: #e5ecff;
  --muted: #9fb0d3;
  --primary: #5b8cff;
  --primary-soft: rgba(91, 140, 255, 0.16);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --output-bg: #08101f;
  --key-item-bg: rgba(8, 16, 32, 0.65);
  --table-row-hover: rgba(255, 255, 255, 0.02);
  --chart-bg: rgba(8, 16, 32, 0.55);
  --eyebrow: #9bc0ff;
}

:root[data-theme="light"] {
  --bg: #eef3fb;
  --bg-body-start: #f8fbff;
  --bg-body-mid: #eef3fb;
  --bg-body-end: #e5edf9;
  --panel: #ffffff;
  --panel-soft: #f5f8ff;
  --border: rgba(71, 85, 105, 0.24);
  --text: #1f2937;
  --muted: #5b6472;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.14);
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #ca8a04;
  --output-bg: #f6f8fc;
  --key-item-bg: #f8faff;
  --table-row-hover: rgba(30, 41, 59, 0.04);
  --chart-bg: #f6f8fc;
  --eyebrow: #1d4ed8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  background: linear-gradient(135deg, var(--bg-body-start) 0%, var(--bg-body-mid) 45%, var(--bg-body-end) 100%);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

.link-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

input[type="checkbox"] {
  accent-color: var(--primary);
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  color: white;
  background: linear-gradient(135deg, var(--primary), #7c62ff);
}

button:hover {
  opacity: 0.95;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  border: 1px solid var(--border);
}

.small-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.danger-outline,
.danger-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #ffd8d8;
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 20px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #7c62ff);
}

.nav-menu {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  background: rgba(91, 140, 255, 0.14);
  border-color: rgba(91, 140, 255, 0.24);
}

.sidebar-footer {
  margin-top: 24px;
}

.mini-card,
.card {
  background: rgba(18, 26, 47, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

.mini-card {
  padding: 14px;
}

.mini-hint,
.muted {
  color: var(--muted);
}

.main {
  padding: 20px;
  overflow-x: hidden;
}

.card {
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar h2 {
  margin: 6px 0;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--eyebrow);
}

.theme-toggle {
  min-width: 106px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid transparent;
}

.badge.success {
  background: rgba(34, 197, 94, 0.14);
  color: #b7f7c8;
}

.badge.error {
  background: rgba(239, 68, 68, 0.14);
  color: #ffd0d0;
}

.badge.pending {
  background: rgba(245, 158, 11, 0.14);
  color: #ffe8b3;
}

.panel {
  display: none;
  margin-top: 18px;
}

.panel.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metrics-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.seven-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.metric-card {
  min-height: 92px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.section-title.wrap {
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

input,
textarea,
select {
  width: 100%;
  background: rgba(8, 16, 32, 0.8);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 6px;
  margin-bottom: 12px;
}

.search-input,
.filter-select {
  width: 220px;
  margin: 0;
}

.filter-select {
  min-width: 132px;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 140px 140px;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.output {
  background: var(--output-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  min-height: 110px;
}

.output.small {
  max-height: 240px;
  overflow: auto;
}

.pill-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #dbe7ff;
  font-size: 12px;
}

.list {
  display: grid;
  gap: 10px;
}

.key-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--key-item-bg);
}

.key-mask {
  font-weight: 600;
  margin-bottom: 4px;
}

.key-meta {
  color: var(--muted);
  font-size: 13px;
}

.feature-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.feature-list li {
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  text-align: left;
  font-size: 14px;
}

.data-table th {
  color: #9bc0ff;
  background: rgba(91, 140, 255, 0.06);
}

.data-table tr:hover td {
  background: var(--table-row-hover);
}

.table-empty {
  text-align: center !important;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  width: min(560px, 100%);
}

.modal-hint,
.confirm-message {
  margin: 0 0 12px;
  line-height: 1.6;
}

.confirm-modal {
  max-width: 480px;
}

.row-check {
  width: 16px;
  height: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.analytics-grid {
  margin-bottom: 16px;
}

.chart-split {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: center;
}

.pie-host,
.trend-chart,
.analytics-list {
  min-height: 240px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--chart-bg);
  padding: 14px;
}

.pie-host {
  display: grid;
  place-items: center;
}

.pie-wrap {
  position: relative;
  width: 180px;
  height: 180px;
}

.pie-donut {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  position: relative;
}

.pie-donut::after {
  content: "";
  position: absolute;
  inset: 28px;
  background: var(--bg);
  border-radius: 50%;
  border: 1px solid var(--border);
}

.pie-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.pie-center strong {
  font-size: 22px;
}

.pie-center span,
.mini-kpi {
  color: var(--muted);
  font-size: 12px;
}

.analytics-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.legend-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 12px;
  background: rgba(91, 140, 255, 0.08);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 4px;
  flex: 0 0 auto;
}

.legend-copy strong {
  display: block;
  margin-bottom: 4px;
}

.chart-shell {
  width: 100%;
}

.chart-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-empty {
  min-height: 200px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 1200px) {
  .seven-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .two-col,
  .metrics-grid,
  .seven-grid,
  .inline-form,
  .chart-split {
    grid-template-columns: 1fr;
  }

  .search-input {
    width: 100%;
  }
}
