/* QBO Extender — "Ocarina of Time / Hyrule Field" theme.
   Daytime Hyrule: blue skies fading into rolling green fields, parchment quest
   panels edged in Triforce gold, royal-blue actions, forest-green accents and a
   heraldic red for negatives. Bright, regal, and calm — no neon, no CRT glow.
   (Palette + surface recolor only — layout/structure and class names unchanged.) */

:root {
  color-scheme: light;

  /* Sky → field background stops */
  --sky-high: #6db6e3;       /* clear blue overhead */
  --sky-low: #abdcf2;        /* pale blue near horizon */
  --haze: #e9f6df;           /* warm horizon haze */
  --field-high: #93c46b;     /* sunlit grass */
  --field-low: #5a9a3f;      /* deeper field */

  /* Parchment surfaces */
  --parchment: #f7efd6;      /* quest panel surface */
  --parchment-2: #fffbef;    /* input wells (lighter) */
  --parchment-3: #f0e4bf;    /* hover / raised */
  --parchment-band: #efe3bc; /* panel header band */

  /* Ink */
  --ink: #34301f;            /* body text — dark sepia */
  --ink-soft: #6a5f3c;       /* labels */
  --ink-faint: #98896018;    /* (unused alpha placeholder) */
  --ink-mute: #8c7e54;       /* faint text */

  /* Royal palette */
  --gold: #c9a227;           /* Triforce gold (primary ornament) */
  --gold-deep: #9c7715;      /* gold border / shadow */
  --gold-light: #e7cb63;     /* gold highlight */
  --royal: #2a4d9b;          /* Hyrule royal blue (links / actions) */
  --royal-deep: #1d3670;     /* deep royal */
  --royal-light: #4f72bd;    /* hover royal */
  --grass: #3f7d33;          /* forest / Kokiri green (accents) */
  --grass-soft: #6fab4d;     /* lighter grass */
  --plum: #6a4c93;           /* royal violet (sparing accent) */
  --red: #b3392f;            /* heraldic red — negatives / destructive */
  --red-deep: #8a2a22;

  /* Lines & effects */
  --line: rgba(120, 92, 24, 0.22);
  --line-strong: rgba(156, 119, 21, 0.55);
  --gilt: linear-gradient(90deg, transparent, var(--gold-light) 18%, var(--gold) 50%, var(--gold-light) 82%, transparent);
  --radius: 9px;
  --shadow: 0 16px 34px -20px rgba(28, 48, 18, 0.55);
  --shadow-soft: 0 6px 18px -12px rgba(28, 48, 18, 0.45);
  --ring-royal: 0 0 0 3px rgba(42, 77, 155, 0.22);

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  min-height: 100vh;
  background-color: var(--sky-low);
  /* Soft clouds drifting over a blue sky that settles into green fields. */
  background-image:
    radial-gradient(46% 30% at 78% 16%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 60%),
    radial-gradient(34% 22% at 22% 24%, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0) 60%),
    radial-gradient(40% 26% at 60% 30%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 62%),
    linear-gradient(
      180deg,
      var(--sky-high) 0%,
      var(--sky-low) 30%,
      var(--haze) 52%,
      var(--field-high) 68%,
      var(--field-low) 100%
    );
  background-repeat: no-repeat;
  background-attachment: fixed;
}

a { color: var(--royal); text-decoration: none; }
a:hover { color: var(--royal-deep); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.12; margin: 0; color: var(--royal-deep); }

