:root {
  --bg: #f4f7f8;
  --ink: #151c24;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --dark: #101820;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --gold: #e8bd4f;
  --rose: #b42318;
  --green: #067647;
  --shadow: 0 18px 50px rgba(20, 31, 43, 0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1fr);
}
.hero-panel {
  background: linear-gradient(135deg, #101820, #173534 62%, #0d1f27);
  color: #fff;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand span {
  width: 52px; height: 52px; border-radius: 8px; display: grid; place-items: center;
  background: var(--gold); color: var(--dark); font-size: 25px; font-weight: 900;
}
.brand p, .brand h1, .eyebrow, .login-card h2 { margin: 0; }
.brand p { direction: ltr; text-align: right; color: #b7c4d2; }
.brand h1 { margin-top: 4px; font-size: clamp(30px, 4vw, 52px); }
.signal {
  width: max-content; max-width: 100%; border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px; padding: 12px 14px; color: #dbe4ee;
}
.login-card {
  place-self: center; width: min(430px, calc(100% - 32px)); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  padding: 34px; display: grid; gap: 18px;
}
.eyebrow { color: var(--teal); font-weight: 900; }
.login-card h2 { font-size: 32px; }

label { display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
input, select, textarea {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; outline: none; background: #fff; color: var(--ink);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.14);
}
button, .export-link {
  min-height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px;
  background: #fff; color: var(--ink); text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; white-space: nowrap;
}
button:disabled { opacity: .65; cursor: wait; }
.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 900; }
.primary:hover { background: var(--teal-dark); }
.message { min-height: 24px; margin: 0; color: var(--rose); }

.admin-view { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  background: var(--dark); color: #fff; padding: 22px; display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh;
}
.compact span { width: 42px; height: 42px; font-size: 21px; }
.compact h1 { font-size: 21px; }
.side-nav { display: grid; gap: 8px; }
.side-nav a {
  color: #dbe4ee; text-decoration: none; border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 10px 12px;
}
.workspace { padding: 24px; display: grid; gap: 16px; align-content: start; }
.topbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.topbar h2 { margin: 6px 0 0; font-size: clamp(24px, 3vw, 38px); }

.control-section, .metrics article, .table-card, .filters {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.control-section { padding: 16px; display: grid; gap: 16px; scroll-margin-top: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-head h3 { margin: 4px 0 0; font-size: 24px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.metrics article { padding: 16px; }
.metrics span { color: var(--muted); }
.metrics strong { display: block; margin-top: 8px; font-size: 26px; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; align-items: end; }
.form-grid .wide { grid-column: span 2; }
.email-grid { grid-template-columns: repeat(5, minmax(0,1fr)); }
.account-grid { grid-template-columns: 1fr 1fr 1fr; }
.account-grid .wide { grid-column: span 2; }
.filters { padding: 14px; display: grid; grid-template-columns: 1fr 220px; gap: 12px; }
.run-strip { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.run-strip.nested { grid-template-columns: repeat(4, minmax(0,1fr)); }
.switch { display: inline-flex; grid-template-columns: none; align-items: center; gap: 8px; white-space: nowrap; }
.switch input { width: 18px; min-height: 18px; accent-color: var(--teal); }

.table-card { overflow: auto; max-height: 420px; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: right; }
th { position: sticky; top: 0; background: #f8fafc; color: #344054; }
.email { direction: ltr; text-align: left; font-weight: 800; }
.badge { border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; }
.active { background: #dff7ed; color: var(--teal-dark); }
.reserved { background: #fff2cc; color: #946200; }
.paused { background: #ffe4e0; color: var(--rose); }

.links-list { display: grid; gap: 14px; }
.link-card { border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 14px; display: grid; gap: 14px; }
.link-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.link-head h4 { margin: 0 0 6px; font-size: 20px; }
.link-head p { margin: 0; color: var(--muted); direction: ltr; text-align: left; word-break: break-all; }
.link-head strong { background: #e7f6f3; color: var(--teal-dark); border-radius: 8px; padding: 10px 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.mini-summary { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 12px; }
.mini-summary span, .mini-summary small { display: block; color: var(--muted); }
.mini-summary strong { display: block; font-size: 22px; margin: 4px 0; }
.card-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.card-actions label:nth-child(3), .card-actions label:nth-child(4), .card-actions .run-strip, .button-row { grid-column: 1 / -1; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.job-status { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 12px; line-height: 1.7; }
.result-list { display: grid; gap: 8px; max-height: 360px; overflow: auto; }
.result-row { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 10px; display: grid; gap: 5px; }
.result-row strong { direction: ltr; text-align: left; }
.result-row span { font-weight: 800; }
.result-row.ok span { color: var(--green); }
.result-row.bad span { color: var(--rose); }
.result-row p { margin: 0; color: var(--muted); line-height: 1.6; }
.empty-state { border: 1px dashed var(--line); border-radius: 8px; padding: 18px; color: var(--muted); background: #fff; }

#toast {
  position: fixed; left: 20px; bottom: 20px; background: var(--dark); color: #fff;
  border-radius: 8px; padding: 12px 14px; opacity: 0; transform: translateY(10px); transition: .18s ease;
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1000px) {
  .admin-view, .login-view, .metrics, .form-grid, .email-grid, .account-grid, .filters, .run-strip, .run-strip.nested, .summary-grid, .card-actions { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .form-grid .wide, .account-grid .wide { grid-column: auto; }
  .topbar, .section-head, .link-head { flex-direction: column; align-items: stretch; }
}
