:root {
  --bg: #f4f6f8;
  --card: #fff;
  --ink: #1a2332;
  --muted: #5b6b7c;
  --line: #d7dee7;
  --brand: #0b5fff;
  --brand-ink: #fff;
  --danger: #c62828;
  --warn: #f9a825;
  --missing: #ffcdd2;
  --warning: #fff59d;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(16, 32, 64, 0.08);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
[x-cloak] { display: none !important; }
.modal[hidden] { display: none !important; }
a { color: var(--brand); }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1.5rem; background: #0f1c2e; color: #fff;
  gap: 1rem;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.userchip { display: flex; gap: 0.75rem; align-items: center; }
.userchip .usertext { display: flex; flex-direction: column; font-size: 0.8rem; line-height: 1.2; }
.userchip .usertext span { opacity: 0.75; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

.nav-menu { position: relative; }
.menu-toggle {
  appearance: none; background: transparent; border: 1px solid rgba(255,255,255,0.35);
  border-radius: 10px; width: 42px; height: 42px; padding: 0; cursor: pointer;
  display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
}
.menu-toggle span {
  display: block; width: 18px; height: 2px; background: #fff; border-radius: 1px;
}
.nav-menu.open .menu-toggle { border-color: #fff; background: rgba(255,255,255,0.08); }
.nav-menu-panel {
  position: absolute; left: 0; top: calc(100% + 0.4rem); min-width: 220px;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 0.4rem; z-index: 40;
  display: grid; gap: 0.15rem;
}
.nav-menu-panel[hidden] { display: none !important; }
.nav-menu-panel a {
  color: var(--ink); text-decoration: none; padding: 0.7rem 0.85rem; border-radius: 8px;
  font-weight: 600;
}
.nav-menu-panel a:hover { background: #eef3fb; color: var(--brand); }
.container { max-width: 880px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.container.wide { max-width: 1100px; }
h1 { margin: 0 0 0.5rem; font-size: 1.9rem; }
h2 { margin: 0 0 1rem; font-size: 1.2rem; }
.lede { color: var(--muted); max-width: 60ch; line-height: 1.5; }
.muted { color: var(--muted); }
.hint { color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; margin: 1.25rem 0; box-shadow: var(--shadow);
}
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 999px;
  padding: 0.65rem 1.2rem; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary { background: #e8eefc; color: #163a8a; }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; opacity: 0.85; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-cancel {
  background: transparent;
  color: #9aa6b5;
  border-color: #c5ced8;
  font-size: 0.95em; /* ~5% smaller */
}
.btn-preview { font-size: 1.1em; /* ~10% larger */ }
.page-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at top left, #dbe7ff, var(--bg) 55%);
}
.auth-card {
  width: min(420px, 92vw); background: var(--card); padding: 2rem; border-radius: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.auth-card h1 { font-family: "IBM Plex Serif", Georgia, serif; }
.alert { padding: 0.75rem 1rem; border-radius: 10px; margin: 1rem 0; }
.alert.error { background: #fdecea; color: #8a1f1f; }
.upload-form { margin-top: 1.5rem; display: grid; gap: 1rem; }
.dropzone {
  display: block; border: 2px dashed #9eb2cb; border-radius: 16px; background: #fbfdff;
  padding: 2.5rem 1rem; text-align: center; cursor: pointer; transition: 0.15s ease;
}
.dropzone.active, .dropzone:hover { border-color: var(--brand); background: #eef4ff; }
.dropzone input { display: none; }
.drop-inner { display: grid; gap: 0.35rem; }
.drop-inner span { color: var(--muted); font-size: 0.9rem; }
.progress-panel {
  background: var(--card); border-radius: var(--radius); padding: 2rem; margin: 1.5rem 0;
  border: 1px solid var(--line); text-align: center; box-shadow: var(--shadow);
}
.spinner {
  width: 42px; height: 42px; margin: 0 auto 1rem; border-radius: 50%;
  border: 3px solid #d9e3f5; border-top-color: var(--brand); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pct { font-size: 2rem; font-weight: 700; }
.bar { height: 10px; background: #e6edf7; border-radius: 999px; overflow: hidden; margin: 1rem 0 0.35rem; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #0b5fff); transition: width 0.3s; }
.timing {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.9em; /* ~10% smaller than surrounding text */
  margin: 0 0 0.75rem;
  line-height: 1.3;
}
.status-msg { font-size: 1.05rem; margin: 0.25rem 0 0.5rem; }
.error { color: var(--danger); }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 18, 32, 0.55); }
.modal-card {
  position: relative; background: var(--card); border-radius: 16px; padding: 1.5rem;
  width: min(480px, 92vw); box-shadow: var(--shadow); z-index: 1;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.25rem; }
.download-modal { z-index: 70; }
.download-card { width: min(440px, 92vw); text-align: center; }
.download-progress-panel {
  margin: 1rem 0 0;
  padding: 1.25rem 1rem;
  box-shadow: none;
}
.download-progress-panel .pct { margin-bottom: 0.25rem; }
.download-actions { justify-content: center; }
.download-actions-complete { flex-wrap: wrap; }
.download-complete-msg {
  margin: 0.75rem 0 0;
  font-size: 1rem;
  color: var(--muted);
}
.download-cancel-modal { z-index: 80; }
.preview-card {
  width: min(980px, 96vw);
  /* Was ~4vh/4vh effective via 92vh max; shrink page margins ~3x → ~1.3vh each side */
  max-height: calc(100vh - 2.6vh);
  height: calc(100vh - 2.6vh);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.preview-close {
  position: absolute;
  top: 0.35rem;
  right: 0.55rem;
  z-index: 30;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #334155;
}
.preview-close:hover { background: #fff; color: #0f172a; }
.preview-scroll {
  flex: 1 1 auto;
  overflow: auto;
  padding: 1.25rem 1.25rem 5.5rem;
}
.preview-float-actions {
  position: absolute;
  right: 1.25rem;
  bottom: 1rem;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
  background: transparent;
}
.preview-float-actions > * { pointer-events: auto; }
.preview-float-actions .note {
  background: rgba(255, 255, 255, 0.92);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  max-width: 260px;
  text-align: right;
  flex: none;
  margin: 0;
}
.sticky-actions { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 0.75rem 0; margin-bottom: 0.5rem; }
.summary-grid, .summary-stack, .field-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.35rem;
}
.field-group-title {
  margin: 0.75rem 0 0.15rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-group:first-child .field-group-title { margin-top: 0; }
.summary-row,
.field-list .editable-field {
  width: 100%;
  max-width: none;
}
.summary-row .radio-row { cursor: default; }
.radio-row { display: flex; gap: 1.25rem; margin-top: 0.4rem; align-items: center; }
.radio-opt { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; cursor: pointer; }
.editable-field {
  position: relative; border: 1px solid transparent; border-radius: 10px; padding: 0.75rem;
  background: #f8fafc; cursor: pointer; transition: 0.12s ease;
}
.editable-field:hover { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.editable-field.missing { background: var(--missing); }
.editable-field.warning { background: var(--warning); }
.editable-field .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.editable-field .value { margin-top: 0.35rem; font-weight: 600; word-break: break-word; }
.edit-hint { position: absolute; right: 8px; top: 8px; font-size: 0.7rem; color: var(--brand); }
.inline-input { width: 100%; margin-top: 0.35rem; padding: 0.4rem 0.5rem; border-radius: 8px; border: 1px solid var(--brand); font: inherit; }
details summary { cursor: pointer; font-weight: 700; }
.badge { display: inline-block; min-width: 1.5rem; text-align: center; border-radius: 999px; padding: 0.1rem 0.45rem; background: #e8eef8; font-size: 0.75rem; margin-left: 0.35rem; }
.badge.bad { background: #ffcdd2; }
.badge.warn { background: #fff59d; }
.form-stack { display: grid; gap: 1.5rem; }
.form-mock h3 { margin: 0 0 0.5rem; }
.form-page {
  position: relative; border: 1px solid #c5d0de; border-radius: 4px; overflow: hidden;
  background: #fff; margin: 0 auto; max-width: 100%;
}
.form-bg { width: 100%; height: 100%; display: block; pointer-events: none; }

/* Cover letter HTML mock (mirrors build_cover_letter_pdf) */
.cover-letter-page { background: #fff; }
.cover-letter {
  position: absolute; inset: 0;
  font-family: "Times New Roman", Times, serif;
  color: #000;
}
.cover-letter-logo {
  position: absolute;
  left: 5.5%;
  top: 4.5%;
  width: 89%;
  height: 91%;
  object-fit: fill;
  pointer-events: none;
}
.cover-letter-body {
  position: absolute;
  left: 12.5%;
  right: 12.5%;
  top: 15%;
  /* Leave room for letterhead footer contact line */
  bottom: 14%;
  font-size: 11.5pt;
  line-height: 1.25;
  overflow: hidden;
}
.cover-static, .cover-line, .cover-money, .cover-yesno, .cover-send, .cover-italic {
  margin: 0 0 0.35rem;
}
.cover-spacer { height: 0.4rem; }
.cover-spacer-lg { height: 0.7rem; }
.cover-label { margin-right: 0.35rem; }
.cover-input {
  font: inherit;
  border: none;
  border-bottom: 1px dotted #999;
  background: rgba(255, 255, 255, 0.65);
  min-width: 12rem;
  width: calc(100% - 5rem);
  padding: 0 2px;
}
.cover-input:focus { outline: 1px solid var(--brand); background: #fff; }
.cover-input:disabled { opacity: 0.5; }
.cover-input-money { width: 14rem; min-width: 8rem; font-weight: inherit; font-style: inherit; }
.cover-money {
  font-size: 16pt;
  font-weight: 700;
  font-style: italic;
  margin-bottom: 0.55rem;
}
.cover-yesno {
  font-size: 16pt;
  font-weight: 700;
  font-style: italic;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.cover-yesno-label { margin-right: 0.5rem; }
.cover-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  padding: 0.05rem 0.35rem;
  font: inherit;
  font-weight: 700;
  font-style: italic;
  color: inherit;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}
.cover-choice:hover { background: rgba(0, 0, 0, 0.06); }
.cover-choice.circled {
  border-color: #111;
  padding: 0.15rem 0.45rem;
}
.cover-send {
  font-size: 11.5pt;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
}
.cover-italic { font-style: italic; font-size: 11.5pt; }
.cover-line.missing, .cover-money.missing { background: rgba(255, 0, 0, 0.28); }
.cover-line.warning, .cover-money.warning { background: rgba(255, 255, 0, 0.4); }

.overlay-slot {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
}
.overlay-slot.overlay-readonly {
  pointer-events: none;
}
.overlay-slot.overlay-readonly .overlay-input-inner,
.overlay-slot.overlay-readonly .overlay-check-inner {
  border-color: transparent;
  background: transparent;
  cursor: default;
}
.overlay-input-inner {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(30, 90, 160, 0.22);
  background: rgba(255, 255, 255, 0.72);
  font-family: Helvetica, Arial, sans-serif;
  font-size: inherit;
  line-height: 1.1;
  padding: 0 2px;
  box-sizing: border-box;
}
.overlay-input-inner[readonly] {
  cursor: default;
  border-color: transparent;
  background: transparent;
}
.overlay-input-inner:focus { outline: 2px solid var(--brand); background: #fff; }
.overlay-input-inner.missing { background: rgba(255, 0, 0, 0.35); }
.overlay-input-inner.warning { background: rgba(255, 255, 0, 0.45); }
.overlay-check-inner {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(30, 90, 160, 0.25);
}
.overlay-check-inner input[type="checkbox"] {
  width: 85%;
  height: 85%;
  margin: 0;
  cursor: pointer;
  accent-color: #1a1a1a;
}
.overlay-check-inner.missing { background: rgba(255, 0, 0, 0.35); }
.overlay-check-inner.warning { background: rgba(255, 255, 0, 0.45); }
.overlay-input {
  position: absolute;
  border: 1px solid rgba(30, 90, 160, 0.22);
  background: rgba(255, 255, 255, 0.72);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 9px;
  line-height: 1.1;
  padding: 0 2px;
  z-index: 2;
  box-sizing: border-box;
}
.overlay-input:focus { outline: 2px solid var(--brand); background: #fff; }
.overlay-input.missing { background: rgba(255, 0, 0, 0.35); }
.overlay-input.warning { background: rgba(255, 255, 0, 0.45); }
.overlay-check {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(30, 90, 160, 0.25);
}
.overlay-check input[type="checkbox"] {
  width: 85%;
  height: 85%;
  margin: 0;
  cursor: pointer;
  accent-color: #1a1a1a;
}
.overlay-check.missing { background: rgba(255, 0, 0, 0.35); }
.overlay-check.warning { background: rgba(255, 255, 0, 0.45); }
.note { color: var(--danger); margin: 0; flex: 1 1 100%; }

.jobs-card { padding: 0; overflow: hidden; }
.jobs-table {
  width: 100%; border-collapse: collapse; font-size: 0.95rem;
}
.jobs-table th, .jobs-table td {
  text-align: left; padding: 0.85rem 1rem; border-bottom: none;
  vertical-align: middle;
}
.jobs-table th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.jobs-table tbody tr {
  box-shadow: inset 0 -1px 0 var(--line);
}
.jobs-table tbody tr:last-child {
  box-shadow: none;
}
.job-name { max-width: 28rem; }
.job-name a { font-weight: 600; text-decoration: none; color: var(--ink); display: block; }
.job-name a:hover { color: var(--brand); }
.job-state { display: block; font-size: 0.8rem; text-transform: capitalize; margin-top: 0.2rem; }
.job-date { white-space: nowrap; color: var(--muted); font-size: 0.9rem; }
.job-actions {
  display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center;
  white-space: nowrap;
}
.job-actions .btn { padding: 0.45rem 0.9rem; font-size: 0.88rem; }
@media (max-width: 800px) {
  .jobs-table thead { display: none; }
  .jobs-table, .jobs-table tbody, .jobs-table tr, .jobs-table td { display: block; width: 100%; }
  .jobs-table tbody tr {
    padding: 0.85rem 1rem;
    box-shadow: inset 0 -1px 0 var(--line);
  }
  .jobs-table td { border: none; padding: 0.25rem 0; }
  .job-actions { justify-content: flex-start; margin-top: 0.5rem; }
}

