/* Form — warm, editorial "paper ledger" aesthetic.
   Deliberately not the default AI gradient look: paper background, ink text,
   one confident evergreen accent, an editorial serif for headlines. */
:root {
  --paper: #f6f3ec;
  --paper-2: #efe9dd;
  --surface: #fffdf8;
  --ink: #1f1e1b;
  --muted: #716f66;
  --line: #e4ddcf;
  --evergreen: #15614a;
  --evergreen-soft: #e6efe8;
  --gold: #b9831b;
  --owe: #9e3b2c;
  --shadow: 0 1px 2px rgba(40, 34, 20, .05), 0 8px 28px rgba(40, 34, 20, .07);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #fbf8f1 0%, transparent 60%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
  background: rgba(255,253,248,.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark {
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  letter-spacing: .3px; color: var(--evergreen);
}
.brand-mark::after { content: "."; color: var(--gold); }
.brand-tag { color: var(--muted); font-size: 13.5px; }
.budget { display: flex; align-items: center; gap: 10px; }
.budget-label { font-size: 13px; color: var(--muted); }
#budget-dots { display: inline-flex; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--evergreen); transition: background .3s; }
.dot.spent { background: var(--line); }

/* Layout */
.layout {
  display: grid; grid-template-columns: 1fr 360px; gap: 26px;
  max-width: 1120px; margin: 0 auto; padding: 26px;
  height: calc(100vh - 67px);
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .messages { max-height: 60vh; }
}

/* Chat */
.chat-pane { display: flex; flex-direction: column; min-height: 0; }
.messages {
  flex: 1; overflow-y: auto; padding: 6px 4px 10px;
  display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth;
}
.msg { max-width: 86%; line-height: 1.5; font-size: 15.5px; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg.assistant {
  align-self: flex-start; background: var(--surface); border: 1px solid var(--line);
  padding: 14px 16px; border-radius: 4px 16px 16px 16px; box-shadow: var(--shadow);
}
.msg.user {
  align-self: flex-end; background: var(--evergreen); color: #f3f7f3;
  padding: 12px 16px; border-radius: 16px 16px 4px 16px;
}
.msg.assistant .cursor {
  display: inline-block; width: 7px; height: 16px; background: var(--evergreen);
  margin-left: 2px; vertical-align: text-bottom; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Upload card (first thing the user sees) */
.upload-card {
  align-self: stretch; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.upload-card h3 { font-family: var(--serif); margin: 0 0 4px; font-size: 19px; }
.upload-card p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.dropzone {
  border: 1.5px dashed #cdc3ad; border-radius: 12px; padding: 26px; text-align: center;
  color: var(--muted); cursor: pointer; transition: all .15s; background: #fcfaf4;
}
.dropzone:hover, .dropzone.drag { border-color: var(--evergreen); background: var(--evergreen-soft); color: var(--evergreen); }
.dropzone strong { color: var(--ink); }
.upload-actions { display: flex; gap: 10px; margin-top: 14px; align-items: center; }
.btn-secondary {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.btn-secondary:hover { border-color: var(--evergreen); color: var(--evergreen); }
.upload-or { color: var(--muted); font-size: 13px; }

/* Composer */
.composer { display: flex; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.input {
  flex: 1; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 13px 15px; font-size: 15px; font-family: var(--sans); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--evergreen); box-shadow: 0 0 0 3px var(--evergreen-soft); }
.input:disabled { background: var(--paper-2); cursor: not-allowed; }
.send {
  width: 48px; border: none; border-radius: 12px; background: var(--evergreen);
  color: #fff; font-size: 20px; cursor: pointer; transition: transform .1s, opacity .2s;
}
.send:disabled { opacity: .4; cursor: not-allowed; }
.send:not(:disabled):hover { transform: translateY(-1px); }

/* Ledger */
.ledger-pane { display: flex; flex-direction: column; gap: 12px; }
.ledger-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(transparent, transparent 31px, #f2ece0 31px, #f2ece0 32px);
}
.ledger-head { display: flex; align-items: center; justify-content: space-between; }
.ledger-card h2 { font-family: var(--serif); font-size: 16px; margin: 0; color: var(--muted); font-weight: 600; }
.verified { font-size: 12px; color: var(--evergreen); background: var(--evergreen-soft); padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.headline { margin: 18px 0 14px; }
.headline-label { display: block; font-size: 13px; color: var(--muted); }
.headline-amount { display: block; font-family: var(--serif); font-size: 40px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.headline.refund .headline-amount { color: var(--evergreen); }
.headline.owe .headline-amount { color: var(--owe); }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; border-top: 1px dotted var(--line); }
.lines li span:first-child { color: var(--muted); }
.lines li span:last-child { font-variant-numeric: tabular-nums; }
.download {
  display: block; text-align: center; margin-top: 18px; text-decoration: none;
  background: var(--gold); color: #fff; padding: 13px; border-radius: 11px;
  font-weight: 600; font-size: 15px; box-shadow: var(--shadow); transition: transform .1s;
}
.download:hover { transform: translateY(-1px); }
.disclaimer { font-size: 11.5px; color: var(--muted); margin: 16px 0 0; line-height: 1.4; }

/* Activity panel */
.activity-toggle {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: transparent; border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 14px; font-size: 13.5px; color: var(--muted); cursor: pointer; font-family: var(--sans);
}
.activity-toggle:hover { color: var(--ink); }
.activity-toggle .chev { transition: transform .2s; }
.activity-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.activity {
  background: #1c1b18; color: #e9e4d8; border-radius: 12px; padding: 12px;
  font-size: 12px; max-height: 320px; overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.evt { display: flex; gap: 8px; padding: 5px 4px; border-bottom: 1px solid #2a2823; }
.evt:last-child { border-bottom: none; }
.evt .ico { flex: none; }
.evt .body { flex: 1; }
.evt .summary { color: #f0ebde; }
.evt .kind { color: #8f897a; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.evt.guardrail .kind { color: #d8a657; }
.evt.compute .kind { color: #7fb685; }
.evt.error .summary { color: #e89a8a; }
.evt.tool .kind { color: #83a8c4; }

/* tiny working chip */
.working { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; padding: 4px 0; }
.working .spin { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--evergreen); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
