:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #151b2e;
  --panel-2: #101729;
  --line: #27324b;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #17213b 0, var(--bg) 42%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: #93c5fd; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(11, 16, 32, .84);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .2px;
}

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 28px; line-height: 1.15; }
h2 { margin-bottom: 6px; font-size: 18px; }
h3 { margin-bottom: 8px; font-size: 15px; }

.muted { color: var(--muted); }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.nowrap { white-space: nowrap; }

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

.page-head .badge { flex: 0 0 auto; }

.server {
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #141c30, #101728);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .18);
}
.server-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.server-head h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.server-head .muted { font-size: 12px; }
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
}
.srv {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
.srv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.srv-top strong { color: var(--text); font-size: 18px; }
.srv small { font-size: 11px; }
.srv-net { display: flex; gap: 14px; font-size: 12px; }
.srv-net b { color: var(--text); font-weight: 650; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1b253c;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.btn:hover { background: #22304d; }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.warn { border-color: #7c5a12; background: #3b2d0c; color: #fde68a; }
.btn.danger { border-color: #7f1d1d; background: #3a1111; color: #fecaca; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.inline { display: inline; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.stat span { display: block; font-size: 24px; font-weight: 800; }
.stat small { color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.card, .panel, .auth-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #171f35, #12192c);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .18);
}

.card { padding: 16px; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.card-head p { margin: 4px 0 0; font-size: 13px; }
.badge-row { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

.panel { padding: 18px; margin-bottom: 16px; }
.panel.narrow { max-width: 640px; }
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }
.panel-head .muted { font-size: 13px; }

.auth-card {
  max-width: 420px;
  margin: 10vh auto 0;
  padding: 28px 22px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-active { background: #0d2f1d; color: #86efac; border: 1px solid #14532d; }
.status-disabled { background: #33260a; color: #fcd34d; border: 1px solid #713f12; }
.status-revoked { background: #351013; color: #fca5a5; border: 1px solid #7f1d1d; }

.meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.meta.wide { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 0; }
.meta div { min-width: 0; }
.meta dt { margin-bottom: 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.meta dd { margin: 0; overflow-wrap: anywhere; }

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions.wrap { row-gap: 10px; }
.actions.spaced { margin-top: 14px; }

.load { display: grid; gap: 7px; margin-top: 13px; }
.load.big { gap: 10px; margin: 6px 0 16px; }
.load-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}
.load-row .dir { color: var(--muted); font-size: 12px; text-align: center; }
.load-val { color: #cbd5e1; font-size: 12px; white-space: nowrap; }
.load-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; }

.meter {
  height: 8px;
  border-radius: 999px;
  background: #0d1425;
  border: 1px solid var(--line);
  overflow: hidden;
}
.load.big .meter { height: 10px; }
.meter.slim { height: 6px; }
.meter-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  transition: width .5s ease;
}
.meter-fill.warn { background: linear-gradient(90deg, #d97706, #fbbf24); }
.meter-fill.hot { background: linear-gradient(90deg, #dc2626, #f87171); }
.meter-fill.over { background: linear-gradient(90deg, #b91c1c, #ef4444); }

.quota { display: grid; gap: 5px; margin-top: 12px; }
.quota.big { margin: 0 0 6px; }
.quota-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.quota-top .over { color: #fca5a5; font-weight: 700; }
.quota-none { margin: 0 0 6px; font-size: 12px; }
.quota-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.quota-form label { width: 140px; font-size: 12px; }
.notice.small { margin-top: 10px; padding: 10px 12px; font-size: 12px; }
.badge.status-over { background: #351013; color: #fca5a5; border: 1px solid #7f1d1d; }
[hidden] { display: none !important; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .14);
}

.table-wrap.devices { margin-top: 14px; }
.share { min-width: 160px; }
.share .meter { margin-bottom: 5px; }
.share .muted { font-size: 11px; }
.share .badge { margin-bottom: 6px; }
.device-action { margin-top: 8px; }
.hint { margin: 10px 0 0; color: #64748b; font-size: 11px; }

.stack { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #cbd5e1; font-size: 13px; font-weight: 600; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #0d1425;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid #1d4ed8; outline-offset: 1px; }

.field { margin-bottom: 16px; }
.field > label { margin-bottom: 7px; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { min-width: 0; }

.notes {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.notes p { margin-bottom: 0; white-space: pre-wrap; color: #cbd5e1; }

.notice {
  margin: 0;
  padding: 14px;
  border: 1px solid #713f12;
  border-radius: 12px;
  background: #2b210b;
  color: #fde68a;
}
.notice.danger { border-color: #7f1d1d; background: #2d1112; color: #fecaca; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }

.tag {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 7px;
  background: #1e293b;
  color: #cbd5e1;
  font-size: 11px;
}

.empty { padding: 28px 10px; text-align: center; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 11px 13px; border-radius: 10px; font-size: 14px; }
.flash.error { background: #3a1111; border: 1px solid #7f1d1d; color: #fecaca; }
.flash.ok { background: #0d2f1d; border: 1px solid #14532d; color: #bbf7d0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 680px) {
  .wrap { padding: 18px 12px 36px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta { grid-template-columns: 1fr; }
  .copyrow { flex-direction: column; }
  .topbar { padding: 12px 14px; }
  .panel { padding: 14px; }
  .load-row { grid-template-columns: 14px minmax(0, 1fr); }
  .load-row .load-val { grid-column: 2; }
}
