:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #121822;
  --surface-2: #161e2b;
  --line: #222c3a;
  --text: #e8edf4;
  --muted: #8a97a8;
  --green: #3ddc84;
  --amber: #ffb84d;
  --red: #ff5c5c;
  --critical: #ff9f43;
  --cyan: #5b8cff;
  --violet: #a78bfa;
  --blue: #5b8cff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 20px;
  background: #090d12;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.label,
small {
  color: var(--muted);
}

.label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.nav {
  display: grid;
  gap: 9px;
}

.nav-item {
  min-height: 39px;
  padding: 0 13px;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  background: linear-gradient(180deg, rgba(91, 140, 255, 0.34), rgba(91, 140, 255, 0.08));
  border-color: rgba(91, 140, 255, 0.46);
}

.session-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
}

.session-panel select,
.confirm-field input,
.login-card input {
  width: 100%;
  margin: 8px 0;
  padding: 9px 10px;
  color: var(--text);
  background: #0e131b;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.content {
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.18;
}

h2 {
  margin-bottom: 0;
  color: var(--amber);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.18;
}

h3 {
  font-size: 13.5px;
  font-weight: 600;
}

.top-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.live,
.status-pill.ok {
  color: var(--green);
  border-color: rgba(61, 220, 132, 0.25);
  background: rgba(61, 220, 132, 0.15);
}

.status-pill.warn {
  color: var(--amber);
  border-color: rgba(255, 184, 77, 0.28);
  background: rgba(255, 184, 77, 0.13);
}

.ghost-button,
.primary-button,
.danger-button,
.control-button {
  appearance: none;
  position: relative;
  overflow: hidden;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -1px 5px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.25);
  font-size: 12.5px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.ghost-button:hover,
.primary-button:hover,
.danger-button:hover,
.control-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.26);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.05));
}

.primary-button {
  background: linear-gradient(180deg, rgba(130, 168, 255, 0.65), rgba(91, 140, 255, 0.34));
  border-color: rgba(160, 190, 255, 0.55);
  color: #f2f6ff;
}

.danger-button,
.control-button.danger {
  background: linear-gradient(180deg, rgba(255, 92, 92, 0.5), rgba(136, 35, 35, 0.3));
  border-color: rgba(255, 92, 92, 0.45);
}

.login-preview,
.metric-grid,
.overview-layout,
.app-grid,
.vps-app-list,
.settings-grid,
.security-grid {
  display: grid;
  gap: 16px;
}

.login-preview {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric-card,
.panel,
.app-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 14px 16px;
}

.metric-card span,
.metric-card small,
.metric-card strong {
  display: block;
}

.metric-card strong {
  margin: 8px 0 4px;
  font-size: 22px;
  font-weight: 700;
}

.metric-card.warn {
  border-color: rgba(255, 184, 77, 0.28);
  background: linear-gradient(180deg, rgba(255, 184, 77, 0.08), rgba(18, 24, 34, 1));
}

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

.overview-layout .wide {
  grid-column: span 2;
}

.vital-panel.critical,
.metric-card.critical {
  border-color: rgba(255, 159, 67, 0.58);
  background: linear-gradient(180deg, rgba(255, 159, 67, 0.1), rgba(18, 24, 34, 1));
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, 1fr);
  min-width: 280px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}

.segmented button {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: var(--text);
  background: rgba(91, 140, 255, 0.18);
}

canvas {
  width: 100%;
  max-height: 350px;
  background: #0e131b;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.app-health,
.server-row,
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-health {
  flex-direction: column;
  align-items: stretch;
  padding: 14px 0;
  border-bottom: 1px solid #1a2330;
}

.app-health:last-child {
  border-bottom: 0;
}

.app-health > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

meter {
  width: 100%;
  height: 10px;
}

.app-gauge-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.server-table {
  display: grid;
  gap: 10px;
}

.server-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.9fr) minmax(420px, 1.8fr) minmax(260px, 0.9fr);
  padding: 14px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.server-row.critical {
  border-color: rgba(255, 159, 67, 0.62);
  background: linear-gradient(180deg, rgba(255, 159, 67, 0.09), rgba(22, 30, 43, 1));
}

