:root {
  color-scheme: dark;
  --bg: #080a0b;
  --panel: #0f1214;
  --surface: #15191c;
  --surface-hover: #1b2024;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #f2f5f4;
  --muted: #8d969f;
  --subtle: #626b73;
  --accent: #62b946;
  --accent-bright: #78d65a;
  --accent-soft: rgba(98, 185, 70, 0.14);
  --danger: #e05252;
  --danger-soft: rgba(224, 82, 82, 0.13);
  --warning: #e9b44c;
  --radius: 10px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv01", "ss03";
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 70% -20%, rgba(98, 185, 70, 0.06), transparent 38%), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }
::selection { color: #081006; background: var(--accent-bright); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); font-weight: 400; }
.eyebrow { margin: 0 0 7px; color: var(--accent-bright); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.55; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(420px, 100%); padding: 38px; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(145deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018)); box-shadow: var(--shadow); }
.login-card h1 { margin: 5px 0 9px; font-size: 34px; font-weight: 590; letter-spacing: -0.8px; }
.login-copy { margin: 0 0 28px; color: var(--muted); line-height: 1.6; }
.login-footnote { margin: 22px 0 0; color: var(--subtle); font-size: 12px; text-align: center; }
.stack { display: grid; gap: 10px; }
.stack label, .confirm-dialog label { color: #c9ced2; font-size: 13px; font-weight: 510; }
input { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255,255,255,0.025); color: var(--text); transition: border-color 150ms ease, background 150ms ease; }
input:hover { border-color: var(--border-strong); }
input:focus { border-color: rgba(98,185,70,0.7); background: rgba(255,255,255,0.04); }
.form-error { min-height: 20px; margin: 2px 0 0; color: #ff8080; font-size: 13px; }

.brand-mark { position: relative; width: 44px; height: 44px; transform: rotate(30deg) skewY(-8deg); }
.brand-mark span { position: absolute; inset: 7px; border: 1px solid rgba(255,255,255,0.18); background: var(--accent); box-shadow: inset 0 -12px 0 rgba(0,0,0,0.18); }
.brand-mark span:nth-child(2) { transform: translate(7px, 7px); opacity: 0.48; }
.brand-mark span:nth-child(3) { transform: translate(14px, 14px); opacity: 0.2; }
.brand-mark.small { width: 34px; height: 34px; transform: rotate(30deg) skewY(-8deg) scale(0.78); transform-origin: left center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 12px 16px; border-right: 1px solid var(--border); background: rgba(11, 13, 15, 0.94); backdrop-filter: blur(18px); }
.brand-row { display: flex; align-items: center; gap: 10px; padding: 0 9px 25px; }
.brand-row strong, .brand-row small { display: block; }
.brand-row strong { font-size: 15px; font-weight: 590; }
.brand-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.nav-list { display: grid; gap: 5px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #aeb5bb; font-size: 13px; text-align: left; cursor: pointer; }
.nav-item span { width: 18px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 17px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,0.035); color: var(--text); }
.nav-item.active { border-color: rgba(255,255,255,0.05); background: rgba(255,255,255,0.055); color: var(--text); box-shadow: inset 2px 0 var(--accent); }
.nav-item.active span { color: var(--accent-bright); }
.sidebar-meta { margin-top: auto; display: flex; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,0.02); }
.sidebar-meta strong, .sidebar-meta small { display: block; font-size: 10px; }
.sidebar-meta small { margin-top: 3px; color: var(--subtle); }

.main-content { min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; max-width: 1440px; margin: 0 auto 24px; }
.title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.title-line h1 { margin: 0; font-size: clamp(23px, 2.5vw, 32px); font-weight: 590; letter-spacing: -0.7px; }
.server-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; font-weight: 590; }
.status-badge.online { border-color: rgba(98,185,70,0.26); background: var(--accent-soft); color: var(--accent-bright); }
.status-badge.offline { border-color: rgba(224,82,82,0.3); background: var(--danger-soft); color: #ff8585; }
.status-badge.pending { color: var(--muted); }

.panel { max-width: 1440px; margin: 0 auto; animation: panel-in 180ms ease; }
@keyframes panel-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; margin-bottom: 11px; }
.metric-card, .card { border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgba(255,255,255,0.037), rgba(255,255,255,0.016)); box-shadow: 0 0 0 1px rgba(0,0,0,0.08); }
.metric-card { min-height: 171px; padding: 18px; }
.card-label { display: flex; justify-content: space-between; align-items: center; color: #cdd2d5; font-size: 12px; font-weight: 510; }
.metric-chip { padding: 3px 7px; border: 1px solid var(--border); border-radius: 5px; background: rgba(255,255,255,0.03); color: #c3c9ce; font: 11px ui-monospace, monospace; }
.metric-value { display: block; margin: 19px 0 5px; font-size: 27px; font-weight: 590; letter-spacing: -0.45px; }
.metric-value.small { font-size: 23px; }
.metric-card p, .card-body > p { margin: 0; color: var(--muted); font-size: 12px; }
.meter { height: 5px; margin-top: 26px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,0.05); }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3e8d33, var(--accent-bright)); transition: width 300ms ease; }
.load-scale { height: 36px; display: flex; align-items: end; gap: 4px; margin-top: 15px; }
.load-scale i { flex: 1; height: 20%; border-radius: 2px 2px 0 0; background: rgba(98,185,70,0.22); }
.load-scale i:nth-child(2), .load-scale i:nth-child(7) { height: 42%; }
.load-scale i:nth-child(3), .load-scale i:nth-child(6) { height: 66%; }
.load-scale i:nth-child(4), .load-scale i:nth-child(5) { height: 91%; background: rgba(98,185,70,0.5); }

