:root {
  --bg: #0f1419;
  --bg-elev: #1a222c;
  --bg-card: #1e2833;
  --border: #2d3a47;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9cf0;
  --accent-2: #2dd4bf;
  --ok: #22c55e;
  --warn: #eab308;
  --danger: #f97316;
  --critical: #ef4444;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2a3a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
code { font-family: var(--mono); font-size: 0.9em; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand img { border-radius: 6px; }
.brand strong { display: block; letter-spacing: 0.02em; }
.brand .muted { font-size: 0.8rem; }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }
.user { color: var(--muted); font-size: 0.9rem; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  border-color: transparent;
  font-weight: 600;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.flash.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-card {
  width: min(400px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  text-align: center;
}
.login-card .logo { width: 120px; height: auto; margin-bottom: 0.5rem; }
.login-card h1 { margin: 0.25rem 0; font-size: 1.4rem; }
.btn-o2w {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(61, 156, 240, 0.45);
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff !important;
  font-weight: 650;
  text-decoration: none !important;
}
.btn-o2w:hover { filter: brightness(1.08); }
.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-form { text-align: left; margin-top: 1.25rem; display: grid; gap: 0.4rem; }
.login-hint { margin-top: 1rem; font-size: 0.8rem; }

.login-form label { font-size: 0.85rem; color: var(--muted); }
.login-form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  margin-bottom: 0.5rem;
}
.login-form button { width: 100%; margin-top: 0.5rem; padding: 0.7rem; }

.filters {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.filter-row {
  display: grid;
  grid-template-columns: 2fr 1fr 0.6fr 0.8fr;
  gap: 0.75rem;
}
.filters label { display: grid; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.filters label.grow { min-width: 0; }
.filters input, .filters select {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
}

.site-grid { display: grid; gap: 0.9rem; }
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.site-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.site-card-head h2 {
  margin: 0;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}
.metric {
  background: rgba(0,0,0,0.18);
  border-radius: 10px;
  padding: 0.65rem;
  min-height: 88px;
}
.metric-label {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.metric-value { font-size: 1.05rem; font-weight: 650; }
.metric-limit { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }
.version-line { margin-top: 0.25rem; font-size: 0.85rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-ok { background: rgba(34,197,94,0.15); color: #86efac; border-color: rgba(34,197,94,0.3); }
.badge-warn { background: rgba(234,179,8,0.15); color: #fde047; border-color: rgba(234,179,8,0.3); }
.badge-danger { background: rgba(249,115,22,0.15); color: #fdba74; border-color: rgba(249,115,22,0.3); }
.badge-critical { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.35); }
.badge-info { background: rgba(61,156,240,0.15); color: #93c5fd; border-color: rgba(61,156,240,0.3); }

.pagination {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin: 1.25rem 0 2rem;
}
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

.filter-row-6 { grid-template-columns: 2fr 1fr 0.5fr 1fr 1fr 0.8fr; }
.site-title-block { min-width: 0; flex: 1; }
.site-title-block h2 { margin-bottom: 0.35rem; }
.badges-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.site-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.metric-limit .src { opacity: 0.7; font-size: 0.7rem; }
.flash.ok {
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.35);
  color: #bbf7d0;
}
.detail-head { margin-bottom: 1.25rem; }
.detail-head h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table input[type=number], .admin-form input[type=text], .admin-form input[type=date], .admin-form select {
  width: 100%;
  max-width: 160px;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.form-grid label { display: grid; gap: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.form-grid input, .form-grid select { max-width: none; }
.modules-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.modules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--text); font-size: 0.9rem; }
.form-actions { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
.btn.danger { color: #fca5a5; border-color: rgba(239,68,68,0.4); }

@media (max-width: 1100px) {
  .filter-row-6 { grid-template-columns: 1fr 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .filter-row { grid-template-columns: 1fr 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .filter-row, .filter-row-6 { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .topbar { flex-wrap: wrap; }
  .modules-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
