:root {
  --ink: #102634;
  --muted: #60717a;
  --paper: #f5f2ea;
  --surface: #fffdf8;
  --navy: #123e52;
  --teal: #176b68;
  --gold: #d99b3d;
  --line: #d9ddd8;
  --danger: #a83b35;
  --shadow: 0 24px 70px rgba(20, 46, 58, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-header { min-height: 86px; padding: 0 4vw; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 28px; color: white; background: var(--navy); border-bottom: 4px solid var(--gold); }
.brand { display: inline-flex; width: fit-content; align-items: center; gap: 12px; color: white; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; color: var(--navy); background: var(--gold); border-radius: 50%; font: 800 19px/1 Georgia, serif; }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 16px/1.15 Georgia, serif; letter-spacing: .02em; }
.brand small { margin-top: 3px; color: #c8d7da; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
nav { height: 86px; display: flex; gap: 28px; align-items: stretch; }
nav a { position: relative; display: flex; align-items: center; color: #c8d7da; text-decoration: none; font-size: 14px; font-weight: 650; }
nav a.active { color: white; }
nav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: white; }
.header-tools { justify-self: end; display: flex; align-items: center; gap: 14px; }
.session-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid rgba(255,255,255,.2); border-radius: 99px; color: #d7e3e5; font-size: 12px; white-space: nowrap; }
.session-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(217,155,61,.13); }
.session-pill.ready i { background: #64c6a5; box-shadow: 0 0 0 4px rgba(100,198,165,.13); }
.api-key-control { display: grid; gap: 3px; }
.api-key-control span { color: #aabdc2; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.api-key-control input { width: 150px; padding: 7px 9px; color: white; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); border-radius: 4px; outline: none; }
.api-key-control input:focus { border-color: var(--gold); }

main { width: min(1380px, 92vw); margin: 0 auto; }
.hero { padding: 72px 0 44px; max-width: 820px; }
.eyebrow, .step { margin: 0 0 12px; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero h1 { margin: 0; font: 500 clamp(44px, 6vw, 76px)/.98 Georgia, serif; letter-spacing: -.045em; }
.hero > p:last-child { max-width: 660px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.6; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 330px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid rgba(16,38,52,.07); }
.form-panel { padding: clamp(28px, 4vw, 54px); }
.panel-heading, .results-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
h2 { margin: 0; font: 500 30px/1.12 Georgia, serif; }
.text-button { padding: 5px 0; color: var(--teal); background: none; border: 0; border-bottom: 1px solid currentColor; cursor: pointer; font-size: 13px; font-weight: 700; }
.search-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 24px; padding-top: 30px; }
.search-form[hidden] { display: none; }
label { display: grid; gap: 8px; }
label > span { color: #425862; font-size: 12px; font-weight: 750; letter-spacing: .035em; }
input, select { width: 100%; min-height: 45px; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid #cbd2cf; border-radius: 3px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23,107,104,.1); }
input::placeholder { color: #9aa7aa; }
.span-2 { grid-column: span 2; }
.form-action { margin-top: 8px; padding-top: 24px; display: flex; justify-content: space-between; align-items: center; gap: 24px; border-top: 1px solid var(--line); }
.form-action p { max-width: 420px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.primary-button { min-height: 48px; padding: 0 0 0 20px; display: inline-flex; align-items: center; gap: 20px; color: white; background: var(--teal); border: 0; border-radius: 3px; cursor: pointer; font-weight: 750; }
.primary-button b { width: 48px; align-self: stretch; display: grid; place-items: center; background: rgba(0,0,0,.14); font-size: 20px; }
.primary-button:hover { background: #125b59; }
.primary-button:disabled { cursor: wait; opacity: .65; }
.primary-button.full { width: 100%; justify-content: space-between; }

.session-panel { padding: 48px 36px; color: white; background: var(--navy); }
.session-panel .step { color: #89c9bd; }
.session-panel h2 { margin-bottom: 20px; font-size: 34px; }
.session-panel > p:not(.step) { margin: 0 0 30px; color: #c3d4d8; font-size: 14px; line-height: 1.65; }
.session-rule { display: flex; align-items: center; gap: 14px; padding: 16px 0; border-top: 1px solid rgba(255,255,255,.13); }
.session-rule span { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid #82aaaF; border-radius: 50%; color: #dce8e9; font-size: 11px; }
.session-rule p { margin: 0; font-size: 13px; }
.session-panel small { display: block; margin-top: 28px; color: #8fa9af; line-height: 1.55; }

.results-section { margin: 34px 0 90px; padding: clamp(28px, 4vw, 48px); background: var(--surface); border: 1px solid rgba(16,38,52,.07); }
.results-heading > span { color: var(--muted); font-size: 13px; }
.empty-state { padding: 64px 20px; text-align: center; color: var(--muted); }
.empty-state > span { width: 56px; height: 56px; margin: 0 auto 18px; display: grid; place-items: center; color: var(--teal); background: #e4efeb; border-radius: 50%; font-size: 30px; }
.empty-state h3 { margin: 0; color: var(--ink); font: 500 21px Georgia, serif; }
.empty-state p { margin: 9px 0 0; font-size: 13px; }
.table-wrap { margin-top: 24px; overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th { padding: 13px 14px; color: white; background: var(--navy); text-align: left; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); }
tbody tr:nth-child(even) { background: #f7f7f3; }
tbody tr:hover { background: #eef5f2; }
tbody tr.selectable { cursor: pointer; }
tbody tr.selectable:focus { outline: 3px solid rgba(23,107,104,.3); outline-offset: -3px; background: #eef5f2; }
tbody tr.selectable.loading { cursor: wait; opacity: .65; }

.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: 420px; padding: 14px 18px; color: white; background: var(--danger); border-radius: 4px; box-shadow: var(--shadow); font-size: 13px; }
dialog { width: min(500px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 5px; box-shadow: 0 30px 100px rgba(3,18,27,.35); }
dialog::backdrop { background: rgba(7,28,39,.72); backdrop-filter: blur(3px); }
.dialog-shell { position: relative; padding: 38px; }
.dialog-shell > p:not(.step):not(.dialog-error) { color: var(--muted); font-size: 13px; line-height: 1.55; }
.dialog-close { position: absolute; right: 14px; top: 10px; color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 28px; }
.captcha-frame { min-height: 92px; margin: 26px 0 20px; display: grid; place-items: center; background: #eef0eb; border: 1px dashed #b9c2be; }
.captcha-frame img { width: 262px; max-width: 80%; image-rendering: auto; }
.dialog-error { margin: 12px 0; color: var(--danger); font-size: 12px; font-weight: 650; }
.dialog-shell .primary-button { margin-top: 18px; }
.details-dialog { width: min(960px, calc(100vw - 28px)); }
.details-shell { max-height: min(820px, calc(100vh - 40px)); overflow-y: auto; }
.details-content { margin-top: 28px; }
.detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.detail-meta > div { min-height: 74px; padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-meta dt { margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-meta dd { margin: 0; font-size: 14px; font-weight: 650; }
.detail-section { margin-top: 30px; }
.detail-section h3 { margin: 0 0 12px; font: 500 20px Georgia, serif; }
.detail-section .table-wrap { margin-top: 0; }
.document-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); }
.document-list li { padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.document-list li:last-child { border-bottom: 0; }
.document-list li > span { display: grid; gap: 4px; }
.document-list small { color: var(--muted); }
.document-download { min-height: 36px; padding: 0 14px; color: white; background: var(--teal); border: 0; border-radius: 3px; cursor: pointer; font-size: 12px; font-weight: 750; }
.document-download:hover { background: #125b59; }
.document-download:disabled { cursor: wait; opacity: .65; }

@media (max-width: 980px) {
  .site-header { grid-template-columns: 1fr auto; padding: 12px 4vw 0; }
  nav { grid-column: 1 / -1; grid-row: 2; height: 50px; }
  .header-tools { grid-column: 2; grid-row: 1; }
  .workspace { grid-template-columns: 1fr; }
  .session-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 22px; }
  .session-panel > .step, .session-panel > h2, .session-panel > p, .session-panel > small { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .site-header { display: flex; flex-wrap: wrap; gap: 10px 18px; }
  .brand { flex: 1; }
  .header-tools { order: 2; width: 100%; justify-content: space-between; }
  nav { order: 3; width: 100%; }
  .hero { padding-top: 48px; }
  .search-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .form-action { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; justify-content: space-between; }
  .session-panel { display: block; }
  .api-key-control { flex: 1; }
  .api-key-control input { width: 100%; }
  .detail-meta { grid-template-columns: 1fr; }
}
