@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=DM+Sans:wght@300;400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0f;
  --surface:   #141417;
  --surface2:  #1c1c21;
  --border:    #2a2a32;
  --border2:   #35353f;
  --gold:      #c9a96e;
  --gold-dim:  #8a6f3e;
  --text:      #ede9e0;
  --muted:     #7a7a8a;
  --faint:     #3a3a46;
  --success:   #4ecb8d;
  --warning:   #e8a93c;
  --danger:    #e05c5c;
  --info:      #6a9fd8;
  --serif:     'Cormorant Garamond', Georgia, serif;
  --sans:      'DM Sans', system-ui, sans-serif;
  --radius:    14px;
  --radius-sm: 8px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.55;
}

/* ── Nav height token ── */
:root {
  --nav-height: 60px;
  /* Total clearance = nav + safe area inset (iPhone notch etc) */
  --nav-clearance: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

/* Nav padding only applies inside the main app, not on auth screen */
#mainApp {
  /* Enough bottom padding so content never hides behind nav */
  padding-bottom: calc(var(--nav-clearance) + 16px);
  min-height: 100vh;
}

/* ── Grain overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.6;
}

/* ────────────────────────────────────── LAYOUT */
.app { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* ── Header ── */
.app-header {
  padding: 24px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.app-wordmark {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.app-wordmark span { color: var(--gold); }

.header-chip {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 100px;
}

/* ── Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(13,13,15,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 500;
  /* Push content above the safe-area inset on notched devices */
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-sizing: content-box; /* height stays 60px; safe-area adds below it */
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.nav-btn.active { color: var(--gold); }
.nav-btn svg { width: 22px; height: 22px; stroke-width: 1.5; }

/* ────────────────────────────────────── SCREENS */
.screen { display: none; animation: screenIn 0.25s ease; }
.screen.active { display: block; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Screen headings ── */
.screen-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}

.screen-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.4;
}

/* ────────────────────────────────────── COMPONENTS */

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}

.card-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 4px;
}

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
  position: relative;
}

.upload-zone.dragging {
  border-color: var(--gold);
  background: rgba(201,169,110,0.05);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-label { font-size: 15px; color: var(--text); font-weight: 500; }
.upload-hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.upload-selected { font-size: 13px; color: var(--gold); margin-top: 8px; font-weight: 500; }

/* ── Divider ── */
.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Textarea ── */
textarea, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  min-height: 120px;
}
textarea:focus { border-color: var(--gold-dim); }
textarea::placeholder { color: var(--muted); }

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  letter-spacing: 0.02em;
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--gold);
  color: #0d0d0f;
  box-shadow: 0 4px 24px rgba(201,169,110,0.2);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 28px rgba(201,169,110,0.3);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}

.btn-danger {
  background: rgba(224,92,92,0.1);
  color: var(--danger);
  border: 1px solid rgba(224,92,92,0.3);
}

.btn-sm {
  width: auto;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 100px;
}

/* ── Loading spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: none;
}
.btn.loading .spinner { display: block; }
.btn.loading .btn-text { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Step indicator ── */
.steps {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.step-dot {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.3s;
}
.step-dot.done { background: var(--gold); }
.step-dot.active { background: var(--gold-dim); }

/* ── Toast / banner ── */
.toast {
  position: fixed;
  /* Sit 8px above the nav bar, accounting for safe-area inset */
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 8px);
  left: 16px; right: 16px;
  max-width: 448px;
  margin: 0 auto;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 600;
  transform: translateY(calc(100% + var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px));
  transition: transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
  pointer-events: none;
}
.toast.show { transform: translateY(0); pointer-events: auto; }
.toast .toast-msg { flex: 1; }
.toast .toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; padding: 0 2px; line-height: 1;
  flex-shrink: 0;
}
.toast .toast-close:hover { color: var(--text); }
.toast.error   { border-color: rgba(224,92,92,0.45);  color: var(--danger);  background: rgba(13,13,15,0.98); }
.toast.success { border-color: rgba(78,203,141,0.35);  color: var(--success); }

