/* ========================================================================
   AgentLedger — Federal Register inspired stylesheet
   Palette: Treasury navy / notarial gold / parchment ground
   ======================================================================== */

:root {
  --navy: #0B2545;
  --navy-2: #13315C;
  --navy-3: #1E3A6A;
  --gold: #C9A961;
  --gold-2: #8F7840;
  --forest: #2F5D3A;
  --ochre: #B8860B;
  --crimson: #8B1A1A;
  --parchment: #F7F5EE;
  --parchment-2: #EDEAE0;
  --ink: #1A1A1A;
  --stone: #B8B0A0;
  --stone-2: #D9D4C7;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow: 0 1px 2px rgba(11, 37, 69, 0.08), 0 4px 16px rgba(11, 37, 69, 0.06);
}

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

html, body {
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--gold-2); }

h1, h2, h3, h4 { font-family: var(--serif); color: var(--navy); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 2.4rem; line-height: 1.15; }
h2 { font-size: 1.6rem; line-height: 1.25; margin-bottom: 0.5rem; }
h3 { font-size: 1.15rem; line-height: 1.3; }
h4 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.12em; font-family: var(--sans); color: var(--gold-2); font-weight: 600; }

p { margin-bottom: 0.9rem; }

code, pre, .mono { font-family: var(--mono); }
pre {
  background: var(--navy);
  color: #E8E4D2;
  padding: 1rem 1.2rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  border-left: 3px solid var(--gold);
}
pre .k { color: var(--gold); }
pre .s { color: #9BC5A8; }
pre .n { color: #E7A877; }
pre .b { color: #B8D0E8; }

/* ======== Header ======== */
.header {
  background: var(--navy);
  color: var(--parchment);
  border-bottom: 3px solid var(--gold);
  padding: 0.8rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.header-brand { display: flex; align-items: center; gap: 0.9rem; text-decoration: none; color: inherit; }
.header-brand img { width: 44px; height: 44px; }
.header-brand .wordmark {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.header-brand .tagline {
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold);
  margin-top: 2px;
}

.nav { display: flex; gap: 0; }
.nav a {
  color: var(--parchment);
  text-decoration: none;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 2px solid transparent;
  transition: border-color 0.15s;
}
.nav a:hover, .nav a.active { border-bottom-color: var(--gold); color: var(--gold); }

/* ======== Page Container ======== */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}
.container-narrow { max-width: 820px; }

/* ======== Federal Bar (top of each view) ======== */
.federal-bar {
  background: var(--parchment-2);
  border-top: 1px solid var(--stone);
  border-bottom: 1px solid var(--stone);
  padding: 0.4rem 2rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--navy-2);
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  text-transform: uppercase;
}

/* ======== Hero (Landing) ======== */
.hero {
  text-align: center;
  padding: 4rem 2rem 3rem;
  border-bottom: 1px solid var(--stone);
}
.hero img.seal { width: 150px; height: 150px; margin-bottom: 1.5rem; }
.hero .eyebrow {
  font-size: 0.78rem;
  color: var(--gold-2);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  margin-bottom: 1rem;
}
.hero h1 { max-width: 820px; margin: 0 auto 1.2rem; }
.hero .lead {
  max-width: 680px;
  margin: 0 auto 2rem;
  font-size: 1.08rem;
  color: #3A3A3A;
}

.cta-row { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-decoration: none;
  border: 1.5px solid var(--navy);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
  color: var(--navy);
}
.btn:hover { background: var(--navy); color: var(--parchment); }
.btn-primary { background: var(--navy); color: var(--parchment); }
.btn-primary:hover { background: var(--navy-2); color: var(--gold); border-color: var(--navy-2); }
.btn-gold { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-2); color: var(--parchment); border-color: var(--gold-2); }
.btn-ghost { border-color: var(--stone); color: var(--navy-2); }
.btn-ghost:hover { background: var(--parchment-2); color: var(--navy); border-color: var(--navy-2); }
.btn-danger { border-color: var(--crimson); color: var(--crimson); }
.btn-danger:hover { background: var(--crimson); color: var(--parchment); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.72rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ======== Panels ======== */
.panel {
  background: #FFFFFF;
  border: 1px solid var(--stone);
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.5rem;
}
.panel-navy {
  background: var(--navy);
  color: var(--parchment);
  border-color: var(--navy);
}
.panel-navy h2, .panel-navy h3 { color: var(--parchment); }
.panel-navy h4 { color: var(--gold); }

.panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--stone-2);
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
}
.panel-hdr h2, .panel-hdr h3 { margin: 0; }

