:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #17202a;
  --muted: #687386;
  --line: #dbe3ec;
  --brand: #2563eb;
  --brand-2: #0f766e;
  --green: #138a48;
  --red: #c7362f;
  --amber: #b7791f;
  --blue: #2563eb;
  --shadow: 0 10px 28px rgba(31, 45, 61, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: #101820;
  color: #d7e0ea;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 20px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
  color: white; border-radius: 8px; font-weight: 900;
}
.nav { display: grid; gap: 6px; }
.nav a, .ghost {
  border: 0; background: transparent; color: #b9c6d3; text-align: left;
  padding: 11px 12px; border-radius: 8px; cursor: pointer;
}
.nav a.active, .nav a:hover, .ghost:hover { background: rgba(255,255,255,.08); color: white; }
.logout { margin-top: auto; }
.content { padding: 30px; max-width: 1500px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 4px; color: var(--brand-2); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
h1 { margin: 0; font-size: 32px; letter-spacing: 0; }
h2 { margin: 0; font-size: 18px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.button, button {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--line); padding: 10px 14px;
  min-height: 42px; cursor: pointer; transition: .15s ease; white-space: nowrap;
}
.primary { background: var(--brand); color: white; border: 1px solid var(--brand); }
.secondary { background: white; color: var(--ink); border: 1px solid var(--line); }
.danger { background: #fff5f5; color: var(--red); border-color: #f3b8b5; }
.button:hover, button:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.full { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px; box-shadow: var(--shadow);
}
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 8px; font-size: 26px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px;
  font-size: 12px; font-weight: 800; border: 1px solid transparent;
}
.VALID, .DELIVERABLE, .ACCEPTED, .COMPLETED { color: var(--green); background: #e8f7ee; border-color: #bce6ca; }
.INVALID, .UNDELIVERABLE, .REJECTED, .FAILED, .CANCELLED { color: var(--red); background: #fff0f0; border-color: #fac8c8; }
.UNKNOWN, .CATCH-ALL, .GREYLISTED, .PAUSED { color: var(--amber); background: #fff8e8; border-color: #f2d899; }
.PROCESSING, .QUEUED { color: var(--blue); background: #edf4ff; border-color: #bdd5ff; }

.chart { display: flex; align-items: end; gap: 8px; min-height: 190px; padding-top: 14px; }
.bar { flex: 1; min-width: 18px; background: linear-gradient(180deg, #14b8a6, #2563eb); border-radius: 6px 6px 0 0; position: relative; }
.bar span { position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 11px; }

.inline-form { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 12px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; min-height: 42px;
  padding: 10px 12px; background: white; color: var(--ink);
}
textarea { min-height: 150px; resize: vertical; }
label { color: var(--muted); font-size: 13px; font-weight: 700; display: grid; gap: 7px; }
.result-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 22px; box-shadow: var(--shadow);
}
.result-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; }
.result-item { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 13px; }
.result-item span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.reason { background: #eef8f6; border-left: 4px solid var(--brand-2); padding: 14px; border-radius: 6px; }

.drop-zone {
  min-height: 190px; border: 2px dashed #aebccd; border-radius: 8px; background: #f9fbfd;
  display: grid; place-items: center; text-align: center; padding: 24px; cursor: pointer;
}
.drop-zone input { display: none; }
.drop-title { display: block; font-size: 20px; color: var(--ink); font-weight: 800; }
.drop-subtitle { display: block; margin-top: 6px; color: var(--muted); }
.preview {
  margin: 14px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.preview div { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.form-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: end; }
.settings-grid { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: span 3; }
.checkline { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.checkline input { width: auto; min-height: auto; }
.combine-options { grid-template-columns: minmax(240px, 1fr) 1fr 1fr; margin: 14px 0; }
.segment-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.segment-field legend { color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.segmented { display: inline-grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented label { display: block; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; min-width: 92px; padding: 10px 16px; text-align: center; color: var(--muted); background: white; }
.segmented input:checked + span { color: white; background: var(--brand); }
.file-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.jobs { display: grid; gap: 14px; }
.job-card { border: 1px solid var(--line); border-radius: 8px; padding: 15px; background: #fbfdff; }
.job-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.progress { height: 10px; border-radius: 999px; background: #e8edf4; overflow: hidden; margin: 12px 0; }
.progress div { height: 100%; background: linear-gradient(90deg, #14b8a6, #2563eb); }
.mini-stats { display: grid; grid-template-columns: repeat(6, minmax(90px, 1fr)); gap: 8px; }
.mini-stats span { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 9px; font-size: 12px; color: var(--muted); }
.mini-stats strong { display: block; color: var(--ink); font-size: 16px; margin-top: 3px; }
.filters { display: flex; gap: 10px; }
.hidden { display: none !important; }
.toast {
  position: fixed; right: 22px; bottom: 22px; background: #101820; color: white;
  padding: 12px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transform: translateY(10px);
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.alert { background: #fff0f0; color: var(--red); border: 1px solid #fac8c8; padding: 10px; border-radius: 8px; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #f6f8fb, #e8f5f2); padding: 24px; }
.login-card {
  width: min(430px, 100%); background: white; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); padding: 28px; display: grid; gap: 14px;
}
.login-brand { color: var(--ink); margin-bottom: 8px; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .metric-grid, .two-col, .settings-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}
@media (max-width: 680px) {
  .content { padding: 18px; }
  .page-head, .job-top { align-items: stretch; flex-direction: column; }
  .metric-grid, .two-col, .inline-form, .form-grid, .settings-grid, .result-grid, .preview, .combine-options { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
}