/* ── Extracted text review ── */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid;
  margin-bottom: 14px;
}
.source-badge.pdf     { border-color: rgba(106,159,216,0.4); color: var(--info); }
.source-badge.ocr     { border-color: rgba(232,169,60,0.4); color: var(--warning); }
.source-badge.manual  { border-color: rgba(78,203,141,0.3); color: var(--success); }
.source-badge.txt     { border-color: var(--border2); color: var(--muted); }

.warnings-box {
  background: rgba(232,169,60,0.06);
  border: 1px solid rgba(232,169,60,0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.warnings-box p { font-size: 13px; color: var(--warning); line-height: 1.5; }

/* ── Terms grid ── */
.terms-grid { display: flex; flex-direction: column; gap: 10px; }

.term-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  animation: fadeUp 0.3s ease forwards;
  opacity: 0;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.term-key {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.term-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.45;
}
.term-value.null { color: var(--faint); font-style: italic; }
.term-value.yes  { color: var(--success); }
.term-value.no   { color: var(--danger); }

.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 100px;
  border: 1px solid;
}
.tag.media    { border-color: rgba(106,159,216,0.35); color: #8bbde0; background: rgba(106,159,216,0.06); }
.tag.excluded { border-color: rgba(224,92,92,0.3); color: #e08888; background: rgba(224,92,92,0.05); }
.tag.risk     { border-color: rgba(224,92,92,0.3); color: #e08888; background: rgba(224,92,92,0.05); }
.tag.ambiguity{ border-color: rgba(232,169,60,0.3); color: #d4a850; background: rgba(232,169,60,0.05); }
.tag.action   { border-color: rgba(78,203,141,0.3); color: #5ac99e; background: rgba(78,203,141,0.05); }

/* Confidence bar */
.conf-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.conf-label { font-size: 11px; color: var(--muted); width: 90px; flex-shrink: 0; }
.conf-bar-wrap { flex: 1; height: 4px; background: var(--faint); border-radius: 2px; overflow: hidden; }
.conf-bar { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.conf-bar.high   { background: var(--success); width: 90%; }
.conf-bar.medium { background: var(--warning); width: 55%; }
.conf-bar.low    { background: var(--danger);  width: 25%; }
.conf-val { font-size: 11px; color: var(--muted); width: 46px; text-align: right; }

/* ── Actions list ── */
.action-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: opacity 0.3s;
}
.action-item.done { opacity: 0.45; }
.action-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.action-dot.urgent { background: var(--danger); }
.action-dot.high   { background: var(--warning); }
.action-dot.normal { background: var(--info); }
.action-dot.done   { background: var(--faint); }

.action-body { flex: 1; }
.action-label { font-size: 14px; line-height: 1.4; }
.action-due { font-size: 11px; color: var(--muted); margin-top: 3px; }

.action-check {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 50%;
  width: 26px; height: 26px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.action-check:hover { border-color: var(--success); color: var(--success); }
.action-check.done { background: var(--success); border-color: var(--success); color: #0d0d0f; }

/* ── Contracts list ── */
.contract-list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.contract-list-item:active { background: var(--surface2); }

.contract-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}
.status-active        { background: var(--success); }
.status-expiring_soon { background: var(--warning); }
.status-expired       { background: var(--danger); }
.status-unknown       { background: var(--faint); }

.cli-title { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.cli-brand { font-size: 13px; color: var(--muted); margin-top: 2px; }
.cli-meta  { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }
.cli-meta span { display: flex; align-items: center; gap: 4px; }

.cli-actions-badge {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.badge-num {
  font-size: 17px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}
.badge-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-title { font-family: var(--serif); font-size: 22px; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 14px; line-height: 1.5; }

/* ── Status pill ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid;
}
.status-pill.active        { border-color: rgba(78,203,141,0.3); color: var(--success); }
.status-pill.expired       { border-color: rgba(224,92,92,0.3); color: var(--danger); }
.status-pill.expiring_soon { border-color: rgba(232,169,60,0.3); color: var(--warning); }
.status-pill.unknown       { border-color: var(--border2); color: var(--muted); }

/* ── Section heading ── */
.section-heading {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Notes textarea ── */
.notes-wrap { position: relative; }
.notes-wrap textarea { min-height: 80px; font-size: 14px; }

/* ── Scrollable text preview ── */
.text-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.65;
  max-height: 200px;
  overflow-y: auto;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.text-preview::-webkit-scrollbar { width: 4px; }
.text-preview::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── Detail back button ── */
.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
}
.back-btn:hover { color: var(--text); }

/* ── Raw JSON toggle ── */
details.raw-toggle summary {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
details.raw-toggle summary::before { content: '▸'; transition: transform 0.2s; }
details[open].raw-toggle summary::before { content: '▾'; }
.raw-json {
  margin-top: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  color: var(--text);
  line-height: 1.6;
}

/* ── Utility ── */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8  { margin-bottom: 8px; }
.row   { display: flex; gap: 10px; }
.row .btn { flex: 1; }

.inline-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--faint);
  color: var(--muted);
  margin-left: 6px;
  vertical-align: middle;
}

@media (prefers-color-scheme: light) {
  /* Keep dark regardless — brand choice */
}

@media (max-width: 380px) {
  .screen-title { font-size: 24px; }
  .app-wordmark { font-size: 20px; }
}

/* ════ V2 ADDITIONS ════════════════════════════════════════════════ */

/* ── Auth screen ── */
/* .screen.active sets display:block — we need to override that for the auth screen
   so the flex centering of .full-screen actually works */
#screen-auth.active {
  display: flex;
  min-height: 100vh;
  align-items: flex-start; /* top-aligned so form doesn't float away on mobile */
  justify-content: center;
  padding: 40px 0 40px; /* breathing room top + bottom */
}

@media (min-height: 700px) {
  /* On taller screens (desktop / large phones) center it properly */
  #screen-auth.active {
    align-items: center;
    padding: 0;
  }
}

.auth-wrap {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
}
.auth-logo  { font-family: var(--serif); font-size: 32px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.auth-logo span { color: var(--gold); }
.auth-sub   { text-align: center; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.1em; margin-bottom: 32px; text-transform: uppercase; }
.auth-heading { font-family: var(--serif); font-size: 22px; font-weight: 500; margin-bottom: 16px; }
.auth-input { display: block; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 14px; color: var(--text); font-family: var(--sans); font-size: 15px; outline: none; margin-bottom: 10px; transition: border-color 0.2s; }
.auth-input:focus { border-color: var(--gold-dim); }
.auth-switch { font-size: 13px; color: var(--muted); margin-top: 14px; text-align: center; }
.auth-switch a { color: var(--gold); text-decoration: none; }
.auth-skip { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: center; margin-top: 10px; }
.auth-skip a { color: var(--muted); }

/* ── Mode badge ── */
.mode-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.2s;
}
.mode-badge.test { border-color: rgba(232,169,60,0.5); color: var(--warning); background: rgba(232,169,60,0.08); }
.mode-badge.production { border-color: rgba(78,203,141,0.4); color: var(--success); background: rgba(78,203,141,0.06); }

/* ── User menu ── */
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 50%; width: 32px; height: 32px; color: var(--muted); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.user-menu { position: absolute; top: 60px; right: 16px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 12px; min-width: 180px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.user-menu-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.user-menu-role { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.user-menu-item { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text); font-family: var(--sans); font-size: 13px; padding: 8px 4px; cursor: pointer; border-radius: 4px; }
.user-menu-item:hover { background: var(--surface); }
.user-menu-item.danger { color: var(--danger); }

/* ── Test mode panel ── */
.test-panel {
  background: rgba(232,169,60,0.05);
  border: 1px solid rgba(232,169,60,0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
}
.test-panel-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--warning);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.test-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(232,169,60,0.1);
}
.test-row:last-child { border-bottom: none; }
.test-row-key   { color: var(--muted); }
.test-row-value { color: var(--text); font-weight: 500; }

/* ── Lifecycle state badge ── */
.lc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid;
}
.lc-success { border-color: rgba(78,203,141,0.3); color: var(--success); }
.lc-warning { border-color: rgba(232,169,60,0.3); color: var(--warning); }
.lc-danger  { border-color: rgba(224,92,92,0.3); color: var(--danger); }
.lc-info    { border-color: rgba(106,159,216,0.3); color: var(--info); }
.lc-muted   { border-color: var(--border2); color: var(--muted); }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 20px; margin-top: 8px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline-event { position: relative; margin-bottom: 14px; }
.timeline-event::before { content: ''; position: absolute; left: -17px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--border2); border: 1px solid var(--border); }
.timeline-event.milestone::before { background: var(--gold-dim); }
.timeline-event.expiry::before    { background: var(--danger); }
.timeline-event.start::before     { background: var(--success); }
.timeline-event.reminder::before  { background: var(--warning); }
.timeline-event.status::before    { background: var(--info); }
.timeline-event.trigger::before   { background: var(--accent2); }
.timeline-label { font-size: 13px; color: var(--text); }
.timeline-date  { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Editable field ── */
.editable-field { display: flex; align-items: flex-start; gap: 8px; }
.edit-btn { background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); font-size: 11px; padding: 2px 7px; cursor: pointer; flex-shrink: 0; margin-top: 1px; }
.edit-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
.field-edited-badge { font-family: var(--mono); font-size: 9px; color: var(--warning); border: 1px solid rgba(232,169,60,0.3); border-radius: 3px; padding: 1px 5px; margin-left: 4px; vertical-align: middle; }
.inline-edit-input { width: 100%; background: var(--surface2); border: 1px solid var(--gold-dim); border-radius: 4px; padding: 6px 10px; color: var(--text); font-family: var(--sans); font-size: 13px; outline: none; }

/* ── Date input ── */
.date-input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; color: var(--text); font-family: var(--sans); font-size: 14px; outline: none; color-scheme: dark; }

/* ── Team dashboard ── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.stat-num  { font-family: var(--serif); font-size: 28px; font-weight: 600; color: var(--text); line-height: 1; }
.stat-lbl  { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; }
.stat-num.warn { color: var(--warning); }
.stat-num.danger { color: var(--danger); }
.stat-num.success { color: var(--success); }

.queue-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 8px; }
.queue-type { font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
.queue-title { font-family: var(--serif); font-size: 16px; font-weight: 500; }
.queue-meta  { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Lifecycle state selector */
.lc-selector { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.lc-option { font-size: 11px; padding: 4px 10px; border-radius: 100px; border: 1px solid var(--border); color: var(--muted); cursor: pointer; background: none; font-family: var(--mono); letter-spacing: 0.04em; transition: all 0.15s; }
.lc-option:hover { border-color: var(--gold-dim); color: var(--text); }
.lc-option.active { border-color: var(--gold); color: var(--gold); background: rgba(201,169,110,0.08); }

/* app-header position:relative for menu */
.app-header { position: relative; }

/* Request search btn */
#requestSearchBtn { background: rgba(106,159,216,0.08); color: var(--info); border: 1px solid rgba(106,159,216,0.3); }

/* ════ v2.3 ADDITIONS ══════════════════════════════════════════════ */

/* ── Version label in wordmark ── */
.app-version {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* ── Debug info in user menu ── */
.user-menu-debug {
  margin-top: 4px;
  padding: 8px;
  background: rgba(232,169,60,0.06);
  border: 1px solid rgba(232,169,60,0.2);
  border-radius: 6px;
  margin-bottom: 4px;
}
.debug-row {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--warning);
  line-height: 1.7;
}

/* ── Inline debug label on contract detail ── */
.debug-inline {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--warning);
  background: rgba(232,169,60,0.08);
  border: 1px solid rgba(232,169,60,0.2);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
}

/* ── Loading / error message states ── */
.loading-msg {
  color: var(--muted);
  font-size: 14px;
  padding: 20px 0;
  font-family: var(--mono);
}
.error-msg {
  color: var(--danger);
  font-size: 14px;
  padding: 16px 0;
  line-height: 1.5;
}

/* ── Search request button variant ── */
.btn-search {
  background: rgba(106,159,216,0.08);
  color: var(--info);
  border: 1px solid rgba(106,159,216,0.3);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: background 0.2s;
}
.btn-search:hover { background: rgba(106,159,216,0.14); }

/* ── source-badge docx variant ── */
.source-badge.docx { border-color: rgba(78,203,141,0.4); color: var(--success); background: rgba(78,203,141,0.06); }

/* ── Upload hint text ── */
.upload-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ════ v2.4 OCR REVIEW ═════════════════════════════════════════════ */

/* ── OCR quality bar ── */
.ocr-quality-bar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
}
.ocr-quality-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.ocr-quality-icon.ocr-quality-success { background: rgba(78,203,141,0.15); color: var(--success); }
.ocr-quality-icon.ocr-quality-warning { background: rgba(232,169,60,0.15); color: var(--warning); }
.ocr-quality-icon.ocr-quality-danger  { background: rgba(224,92,92,0.15);  color: var(--danger); }
.ocr-quality-icon.ocr-quality-muted   { background: var(--faint); color: var(--muted); }

.ocr-quality-label {
  font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.3;
}
.ocr-quality-summary {
  font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.5;
}

/* ── Loading state ── */
.ocr-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
  color: var(--muted);
  font-size: 14px;
}
.ocr-loading-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.ocr-loading-label { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ── Production mode message ── */
.ocr-prod-msg {
  text-align: center;
  padding: 24px 18px;
  font-size: 15px;
  font-weight: 500;
}

/* ── No issues ── */
.ocr-no-issues {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
}
.ocr-no-issues-icon  { font-size: 32px; color: var(--success); margin-bottom: 8px; }
.ocr-no-issues-label { font-family: var(--serif); font-size: 18px; color: var(--text); margin-bottom: 4px; }
.ocr-no-issues-sub   { font-size: 13px; }

/* ── Suggestion cards ── */
.ocr-suggestion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
  animation: fadeUp 0.25s ease forwards;
  opacity: 0;
}
.ocr-suggestion-card.ocr-card-accepted { border-color: rgba(78,203,141,0.4); }
.ocr-suggestion-card.ocr-card-rejected { opacity: 0.5; }
.ocr-suggestion-card.ocr-card-edited   { border-color: rgba(106,159,216,0.4); }

.ocr-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ocr-card-type {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.ocr-card-conf {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid;
}
.ocr-card-conf.conf-high   { border-color: rgba(78,203,141,0.4); color: var(--success); }
.ocr-card-conf.conf-medium { border-color: rgba(232,169,60,0.4); color: var(--warning); }
.ocr-card-conf.conf-low    { border-color: rgba(224,92,92,0.3);  color: var(--danger); }

.ocr-card-row    { margin-bottom: 6px; }
.ocr-card-label  { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 2px; }
.ocr-card-original  { font-family: var(--mono); font-size: 13px; color: var(--danger); word-break: break-all; }
.ocr-card-suggested { font-family: var(--mono); font-size: 13px; color: var(--success); word-break: break-all; }
.ocr-card-reason { font-size: 12px; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }

/* ── Suggestion action buttons ── */
.ocr-card-actions, .ocr-card-edit-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-ocr {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: none;
  transition: background 0.15s;
}
.btn-ocr.accept { border-color: rgba(78,203,141,0.4); color: var(--success); }
.btn-ocr.accept:hover { background: rgba(78,203,141,0.1); }
.btn-ocr.reject { border-color: rgba(224,92,92,0.3); color: var(--danger); }
.btn-ocr.reject:hover { background: rgba(224,92,92,0.08); }
.btn-ocr.edit   { border-color: var(--border2); color: var(--muted); }
.btn-ocr.edit:hover { color: var(--text); border-color: var(--muted); }

/* ── Inline edit input for OCR corrections ── */
.ocr-edit-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  min-width: 0;
}

/* ── Card status after decision ── */
.ocr-card-status {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 0;
  margin-top: 4px;
}
.ocr-status-accepted { color: var(--success); }
.ocr-status-rejected { color: var(--muted); }
.ocr-status-edited   { color: var(--info); }

/* ── Bulk action buttons ── */
.ocr-bulk-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.btn-ocr-bulk {
  flex: 1;
  padding: 9px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: none;
}
.btn-ocr-bulk.accept-all { border-color: rgba(78,203,141,0.3); color: var(--success); }
.btn-ocr-bulk.reject-all { border-color: rgba(224,92,92,0.25); color: var(--danger); }
.btn-ocr-bulk:hover { opacity: 0.8; }

/* ── Editable field in terms screen (pre-save) ── */
/* (reuses existing .editable-field, .edit-btn, .inline-edit-input from v2.2) */

/* ════ v2.4.1 ADDITIONS ════════════════════════════════════════════ */

/* ── Production mode summary card ── */
.prod-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  animation: fadeUp 0.3s ease forwards;
  opacity: 0;
}
.prod-summary-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.prod-summary-section:last-child { border-bottom: none; }
.prod-section-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.prod-section-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.prod-section-value.null { color: var(--faint); font-style: italic; }
.prod-section-value.yes  { color: var(--success); }
.prod-section-value.warn { color: var(--warning); }
.prod-section-value.no   { color: var(--danger); }

