:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: #111722;
  --panel-2: #171e2b;
  --line: #273044;
  --text: #f5f7fb;
  --muted: #8d98ad;
  --accent: #8b5cf6;
  --accent-2: #2dd4bf;
  --danger: #fb7185;
  --warning: #fbbf24;
  --success: #34d399;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 10%, #21193a 0, var(--bg) 42%); }
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 22px; background: rgba(17, 23, 34, .94); box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 760; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), #4f46e5); box-shadow: 0 0 28px rgba(139, 92, 246, .3); }
.login-card h1 { margin: 32px 0 8px; font-size: 30px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field label { color: #cbd3e1; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #0c111a; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, .13); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; background: var(--accent); color: white; font-weight: 720; cursor: pointer; }
.button:hover { filter: brightness(1.08); }
.button:disabled { opacity: .55; cursor: progress; }
.button.secondary { background: var(--panel-2); border-color: var(--line); color: #e9edf6; }
.button.danger { background: rgba(251, 113, 133, .14); border-color: rgba(251, 113, 133, .35); color: #fecdd3; }
.button.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.error-message { min-height: 20px; color: #fda4af; font-size: 13px; }

.admin-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; border-right: 1px solid var(--line); background: #0b0f17; overflow-y: auto; }
.sidebar .brand { padding: 0 8px 24px; }
.nav { display: grid; gap: 3px; }
.nav a { padding: 10px 12px; border-radius: 9px; color: #aab4c7; font-size: 14px; }
.nav a:hover, .nav a.active { color: white; background: var(--panel-2); }
.sidebar-footer { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.admin-main { min-width: 0; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: rgba(8, 11, 18, .85); backdrop-filter: blur(14px); }
.topbar strong { display: block; }
.topbar small { color: var(--muted); }
.page { padding: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.card h2, .card h3 { margin: 0 0 14px; }
.metric-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.metric-value { margin-top: 9px; font-size: 27px; font-weight: 760; letter-spacing: -.03em; }
.metric-detail { margin-top: 7px; color: var(--muted); font-size: 12px; }
.charts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.chart { min-height: 310px; }
.chart canvas { width: 100%; height: 240px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.legend i { width: 9px; height: 9px; display: inline-block; margin-right: 5px; border-radius: 99px; }
.dot-purple { background: #8b5cf6; }
.dot-teal { background: #2dd4bf; }
.dot-green { background: #34d399; }
.dot-red { background: #fb7185; }
.dot-yellow { background: #fbbf24; }
.mt-16 { margin-top: 16px; }
.dashboard-warning { margin-bottom: 16px; border-color: rgba(251, 191, 36, .35); }
.dashboard-warning p:last-child { margin-bottom: 0; }

.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, 1fr)) auto; gap: 10px; margin-bottom: 16px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; padding: 12px 14px; text-align: left; color: #aeb8ca; background: #151b27; white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: #c8d0df; background: #131925; font-size: 11px; white-space: nowrap; }
.badge.active, .badge.finished, .badge.success, .badge.ok { color: #a7f3d0; border-color: rgba(52, 211, 153, .28); background: rgba(52, 211, 153, .09); }
.badge.failed, .badge.disabled, .badge.error, .badge.denied { color: #fecdd3; border-color: rgba(251, 113, 133, .28); background: rgba(251, 113, 133, .09); }
.badge.suspended, .badge.warning, .badge.degraded { color: #fde68a; border-color: rgba(251, 191, 36, .28); background: rgba(251, 191, 36, .09); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.details .wide { grid-column: 1 / -1; }
.definition { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(0, 1.3fr); gap: 9px 16px; margin: 0; }
.definition dt { color: var(--muted); }
.definition dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.empty, .loading { padding: 32px; text-align: center; color: var(--muted); }
.service-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.service { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.log-lines { max-height: 420px; overflow: auto; padding: 14px; border-radius: 10px; background: #070a10; color: #bcc6d8; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.55 ui-monospace, monospace; }
dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--panel); box-shadow: 0 30px 90px #000; }
dialog::backdrop { background: rgba(0, 0, 0, .72); }
.dialog-content { padding: 22px; }
.dialog-content h2 { margin-top: 0; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .service-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav a { padding: 8px; text-align: center; font-size: 12px; }
  .sidebar-footer { display: none; }
  .topbar, .page { padding-left: 18px; padding-right: 18px; }
  .cards, .charts, .details, .service-list { grid-template-columns: 1fr; }
  .details .wide { grid-column: auto; }
  .filters { grid-template-columns: 1fr; }
}
