:root {
  color-scheme: dark;
  --bg: #0b1017;
  --surface: #121a24;
  --surface-raised: #182331;
  --surface-soft: #0f161f;
  --border: #27384a;
  --border-strong: #36516b;
  --text: #f2f6fb;
  --muted: #98aabd;
  --faint: #6f8297;
  --accent: #65b9ff;
  --accent-strong: #2d91e6;
  --success: #62e2b2;
  --success-bg: #123d35;
  --warning: #ffd27a;
  --warning-bg: #4a3518;
  --danger: #ff98a8;
  --danger-bg: #48202c;
  --shadow: 0 22px 70px rgb(0 0 0 / 25%);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 84% -10%, #1a3852 0, transparent 34%), var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .drop-zone:focus-visible {
  outline: 3px solid rgb(101 185 255 / 40%);
  outline-offset: 3px;
}
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 20; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent); color: #061321; font-weight: 800; transition: top .18s ease; }
.skip-link:focus { top: 16px; }
.shell { width: min(100% - 40px, 1120px); margin: 0 auto; padding: 28px 0 72px; }

.site-header { display: flex; align-items: center; gap: 28px; min-height: 48px; margin-bottom: 42px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 1.18rem; font-weight: 850; letter-spacing: -.025em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgb(101 185 255 / 28%); border-radius: 10px; background: #17304a; color: var(--accent); }
.brand-mark svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.main-nav { flex: 1; }
.main-nav a { color: var(--muted); text-decoration: none; font-size: .9rem; }
.main-nav a:hover { color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .9rem; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 999px; background: rgb(18 26 36 / 72%); }
.user-chip strong { color: var(--text); }
.user-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgb(98 226 178 / 12%); }
.inline-form { display: inline; }
.link-button, .text-button { border: 0; background: transparent; color: var(--accent); padding: 6px 0; font-weight: 700; }
.link-button:hover, .text-button:hover { color: var(--text); }

