/* Plap Debt — night-ledger theme
   cloth   #14291F  deep pine green background
   paper   #F3EDDD  ledger card
   ink     #23211A  text on paper
   brass   #C9973F  accent / meter
   debit   #B23A31  debt goes up
   credit  #2F6B47  debt goes down
*/

:root {
  --cloth: #14291f;
  --cloth-line: #1b3529;
  --paper: #f3eddd;
  --paper-edge: #e4dcc6;
  --ink: #23211a;
  --ink-soft: #6b6553;
  --brass: #c9973f;
  --brass-deep: #a4782c;
  --debit: #b23a31;
  --credit: #2f6b47;
  --font-display: "Bricolage Grotesque", "Arial Black", sans-serif;
  --font-body: "Public Sans", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 34px, var(--cloth-line) 34px 35px),
    var(--cloth);
}

.eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
}

.card {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.35), 0 14px 34px rgba(0,0,0,.35);
}

/* ------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card { width: min(24rem, 100%); padding: 2rem 1.75rem; }

.login-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 8vw, 2.8rem);
  line-height: 1;
  margin: 0.5rem 0 0.25rem;
}

.login-sub { margin: 0 0 1.5rem; color: var(--ink-soft); }

/* ------------------------------------------------------------ layout */

.app-wrap {
  width: min(46rem, 100%);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: grid;
  gap: 1rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.25rem 0;
}

.topbar-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
  border: 1px solid var(--brass);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

.btn-quiet {
  background: none;
  border: none;
  padding: 0.25rem 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--paper);
  opacity: 0.75;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-quiet:hover { opacity: 1; }

/* ------------------------------------------------------- ledger card */

.ledger-card { padding: 1.75rem clamp(1.25rem, 5vw, 2.5rem) 2rem; }

.ledger-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 5vw, 2rem);
  margin: 0;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
}

.counter {
  margin: 1.25rem 0 0.15rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(2.6rem, 11vw, 4.6rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.15em;
}

.counter-unit {
  font-size: 0.28em;
  font-weight: 500;
  color: var(--brass-deep);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-left: 0.4em;
}

.counter.bump { animation: bump 0.45s ease; }
@keyframes bump {
  30% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.counter-note {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

/* meter */
.meter { margin-bottom: 1.5rem; }

.meter-track {
  height: 14px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(-45deg, var(--brass) 0 8px, var(--brass-deep) 8px 16px);
  transition: width 0.6s ease;
}

.meter-ticks {
  display: flex;
  justify-content: space-between;
  height: 6px;
  margin: 2px 1px 3px;
}
.meter-ticks i { width: 1.5px; background: var(--ink); opacity: 0.55; }
.meter-ticks i:nth-child(odd) { height: 4px; opacity: 0.3; }

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-soft);
}
.ceiling-label { color: var(--debit); font-weight: 700; }

/* adjust controls */
.adjust { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; }

.amount-field { flex: 1 1 10rem; }

.adjust-buttons { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.field { display: grid; gap: 0.3rem; margin-bottom: 0.9rem; }
.adjust .field { margin-bottom: 0; }

.field span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input {
  font: inherit;
  font-family: var(--font-mono);
  padding: 0.6rem 0.7rem;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: #fffdf6;
  color: var(--ink);
  width: 100%;
}
.field input:focus-visible { outline: 3px solid var(--brass); outline-offset: 1px; }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.btn-brass  { background: var(--brass);  color: #241a05; width: 100%; }
.btn-debit  { background: var(--debit);  color: #fff; }
.btn-credit { background: var(--credit); color: #fff; }

.viewer-note { color: var(--ink-soft); font-size: 0.9rem; margin: 0; }

.grant-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--ink-soft);
  font-size: 0.9rem;
  cursor: pointer;
}
.grant-row input { width: 1.05rem; height: 1.05rem; accent-color: var(--brass-deep); }

.error {
  color: var(--debit);
  font-size: 0.88rem;
  margin: 0.75rem 0 0;
  font-weight: 600;
}

/* ----------------------------------------------------------- history */

.history-card { padding: 1.25rem clamp(1.25rem, 5vw, 2.5rem) 1.5rem; }

.history-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.history-empty { color: var(--ink-soft); margin: 0; }

.history { width: 100%; border-collapse: collapse; font-size: 0.86rem; }

.history th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 2px solid var(--ink);
  padding: 0.35rem 0.4rem;
}

.history td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--paper-edge);
  vertical-align: top;
}

.history .num, .history td.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.history .who { font-family: var(--font-mono); }
.debit-cell  { color: var(--debit); font-weight: 700; }
.credit-cell { color: var(--credit); font-weight: 700; }
.event-cell  { color: var(--ink-soft); font-style: italic; }
.when-cell   { color: var(--ink-soft); white-space: nowrap; }

.foot {
  text-align: center;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: rgba(243, 237, 221, 0.55);
}

/* ------------------------------------------------------------ dialog */

.dialog {
  border: 1px solid var(--paper-edge);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  padding: 1.5rem;
  width: min(22rem, calc(100vw - 2rem));
}
.dialog::backdrop { background: rgba(10, 20, 15, 0.65); }
.dialog h2 { font-family: var(--font-display); margin: 0 0 1rem; font-size: 1.2rem; }
.dialog-buttons { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 0.5rem; }
.dialog .btn-quiet { color: var(--ink-soft); }
.dialog .btn-brass { width: auto; }

/* ------------------------------------------------------------ mobile */

@media (max-width: 480px) {
  .adjust-buttons { width: 100%; }
  .adjust-buttons .btn { flex: 1; }
  .history .when-cell { white-space: normal; }
  .meter-labels span:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .counter.bump { animation: none; }
  .meter-fill { transition: none; }
}
