:root {
  --bg-0: #0a0612;
  --bg-1: #120a1d;
  --bg-2: #1a1028;
  --surface: rgba(22, 14, 34, 0.68);
  --surface-strong: rgba(16, 10, 26, 0.94);
  --surface-soft: rgba(255, 245, 235, 0.03);
  --border: rgba(251, 191, 36, 0.14);
  --border-strong: rgba(251, 191, 36, 0.24);
  --text: #fff7ed;
  --text-soft: #f3dcc3;
  --muted: #c4a68a;
  --muted-2: #8f7666;
  --primary: #f59e0b;
  --primary-2: #ea580c;
  --primary-3: #fbbf24;
  --accent: #f472b6;
  --ok: #fbbf24;
  --ok-soft: rgba(251, 191, 36, 0.14);
  --warn: #fb923c;
  --warn-soft: rgba(251, 146, 60, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
  --info: #f472b6;
  --info-soft: rgba(244, 114, 182, 0.12);
  --font: "Manrope", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 32px;
  --sidebar-w: 260px;
  --content-pad: 28px 32px 40px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 30%, #1a0f26 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scene */
.scene { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.scene-gradient {
  position: absolute; inset: -10%;
  background:
    radial-gradient(900px 480px at 10% 15%, rgba(245, 158, 11, 0.14), transparent 60%),
    radial-gradient(700px 420px at 85% 75%, rgba(219, 39, 119, 0.10), transparent 60%);
}
.scene-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(251, 191, 36, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(251, 191, 36, 0.05) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse 80% 70% at 40% 40%, #000 30%, transparent 85%);
  opacity: 0.3;
}

/* App shell */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(18, 11, 29, 0.92), rgba(12, 8, 20, 0.96));
  display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
}
.sidebar-top { display: flex; flex-direction: column; }
.brand {
  display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center;
  padding: 4px 8px 20px; border-bottom: 1px solid var(--border);
}
.brand-mark, .brand-mark svg { width: 44px; height: 44px; display: block; }
.brand-text .overline {
  font-size: 0.68rem; color: var(--primary-3); letter-spacing: 0.14em;
  text-transform: uppercase; font-weight: 700; display: block; margin-bottom: 2px;
}
.brand-text strong { font-size: 1rem; letter-spacing: -0.02em; color: var(--text); }
.nav { display: grid; gap: 6px; margin-top: 18px; }
.nav-item {
  display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 12px;
  height: 42px; padding: 0 12px; border-radius: 12px;
  color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 600;
  border: 1px solid transparent; transition: 0.15s ease;
}
.nav-item:hover { color: var(--text); background: rgba(251, 191, 36, 0.06); }
.nav-item.active {
  color: #fff7ed;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(219, 39, 119, 0.10));
  border-color: rgba(251, 191, 36, 0.2);
}
.nav-ico { text-align: center; color: var(--primary-3); font-size: 0.95rem; line-height: 1; }
.sidebar-foot { padding: 16px 8px 0; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--text-soft); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.dot.err { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.meta-line { display: flex; justify-content: space-between; font-size: 0.8rem; gap: 12px; }
.meta-line .k { color: var(--muted-2); }
.meta-line .v { color: var(--text-soft); }

/* Content */
.content { padding: var(--content-pad); min-width: 0; }
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.page-header h1 { margin: 0 0 4px; font-size: 1.7rem; letter-spacing: -0.03em; line-height: 1.15; }
.subtitle { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.clock-block { text-align: right; }
.clock-block .k { display: block; font-size: 0.72rem; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.clock-block .v { font-size: 0.9rem; color: var(--text-soft); }

.layout-stack { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; width: 100%; }

/* Cards / Panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
}
.panel { padding: 20px; }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.panel-head h2 { margin: 0 0 2px; font-size: 1.05rem; letter-spacing: -0.02em; line-height: 1.3; }
.hint { font-size: 0.8rem; color: var(--muted-2); line-height: 1.45; }
.panel-inline-head, .section-head-inline { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-inline-head h3, .section-block h3 { margin: 0 0 2px; font-size: 0.98rem; letter-spacing: -0.01em; color: var(--text); }
.panel-inline-head p { margin: 0; }

.section-block {
  padding: 16px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: rgba(255, 247, 237, 0.02); display: grid; gap: 12px;
}
.section-block.inner { margin-top: 14px; }

/* Buttons */
.btn-primary, .btn-ghost, .btn-danger {
  font: 600 0.9rem var(--font); cursor: pointer; transition: 0.15s ease;
  border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; white-space: nowrap; text-decoration: none;
}
.btn-primary {
  height: 42px; padding: 0 16px; border: none; color: #2a0a12;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 35%, #f97316 70%, #db2777 100%);
  box-shadow: 0 10px 24px rgba(234, 88, 12, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  height: 42px; padding: 0 14px; border: 1px solid var(--border-strong);
  background: var(--surface-soft); color: var(--text-soft);
}
.btn-ghost:hover { border-color: rgba(251, 191, 36, 0.4); color: var(--text); background: rgba(251, 191, 36, 0.08); }
.btn-danger {
  height: 42px; padding: 0 14px; border: 1px solid rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.08); color: #fecdd3;
}
.btn-danger:hover { background: rgba(251, 113, 133, 0.14); }
.btn-primary.sm, .btn-ghost.sm, .btn-danger.sm { height: 34px; padding: 0 12px; font-size: 0.82rem; border-radius: 10px; }
.icon-btn {
  width: 34px; height: 34px; border: 1px solid var(--border); background: var(--surface-soft);
  color: var(--muted); border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: 0.15s; font: 600 0.9rem var(--font);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 9.5rem; height: 28px;
  padding: 0 12px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap; text-align: center; box-sizing: border-box;
}
.badge.ok { color: #fde68a; background: var(--ok-soft); border-color: rgba(251, 191, 36, 0.22); }
.badge.warn { color: #fed7aa; background: var(--warn-soft); border-color: rgba(251, 146, 60, 0.22); }
.badge.err, .badge.crit { color: #fecdd3; background: var(--danger-soft); border-color: rgba(251, 113, 133, 0.22); }
.badge.neutral { color: var(--text-soft); background: rgba(255, 247, 237, 0.05); border-color: var(--border); }
.badge.sm { min-width: 9.5rem; height: 28px; font-size: 0.72rem; padding: 0 12px; }
.count-badge {
  height: 28px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center;
  font-size: 0.78rem; font-weight: 700; color: var(--text-soft); border: 1px solid var(--border); background: var(--surface-soft);
}

/* Tables */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th, .table td {
  padding: 12px 14px; text-align: left; font-size: 0.86rem;
  border-bottom: 1px solid rgba(251, 191, 36, 0.08); vertical-align: middle;
}
.table th {
  font-size: 0.72rem; color: var(--muted-2); text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 700; background: rgba(255, 247, 237, 0.02); white-space: nowrap;
}
.table td { color: var(--text-soft); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(251, 191, 36, 0.03); }
.col-actions { width: 140px; text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* KV / Info grids */
.kv-grid { display: grid; gap: 10px; }
.kv-grid.cols-2, .cols-2 { grid-template-columns: 1fr 1fr; }
.kv-grid.cols-3, .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv-grid.cols-4, .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kv {
  display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface-soft); min-height: 54px; align-content: center;
}
.kv .k { font-size: 0.7rem; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.kv .v { font-size: 0.86rem; color: var(--text-soft); font-weight: 600; word-break: break-word; }
.kv pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 500 0.82rem var(--mono); color: var(--text-soft); line-height: 1.5; }
.kv.span-2 { grid-column: span 2; }
.kv.span-3 { grid-column: span 3; }

/* Forms */
.form-grid { display: grid; gap: 12px; }
.form-stack { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text-soft); }
.field-hint { font-size: 0.76rem; color: var(--muted-2); line-height: 1.4; }
.req { color: var(--accent); font-weight: 700; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
input, select, textarea, .search, .select {
  width: 100%; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface-strong);
  color: var(--text); font: 500 0.9rem var(--font);
}
input, select, .search, .select { height: 42px; }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; font-family: var(--mono); font-size: 0.84rem; }
input:focus, select:focus, textarea:focus, .search:focus, .select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.22);
}
::placeholder { color: #6b5447; }

.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tab {
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-soft); color: var(--muted); font: 600 0.86rem var(--font);
  cursor: pointer; transition: 0.15s;
}
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab.active {
  color: #fff7ed; background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(219, 39, 119, 0.10));
  border-color: rgba(251, 191, 36, 0.28);
}
.tab-panel { display: block; }
.tab-panel[hidden] { display: none; }

/* Alerts / misc */
.alert-global { display: none; margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; font-size: 0.88rem; border: 1px solid transparent; }
.alert-global.show { display: block; }
.alert-global.ok { color: #fde68a; background: var(--ok-soft); border-color: rgba(251, 191, 36, 0.22); }
.alert-global.err { color: #fecdd3; background: var(--danger-soft); border-color: rgba(251, 113, 133, 0.22); }
.empty {
  padding: 28px 22px; text-align: center; color: var(--muted); font-size: 0.92rem;
  border: 1px dashed rgba(251, 191, 36, 0.18); border-radius: 12px; background: rgba(255, 247, 237, 0.02); line-height: 1.5;
}
.mono { font-family: var(--mono); }
.ok-text { color: #fde68a; }

/* Modal base */
.modal { position: fixed; inset: 0; z-index: 40; display: none; }
.modal.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 4, 10, 0.72); backdrop-filter: blur(4px); }
.modal-dialog {
  position: relative; width: min(760px, calc(100% - 32px)); margin: 5vh auto; max-height: 90vh; overflow: auto;
  background: linear-gradient(180deg, rgba(22, 14, 34, 0.98), rgba(14, 9, 24, 0.99));
  border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0 0 4px; font-size: 1.15rem; }
.modal-sub { margin: 0; font-size: 0.84rem; color: var(--muted); line-height: 1.45; }
.modal-body { padding: 20px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 4px; }

/* Responsive */
@media (max-width: 1100px) {
  .kv-grid.cols-4, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv-grid.cols-3, .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 20px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; justify-content: flex-start; }
}
@media (max-width: 700px) {
  .kv-grid.cols-2, .cols-2, .kv-grid.cols-3, .cols-3, .kv-grid.cols-4, .cols-4 { grid-template-columns: 1fr; }
  .nav { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
}