.page-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow, .section-kicker { margin: 0 0 9px; color: var(--accent); font-size: .7rem; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { margin-bottom: 8px; letter-spacing: -.045em; line-height: 1.05; }
h1 { font-size: clamp(2.15rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); }
h3 { margin-bottom: 10px; font-size: .95rem; }
.intro-copy { max-width: 560px; margin-bottom: 0; font-size: 1rem; }
.muted { color: var(--muted); }
.readiness { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; color: var(--muted); font-size: .78rem; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.summary-card { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 11px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgb(18 26 36 / 82%); }
.summary-label { grid-column: 1 / -1; color: var(--muted); font-size: .76rem; font-weight: 700; }
.summary-card strong { font-size: 1.65rem; letter-spacing: -.04em; }
.summary-hint { color: var(--faint); font-size: .74rem; }
.summary-card.attention strong { color: var(--warning); }

.card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: linear-gradient(135deg, rgb(18 26 36 / 97%), rgb(15 22 31 / 97%)); box-shadow: var(--shadow); }
.send-card { padding: 24px; }
.history-card { margin-top: 18px; padding: 24px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.panel-head h2 { margin-bottom: 6px; }
.panel-head p:last-child { margin-bottom: 0; }
.readiness { padding-top: 5px; }
.send-layout { display: grid; grid-template-columns: minmax(190px, .32fr) minmax(0, 1fr); gap: 24px; margin-top: 24px; }
.destination-panel { padding: 2px 0; }
label { display: grid; gap: 8px; color: #dce8f3; font-size: .82rem; font-weight: 750; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); color: var(--text); padding: 10px 12px; }
select { appearance: auto; }
.field-hint { margin: 10px 0 0; color: var(--faint); font-size: .78rem; }
.document-panel { min-width: 0; }
.drop-zone { min-height: 210px; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 26px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md); color: var(--muted); text-align: center; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.drop-zone:hover, .drop-zone.dragover, .drop-zone:focus { border-color: var(--accent); background: rgb(35 88 127 / 14%); }
.drop-zone.dragover { transform: translateY(-2px); }
.drop-zone strong { color: var(--text); font-size: 1.08rem; }
.drop-zone small { color: var(--faint); font-size: .76rem; }
.drop-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 3px; border-radius: 13px; background: #17304a; color: var(--accent); }
.drop-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.choose-button, .primary, .secondary { min-height: 44px; border-radius: var(--radius-sm); padding: 10px 16px; }
.choose-button, .secondary { border: 1px solid var(--border); background: var(--surface-raised); color: var(--text); }
.choose-button { min-height: 38px; padding: 7px 14px; color: var(--accent); font-size: .86rem; font-weight: 800; }
.choose-button:hover, .secondary:hover { border-color: var(--border-strong); background: #203043; }
.primary { border: 0; background: linear-gradient(135deg, var(--accent-strong), #526ce8); color: white; font-weight: 850; box-shadow: 0 8px 22px rgb(45 145 230 / 20%); }
.primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.primary, .secondary, .choose-button { transition: filter .18s ease, transform .18s ease, border-color .18s ease, background .18s ease; }
.send-footer { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.send-button { min-width: 130px; }
.send-button.is-submitting { position: relative; }
.alert { border-radius: var(--radius-sm); padding: 11px 13px; font-size: .86rem; }
.alert.error { border: 1px solid #9c4b5d; background: var(--danger-bg); color: #ffd6dc; }
.alert.ok { border: 1px solid #2f9379; background: var(--success-bg); color: #d0ffef; }
.hidden { display: none !important; }

.selected-document { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; align-items: center; gap: 15px; min-height: 94px; margin-top: 12px; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-soft); }
.preview-frame { display: grid; place-items: center; width: 80px; height: 70px; overflow: hidden; border-radius: var(--radius-sm); background: #f8fafc; }
.preview-frame img { width: 100%; height: 100%; object-fit: contain; }
.pdf-preview { display: grid; justify-items: center; gap: 1px; color: var(--accent-strong); font-size: .62rem; text-align: center; }
.pdf-preview svg { width: 30px; height: 35px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pdf-preview span { color: var(--faint); font-size: .56rem; }
.selected-copy { min-width: 0; display: grid; gap: 6px; }
.file-info { overflow-wrap: anywhere; color: var(--text); font-size: .9rem; font-weight: 750; }
.file-status { color: var(--success); font-size: .76rem; font-weight: 750; }

.history-head { align-items: center; }
.history-status { min-height: 20px; margin-top: 18px; color: var(--faint); font-size: .78rem; }
.job-list { display: grid; gap: 10px; margin-top: 8px; }
.loading-state, .empty-state { display: grid; place-items: center; gap: 10px; min-height: 130px; border: 1px dashed var(--border); border-radius: var(--radius-md); color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.job { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 15px 22px; align-items: center; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: rgb(11 16 23 / 56%); }
.job.is-active { border-color: #2b688e; background: linear-gradient(100deg, rgb(19 48 70 / 45%), rgb(11 16 23 / 56%)); }
.job.is-attention { border-color: #69404c; }
.job-overline { display: flex; align-items: center; gap: 9px; min-width: 0; }
.job-time { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.job-recipient { overflow-wrap: anywhere; font-weight: 800; }
.job-document { overflow-wrap: anywhere; color: var(--text); font-size: .91rem; font-weight: 750; }
.job-subline { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 5px; color: var(--muted); font-size: .77rem; }
.job-subline span { display: inline-flex; align-items: center; gap: 5px; }
.job-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.job-actions .secondary { min-height: 38px; padding: 7px 12px; font-size: .8rem; }
.status { display: inline-flex; align-items: center; width: max-content; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: .66rem; font-weight: 850; letter-spacing: .07em; }
.status::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }
.status.success { color: var(--success); background: var(--success-bg); }
.status.failed { color: var(--danger); background: var(--danger-bg); }
.status.active { color: var(--accent); background: #153953; }
.status.unknown { color: var(--warning); background: var(--warning-bg); }
.job-stat { display: grid; gap: 2px; min-width: 0; }
.job-stat-label { color: var(--faint); font-size: .68rem; }
.job-stat-value { color: var(--muted); font-size: .8rem; font-weight: 700; overflow-wrap: anywhere; }
.job-stats { display: flex; flex-wrap: wrap; gap: 16px; }
.job-warning { grid-column: 1 / -1; margin: -2px 0 0; padding: 10px 12px; border-left: 3px solid var(--warning); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: rgb(74 53 24 / 45%); color: #ffe5af; font-size: .8rem; }
.job-events { grid-column: 1 / -1; display: grid; gap: 16px; padding: 18px 2px 2px; border-top: 1px solid var(--border); }
.detail-section { display: grid; gap: 9px; }
.detail-section h3 { margin-bottom: 0; color: var(--text); }
.details-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.detail-item { display: grid; gap: 3px; min-width: 0; padding: 10px; border: 1px solid rgb(39 56 74 / 65%); border-radius: var(--radius-sm); background: var(--surface-soft); }
.detail-label { color: var(--faint); font-size: .68rem; }
.detail-item strong { overflow-wrap: anywhere; color: var(--muted); font-size: .78rem; }
.attempt-list, .event-list { display: grid; gap: 0; }
.attempt-line, .event-line { padding: 8px 0; border-top: 1px solid rgb(39 56 74 / 65%); color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.attempt-line:first-child, .event-line:first-child { border-top: 0; }
.preview-link { width: max-content; font-size: .8rem; font-weight: 700; }

.auth-layout { width: min(100%, 430px); margin: 10vh auto 0; }
.auth-brand { margin: 0 0 23px 4px; }
.auth-brand .brand { font-size: 1.45rem; }
.auth-tagline { margin: 10px 0 0 44px; color: var(--muted); font-size: .86rem; }
.auth-card { padding: 30px; }
.auth-card h1 { font-size: 2rem; }
.auth-card .alert { margin: 20px 0 -4px; }
.stack { display: grid; gap: 17px; margin-top: 25px; }
.auth-card .primary { width: 100%; display: flex; justify-content: center; gap: 10px; }
.auth-footnote { margin: 18px 4px 0; color: var(--faint); font-size: .74rem; text-align: center; }

@media (max-width: 820px) {
  .shell { width: min(100% - 28px, 680px); }
  .site-header { margin-bottom: 32px; }
  .main-nav { display: none; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .send-layout { grid-template-columns: 1fr; gap: 18px; }
  .destination-panel { max-width: 420px; }
  .job { grid-template-columns: 1fr auto; }
  .job-main { min-width: 0; }
  .job-stats { grid-column: 1 / -1; }
  .job-actions { grid-column: 2; grid-row: 1; }
  .details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .shell { width: min(100% - 20px, 680px); padding-top: 18px; padding-bottom: 42px; }
  .site-header { align-items: flex-start; gap: 13px; margin-bottom: 28px; }
  .user-menu { margin-left: auto; gap: 9px; }
  .user-chip { min-width: 0; max-width: 132px; padding: 7px 9px; }
  .user-chip strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-intro, .panel-head { display: grid; gap: 14px; }
  .page-intro { margin-bottom: 18px; }
  .send-card, .history-card { padding: 18px; border-radius: 16px; }
  .send-layout { margin-top: 22px; }
  .drop-zone { min-height: 190px; padding: 22px 14px; }
  .send-footer { align-items: stretch; flex-direction: column; }
  .send-button { width: 100%; }
  .selected-document { grid-template-columns: 64px minmax(0, 1fr); }
  .preview-frame { width: 64px; height: 64px; }
  .selected-document .text-button { grid-column: 2; justify-self: start; }
  .history-head { display: flex; align-items: flex-start; flex-direction: row; }
  .history-head .secondary { flex: 0 0 auto; }
  .job { grid-template-columns: 1fr; gap: 13px; padding: 15px; }
  .job-actions, .job-stats { grid-column: auto; grid-row: auto; justify-content: flex-start; }
  .job-actions { justify-content: flex-start; }
  .job-actions .secondary { flex: 0 0 auto; }
  .details-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