.eyebrow {
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.num--neg { color: var(--red); }

/* ===== Masthead — a royal banner ===== */
.masthead {
  position: relative;
  z-index: 100; /* keep the nav dropdown above page content */
  background: linear-gradient(180deg, var(--royal) 0%, var(--royal-deep) 100%);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 0 var(--gold-deep), var(--shadow-soft);
}
.masthead__bar {
  max-width: 1040px; margin: 0 auto; padding: 15px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.wordmark { display: flex; align-items: center; gap: 11px; }
.wordmark__qbo {
  font-family: var(--display);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.18em;
  color: #3a2c05; text-transform: uppercase;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border: 1px solid var(--gold-deep); border-radius: 4px; padding: 3px 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.wordmark__name {
  font-family: var(--display);
  font-size: 1.55rem; font-weight: 700; font-style: normal;
  letter-spacing: 0.02em; color: #fdf7e3;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.mast-nav { display: flex; align-items: center; gap: 20px; }
.mast-nav a {
  font-family: var(--display);
  font-size: 0.92rem; font-weight: 600; letter-spacing: 0.03em;
  color: #eaf1ff; padding-bottom: 2px; border-bottom: 2px solid transparent;
}
.mast-nav a:hover { color: #fff; border-color: var(--gold); text-decoration: none; }
.mast-nav .who { color: #c4d2f0; font-family: var(--sans); font-size: 0.82rem; letter-spacing: 0; }

/* Reference dropdown menu */
.navmenu { position: relative; display: inline-flex; }
.navmenu__trigger {
  font-family: var(--display); font-size: 0.92rem; font-weight: 600;
  letter-spacing: 0.03em; color: #eaf1ff;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 0 0 2px; cursor: pointer;
}
.navmenu:hover .navmenu__trigger,
.navmenu:focus-within .navmenu__trigger { color: #fff; border-color: var(--gold); }
.navmenu__panel {
  position: absolute; top: 100%; right: 0; min-width: 196px;
  display: none; flex-direction: column;
  margin-top: 12px; padding: 7px;
  background: var(--parchment); border: 1px solid var(--gold-deep);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 80;
}
.navmenu__panel::before { content: ""; position: absolute; top: -12px; left: 0; right: 0; height: 12px; }
.navmenu:hover .navmenu__panel,
.navmenu:focus-within .navmenu__panel { display: flex; }
.navmenu__panel a {
  font-family: var(--display); font-size: 0.9rem; font-weight: 600;
  letter-spacing: 0.01em; color: var(--ink); border-bottom: 0;
  padding: 9px 11px; border-radius: 5px;
}
.navmenu__panel a:hover { color: var(--royal-deep); background: rgba(42, 77, 155, 0.10); text-decoration: none; }

/* gilded divider under the banner (was the guilloche) */
.guilloche {
  height: 3px;
  background: var(--gilt);
  opacity: 0.9;
}

/* ===== Layout ===== */
.wrap { max-width: 1040px; margin: 0 auto; padding: 34px 24px 90px; position: relative; z-index: 1; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 {
  font-family: var(--display); font-weight: 700; font-size: 2.15rem;
  letter-spacing: 0.01em; color: var(--royal-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.page-head .eyebrow { display: block; margin-bottom: 6px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--display); font-size: 0.86rem; font-weight: 700;
  letter-spacing: 0.02em;
  padding: 9px 16px; border-radius: 7px;
  border: 1px solid var(--gold-deep); background: var(--parchment);
  color: var(--ink); cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: box-shadow 130ms ease, background 130ms ease, border-color 130ms ease, color 130ms ease, transform 80ms ease;
}
.btn:hover { background: var(--parchment-3); border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border-color: var(--gold-deep); color: #3a2c05;
}
.btn--primary:hover { background: linear-gradient(180deg, #f1da82, var(--gold-light)); border-color: var(--gold-deep); color: #3a2c05; }
.btn--danger { color: var(--red); border-color: rgba(179, 57, 47, 0.5); background: rgba(179, 57, 47, 0.06); }
.btn--danger:hover { background: var(--red); border-color: var(--red-deep); color: #fff4ef; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-soft); box-shadow: none; }
.btn--ghost:hover { color: var(--royal-deep); background: rgba(42, 77, 155, 0.08); border-color: transparent; }
.btn--sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Quest panels ===== */
.sheet {
  position: relative;
  background: var(--parchment);
  border: 1.5px solid var(--gold-deep);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  overflow: hidden;
}
/* gilded top edge — the regal signature */
.sheet::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gilt); pointer-events: none;
}
.sheet__band {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line-strong);
  background: var(--parchment-band);
}
.sheet__body { padding: 22px 20px; }

/* ===== Fields ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-family: var(--display); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.04em; color: var(--ink-soft);
}
.input, .select {
  width: 100%; font-family: var(--sans); font-size: 0.95rem; color: var(--ink);
  background: var(--parchment-2); border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 9px 11px;
  transition: border-color 130ms ease, box-shadow 130ms ease, background 130ms ease;
}
.input::placeholder { color: var(--ink-mute); }
.input:focus, .select:focus {
  outline: none; background: #fff;
  border-color: var(--royal); box-shadow: var(--ring-royal);
}
.input--num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.field-error { color: var(--red); font-size: 0.78rem; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }

/* ===== Ledger tables ===== */
.ledger { width: 100%; border-collapse: collapse; }
.ledger thead th {
  font-family: var(--display); font-size: 0.76rem; font-weight: 700;
  letter-spacing: 0.04em; color: var(--ink-soft);
  text-align: left; padding: 11px 12px;
  border-bottom: 2px solid var(--gold); background: var(--parchment-band);
}
.ledger thead th.r { text-align: right; }
.ledger tbody td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ledger tbody tr:last-child td { border-bottom: none; }
.ledger tbody tr:hover td { background: rgba(111, 171, 77, 0.12); }
.ledger .doclink { font-family: var(--mono); font-weight: 600; color: var(--royal); }
.ledger .doclink:hover { color: var(--royal-deep); text-decoration: underline; text-underline-offset: 3px; }

.tag {
  font-family: var(--display); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--grass); background: rgba(63, 125, 51, 0.10);
  border: 1px solid rgba(63, 125, 51, 0.4); border-radius: 999px; padding: 1px 9px;
}

/* reference-table cell utilities */
.ledger td.r { text-align: right; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-mute); }
.pill {
  font-family: var(--display); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 1px 9px; border-radius: 999px; border: 1px solid;
}
.pill--on { color: var(--grass); border-color: rgba(63, 125, 51, 0.45); background: rgba(63, 125, 51, 0.10); }
.pill--off { color: var(--ink-mute); border-color: var(--line); }
code {
  font-family: var(--mono); font-size: 0.85em; color: var(--royal-deep);
  background: rgba(42, 77, 155, 0.10); padding: 1px 5px; border-radius: 4px;
}

/* ===== Definition grid ===== */
.defs { display: grid; grid-template-columns: max-content 1fr; gap: 11px 24px; margin: 0; }
.defs dt {
  font-family: var(--display); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.04em; color: var(--ink-soft); align-self: center;
}
.defs dd { margin: 0; }

/* ===== Document form: lines + live total ===== */
.lines-wrap { overflow-x: auto; }
.lines { width: 100%; border-collapse: collapse; min-width: 720px; }
.lines thead th {
  font-family: var(--display); font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.03em; color: var(--ink-soft);
  text-align: left; padding: 8px 8px 10px; border-bottom: 2px solid var(--gold);
}
.lines thead th.r { text-align: right; }
.lines tbody td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines .col-amount {
  font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right;
  padding-top: 16px; white-space: nowrap; color: var(--ink);
}
.lines .col-rm { text-align: center; width: 44px; }
.line-row.is-removed { display: none; }

.rm-btn {
  border: 1px solid transparent; background: transparent; color: var(--ink-mute);
  font-family: var(--mono); font-size: 1.1rem; line-height: 1;
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer; margin-top: 6px;
}
.rm-btn:hover { color: var(--red); border-color: rgba(179, 57, 47, 0.5); background: rgba(179, 57, 47, 0.08); }

/* running-total readout — hero of entry */
.totals {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 20px; border-top: 2px solid var(--gold);
  background: var(--parchment-band); flex-wrap: wrap;
}
.totals__note { font-size: 0.85rem; color: var(--ink-soft); max-width: 36ch; }
.totals__fig { text-align: right; }
.totals__fig .eyebrow { display: block; margin-bottom: 4px; }
.totals__amount {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(2rem, 6vw, 3rem); font-weight: 600; letter-spacing: 0.01em;
  line-height: 1; color: var(--royal-deep);
}
.totals__amount.is-neg { color: var(--red); }

.form-actions { display: flex; gap: 12px; margin-top: 24px; align-items: center; }

/* ===== Notices ===== */
.notice {
  border: 1px solid var(--line-strong); border-left: 4px solid var(--grass);
  background: var(--parchment); border-radius: 7px;
  padding: 11px 14px; margin-bottom: 16px; font-size: 0.92rem;
  box-shadow: var(--shadow-soft);
}
.notice--error { border-left-color: var(--red); }

.empty { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty .eyebrow { display: block; margin-bottom: 8px; }

/* ===== Login scroll ===== */
.cert {
  position: relative; max-width: 390px; margin: 9vh auto 0;
  background: var(--parchment);
  border: 1.5px solid var(--gold-deep); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px 30px; overflow: hidden;
}
.cert::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gilt);
}
.cert h1 {
  font-family: var(--display); font-weight: 700;
  letter-spacing: 0.01em; font-size: 1.6rem; margin-bottom: 20px; color: var(--royal-deep);
}
.cert .field { margin-bottom: 15px; }

.pagination {
  display: flex; gap: 12px; align-items: center; margin-top: 18px;
  font-family: var(--display); font-size: 0.85rem; color: var(--ink-soft);
}

/* ===== Tom Select (parchment) ===== */
.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
  background: var(--parchment-2); border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 8px 11px; font-family: var(--sans); font-size: 0.95rem; color: var(--ink);
  box-shadow: none; min-height: 0;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--royal); box-shadow: var(--ring-royal); background: #fff;
}
.ts-control input { color: var(--ink); }
.ts-control input::placeholder { color: var(--ink-mute); }
.ts-control > .item { color: var(--ink); }
.ts-dropdown {
  border: 1px solid var(--gold-deep); border-radius: 7px;
  box-shadow: var(--shadow); background: var(--parchment);
  margin-top: 5px; color: var(--ink); z-index: 60;
}
.ts-dropdown .option { padding: 8px 11px; font-size: 0.92rem; color: var(--ink); }
.ts-dropdown .option.active { background: rgba(42, 77, 155, 0.12); color: var(--royal-deep); }
.ts-dropdown .active { background: var(--royal); color: #fff; }
.ts-dropdown .no-results { padding: 8px 11px; color: var(--ink-soft); font-size: 0.88rem; }

/* ===== A11y & motion ===== */
:focus-visible { outline: 2px solid var(--royal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media (max-width: 640px) {
  .masthead__bar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .totals { flex-direction: column; align-items: stretch; }
  .totals__fig { text-align: left; }
}

/* ===== Comments ===== */
.comment-form textarea { resize: vertical; min-height: 64px; }
.comment-list {
  list-style: none; margin: 22px 0 0; padding: 18px 0 0;
  border-top: 1px solid var(--line);
}
.comment-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment-item:last-child { border-bottom: 0; }
.comment-head {
  display: flex; align-items: baseline; gap: 12px;
  font-family: var(--display); font-size: 0.85rem;
}
.comment-author { font-weight: 700; color: var(--royal-deep); letter-spacing: 0.01em; }
.comment-meta {
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-mute);
}
.comment-edit { margin-left: auto; font-size: 0.8rem; }
.comment-body {
  margin-top: 6px; font-size: 0.95rem; color: var(--ink); font-family: var(--sans);
  white-space: normal; word-break: break-word;
}
.comment-empty { padding: 12px 0; }
