:root {
  --ink: #18231d;
  --muted: #66736c;
  --paper: #f5f7f3;
  --surface: #fff;
  --line: #dce3dd;
  --brand: #1d6045;
  --brand-dark: #154735;
  --brand-soft: #e6f2eb;
  --success: #23764f;
  --failure: #a23c35;
  --failure-soft: #f9e9e7;
  --pending: #8a6516;
  --pending-soft: #fbf1d9;
  --shadow: 0 18px 48px rgba(28, 54, 40, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 85% 5%, rgba(168, 207, 184, 0.28), transparent 27rem), var(--paper); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid rgba(220, 227, 221, 0.8); background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(14px); }
.brand { display: flex; gap: 12px; align-items: center; color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: -0.02em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: white; background: var(--brand); font-size: 12px; letter-spacing: 0.08em; }
.service-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: #aab2ad; }
.health-dot.online { background: #39a56d; box-shadow: 0 0 0 4px rgba(57, 165, 109, 0.12); }
.health-dot.offline { background: #c14a42; box-shadow: 0 0 0 4px rgba(193, 74, 66, 0.12); }

main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.hero { padding: 72px 0 46px; max-width: 780px; }
.eyebrow, .section-kicker { margin: 0 0 12px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
h1 { margin: 0; max-width: 720px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(42px, 6vw, 72px); line-height: 1.02; letter-spacing: -0.045em; font-weight: 500; }
.hero-copy { max-width: 650px; margin: 24px 0 0; color: var(--muted); font-size: 18px; line-height: 1.65; }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 16px 2px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.tab.active { color: var(--brand); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }

.view { display: none; margin: 32px 0 64px; padding: 36px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.view.active { display: block; }
.section-heading, .panel-heading, .job-summary, .results-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 4px; font-size: 28px; letter-spacing: -0.03em; }
h3 { margin-bottom: 6px; font-size: 18px; }
.panel-heading p, .results-header p { margin-bottom: 0; color: var(--muted); font-size: 14px; }
.mode-switch { display: flex; padding: 4px; border-radius: 10px; background: #eef1ed; }
.mode-button { padding: 9px 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 700; }
.mode-button.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(31, 54, 41, 0.08); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-top: 32px; }
label { display: flex; flex-direction: column; gap: 8px; color: #35433b; font-size: 14px; font-weight: 700; }
input, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cdd6cf; border-radius: 9px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 96, 69, 0.12); }
.field-help { color: var(--muted); font-size: 12px; font-weight: 500; }
.recipient-panel { margin-top: 32px; padding-top: 28px; border-top: 1px solid var(--line); }
.recipient-rows { display: grid; gap: 12px; margin-top: 20px; }
.recipient-row { display: grid; grid-template-columns: 36px 1fr 1fr 40px; gap: 12px; align-items: end; }
.recipient-number { display: grid; place-items: center; height: 44px; color: var(--muted); font-size: 13px; font-weight: 800; }
.icon-button { height: 44px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--failure); cursor: pointer; font-size: 20px; }
.icon-button:disabled { opacity: 0.35; cursor: not-allowed; }

.button { min-height: 42px; padding: 10px 16px; border-radius: 9px; cursor: pointer; font-weight: 750; border: 1px solid transparent; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { border-color: #cbd5cd; color: #304239; background: white; }
.button.secondary:hover { border-color: #9eaea2; background: #f9faf8; }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button.compact { min-height: 36px; padding: 7px 12px; font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 28px; }
.upload-area { display: grid; place-items: center; gap: 8px; margin-top: 20px; padding: 44px 20px; border: 1px dashed #9caf9f; border-radius: 14px; background: #f8faf7; cursor: pointer; text-align: center; }
.upload-area:hover { border-color: var(--brand); background: #f2f7f3; }
.upload-area span { color: var(--muted); font-weight: 500; }
.upload-area input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--brand-soft); color: var(--brand) !important; font-size: 12px; font-weight: 850 !important; }
.selected-file { margin: 12px 0 0; color: var(--muted); text-align: center; font-size: 13px; }
.message, .archive-message { margin-top: 20px; padding: 13px 15px; border-radius: 9px; background: var(--failure-soft); color: #7d2d28; font-size: 14px; }
.message.success, .archive-message.success { background: var(--brand-soft); color: var(--brand-dark); }
.spinner { width: 16px; height: 16px; margin-left: 8px; display: inline-block; border: 2px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.job-lookup { display: flex; flex-direction: row; gap: 8px; min-width: min(460px, 100%); }
.monitor-heading { align-items: end; }
.empty-state { display: grid; justify-items: center; padding: 90px 20px 70px; color: var(--muted); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 16px; color: var(--brand); background: var(--brand-soft); font-size: 13px; font-weight: 850; }
.empty-state h3 { color: var(--ink); }
.job-summary { margin-top: 34px; padding: 24px; border-radius: 14px; background: #f4f7f3; }
.job-title-line { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.job-title-line h3 { margin: 0; font-size: 22px; }
.job-metadata, .job-id-line { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.job-id-line code { color: #33463b; }
.text-button { border: 0; color: var(--brand); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; }
.summary-actions { display: flex; gap: 8px; }
.status-badge { padding: 5px 9px; border-radius: 999px; background: var(--pending-soft); color: var(--pending); font-size: 11px; font-weight: 850; letter-spacing: .04em; }
.status-badge.completed { color: var(--success); background: var(--brand-soft); }
.status-badge.failed, .status-badge.partially-completed { color: var(--failure); background: var(--failure-soft); }
.status-badge.processing { color: #295d86; background: #e6f0f8; }
.progress-section { margin-top: 28px; }
.progress-labels { display: flex; justify-content: space-between; margin-bottom: 9px; font-size: 14px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: #e5eae5; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #4a9a72); transition: width .35s ease; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.metric-card { padding: 20px; border: 1px solid var(--line); border-radius: 12px; }
.metric-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { display: block; margin-top: 9px; font-size: 30px; letter-spacing: -.04em; }
.metric-card.success strong { color: var(--success); }
.metric-card.failure strong { color: var(--failure); }
.metric-card.pending strong { color: var(--pending); }
.results-header { align-items: end; margin-top: 36px; }
.filter-label { min-width: 160px; }
.table-shell { margin-top: 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: #526159; background: #f4f6f3; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: 0; }
.recipient-primary { display: block; color: var(--ink); font-weight: 750; }
.recipient-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.outcome-error { max-width: 280px; color: var(--failure); }
.action-column { text-align: right; }
td.action-column a, .archive-message a { color: var(--brand); font-weight: 800; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; color: var(--muted); font-size: 13px; }
.pagination > div { display: flex; gap: 8px; }
footer { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 40px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
footer a { color: var(--brand); font-weight: 750; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .topbar { padding: 0 20px; }
  main, footer { width: min(100% - 28px, 1180px); }
  .hero { padding-top: 48px; }
  .view { padding: 22px; border-radius: 15px; }
  .section-heading, .panel-heading, .job-summary, .results-header { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .recipient-row { grid-template-columns: 30px 1fr 40px; }
  .recipient-row label:nth-of-type(2) { grid-column: 2 / 3; }
  .mode-switch, .job-lookup { width: 100%; }
  .mode-button { flex: 1; }
  .monitor-heading { align-items: stretch; }
  .summary-actions { width: 100%; }
  .summary-actions .button { flex: 1; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; }
}
