:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --safe: #22c55e;
  --warn: #eab308;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  margin: 4rem auto;
}
.center { text-align: center; }
.muted { color: var(--muted); font-size: 0.9rem; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 1rem; }

label { display: block; margin: 1rem 0 0.35rem; font-size: 0.85rem; color: var(--muted); }
input, textarea, select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1117;
  color: var(--text);
}
textarea { resize: vertical; }

button {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  margin-top: 0.75rem;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  width: 100%;
}
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.is-loading { opacity: 0.7; }
button.link { background: none; border: none; color: var(--accent); margin: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 1.1rem; }
.user-meta { display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
.badge {
  background: #243044;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.tabs, .subtabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.tabs button, .subtabs button {
  margin: 0;
  background: transparent;
}
.tabs button.active, .subtabs button.active {
  background: var(--accent);
  border-color: var(--accent);
}

main { padding: 1.5rem; max-width: 960px; margin: 0 auto; }

.worker-status {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.worker-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.worker-status-title { font-weight: 600; font-size: 0.95rem; }
.btn-worker-refresh {
  margin-top: 0;
  width: auto;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.2;
  background: #243044;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.btn-worker-refresh:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.worker-status-body { font-size: 0.9rem; line-height: 1.5; }
.worker-status-state {
  display: flex;
  align-items: center;
  font-weight: 600;
}
.worker-status-body.online .worker-status-state { color: var(--safe); }
.worker-status-body.offline .worker-status-state { color: var(--danger); }
.worker-status-body.neutral .worker-status-state { color: var(--muted); }
.worker-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.45rem;
  flex-shrink: 0;
}
.worker-status-dot.online { background: var(--safe); box-shadow: 0 0 8px var(--safe); }
.worker-status-dot.offline { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.worker-status-dot.neutral { background: var(--muted); }
.worker-status-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.35rem;
  line-height: 1.45;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.card .label { color: var(--muted); font-size: 0.85rem; }
.card .value { font-size: 1.75rem; font-weight: 600; }

#chart-daily {
  width: 100%;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.chart-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 10;
  transform: translate(-50%, -110%);
}

.dashboard-period {
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.dashboard-period label { margin: 0; }
.dashboard-period input[type="date"] { width: auto; flex: 0 1 160px; }
.dashboard-period button { width: auto; margin-top: 0; }
.dashboard-period span { color: var(--muted); }

.progress-bar {
  height: 4px;
  background: #243044;
  border-radius: 4px;
  margin-top: 0.75rem;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: 4px;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); width: 40%; }
  50% { width: 60%; }
  100% { transform: translateX(250%); width: 40%; }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 1rem;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.breakdown { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 1rem; align-items: flex-start; }
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
  min-width: 200px;
}
.breakdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}
.breakdown-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.breakdown-item strong { min-width: 5.5rem; }

.donut-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  pointer-events: none;
}

.btn-otp {
  width: 100%;
  background: #243044;
  border-color: var(--border);
  transition: background 0.15s, border-color 0.15s;
}
.btn-otp:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-logout {
  margin-top: 0;
  width: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  background: #243044;
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--danger);
  color: #fca5a5;
}

.tabs button {
  transition: background 0.15s, border-color 0.15s;
}
.tabs button:not(.active):hover {
  background: #243044;
  border-color: var(--accent);
}

.jobs-toolbar {
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.jobs-toolbar label { margin: 0; font-size: 0.85rem; }
.jobs-toolbar select { width: auto; min-width: 100px; }

.jobs-pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}
.jobs-pagination button { margin-top: 0; width: auto; }

.faq-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.faq-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
}
.faq-item h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}
.faq-item p { margin: 0; font-size: 0.9rem; color: var(--muted); }

#login-otp-block { margin-top: 0.5rem; }

.results-table-wrap { margin-top: 1rem; overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
}
th { background: var(--panel); }

.status-safe { color: var(--safe); }
.status-invalid, .status-syntax_error, .status-disposable { color: var(--danger); }
.status-disabled { color: #b91c1c; }
.status-catch_all, .status-role { color: var(--warn); }
.status-inbox_full { color: #f59e0b; }
.status-unknown, .status-blocked { color: var(--muted); }

.row { display: flex; gap: 0.5rem; }
.row input { flex: 1; }
.row button { width: auto; white-space: nowrap; }

pre.code, pre.secret {
  background: #0d1117;
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8rem;
}
pre.secret { color: #fbbf24; }

#api-keys-list { list-style: none; padding: 0; }
#api-keys-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
#api-keys-list .key-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}
#api-keys-list .key-actions button { margin-top: 0; width: auto; }

.api-key-copy-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  align-items: stretch;
}
.api-key-copy-row input { flex: 1; font-family: monospace; font-size: 0.85rem; }
.api-key-copy-row button { width: auto; margin-top: 0; white-space: nowrap; }

.admin-status { margin-bottom: 0.75rem; }
.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.admin-toolbar button { margin-top: 0; width: auto; }
.admin-table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.admin-table { min-width: 640px; }
.admin-table .bal-input {
  width: 110px;
  padding: 0.5rem;
  font-size: 1rem;
}
.admin-table .actions-cell {
  white-space: nowrap;
}
.admin-table .actions-cell button {
  margin-top: 0;
  margin-right: 0.35rem;
  width: auto;
  display: inline-block;
}
.admin-table tr.admin-row { background: rgba(59, 130, 246, 0.12); }
.role-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
}
.role-admin { background: #3b82f6; color: #fff; }
.role-user { background: #243044; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
}