.overview-grid { display: grid; grid-template-columns: 0.9fr 1.1fr 1.1fr; gap: 11px; margin-bottom: 11px; }
.card-header { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card-header h3 { margin: 0; font-size: 13px; font-weight: 590; }
.card-body { padding: 16px; }
.state-line { display: flex; align-items: center; gap: 9px; min-height: 34px; }
.status-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(98,185,70,0.08); }
.status-dot.pending { background: var(--subtle); box-shadow: none; }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 0 4px rgba(224,82,82,0.08); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 17px 0 15px; }
.button-row.end { justify-content: flex-end; }
.button { min-height: 37px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 13px; border: 1px solid var(--border-strong); border-radius: 7px; background: rgba(255,255,255,0.04); color: #e5e8e7; font-size: 12px; font-weight: 510; cursor: pointer; transition: background 140ms ease, border-color 140ms ease, transform 140ms ease; }
.button:hover:not(:disabled) { border-color: rgba(255,255,255,0.19); background: rgba(255,255,255,0.075); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: 0.45; cursor: wait; }
.button.primary, .button.success { border-color: rgba(116,212,84,0.45); background: linear-gradient(#66bb4b, #4c9d37); color: #071006; }
.button.primary:hover:not(:disabled), .button.success:hover:not(:disabled) { background: linear-gradient(#78d65a, #58ad40); }
.button.danger { border-color: rgba(224,82,82,0.45); background: var(--danger-soft); color: #ff8989; }
.button.danger:hover:not(:disabled) { background: rgba(224,82,82,0.23); }
.button.wide { width: 100%; margin-top: 7px; }
.text-button { padding: 4px 0; border: 0; background: none; color: var(--accent-bright); font-size: 11px; cursor: pointer; }
.text-button:hover { text-decoration: underline; }

.list { min-height: 80px; }
.list-row { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(255,255,255,0.045); font-size: 12px; }
.list-row:last-child { border-bottom: 0; }
.list-row-main { min-width: 0; display: flex; align-items: center; gap: 9px; }
.avatar { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 5px; background: rgba(98,185,70,0.13); color: var(--accent-bright); font-size: 11px; font-weight: 590; }
.list-row small { color: var(--muted); }
.compact .list-row { min-height: 32px; }
.empty-state { margin: 18px 0; color: var(--subtle); font-size: 12px; }
.backup-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.backup-summary div { padding: 9px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255,255,255,0.02); }
.backup-summary span, .backup-summary strong { display: block; }
.backup-summary span { color: var(--muted); font-size: 10px; }
.backup-summary strong { margin-top: 3px; font-size: 12px; }

.console-card { overflow: hidden; }
.console-output { min-height: 215px; max-height: 330px; margin: 0; padding: 15px 17px; overflow: auto; border: 0; background: #090b0c; color: #aeb7b0; font: 11px/1.58 "JetBrains Mono", "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; word-break: break-word; scrollbar-color: #353b3e transparent; }
.console-output.full { min-height: 56vh; max-height: 66vh; }
.console-page { overflow: hidden; }
.console-form { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 11px 13px; border-top: 1px solid var(--border); background: #0c0f10; }
.console-form span { color: var(--accent-bright); font-family: ui-monospace, monospace; }
.console-form input { min-height: 37px; border: 0; background: transparent; font-family: ui-monospace, monospace; }
.command-result { min-height: 30px; margin: 0; padding: 7px 15px 11px; background: #0c0f10; color: var(--muted); font: 11px ui-monospace, monospace; }

.section-heading { min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-heading h2 { margin: 0; font-size: 28px; font-weight: 590; letter-spacing: -0.5px; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 15px; }
.access-list .list-row { min-height: 44px; }
.icon-action { min-width: 30px; min-height: 29px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: #ff8585; font-size: 11px; cursor: pointer; }
.icon-action:hover { background: var(--danger-soft); }
.policy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.policy-grid span, .policy-grid strong { display: block; }
.policy-grid span { margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.policy-grid strong { font-size: 13px; }
.callout { margin: 0 16px 16px !important; padding: 11px; border: 1px solid rgba(233,180,76,0.18); border-radius: 7px; background: rgba(233,180,76,0.06); color: #d2bc88 !important; line-height: 1.5; }
.table-card { margin-top: 11px; overflow: hidden; }
.backup-table-row { display: grid; grid-template-columns: minmax(230px, 1fr) 140px 110px 90px; gap: 12px; align-items: center; min-height: 47px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 12px; }
.backup-table-row:last-child { border-bottom: 0; }
.checksum-ok { color: var(--accent-bright); }
.checksum-bad { color: #f08b82; font-weight: 600; }
.details-list { margin: 0; }
.details-list div { display: grid; grid-template-columns: 130px 1fr; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.details-list div:last-child { border-bottom: 0; }
.details-list dt { color: var(--muted); font-size: 12px; }
.details-list dd { margin: 0; font: 12px ui-monospace, monospace; overflow-wrap: anywhere; }

.settings-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 0.85fr); gap: 11px; align-items: start; }
.settings-card { overflow: hidden; }
.settings-card .card-header > div p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; align-content: start; gap: 7px; color: #c9ced2; font-size: 12px; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-weight: 550; }
.field small, .toggle-field small { display: block; color: var(--muted); font-size: 10px; line-height: 1.45; }
.field input, .field select { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255,255,255,0.025); color: var(--text); }
.field select { color-scheme: dark; }
.field input:focus, .field select:focus { border-color: rgba(98,185,70,0.7); background: rgba(255,255,255,0.04); }
.toggle-field { min-height: 66px; display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: rgba(255,255,255,0.018); cursor: pointer; }
.toggle-field input { width: 17px; min-height: 17px; margin: 2px 0 0; accent-color: var(--accent-bright); }
.toggle-field strong { display: block; margin-bottom: 4px; font-size: 12px; }
.memory-setting { min-height: 145px; }
.settings-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255,255,255,0.018); }
.settings-actions p { margin: 0; color: var(--muted); font-size: 12px; }
.restart-callout { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 11px; padding: 15px 16px; border: 1px solid rgba(233,180,76,0.28); border-radius: var(--radius); background: rgba(233,180,76,0.07); }
.restart-callout strong { color: #efd18d; font-size: 13px; }
.restart-callout p { margin: 4px 0 0; color: #c9b98f; font-size: 11px; }
.settings-meta { margin-top: 11px; }

.confirm-dialog { width: min(460px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 12px; background: #141719; color: var(--text); box-shadow: 0 26px 90px rgba(0,0,0,0.58); }
.confirm-dialog::backdrop { background: rgba(0,0,0,0.76); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 24px; }
.confirm-dialog h2 { margin: 0 0 10px; font-size: 22px; }
.confirm-dialog p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.55; }
.confirm-dialog input { margin-top: 8px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(420px, calc(100% - 40px)); padding: 11px 14px; border: 1px solid var(--border-strong); border-radius: 8px; background: #1b2021; box-shadow: var(--shadow); color: var(--text); font-size: 12px; }
.toast.error { border-color: rgba(224,82,82,0.4); color: #ff9292; }

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .overview-grid > :last-child { grid-column: 1 / -1; }
  .settings-form { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; z-index: 10; width: 100%; height: auto; padding: 9px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand-row, .sidebar-meta { display: none; }
  .nav-list { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; }
  .nav-item { width: auto; min-width: max-content; padding: 9px 10px; }
  .nav-item span { display: none; }
  .nav-item.active { box-shadow: inset 0 -2px var(--accent); }
  .main-content { padding: 18px 14px 36px; }
  .topbar { align-items: center; }
  .server-meta { display: none; }
  .metrics-grid, .overview-grid, .two-column { grid-template-columns: 1fr; }
  .overview-grid > :last-child { grid-column: auto; }
  .metric-card { min-height: 145px; }
  .section-heading { min-height: 66px; }
  .backup-table-row { grid-template-columns: 1fr auto; }
  .backup-table-row > :nth-child(2), .backup-table-row > :nth-child(4) { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .settings-actions, .restart-callout { align-items: stretch; flex-direction: column; }
}

@media (max-width: 470px) {
  .login-shell { padding: 14px; }
  .login-card { padding: 28px 22px; }
  .title-line h1 { max-width: 250px; font-size: 21px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .topbar .button { padding-inline: 10px; }
  .button-row .button { flex: 1; }
  .policy-grid { grid-template-columns: 1fr; }
  .console-form { grid-template-columns: auto minmax(0, 1fr); }
  .console-form .button { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
