:root {
  color-scheme: dark;
  --bg: #070a10;
  --bg-elevated: #0b0f17;
  --panel: #0e131c;
  --panel-hover: #111827;
  --muted: #8b95a8;
  --fg: #eef2f8;
  --fg-soft: #c8d0dc;
  --accent: #2ee89a;
  --accent-muted: #1fa86a;
  --accent-dim: rgba(46, 232, 154, 0.12);
  --accent-ring: rgba(46, 232, 154, 0.45);
  --danger: #ff5a5a;
  --danger-dim: rgba(255, 90, 90, 0.12);
  --warn: #f0b429;
  --warn-dim: rgba(240, 180, 41, 0.12);
  --line: rgba(255, 255, 255, 0.055);
  --line-strong: rgba(255, 255, 255, 0.09);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-float: 0 16px 48px rgba(0, 0, 0, 0.55);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100dvh;
  font: 14px/1.5 var(--font);
  color: var(--fg);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -25%, rgba(46, 232, 154, 0.055), transparent 50%),
    radial-gradient(ellipse 55% 45% at 95% 20%, rgba(99, 140, 255, 0.035), transparent);
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

a:hover { text-decoration: underline; }

.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--fg);
}

.admin-brand:hover { text-decoration: none; }

.admin-brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(46, 232, 154, 0.15), rgba(8, 12, 18, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 0 0 1px rgba(46, 232, 154, 0.2);
  display: grid;
  place-items: center;
  color: var(--accent);
}

.admin-brand .t1 {
  display: block;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.admin-brand .t2 {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.035), rgba(0, 0, 0, 0.22));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 16px; }

.card h1,
.card h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.card h1 { font-size: 1.45rem; margin-bottom: 16px; }

.login-wrap {
  min-height: calc(100dvh - 48px);
  display: grid;
  place-items: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

label:first-of-type { margin-top: 0; }

input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.28);
  color: var(--fg);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: rgba(46, 232, 154, 0.4);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  vertical-align: middle;
  margin-right: 8px;
}

.check-label {
  display: flex;
  align-items: center;
  margin-top: 14px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--fg-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(145deg, var(--accent-muted), var(--accent));
  color: #041510;
  border-color: rgba(46, 232, 154, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-success {
  background: var(--accent-dim);
  color: #b8f5d8;
  border-color: rgba(46, 232, 154, 0.28);
}

.btn-success:hover {
  background: rgba(46, 232, 154, 0.18);
}

.btn-warning {
  background: var(--warn-dim);
  color: #ffe9a8;
  border-color: rgba(240, 180, 41, 0.3);
}

.btn-warning:hover {
  background: rgba(240, 180, 41, 0.18);
}

.btn-danger {
  background: var(--danger-dim);
  color: #ffb4b4;
  border-color: rgba(255, 90, 90, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 90, 90, 0.18);
}

.btn-outline,
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg-soft);
  border-color: var(--line-strong);
}

.btn-outline:hover,
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--fg);
}

.btn-block { width: 100%; margin-top: 16px; }

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

.toolbar h1 {
  flex: 1;
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

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

td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

td img {
  height: 32px;
  width: 32px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.color-swatch {
  display: inline-block;
  width: 18px;
  height: 14px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.action-cell .btn {
  padding: 7px 11px;
  font-size: 12px;
}

.err {
  color: #ff8a8a;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
}

.hidden { display: none !important; }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal.is-open { display: flex; }

.modal-inner {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-float);
}

.modal-inner h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.row .btn { flex: 1; }

.feedback { margin-bottom: 0; }

.feedback h2 { margin-bottom: 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 16px 0 14px;
}

.stat {
  padding: 14px 14px 12px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}

.stat .k {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

.stat .v {
  font-size: 1.1rem;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.stat.ok {
  border-color: rgba(46, 232, 154, 0.25);
  background: rgba(46, 232, 154, 0.07);
}

.stat.ok .v { color: #9ef0c8; }

.stat.bad {
  border-color: rgba(255, 90, 90, 0.25);
  background: rgba(255, 90, 90, 0.07);
}

.stat.bad .v { color: #ffb0b0; }

.stat.warn {
  border-color: rgba(240, 180, 41, 0.25);
  background: rgba(240, 180, 41, 0.07);
}

.stat.warn .v { color: #ffe08a; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-on {
  background: rgba(46, 232, 154, 0.14);
  color: #9ef0c8;
  border: 1px solid rgba(46, 232, 154, 0.28);
}

.badge-off {
  background: rgba(255, 90, 90, 0.12);
  color: #ffb0b0;
  border: 1px solid rgba(255, 90, 90, 0.28);
}

.badge-busy {
  background: rgba(240, 180, 41, 0.12);
  color: #ffe08a;
  border: 1px solid rgba(240, 180, 41, 0.28);
}

.log {
  max-height: 160px;
  overflow: auto;
  font-size: 12px;
  background: #060910;
  color: #c8d0dc;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: ui-monospace, Consolas, monospace;
}

.log div { margin: 3px 0; }

.log time {
  color: #7ee8b8;
  margin-right: 8px;
}

.mini {
  font-size: 13px;
  margin: 0 0 10px;
  color: var(--muted);
}

.section-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg-soft);
}

.back-link {
  margin-top: 18px;
  font-size: 13px;
}

.scan-card h2 { margin-bottom: 4px; }

.scan-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.scan-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scan-progress-wrap { margin-bottom: 12px; }

.scan-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--fg-soft);
}

.scan-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border: 1px solid var(--line);
}

.scan-progress span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-muted), var(--accent));
  transition: width 0.2s ease;
}

.scan-action .btn {
  padding: 6px 12px;
  font-size: 12px;
}

.scan-empty {
  color: var(--muted);
  text-align: center;
  padding: 18px 12px !important;
}

td code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  color: #9ef0c8;
}

@media (max-width: 640px) {
  .wrap { padding: 16px 14px 32px; }

  .toolbar h1 {
    width: 100%;
    font-size: 1.25rem;
  }

  .toolbar .btn { flex: 1 1 auto; }

  .action-cell .btn {
    flex: 1 1 calc(50% - 6px);
  }
}