/* ======== Stat cards ======== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.stat {
  background: var(--parchment);
  border: 1px solid var(--stone-2);
  padding: 1rem;
  border-radius: 3px;
}
.stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--navy-2);
  margin-bottom: 0.3rem;
  font-weight: 600;
}
.stat .value {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
}
.stat .sub {
  font-size: 0.78rem;
  color: #555;
  margin-top: 0.2rem;
}

/* ======== Trust score dial ======== */
.score-main {
  text-align: center;
  padding: 1.2rem 1rem;
  background: linear-gradient(180deg, var(--parchment) 0%, #FFFFFF 100%);
  border: 1px solid var(--gold);
  border-radius: 3px;
  position: relative;
}
.score-main::before {
  content: "AGENT FICO";
  position: absolute;
  top: 0.6rem;
  left: 0;
  right: 0;
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--gold-2);
  font-weight: 700;
}
.score-value {
  font-family: var(--serif);
  font-size: 3.8rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  margin-top: 1.5rem;
}
.score-band {
  font-family: var(--sans);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--forest);
  margin-top: 0.4rem;
  font-weight: 600;
}
.score-band.band-fair { color: var(--ochre); }
.score-band.band-poor { color: var(--crimson); }

/* Sub-score bars */
.sub-scores { margin-top: 1rem; }
.sub-score-row {
  display: grid;
  grid-template-columns: 110px 1fr 50px;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}
.sub-score-row .name { color: var(--navy-2); font-weight: 500; }
.sub-score-row .bar {
  height: 8px;
  background: var(--stone-2);
  border-radius: 2px;
  overflow: hidden;
}
.sub-score-row .bar-fill {
  height: 100%;
  background: var(--forest);
  transition: width 0.4s ease, background 0.3s;
}
.sub-score-row .bar-fill.fair { background: var(--ochre); }
.sub-score-row .bar-fill.poor { background: var(--crimson); }
.sub-score-row .num { text-align: right; font-family: var(--mono); font-weight: 600; color: var(--navy); }

/* ======== Status pill ======== */
.pill {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 2px;
  border: 1px solid;
}
.pill-active { color: var(--forest); border-color: var(--forest); background: rgba(47,93,58,0.08); }
.pill-flagged { color: var(--ochre); border-color: var(--ochre); background: rgba(184,134,11,0.08); }
.pill-revoked { color: var(--crimson); border-color: var(--crimson); background: rgba(139,26,26,0.08); }
.pill-pending { color: var(--navy-2); border-color: var(--stone); background: var(--parchment); }

/* ======== Banner ======== */
.banner {
  padding: 0.8rem 1.2rem;
  border-left: 4px solid;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border-radius: 2px;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}
.banner-info { background: rgba(11,37,69,0.05); border-color: var(--navy); color: var(--navy); }
.banner-warn { background: rgba(184,134,11,0.1); border-color: var(--ochre); color: #6B4E05; }
.banner-danger { background: rgba(139,26,26,0.08); border-color: var(--crimson); color: var(--crimson); }
.banner-success { background: rgba(47,93,58,0.08); border-color: var(--forest); color: var(--forest); }
.banner strong { display: block; margin-bottom: 0.2rem; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem; }

/* ======== Forms ======== */
.form-row { margin-bottom: 1rem; }
.form-row label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--navy-2);
  margin-bottom: 0.3rem;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--stone);
  border-radius: 2px;
  background: var(--parchment);
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink);
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 0;
  border-color: var(--gold);
}
.form-row .hint { font-size: 0.72rem; color: #666; margin-top: 0.2rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ======== Tables ======== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--navy-2);
  font-weight: 700;
  padding: 0.5rem 0.7rem;
  border-bottom: 1.5px solid var(--navy);
  background: var(--parchment);
}
td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--stone-2);
  vertical-align: middle;
}
tr:hover td { background: var(--parchment); }

/* ======== Demo-specific ======== */
.demo-wrap {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}
.demo-steps {
  list-style: none;
  padding: 0;
  border-left: 2px solid var(--stone-2);
}
.demo-steps li {
  padding: 0.6rem 0 0.6rem 1rem;
  margin-left: -2px;
  border-left: 2px solid transparent;
  font-size: 0.85rem;
  color: #666;
  position: relative;
  cursor: default;
}
.demo-steps li.active { border-left-color: var(--gold); color: var(--navy); font-weight: 600; }
.demo-steps li.done { color: var(--forest); border-left-color: var(--forest); }
.demo-steps li .num {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--gold-2);
  margin-right: 0.5rem;
}

.demo-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--stone-2);
}