.server-name strong,
.server-name small {
  display: block;
}

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

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 10px;
}

.gauge {
  min-height: 128px;
  padding: 10px;
  background: #0f1520;
  border: 1px solid #1a2330;
  border-radius: 8px;
  text-align: center;
}

.gauge.critical {
  border-color: rgba(255, 159, 67, 0.55);
  background: rgba(255, 159, 67, 0.08);
}

.gauge-ring {
  --value: 0;
  --color: var(--green);
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 7px;
  border-radius: 50%;
  background: conic-gradient(var(--color) calc(var(--value) * 1%), #263140 0);
  position: relative;
}

.gauge-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--panel2);
}

.gauge-ring strong {
  position: relative;
  z-index: 1;
  font-size: 16px;
}

.gauge span,
.gauge small {
  display: block;
}

.gauge span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.control-button {
  min-width: 78px;
}

.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.app-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.vps-app-list {
  grid-template-columns: 1fr;
}

.vps-app-card {
  padding: 16px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.vps-app-card.critical {
  border-color: rgba(255, 159, 67, 0.62);
  background: linear-gradient(180deg, rgba(255, 159, 67, 0.09), rgba(22, 30, 43, 1));
}

.vps-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

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

.process-panel {
  padding: 14px;
  background: #0f1520;
  border: 1px solid #1a2330;
  border-radius: 8px;
}

.process-panel.critical {
  border-color: rgba(255, 159, 67, 0.55);
  background: rgba(255, 159, 67, 0.08);
}

.process-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.app-card {
  padding: 18px;
}

.app-card p {
  color: var(--muted);
  line-height: 1.5;
  font-size: 12.5px;
}

.app-card .app-gauge-row {
  grid-template-columns: repeat(2, minmax(88px, 1fr));
  margin-top: 14px;
}

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

.alert-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px minmax(220px, 1.4fr);
  padding: 14px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.alert-row.high {
  border-color: rgba(255, 92, 92, 0.45);
  background: rgba(255, 92, 92, 0.08);
}

.alert-row.critical {
  border-color: rgba(255, 159, 67, 0.58);
  background: rgba(255, 159, 67, 0.1);
}

.security-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.security-grid div {
  min-height: 68px;
  display: grid;
  place-items: center;
  padding: 14px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}

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

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

.settings-nav {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.settings-nav-item {
  min-height: 38px;
  padding: 0 12px;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
}

.settings-nav-item.active,
.settings-nav-item:hover {
  color: var(--text);
  border-color: rgba(91, 140, 255, 0.46);
  background: linear-gradient(180deg, rgba(91, 140, 255, 0.34), rgba(91, 140, 255, 0.08));
}

.settings-page {
  display: none;
}

.settings-page.active {
  display: block;
}

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

.settings-form.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-form label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-form input,
.settings-form select {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #0e131b;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.settings-form input:focus,
.settings-form select:focus {
  outline: none;
  border-color: var(--blue);
}

.role-matrix {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.role-matrix article {
  padding: 14px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.role-matrix h3 {
  margin-bottom: 10px;
  color: var(--amber);
}

.role-matrix ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

dialog {
  max-width: min(460px, calc(100vw - 28px));
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.dialog-card {
  padding: 22px;
  background: var(--surface);
}

.login-card {
  display: grid;
  gap: 10px;
}

.confirm-field {
  display: block;
  margin: 18px 0;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .shell,
  .overview-layout {
    grid-template-columns: 1fr;
  }

  .overview-layout .wide {
    grid-column: auto;
  }

  .sidebar {
    position: static;
  }

  .metric-grid,
  .app-gauge-row,
  .app-grid,
  .vps-app-grid,
  .settings-grid,
  .settings-shell,
  .role-matrix,
  .security-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .server-row {
    grid-template-columns: 1fr;
  }

  .server-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .content,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .login-preview,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .app-gauge-row,
  .app-grid,
  .vps-app-grid,
  .settings-grid,
  .settings-shell,
  .settings-form,
  .settings-form.compact,
  .role-matrix,
  .security-grid,
  .alert-row,
  .server-row {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
    min-width: 0;
  }
}
