:root {
  --ink: #1C1B17;
  --paper: #FBF7EE;
  --ledger: #1F3D2E;
  --ledger-light: #E4EDE4;
  --stamp: #B23A2E;
  --brass: #C9A227;
  --border: #D9D2C0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  line-height: 1.55;
}

h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 500; margin: 0 0 .5rem; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 2rem; border-bottom: 1px solid var(--border);
}
.wordmark { font-family: 'Fraunces', serif; font-size: 1.15rem; font-weight: 600; }
.link-btn {
  background: none; border: none; font-family: inherit; font-size: .95rem;
  color: var(--ledger); text-decoration: underline; cursor: pointer;
}

.cta {
  background: var(--ledger); color: var(--paper); border: none;
  padding: .8rem 1.6rem; border-radius: 4px; font-family: inherit; font-size: 1rem;
  cursor: pointer; transition: transform .1s ease;
}
.cta:hover { transform: translateY(-1px); }
.cta.small { padding: .5rem 1rem; font-size: .85rem; }

/* ---- Hero: the receipt ---- */
.hero { display: flex; justify-content: center; padding: 4rem 1.5rem 2rem; }
.receipt {
  background: #fff; width: 100%; max-width: 480px; padding: 2.5rem 2rem 1.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgba(28, 27, 23, 0.08);
  position: relative;
}
.receipt-hole {
  width: 10px; height: 10px; border-radius: 50%; background: var(--paper);
  border: 1px solid var(--border); position: absolute; top: -6px; left: 50%;
  transform: translateX(-50%);
}
.receipt-eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: .75rem; letter-spacing: .08em;
  color: var(--stamp); margin: 0 0 1.25rem;
}
.receipt h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); line-height: 1.15; }
.receipt-sub { color: #55524A; margin: 1rem 0 1.75rem; }
.receipt-ticker {
  margin-top: 1.75rem; font-family: 'IBM Plex Mono', monospace; font-size: .82rem;
  color: var(--ledger); min-height: 1.4em; border-top: 1px dashed var(--border); padding-top: .9rem;
}
.receipt-tear {
  position: absolute; bottom: -1px; left: 0; right: 0; height: 10px;
  background: repeating-linear-gradient(-45deg, var(--paper) 0 6px, transparent 6px 12px);
}

/* ---- Line items (how it works) ---- */
.lines { max-width: 680px; margin: 3rem auto 5rem; padding: 0 1.5rem; }
.line-item {
  display: flex; gap: 1.25rem; padding: 1.5rem 0; border-top: 1px solid var(--border);
}
.line-no {
  font-family: 'IBM Plex Mono', monospace; color: var(--brass); font-size: .95rem;
  min-width: 1.6rem;
}
.line-item p { color: #55524A; margin: .35rem 0 0; }

/* ---- Auth pages (login.html / signup.html) ---- */
.auth-wrap { display: flex; justify-content: center; padding: 4rem 1.5rem; }
.auth-card { max-width: 400px; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }
.auth-card label { font-size: .9rem; display: flex; flex-direction: column; gap: .35rem; }
.auth-card input {
  font-family: inherit; font-size: 1rem; padding: .6rem .7rem;
  border: 1px solid var(--border); border-radius: 4px; background: #fff;
}
.field-hint { font-size: .78rem; color: #706C60; }
.form-error { color: var(--stamp); font-size: .85rem; min-height: 1.2em; margin: 0; }
.modal-switch { font-size: .85rem; margin-top: 1.25rem; text-align: center; }
a.wordmark, a.link-btn, a.cta { text-decoration: none; }
a.link-btn { text-decoration: underline; }
a.cta { display: inline-block; }
.cta:disabled { opacity: .6; cursor: default; transform: none; }

/* ---- Chat pending state ---- */
.chat-msg.pending p { color: #706C60; }
.chat-msg.pending p::after {
  content: ""; display: inline-block; width: .8em;
  animation: cf-dots 1.2s steps(4, end) infinite;
}
@keyframes cf-dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

/* ---- Hidden attribute support (used instead of inline style toggles) ---- */
[hidden] { display: none !important; }

/* ---- Dashboard ---- */
.dashboard-body { background: var(--paper); }
.setup-pane, .main-pane { max-width: 960px; margin: 2.5rem auto; padding: 0 1.5rem; }
.setup-pane form { display: flex; flex-direction: column; gap: 1rem; max-width: 360px; margin-top: 1.5rem; }
.setup-pane label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.setup-pane input, .setup-pane select { font-family: inherit; font-size: 1rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 4px; }
.muted { color: #706C60; }
.muted.small { font-size: .82rem; }

.main-pane { display: grid; grid-template-columns: 240px 1fr; gap: 2rem; align-items: start; }
.connectors { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 1.25rem; }
.connector-card {
  display: flex; flex-direction: column; gap: .4rem; padding: .9rem 0;
  border-top: 1px solid var(--border);
}
.connector-card:first-of-type { border-top: none; }
.connector-name { font-weight: 500; }
.connector-status { font-size: .8rem; color: #706C60; }
.connector-card button {
  align-self: flex-start; background: var(--ledger-light); color: var(--ledger);
  border: none; padding: .4rem .8rem; border-radius: 4px; font-family: inherit; cursor: pointer;
}
.toast-form { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.toast-form input { font-family: inherit; padding: .5rem; border: 1px solid var(--border); border-radius: 4px; }

.chat { background: #fff; border: 1px solid var(--border); border-radius: 6px; display: flex; flex-direction: column; height: 70vh; }
.chat-log { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.chat-msg { max-width: 80%; padding: .8rem 1rem; border-radius: 8px; }
.chat-msg.assistant { background: var(--ledger-light); align-self: flex-start; }
.chat-msg.user { background: var(--ink); color: var(--paper); align-self: flex-end; }
.chat-msg p { margin: 0; }
.chat-input { display: flex; gap: .75rem; padding: 1rem; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1; font-family: inherit; font-size: 1rem; padding: .7rem; border: 1px solid var(--border); border-radius: 4px;
}

@media (max-width: 720px) {
  .main-pane { grid-template-columns: 1fr; }
}
