:root {
  --bg: #08111f;
  --bg-deep: #10233b;
  --surface: rgba(10, 20, 36, 0.76);
  --surface-strong: #0f1c31;
  --surface-border: rgba(146, 170, 200, 0.18);
  --ink: #e8eef7;
  --ink-soft: rgba(214, 226, 241, 0.74);
  --accent: #3f82d8;
  --accent-dark: #8cb6ef;
  --green: #6ec7b2;
  --amber: #d7b36b;
  --red: #d88989;
  --slate: #9aa9bc;
  --shadow: 0 22px 60px rgba(1, 8, 19, 0.36);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 999px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(65, 118, 196, 0.28), transparent 32%),
    radial-gradient(circle at 85% 15%, rgba(132, 169, 221, 0.16), transparent 24%),
    linear-gradient(180deg, #07101b 0%, var(--bg) 42%, #0d1828 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(173, 195, 220, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(173, 195, 220, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.6), transparent 80%);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 72px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px;
  margin-bottom: 28px;
  background: rgba(10, 21, 37, 0.74);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(1, 8, 19, 0.24);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #173764, var(--accent));
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong,
.topnav a,
h1,
h2,
h3,
.button,
.module-index,
.status-pill,
.chip,
.module-state,
.eyebrow {
  font-family: 'Space Grotesk', sans-serif;
}

.brand-copy small {
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
}

.topnav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.95rem;
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--ink);
}

.btn-logout {
  margin-left: auto;
  padding: .375rem .875rem;
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: .8125rem;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}

.btn-logout:hover {
  color: var(--red);
  border-color: var(--red);
}

main {
  display: grid;
  gap: 28px;
}

.hero,
.modules,
.email-workbench,
.workflow,
.readiness {
  position: relative;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero::after,
.workflow::after {
  content: '';
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(86, 136, 206, 0.22), transparent 68%);
  top: -70px;
  right: -60px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.95fr;
  gap: 24px;
  align-items: stretch;
}

.hero-copy,
.hero-panel,
.module-grid,
.panel-grid,
.timeline,
.readiness-grid {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h1,
h2,
h3,
p,
dl {
  margin-top: 0;
}

h1 {
  max-width: 12ch;
  margin-bottom: 16px;
  font-size: clamp(3rem, 6vw, 5.6rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.25rem;
}

p {
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.7;
}

.hero-text {
  max-width: 58ch;
  margin-bottom: 24px;
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, #1b3f71, var(--accent));
  color: #fff;
  box-shadow: 0 12px 28px rgba(22, 54, 97, 0.36);
}

.button-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(146, 170, 200, 0.18);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.hero-metrics div,
.panel-card,
.module-card,
.timeline-step,
.readiness-card {
  border: 1px solid rgba(146, 170, 200, 0.14);
}

.hero-metrics div {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
}

.hero-metrics dt {
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.hero-metrics dd {
  margin: 0;
  font-weight: 700;
}

.hero-panel {
  display: grid;
  gap: 14px;
}

.panel-card {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: rgba(12, 24, 42, 0.88);
}

.panel-card-highlight {
  min-height: 250px;
  background:
    linear-gradient(155deg, rgba(17, 33, 58, 0.98), rgba(25, 50, 84, 0.84)),
    var(--surface-strong);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-kicker,
.status-pill,
.chip,
.module-state {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.panel-kicker {
  color: var(--accent-dark);
  background: rgba(63, 130, 216, 0.14);
}

.status-pill {
  color: var(--green);
  background: rgba(110, 199, 178, 0.12);
}

.panel-grid,
.module-grid,
.readiness-grid {
  display: grid;
  gap: 14px;
}

.panel-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-card p {
  margin-bottom: 0;
  font-size: 0.95rem;
}

.chip-green {
  color: var(--green);
  background: rgba(110, 199, 178, 0.12);
}

.chip-amber {
  color: var(--amber);
  background: rgba(215, 179, 107, 0.12);
}

.chip-red {
  color: var(--red);
  background: rgba(216, 137, 137, 0.12);
}

.chip-slate {
  color: var(--slate);
  background: rgba(154, 169, 188, 0.12);
}

.section-heading {
  display: grid;
  gap: 4px;
  max-width: 800px;
  margin-bottom: 24px;
}

.section-heading.narrow {
  max-width: 650px;
}

.module-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.module-card,
.readiness-card {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: rgba(12, 24, 42, 0.92);
}

.module-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 260px;
}

.module-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1rem;
  font-weight: 700;
}

.feature-upload {
  background: linear-gradient(180deg, rgba(22, 62, 109, 0.94), rgba(11, 25, 43, 0.98));
}

.feature-results {
  background: linear-gradient(180deg, rgba(33, 73, 123, 0.94), rgba(11, 25, 43, 0.98));
}

.feature-dashboard {
  background: linear-gradient(180deg, rgba(20, 44, 77, 0.94), rgba(11, 25, 43, 0.98));
}

.feature-mail {
  background: linear-gradient(180deg, rgba(41, 61, 88, 0.94), rgba(11, 25, 43, 0.98));
}

.module-state {
  width: fit-content;
  color: var(--accent-dark);
  background: rgba(63, 130, 216, 0.14);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.timeline-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: rgba(12, 24, 42, 0.9);
}

.timeline-step > span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
}

.readiness-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.email-workbench {
  display: grid;
  gap: 24px;
}

.health-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.signal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(146, 170, 200, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.signal-live {
  color: #c8f1e7;
  border-color: rgba(110, 199, 178, 0.34);
  background: rgba(59, 111, 98, 0.18);
}

.signal-warn {
  color: #f1ddad;
  border-color: rgba(215, 179, 107, 0.34);
  background: rgba(112, 89, 47, 0.18);
}

.workbench-controls {
  display: grid;
  grid-template-columns: 140px minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid rgba(146, 170, 200, 0.18);
  background: rgba(8, 17, 31, 0.72);
  color: var(--ink);
  font: inherit;
}

.field input:focus {
  outline: 2px solid rgba(140, 182, 239, 0.38);
  outline-offset: 2px;
}

.field-wide {
  min-width: 0;
}

.workbench-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 18px;
}

.workbench-panel {
  min-height: 440px;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(146, 170, 200, 0.14);
  background: rgba(10, 20, 36, 0.68);
}

.workbench-empty,
.result-empty,
.attachment-empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  border-radius: 18px;
  border: 1px dashed rgba(146, 170, 200, 0.18);
  color: var(--ink-soft);
  text-align: center;
  padding: 18px;
}

.mail-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(146, 170, 200, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.mail-card + .mail-card {
  margin-top: 14px;
}

.mail-card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.mail-subject {
  margin-bottom: 6px;
  color: var(--ink);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
}

.mail-meta,
.mail-preview {
  margin-bottom: 0;
}

.attachment-list {
  display: grid;
  gap: 10px;
}

.attachment-button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(63, 130, 216, 0.22);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16, 35, 59, 0.92), rgba(17, 42, 71, 0.7));
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.attachment-button small {
  color: var(--accent-dark);
}

