:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-dim: #0ea5e9;
  --success: #4ade80;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.95rem;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="password"],
input[type="search"],
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: var(--primary-dim);
  color: #0f172a;
}

.btn-primary:hover { background: var(--primary); }

.btn-ghost {
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.error {
  margin-top: 12px;
  color: #f87171;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}

.main { padding: 24px; max-width: 100%; margin: 0 auto; }

.page-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.75rem; font-weight: 700; margin-top: 4px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.toolbar input[type="search"] { max-width: 260px; }
.toolbar select { max-width: 180px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: #172033;
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-test { background: #422006; color: var(--warn); }
.badge-await { background: #1e3a5f; color: var(--primary); }
.badge-active { background: #14532d; color: var(--success); }
.badge-off { background: #334155; color: var(--muted); }

.empty {
  padding: 48px;
  text-align: center;
  color: var(--muted);
}

.meta { color: var(--muted); font-size: 0.85rem; }

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.modal-sn {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal label {
  display: block;
  margin-bottom: 14px;
}

.modal input[type="text"],
.modal textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

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

.modal .btn-primary {
  width: auto;
  margin-top: 0;
  padding: 10px 20px;
}
