:root {
  --canvas: #f4f3ef;
  --paper: #fbfaf7;
  --ink: #171b1e;
  --muted: #687178;
  --line: #d8dcda;
  --accent: #f05d38;
  --accent-dark: #c74325;
  --mint: #d8f0e2;
  --navy: #173341;
  --shadow: 0 14px 36px rgba(29, 42, 48, 0.07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 51, 65, 0.035) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(rgba(23, 51, 65, 0.035) 1px, transparent 1px) 0 0 / 38px 38px,
    var(--canvas);
  font-family: Manrope, Arial, sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}
.auth-card {
  width: min(100%, 420px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.auth-card h1 { margin-bottom: 14px; font-size: 48px; }
.auth-card > p:not(.eyebrow):not(.notice) { margin-bottom: 25px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.auth-password { display: block; margin-bottom: 18px; }
.auth-password span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.auth-card .button { width: 100%; }
body.authenticated #auth-gate { display: none !important; }
body.authenticated #app-shell { display: block !important; }

.shell { max-width: 1180px; margin: 0 auto; padding: 62px 28px 80px; }

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  padding: 0 4px 42px;
}

.eyebrow, .section-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow span { display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--accent); border-radius: 50%; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(42px, 7vw, 72px); letter-spacing: -0.075em; line-height: 0.95; }
h1 em { color: var(--accent); font-style: normal; }
h2 { margin-bottom: 0; font-size: 25px; letter-spacing: -0.045em; }
h3 { margin-bottom: 0; font-size: 17px; letter-spacing: -0.03em; }
.lede { max-width: 590px; margin-bottom: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }

.api-link, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}
.api-link { padding: 0 15px; white-space: nowrap; }
.api-link:hover, .button.ghost:hover { color: var(--paper); background: var(--ink); transform: translateY(-1px); }
.button { padding: 0 16px; }
.button.primary { color: white; border-color: var(--accent); background: var(--accent); }
.button.primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.48; transform: none; }
.button.ghost { min-height: 34px; padding: 0 11px; border-color: var(--line); font-size: 11px; }
.hero-actions { display: flex; align-items: center; gap: 9px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { display: flex; gap: 9px; padding: 15px 20px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-family: "DM Mono", monospace; font-size: 12px; }
.tab span { color: var(--ink); font-family: Manrope, Arial, sans-serif; font-size: 13px; font-weight: 800; }
.tab.active { border-bottom-color: var(--accent); color: var(--accent); }
.panel { padding: 42px 0 0; }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 27px; }
.panel-heading > p { max-width: 455px; margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: right; }

.upload-form, .search-form, .metrics-card { padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.dropzone { display: flex; min-height: 170px; flex-direction: column; align-items: center; justify-content: center; padding: 24px; border: 1.5px dashed #aeb8b5; border-radius: 5px; background: #f7f9f5; text-align: center; transition: border-color 160ms ease, background 160ms ease; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: #fff6f0; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-icon { display: grid; width: 37px; height: 37px; place-items: center; margin-bottom: 11px; border-radius: 50%; color: var(--paper); background: var(--navy); font-family: "DM Mono", monospace; font-size: 20px; }
.dropzone strong { font-size: 14px; }
.dropzone small { margin-top: 7px; color: var(--muted); font-size: 11px; }
.upload-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 16px; }
.muted { color: var(--muted); font-size: 12px; }
.notice { margin: 18px 0 0; padding: 12px 14px; border-left: 3px solid var(--navy); color: var(--navy); background: #e8f0ee; font-size: 12px; line-height: 1.5; }
.notice.error { border-color: #b53c26; color: #7a2518; background: #fbe9e4; }

.split-section { display: grid; grid-template-columns: 0.82fr 1.18fr; gap: 42px; margin-top: 52px; }
.subheading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.subheading .section-label { margin-bottom: 5px; }
.count { color: var(--accent); font-family: "DM Mono", monospace; font-size: 12px; }
.document-list, .points-list, .search-results { border-top: 1px solid var(--line); }
.loading, .empty-state { padding: 22px 0; color: var(--muted); font-size: 13px; }
.document-row { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.document-name { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.document-tag { flex: none; color: var(--accent-dark); font-family: "DM Mono", monospace; font-size: 10px; }
.point { padding: 14px 0; border-bottom: 1px solid var(--line); }
.point-top { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 8px; color: var(--navy); font-size: 11px; font-weight: 800; }
.point code, .result-id { color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.point p { display: -webkit-box; overflow: hidden; margin: 0; color: #495258; font-size: 12px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

.search-form { display: grid; grid-template-columns: 1fr; gap: 17px; }
.search-form label span { display: block; margin-bottom: 7px; color: var(--ink); font-size: 12px; font-weight: 800; }
.search-form label small { color: var(--muted); font-size: 10px; font-weight: 500; }
textarea, input, select { width: 100%; border: 1px solid #c9cfcc; border-radius: 4px; outline: none; color: var(--ink); background: white; }
textarea, input { padding: 11px 12px; }
textarea { min-height: 82px; resize: vertical; line-height: 1.45; }
select { height: 42px; padding: 0 10px; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240, 93, 56, 0.13); }
.search-controls { display: grid; grid-template-columns: minmax(200px, 1fr) 110px auto; align-items: end; gap: 13px; }
.search-controls label span { margin-bottom: 7px; }
.relevance-field { padding-top: 4px; }
.results-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 42px; margin-top: 47px; }
.results-heading { margin-bottom: 0; }
.method-badge { padding: 6px 8px; border: 1px solid #b8c3bd; border-radius: 3px; color: var(--navy); background: #e5f1e9; font-family: "DM Mono", monospace; font-size: 10px; }
.result { padding: 18px 0; border-bottom: 1px solid var(--line); }
.result-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.result-source { color: var(--navy); font-size: 12px; font-weight: 800; }
.score { flex: none; color: var(--accent-dark); font-family: "DM Mono", monospace; font-size: 12px; font-weight: 500; }
.result-id { display: block; margin-top: 5px; }
.result-content { margin: 11px 0 0; color: #42494e; font-size: 13px; line-height: 1.65; }
.score-detail { margin-top: 8px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.metrics-card { align-self: start; }
.metrics-card h3 { margin-bottom: 21px; }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.metric { display: flex; min-height: 84px; flex-direction: column; justify-content: center; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric span { color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.metric strong { margin-top: 4px; color: var(--navy); font-size: 22px; letter-spacing: -0.05em; }
.metrics-note { margin: 15px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

@media (max-width: 760px) {
  .shell { padding: 35px 18px 54px; }
  .hero, .panel-heading { align-items: flex-start; flex-direction: column; }
  .hero { gap: 20px; padding-bottom: 31px; }
  .panel-heading { gap: 12px; }
  .panel-heading > p { text-align: left; }
  .split-section, .results-layout { grid-template-columns: 1fr; gap: 36px; }
  .search-controls { grid-template-columns: 1fr 100px; }
  .search-controls .button { grid-column: 1 / -1; }
  .tabs { overflow-x: auto; }
  .tab { padding-right: 13px; padding-left: 13px; white-space: nowrap; }
}
