/* ValPilot design system
   Palette: ink paper background, deep navy structure, verification-teal for
   approved/compliant states, amber for gaps/attention. Signature element:
   the "custody strip" - a stamped chain-of-custody ledger shown on every
   generated artifact (Draft -> Reviewed -> Approved) with hash + timestamp,
   because traceability *is* the product.
*/
:root {
  --paper: #FAF8F3;
  --ink: #14181F;
  --navy: #1B2942;
  --navy-deep: #101827;
  --line: #DEDAD0;
  --teal: #0F6B5C;
  --teal-soft: #E4F1EE;
  --amber: #B4550F;
  --amber-soft: #FBEEE1;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --serif: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--navy-deep); color: #EDEBE4;
  border-bottom: 3px solid var(--teal);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: 0.01em; }
.brand-tag { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #9CA9C2; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: #C9CEDB; }
.topbar-right button { font-family: var(--sans); }
.credit-pill {
  background: rgba(15,107,92,0.25); border: 1px solid var(--teal); color: #A9E8DB;
  padding: 4px 12px; border-radius: 999px; font-family: var(--mono); font-size: 12px; cursor: pointer;
}
.credit-pill:hover { background: rgba(15,107,92,0.4); }

/* ---------- Auth screens ---------- */
.auth-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px;
}
.auth-card {
  width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line);
  padding: 36px 34px; position: relative;
}
.auth-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--navy);
}
.auth-title { font-family: var(--serif); font-size: 26px; margin: 0 0 4px; }
.auth-sub { color: #6B7280; font-size: 13.5px; margin: 0 0 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; letter-spacing: 0.01em; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid #C9C4B8; background: var(--paper);
  font-family: var(--sans); font-size: 14px;
}
.field input:focus, .field select:focus { border-color: var(--navy); background: #fff; }
.field .hint { font-size: 11.5px; color: #8A8578; margin-top: 5px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: none; font-family: var(--sans); font-weight: 600; font-size: 13.5px;
  cursor: pointer; letter-spacing: 0.01em; transition: background 0.12s ease;
}
.btn-primary { background: var(--navy); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--navy-deep); }
.btn-secondary { background: transparent; border: 1px solid var(--navy); color: var(--navy); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-ghost { background: none; border: 1px solid var(--line); color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-switch { margin-top: 20px; font-size: 13px; text-align: center; color: #6B7280; }
.auth-switch a { color: var(--navy); cursor: pointer; font-weight: 600; }
.error-banner {
  background: #FBEAEA; border: 1px solid #E3B4B4; color: #7A2020; padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
}
.mfa-qr { display: flex; justify-content: center; margin: 18px 0; }
.mfa-qr img { border: 1px solid var(--line); padding: 10px; background: #fff; }
.mfa-key { font-family: var(--mono); font-size: 12px; background: var(--paper); padding: 8px 10px; border: 1px dashed var(--line); word-break: break-all; }

/* ---------- Dashboard layout ---------- */
.dash { flex: 1; display: flex; }
.sidebar {
  width: 220px; background: #fff; border-right: 1px solid var(--line); padding: 20px 0;
}
.sidebar nav a {
  display: block; padding: 11px 24px; font-size: 13.5px; color: #4B5060; text-decoration: none;
  border-left: 3px solid transparent; cursor: pointer;
}
.sidebar nav a:hover { background: var(--paper); }
.sidebar nav a.active { border-left-color: var(--teal); background: var(--teal-soft); color: var(--ink); font-weight: 600; }
.main { flex: 1; padding: 30px 40px; max-width: 1100px; }
.page-title { font-family: var(--serif); font-size: 24px; margin: 0 0 4px; }
.page-sub { color: #6B7280; font-size: 13.5px; margin: 0 0 26px; }

.card { background: #fff; border: 1px solid var(--line); padding: 24px; margin-bottom: 20px; }
.card h3 { font-family: var(--serif); font-size: 17px; margin: 0 0 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #7A7566; font-weight: 600; }
tr:hover td { background: var(--paper); }
.hash { font-family: var(--mono); font-size: 11.5px; color: #6B7280; }

.tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 8px; }
.tag-draft { background: var(--amber-soft); color: var(--amber); }
.tag-reviewed { background: #E7ECF5; color: var(--navy); }
.tag-approved { background: var(--teal-soft); color: var(--teal); }

/* Signature element: chain-of-custody strip */
.custody-strip { display: flex; align-items: stretch; margin: 18px 0; border: 1px solid var(--line); }
.custody-step {
  flex: 1; padding: 12px 14px; border-right: 1px solid var(--line); position: relative;
}
.custody-step:last-child { border-right: none; }
.custody-step.done { background: var(--teal-soft); }
.custody-step .cs-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: #6B7280; }
.custody-step.done .cs-label { color: var(--teal); }
.custody-step .cs-value { font-family: var(--mono); font-size: 12px; margin-top: 4px; word-break: break-word; }

textarea.markdown-view {
  width: 100%; min-height: 420px; font-family: var(--mono); font-size: 12.5px; padding: 16px;
  border: 1px solid var(--line); background: #fdfcf9; white-space: pre-wrap;
}
select, input[type=file] { font-family: var(--sans); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.checklist { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.checklist li { padding: 4px 0; }
.checklist li::before { content: '— '; color: var(--teal); }
.empty-state { text-align: center; padding: 40px 20px; color: #8A8578; font-size: 13.5px; }

@media (max-width: 800px) {
  .dash { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: 8px; }
  .sidebar nav { display: flex; }
  .main { padding: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
}