/* ── Collapsible "View details" in production mode ── */
details.prod-details { margin-bottom: 10px; }
details.prod-details summary {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
details.prod-details summary:hover { background: var(--surface2); color: var(--text); }
details.prod-details summary::before { content: '▸'; font-size: 11px; }
details[open].prod-details summary::before { content: '▾'; }
details.prod-details .prod-details-body {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 14px 16px;
}

/* ── Production action helper text ── */
.action-helper-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

/* ── Request search card ── */
.request-search-card {
  background: var(--surface);
  border: 1px solid rgba(106,159,216,0.25);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 4px;
}
.request-search-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.request-search-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

/* ════ v2.5 ADDITIONS ══════════════════════════════════════════════ */

/* ── Attachment item ── */
.attachment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.att-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.att-icon { font-size: 14px; flex-shrink: 0; }
.att-label {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  word-break: break-all;
}
.att-cat {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.att-delete {
  background: none; border: none;
  color: var(--muted); cursor: pointer; font-size: 12px;
  padding: 2px 4px; flex-shrink: 0;
}
.att-delete:hover { color: var(--danger); }
.att-url {
  display: block;
  font-size: 11px;
  color: var(--info);
  margin-top: 4px;
  word-break: break-all;
  text-decoration: none;
}
.att-url:hover { text-decoration: underline; }
.att-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* ── Attachment add form ── */
.attachment-add-form { margin-top: 4px; }
.att-select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  color-scheme: dark;
}
.att-type-row {
  display: flex;
  gap: 6px;
}
.btn-att-type {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-att-type:hover { border-color: var(--gold-dim); color: var(--text); }
.btn-att-type.active { border-color: var(--gold); color: var(--gold); background: rgba(201,169,110,0.07); }
.att-file-input {
  width: 100%;
  font-size: 13px;
  color: var(--muted);
}

/* ════ v2.6 LAYOUT / UX FIXES ══════════════════════════════════════ */

/* ── Desktop: wider comfortable layout ── */
@media (min-width: 640px) {
  .app {
    max-width: 680px;
  }
  .screen-title { font-size: 32px; }
  /* Two-column grid for stat cards */
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .app { max-width: 780px; }
}

/* ── Lifecycle diagnostics panel ── */
.lc-diag-panel {
  background: rgba(106,159,216,0.05);
  border: 1px solid rgba(106,159,216,0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}
