:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-border: #e5e7eb;
  --text: #0f172a;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --sidebar: #0f172a;
  --success: #10b981;
  --warn: #f59e0b;
  --error: #ef4444;
}

* { box-sizing:border-box; }

body {
  margin:0;
  font-family:"Segoe UI", Tahoma, sans-serif;
  background:var(--bg);
  color:var(--text);
}

a { color:inherit; }

.auth-container {
  width:360px;
  margin:120px auto;
  background:var(--panel);
  padding:26px;
  border-radius:14px;
  border:1px solid var(--panel-border);
  box-shadow:0 18px 40px rgba(15,23,42,0.12);
}

.auth-container input {
  width:100%;
  padding:12px;
  margin:10px 0;
  border-radius:10px;
  border:1px solid #cbd5e1;
  background:linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow:inset 0 1px 2px rgba(15,23,42,0.08);
  transition:border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-container input:focus {
  outline:none;
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(37,99,235,0.18), inset 0 1px 2px rgba(15,23,42,0.06);
}

.auth-container input::placeholder {
  color:#94a3b8;
}

.auth-container button {
  width:100%;
  padding:12px;
  background:linear-gradient(135deg, var(--accent), var(--accent-strong));
  border:none;
  border-radius:10px;
  color:white;
  font-weight:600;
  cursor:pointer;
}

.wrapper {
  display:flex;
  min-height:100vh;
  background:var(--bg);
}

.sidebar {
  width:250px;
  background:linear-gradient(180deg, var(--sidebar), #111827);
  color:#e5e7eb;
  padding:24px;
  display:flex;
  flex-direction:column;
  gap:12px;
  box-shadow:6px 0 24px rgba(0,0,0,0.22);
}

.sidebar h2 {
  margin:0 0 12px;
  color:#fff;
  letter-spacing:0.5px;
}

.sidebar a {
  display:block;
  padding:12px 14px;
  color:#e5e7eb;
  text-decoration:none;
  border-radius:10px;
  transition:all 0.15s ease;
}

.sidebar a:hover {
  background:rgba(255,255,255,0.06);
}

.sidebar a.active {
  background:rgba(37,99,235,0.22);
  color:#fff;
  box-shadow:0 10px 24px rgba(37,99,235,0.22);
}

.content {
  flex-grow:1;
  padding:32px 36px 40px;
  display:flex;
  flex-direction:column;
  gap:18px;
}

.card {
  padding:20px;
  background:var(--panel);
  border-radius:12px;
  border:1px solid var(--panel-border);
  box-shadow:0 12px 30px rgba(15,23,42,0.12);
}

.page-header {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  flex-wrap:wrap;
  gap:16px;
}

.header-actions {
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.header-action-form {
  margin:0;
}

.page-title h1 {
  margin:4px 0;
}

.page-title .subtext {
  margin:6px 0 0;
}

.eyebrow {
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:var(--muted);
  font-size:12px;
  margin:0 0 4px;
}

.subtext {
  color:var(--muted);
  margin:0;
}

.header-metrics {
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.chip {
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  background:rgba(37,99,235,0.08);
  border:1px solid var(--panel-border);
  border-radius:999px;
  font-weight:600;
}

.chip .dot {
  width:10px;
  height:10px;
  border-radius:50%;
  background:var(--accent);
  box-shadow:0 0 0 4px rgba(37,99,235,0.12);
}

.alert {
  padding:14px 16px;
  border-radius:12px;
  border:1px solid #fecdd3;
  background:#fff6f6;
  color:#b91c1c;
}

.alert-success {
  border-color:#bbf7d0;
  background:#f0fdf4;
  color:#15803d;
}

.alert-error {
  border-color:#fecdd3;
  background:#fff6f6;
  color:#b91c1c;
}

.empty-state {
  padding:28px;
  border:1px dashed var(--panel-border);
  border-radius:14px;
  background:var(--panel);
  color:var(--muted);
}

.server-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:16px;
}

.server-card {
  position:relative;
  overflow:hidden;
  padding:18px;
  background:var(--panel);
  border:1px solid var(--panel-border);
  border-radius:14px;
  box-shadow:0 16px 32px rgba(15,23,42,0.16);
  cursor:pointer;
  transition:transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.server-card:after {
  content:"";
  position:absolute;
  left:0;
  top:0;
  width:100%;
  height:4px;
  background:linear-gradient(90deg, var(--accent), var(--accent-strong));
  opacity:0.9;
}

.server-card:hover,
.server-card:focus-visible {
  transform:translateY(-2px);
  box-shadow:0 18px 34px rgba(15,23,42,0.22);
  border-color:rgba(37,99,235,0.4);
  outline:none;
}

.server-card:focus-visible {
  box-shadow:0 0 0 3px rgba(37,99,235,0.25), 0 18px 34px rgba(15,23,42,0.22);
}

.server-card-header {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:16px;
}

.server-actions {
  display:flex;
  align-items:center;
  gap:8px;
}

.server-id {
  margin:4px 0 0;
  font-size:18px;
  letter-spacing:0.3px;
}

.status-badge {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 11px;
  border-radius:999px;
  font-weight:600;
  font-size:13px;
  background:rgba(59,130,246,0.12);
  color:#1d4ed8;
}

.status-badge .status-dot {
  width:9px;
  height:9px;
  border-radius:50%;
  background:currentColor;
  box-shadow:0 0 0 4px rgba(59,130,246,0.14);
}

.status-running { background:rgba(16,185,129,0.15); color:#047857; }
.status-starting { background:rgba(245,158,11,0.18); color:#b45309; }
.status-stopped { background:rgba(156,163,175,0.2); color:#374151; }
.status-unknown { background:rgba(59,130,246,0.12); color:#1d4ed8; }
.status-online { background:rgba(16,185,129,0.15); color:#047857; }
.status-ready { background:rgba(16,185,129,0.15); color:#047857; }
.status-idle { background:rgba(59,130,246,0.12); color:#1d4ed8; }
.status-offline { background:rgba(239,68,68,0.16); color:#b91c1c; }

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

.agent-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(320px, 1fr));
  gap:16px;
}

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

.agent-meta .ram-block {
  grid-column:1 / -1;
  padding:10px 12px;
  border:1px dashed var(--panel-border);
  border-radius:12px;
  background:linear-gradient(135deg, rgba(37,99,235,0.04), rgba(37,99,235,0.08));
}

.ram-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
}

.meter {
  position:relative;
  width:100%;
  height:9px;
  border-radius:999px;
  background:#e5e7eb;
  overflow:hidden;
  margin:8px 0;
}

.meter-fill {
  position:absolute;
  left:0;
  top:0;
  height:100%;
  background:linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-radius:999px;
  box-shadow:0 4px 12px rgba(37,99,235,0.25);
}

.template-footer {
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px 16px;
  margin-top:12px;
  border-top:1px dashed var(--panel-border);
  padding-top:12px;
}

.label {
  margin:0;
  text-transform:uppercase;
  letter-spacing:0.05em;
  font-size:11px;
  color:var(--muted);
}

.value {
  margin:2px 0 0;
  font-weight:700;
  color:var(--text);
}

.template-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(320px, 1fr));
  gap:16px;
}

.stat-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
  gap:16px;
}

.dashboard-sections {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(340px, 1fr));
  gap:18px;
}

.settings-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(320px, 1fr));
  gap:20px;
  align-items:start;
}

.settings-card {
  position:relative;
  overflow:hidden;
}

.settings-card:before {
  content:"";
  position:absolute;
  left:0;
  top:0;
  width:100%;
  height:4px;
  background:linear-gradient(90deg, var(--accent), var(--accent-strong));
  opacity:0.9;
}

.settings-card .section-heading {
  padding-bottom:14px;
  border-bottom:1px dashed var(--panel-border);
  margin-bottom:16px;
}

.settings-form {
  margin-top:0;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.form-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:12px 16px;
}

.form-group {
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:12px;
  border-radius:12px;
  border:1px solid var(--panel-border);
  background:linear-gradient(135deg, #f8fafc, #eef2ff);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,0.5);
}

.form-group label {
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:0.06em;
  color:var(--muted);
  font-weight:700;
}

.form-group input {
  width:100%;
  padding:12px 12px;
  border-radius:10px;
  border:1px solid #cbd5e1;
  font-size:14px;
  background:linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow:inset 0 1px 2px rgba(15,23,42,0.08);
  transition:border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form-group input:focus {
  outline:none;
  border-color:var(--accent);
  background:#fff;
  box-shadow:0 0 0 3px rgba(37,99,235,0.18), inset 0 1px 2px rgba(15,23,42,0.06);
}

.form-group input::placeholder {
  color:#94a3b8;
}

.form-actions {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  padding-top:6px;
}

.form-hint {
  margin:0;
  color:var(--muted);
  font-size:12px;
}

.section-heading h3 {
  margin:4px 0 2px;
}

.highlight-card {
  display:flex;
  flex-direction:column;
  gap:10px;
}

.highlight-body {
  display:grid;
  grid-template-columns:140px 1fr;
  gap:14px;
  align-items:center;
}

.ram-legend {
  display:flex;
  flex-direction:column;
  gap:10px;
}

.legend-row {
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--panel-border);
  background:linear-gradient(135deg, rgba(37,99,235,0.04), rgba(37,99,235,0.08));
}

.mini-dot {
  width:10px;
  height:10px;
  border-radius:50%;
  background:var(--accent);
  box-shadow:0 0 0 4px rgba(37,99,235,0.12);
}

.mini-muted {
  background:var(--muted);
  box-shadow:0 0 0 4px rgba(107,114,128,0.12);
}

.list-card .list {
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.list-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--panel-border);
  background:linear-gradient(135deg, #f8fafc, #eef2ff);
  box-shadow:0 10px 26px rgba(15,23,42,0.12);
}

.list-left {
  display:flex;
  align-items:flex-start;
  gap:10px;
}

.list-title {
  margin:0;
  font-weight:700;
}

.list-sub {
  margin:2px 0 0;
  color:var(--muted);
}

.list-right {
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:6px;
  min-width:150px;
}

.inline-form { margin:0; }

.btn-small {
  padding:6px 10px;
  font-size:12px;
  border-radius:8px;
  box-shadow:0 8px 18px rgba(37,99,235,0.18);
}

.list-meta {
  margin:0;
  color:var(--muted);
  font-weight:600;
}

.status-pill {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  font-weight:700;
  background:rgba(37,99,235,0.08);
  color:var(--text);
}

.pill-muted {
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  background:rgba(15,23,42,0.06);
  color:var(--muted);
  font-weight:700;
}

.status-pill .mini-dot {
  box-shadow:none;
}

.stat-card {
  display:flex;
  flex-direction:column;
  gap:6px;
}

.stat-value {
  margin:0;
  font-size:32px;
  letter-spacing:0.3px;
}

.stat-pill {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  background:rgba(15,23,42,0.06);
  font-weight:600;
  color:var(--text);
  width:max-content;
}

.dot {
  width:9px;
  height:9px;
  border-radius:50%;
  background:var(--accent);
  box-shadow:0 0 0 4px rgba(37,99,235,0.12);
}

.dot-online {
  background:var(--success);
  box-shadow:0 0 0 4px rgba(16,185,129,0.16);
}

.ram-card {
  display:grid;
  grid-template-columns:140px 1fr;
  align-items:center;
  gap:14px;
}

.ram-visual {
  display:flex;
  justify-content:center;
}

.progress-circle {
  --value:0;
  width:120px;
  aspect-ratio:1/1;
  border-radius:50%;
  background:conic-gradient(var(--accent) calc(var(--value) * 1%), #e5e7eb 0);
  display:grid;
  place-items:center;
  position:relative;
  box-shadow:0 8px 24px rgba(37,99,235,0.16);
}

.progress-center {
  width:68%;
  height:68%;
  border-radius:50%;
  background:var(--panel);
  display:grid;
  place-items:center;
  box-shadow:inset 0 0 0 1px var(--panel-border);
  text-align:center;
  padding:8px;
}

.progress-value {
  font-weight:800;
  font-size:20px;
}

.progress-sub {
  margin:0;
  color:var(--muted);
  font-size:12px;
}

.ram-details h2 {
  margin:4px 0 2px;
}

.ram-details .subtext {
  margin-top:4px;
}

.api-hint {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:14px;
}

.api-meta {
  display:flex;
  gap:18px;
  flex-wrap:wrap;
}

.masked-key {
  letter-spacing:0.1em;
}

@media (max-width: 720px) {
  .ram-card {
    grid-template-columns:1fr;
  }
  .ram-visual {
    justify-content:flex-start;
  }
  .highlight-body {
    grid-template-columns:1fr;
  }
}

.btn {
  background:linear-gradient(135deg, var(--accent), var(--accent-strong));
  color:#fff;
  border:none;
  border-radius:10px;
  padding:10px 14px;
  font-weight:700;
  cursor:pointer;
  box-shadow:0 12px 24px rgba(37,99,235,0.26);
  transition:transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:hover {
  transform:translateY(-1px);
  box-shadow:0 14px 28px rgba(37,99,235,0.32);
}

.btn:active {
  transform:translateY(0);
  box-shadow:0 10px 20px rgba(37,99,235,0.22);
}

.btn-danger {
  background:linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow:0 12px 24px rgba(239,68,68,0.3);
}

.btn-ghost {
  background:transparent;
  color:var(--text);
  border:1px solid var(--panel-border);
  box-shadow:none;
}

.modal-backdrop {
  position:fixed;
  inset:0;
  background:rgba(15,23,42,0.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:1000;
}

.modal-backdrop.active {
  display:flex;
}

.modal {
  background:var(--panel);
  border:1px solid var(--panel-border);
  border-radius:14px;
  padding:20px 22px;
  width:100%;
  max-width:420px;
  box-shadow:0 20px 44px rgba(15,23,42,0.25);
}

.modal-wide { max-width:960px; }

.modal-header {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:10px;
}

.modal-header-actions {
  display:flex;
  align-items:center;
  gap:10px;
}

.log-window {
  background:#0b1224;
  border:1px solid #111827;
  border-radius:12px;
  padding:10px 12px;
  margin-top:10px;
  min-height:260px;
  max-height:420px;
  overflow-y:auto;
  font-family:"SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  color:#e5e7eb;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,0.02);
}

.log-line {
  display:grid;
  grid-template-columns:110px 80px 1fr;
  gap:10px;
  align-items:flex-start;
  padding:6px 0;
  border-bottom:1px solid rgba(255,255,255,0.04);
}

.log-line:last-child { border-bottom:none; }

.log-time {
  color:#a5b4fc;
  font-size:12px;
}

.log-stream {
  text-transform:uppercase;
  letter-spacing:0.08em;
  color:#38bdf8;
  font-weight:700;
  font-size:11px;
}

.log-stream-system { color:#fbbf24; }
.log-stream-stderr { color:#fb7185; }

.log-text {
  white-space:pre-wrap;
  word-break:break-word;
  font-size:13px;
  color:#e5e7eb;
}

.log-placeholder {
  margin:6px 0;
  color:#cbd5e1;
}

.command-form {
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.command-row {
  display:flex;
  gap:10px;
}

.command-row input {
  flex:1;
  padding:11px 12px;
  border-radius:10px;
  border:1px solid var(--panel-border);
  font-size:14px;
}

.command-row input:focus {
  outline:2px solid rgba(37,99,235,0.28);
  border-color:var(--accent);
}

.muted-hint {
  margin:0;
  color:var(--muted);
  font-size:12px;
}

.modal-actions {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:16px;
}

@media (max-width: 640px) {
  .log-line {
    grid-template-columns:1fr;
    gap:6px;
  }
}

body.no-scroll { overflow:hidden; }
