:root {
  --bg: #0b1020;
  --panel: #11182d;
  --panel2: #151f3a;
  --text: #eef4ff;
  --muted: #93a4c7;
  --line: rgba(255,255,255,.08);
  --accent: #30d5c8;
  --danger: #ff5c7a;
  --ok: #54d88a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0e172d, #090e1d);
  border-right: 1px solid var(--line);
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.04em;
  margin-bottom: 32px;
}
.brand span { color: var(--accent); }

nav a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 6px;
}
nav a.active, nav a:hover {
  color: var(--text);
  background: rgba(48,213,200,.12);
}

.logout {
  margin-top: 28px;
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 12px;
}
.env {
  position: absolute;
  bottom: 20px;
  color: var(--muted);
  font-size: 12px;
}

.content {
  flex: 1;
  padding: 32px;
  overflow: auto;
}

h1 { margin: 0 0 24px; font-size: 28px; letter-spacing: -.03em; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
}
.label { color: var(--muted); font-size: 13px; }
.value { font-size: 30px; font-weight: 800; margin-top: 8px; }

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
input, select {
  background: #0d1428;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
}
button {
  background: var(--accent);
  color: #031315;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}
button.danger { background: var(--danger); color: white; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}
th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 12px;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
tr:hover td { background: rgba(255,255,255,.025); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.error { color: #ff9aad; max-width: 360px; }

.pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(48,213,200,.12);
  color: var(--accent);
  font-size: 12px;
}
.pill.failed { color: var(--danger); background: rgba(255,92,122,.12); }
.pill.done { color: var(--ok); background: rgba(84,216,138,.12); }

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

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #17264a, #070b16 55%);
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 30px 90px rgba(0,0,0,.35);
}
.login-card h1 { font-size: 22px; }
.login-card label { display: block; color: var(--muted); margin: 14px 0 6px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 18px; }
.login-brand { margin-bottom: 18px; }
.alert {
  background: rgba(255,92,122,.12);
  color: #ff9aad;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 14px;
}
pre { margin: 0; white-space: pre-wrap; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  gap: 10px;
  max-width: 520px;
}

.form-grid label {
  color: var(--muted);
  font-size: 13px;
}

.ok {
  background: rgba(84,216,138,.12);
  color: #8ff0b6;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.button-link {
  display: inline-flex;
  background: var(--accent);
  color: #031315;
  text-decoration: none;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
}

.qr {
  display: block;
  width: 220px;
  height: 220px;
  background: white;
  padding: 12px;
  border-radius: 16px;
  margin: 16px 0;
}

.admin-box {
  margin-top: 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.active {
  background: rgba(84,216,138,.12);
  color: #54d88a;
}

.status-badge.disabled {
  background: rgba(255,92,122,.12);
  color: #ff5c7a;
}

.status-badge.muted-badge {
  background: rgba(147,164,199,.12);
  color: var(--muted);
}

.disabled-row {
  opacity: .58;
}

.current-marker {
  display: inline-flex;
  margin-top: 4px;
  color: var(--accent);
}

button.success {
  background: #54d88a;
  color: #031315;
}

/* compact admin tables */
.compact-table table {
  min-width: 1180px;
  table-layout: auto;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
  line-height: 1.15;
  vertical-align: middle;
}

.compact-table th {
  font-size: 11px;
}

.compact-table td {
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

.sep {
  margin: 0 4px;
}

.compact-filters {
  margin-bottom: 12px;
}

.compact-filters input,
.compact-filters select,
.compact-filters button {
  padding: 8px 10px;
  min-height: 36px;
}

.compact-panel {
  padding: 16px;
}

.compact-panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

.compact-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

.compact-actions button,
.compact-inline button {
  padding: 7px 9px;
  border-radius: 10px;
  white-space: nowrap;
}

.compact-inline select {
  padding: 7px 9px;
  min-height: 34px;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 8px;
  background: rgba(147,164,199,.12);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.copy-btn:hover,
.copy-btn.copied {
  background: rgba(48,213,200,.16);
  color: var(--accent);
}

.danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255,92,122,.35);
}

.danger-outline:hover {
  background: rgba(255,92,122,.12);
}

.compact-error {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-json {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  max-width: 100%;
}

.status-badge {
  white-space: nowrap;
}

.compact-table table {
  width: 100%;
  table-layout: auto;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
  line-height: 1.15;
  vertical-align: middle;
}

.compact-table th {
  font-size: 11px;
}

.compact-table td {
  font-size: 13px;
}

.table-wrap {
  overflow-x: visible;
}

.nowrap {
  white-space: nowrap;
}

.sep {
  margin: 0 4px;
}

.compact-filters input,
.compact-filters select,
.compact-filters button {
  padding: 8px 10px;
  min-height: 36px;
}

.compact-panel {
  padding: 16px;
}

.compact-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

.copy-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1;
}

.copy-btn {
  background: rgba(147,164,199,.12);
  color: var(--muted);
  margin-left: 5px;
}

.copy-btn:hover,
.copy-btn.copied {
  background: rgba(48,213,200,.16);
  color: var(--accent);
}

.icon-btn {
  background: rgba(147,164,199,.10);
  color: var(--text);
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.ok-btn {
  background: rgba(84,216,138,.14);
  color: #54d88a;
}

.pro-btn {
  background: rgba(48,213,200,.14);
  color: var(--accent);
}

.ghost-btn {
  background: rgba(147,164,199,.10);
  color: var(--muted);
}

.danger-btn {
  background: rgba(255,92,122,.14);
  color: #ff5c7a;
}

.danger-outline {
  background: transparent;
  color: #ff5c7a;
  border: 1px solid rgba(255,92,122,.35);
}

.compact-error {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-json {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border-radius: 999px;
  background: rgba(84,216,138,.16);
  color: #54d88a;
  font-size: 13px;
  font-weight: 900;
}

.save-btn {
  background: rgba(48,213,200,.14);
  color: var(--accent);
}

.wide-icon-btn {
  width: auto;
  min-width: 58px;
  padding: 0 9px;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
}

.wide-icon-btn span {
  font-size: 11px;
  line-height: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(520px, 1.5fr);
  gap: 18px;
  align-items: start;
}

.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px 14px;
  align-items: center;
}

.kv > div:nth-child(odd) {
  color: var(--muted);
  font-size: 13px;
}

.kv > div:nth-child(even) {
  min-width: 0;
}

.mini-cards {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.mini-cards .card {
  padding: 14px;
  border-radius: 16px;
}

.mini-cards .value {
  font-size: 22px;
}

.detail-actions {
  justify-content: flex-start;
}

.row-link {
  color: var(--text);
  text-decoration: none;
}

.row-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 1200px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.limit-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.small-value {
  font-size: 22px;
}

.limit-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.limit-form label {
  color: var(--muted);
  font-size: 12px;
  grid-row: 1;
}

.limit-form input,
.limit-form button {
  grid-row: 2;
  min-height: 36px;
  padding: 8px 10px;
}

@media (max-width: 1400px) {
  .limit-form {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .limit-form label,
  .limit-form input,
  .limit-form button {
    grid-row: auto;
  }
}