.attachment-button:hover,
.attachment-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(6, 14, 26, 0.26);
}

.result-surface {
  display: grid;
  align-content: start;
}

.result-summary {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.result-kicker {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--accent-dark);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-summary h3 {
  margin-bottom: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.result-panel {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(146, 170, 200, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.result-panel dl,
.result-panel dt,
.result-panel dd {
  margin: 0;
}

.result-panel dl {
  display: grid;
  gap: 14px;
}

.result-panel dt {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.result-item + .result-item {
  margin-top: 12px;
}

.result-item strong,
.result-item span {
  display: block;
}

.result-item span {
  margin-top: 4px;
  color: var(--ink-soft);
}

/* ── Invoice head grid ── */
.result-head-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.result-head-item {
  flex: 1 1 140px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(146, 170, 200, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.result-head-label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.result-head-value {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
}

.result-head-value.val-ok {
  color: var(--green);
}

.result-head-value.val-warn {
  color: var(--amber);
}

/* ── Invoice items table ── */
.result-table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid rgba(146, 170, 200, 0.12);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  line-height: 1.45;
}

.result-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.result-table th {
  padding: 10px 12px;
  background: rgba(15, 28, 49, 0.96);
  color: var(--ink-soft);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid rgba(146, 170, 200, 0.16);
}

.result-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(146, 170, 200, 0.07);
  vertical-align: top;
}

.result-table tbody tr:hover {
  background: rgba(63, 130, 216, 0.07);
}

.result-table tbody tr.row-fee {
  background: rgba(154, 169, 188, 0.06);
}

.result-table tbody tr.row-fee:hover {
  background: rgba(154, 169, 188, 0.12);
}

.col-pos { width: 40px; text-align: center; }
.col-qty,
.col-price,
.col-total { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-desc { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-amq code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(63, 130, 216, 0.12);
  font-size: 0.82rem;
  white-space: nowrap;
}

.col-type { text-align: center; }

.chip-tiny {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.03em;
}

.chip-product {
  color: var(--green);
  background: rgba(110, 199, 178, 0.1);
}

.chip-fee {
  color: var(--slate);
  background: rgba(154, 169, 188, 0.12);
}

.empty-row {
  text-align: center;
  color: var(--ink-soft);
  padding: 28px 12px;
}

/* ── Raw data details ── */
.result-details {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(146, 170, 200, 0.14);
}

.result-details summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-family: 'Space Grotesk', sans-serif;
}

.result-details pre {
  margin-top: 14px;
  padding: 16px;
  overflow: auto;
  border-radius: 16px;
  background: rgba(8, 17, 31, 0.76);
  color: #dce8f7;
  font-size: 0.85rem;
  line-height: 1.5;
}

@media (max-width: 1080px) {
  .hero,
  .module-grid,
  .timeline,
  .readiness-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero {
    align-items: start;
  }

  .workbench-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .workbench-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1200px);
    padding-top: 12px;
  }

  .topbar,
  .hero,
  .modules,
  .email-workbench,
  .workflow,
  .readiness {
    padding: 22px;
  }

  .topbar,
  .hero,
  .panel-grid,
  .module-grid,
  .timeline,
  .readiness-grid,
  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topnav {
    gap: 12px 18px;
  }

  h1 {
    max-width: none;
    font-size: clamp(2.6rem, 14vw, 4rem);
  }

  .hero-actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .mail-card-header,
  .result-summary,
  .attachment-button {
    flex-direction: column;
    align-items: flex-start;
  }
}