/* ======== Sandbox layout ======== */
.sandbox-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 960px) {
  .sandbox-grid { grid-template-columns: 1fr; }
  .demo-wrap { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ======== Ticker / Transaction log ======== */
.tx-log {
  max-height: 260px;
  overflow-y: auto;
  background: var(--navy);
  color: #E8E4D2;
  font-family: var(--mono);
  font-size: 0.76rem;
  padding: 0.8rem;
  border-radius: 3px;
  border: 1px solid var(--navy-2);
}
.tx-log .row { padding: 0.2rem 0; border-bottom: 1px dashed rgba(255,255,255,0.08); }
.tx-log .row:last-child { border-bottom: 0; }
.tx-log .t { color: var(--gold); }
.tx-log .ok { color: #9BC5A8; }
.tx-log .warn { color: #E7B85D; }
.tx-log .bad { color: #E28A8A; }

/* ======== Chart wrapper ======== */
.chart-wrap {
  background: #FFFFFF;
  padding: 1rem;
  border: 1px solid var(--stone-2);
  border-radius: 3px;
  height: 280px;
  position: relative;
}

/* ======== Modal ======== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(11,37,69,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
}
.modal {
  background: var(--parchment);
  border: 1px solid var(--navy);
  border-top: 4px solid var(--gold);
  padding: 2rem;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 2px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--navy-2);
  line-height: 1;
}

/* ======== VDC card (credential display) ======== */
.vdc {
  background: var(--parchment);
  border: 2px solid var(--navy);
  border-top: 8px solid var(--gold);
  padding: 1.5rem;
  margin: 1rem 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  position: relative;
  border-radius: 3px;
  box-shadow: var(--shadow);
}
.vdc::before {
  content: "VERIFIABLE DIGITAL CREDENTIAL";
  position: absolute;
  top: -14px;
  left: 1rem;
  background: var(--gold);
  color: var(--navy);
  padding: 2px 10px;
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}
.vdc .kv { display: grid; grid-template-columns: 160px 1fr; gap: 0.4rem 1rem; }
.vdc .kv .k { color: var(--gold-2); font-weight: 600; }
.vdc .kv .v { color: var(--navy); word-break: break-all; }

/* ======== Rubric map table ======== */
.rubric-table th:nth-child(1) { width: 22%; }
.rubric-table th:nth-child(2) { width: 55%; }
.rubric-table td code { font-size: 0.78rem; }

/* ======== Utilities ======== */
.muted { color: #666; }
.small { font-size: 0.82rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.row { display: flex; gap: 0.8rem; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; }
.grow { flex: 1; }
.hidden { display: none !important; }

footer {
  background: var(--navy);
  color: var(--parchment);
  padding: 2rem;
  text-align: center;
  font-size: 0.82rem;
  border-top: 3px solid var(--gold);
  margin-top: 3rem;
}
footer a { color: var(--gold); }

@keyframes sealStamp {
  0% { transform: scale(1.5) rotate(-8deg); opacity: 0; }
  60% { transform: scale(0.95) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.stamp-in { animation: sealStamp 0.5s ease-out; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.pulse { animation: pulse 1.2s ease-in-out infinite; }

/* ======== Auto-responder trace ======== */
.ar-trace {
  margin-top: 1rem;
  padding: 0.2rem;
  max-height: 60vh;
  overflow-y: auto;
  border-top: 1px solid var(--stone-2);
  border-bottom: 1px solid var(--stone-2);
}
.ar-step {
  background: var(--parchment);
  border: 1px solid var(--stone-2);
  border-left: 4px solid var(--navy-2);
  padding: 0.7rem 0.9rem;
  margin: 0.6rem 0;
  border-radius: 2px;
  animation: stepIn 0.25s ease-out;
}
.ar-step.ar-start { border-left-color: var(--gold); background: #FDFAF0; }
.ar-step.ar-reasoning { border-left-color: var(--navy); }
.ar-step.ar-tool { border-left-color: #4a6fa5; background: #F8FAFC; }
.ar-step.ar-tool-exec { border-left-color: var(--crimson); background: #FDF6F6; }
.ar-step.ar-tool-loose { border-left-color: #4a6fa5; background: #F8FAFC; }
.ar-step.ar-end { border-left-color: var(--forest); background: #F3F7F3; }
.ar-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 0.35rem;
}
.ar-step.ar-tool .ar-label { color: #4a6fa5; }
.ar-step.ar-tool-exec .ar-label { color: var(--crimson); }
.ar-step.ar-end .ar-label { color: var(--forest); }
.ar-turn {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #999;
  letter-spacing: 0.15em;
  padding: 0.6rem 0 0.3rem;
  text-transform: lowercase;
}
.ar-body {
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.55;
}
.ar-tool-head {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
}
.ar-tool-args summary,
.ar-tool-result-slot summary,
.ar-step details summary {
  cursor: pointer;
  padding: 0.2rem 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #666;
  list-style: revert;
}
.ar-tool-args pre,
.ar-tool-result-slot pre,
.ar-step details pre {
  max-height: 260px;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.45;
  margin-top: 0.25rem;
}
.ar-tool-result-slot { margin-top: 0.3rem; }

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