/* Ledger Legends — styles */

:root {
  --green: #1a7f4b;
  --green-dark: #12603a;
  --green-light: #e7f5ee;
  --paper: #faf8f2;
  --ink: #2b2b2b;
  --muted: #6e6e6e;
  --line: #e3ddd0;
  --red: #c0392b;
  --gold: #f5b301;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 720px; margin: 0 auto; padding: 12px 14px 60px; }

h1 { font-size: 1.7rem; }
h2 { font-size: 1.05rem; margin: 18px 0 8px; }
p { margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 0.9rem; }
hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---- cards & buttons ---- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 12px;
}
.center { text-align: center; }

.btn {
  font: inherit;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { width: 100%; padding: 13px; font-size: 1.05rem; margin-top: 16px; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.hidden { display: none !important; }
.row-end { display: flex; justify-content: flex-end; margin-top: 12px; }
.row-end.gap { gap: 8px; }
.row-center { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 12px;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.brand.small { font-size: 0.95rem; text-align: center; }
.topbar-right { display: flex; gap: 4px; }

/* ---- setup ---- */
.setup { text-align: center; margin-top: 24px; }
.logo-big { font-size: 3rem; }
.tagline { color: var(--muted); margin-bottom: 8px; }
.setup h2 { text-align: left; }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-card {
  font: inherit; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: #fff; padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.theme-card.sel { border-color: var(--green); background: var(--green-light); font-weight: 600; }
.theme-emoji { font-size: 1.9rem; }
.setup label { display: block; text-align: left; font-size: 0.9rem; font-weight: 600; margin-top: 12px; }
.setup input {
  display: block; width: 100%; font: inherit;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-top: 4px;
}
.setup input:focus { outline: 2px solid var(--green); border-color: var(--green); }

/* ---- home ---- */
.biz-banner { display: flex; align-items: center; gap: 14px; background: var(--green); border-color: var(--green); color: #fff; }
.biz-emoji { font-size: 2.2rem; }
.biz-name { font-weight: 700; font-size: 1.15rem; }
.biz-owner { font-size: 0.85rem; opacity: 0.9; }

.unit-list { display: flex; flex-direction: column; gap: 10px; }
.card.unit { margin-bottom: 0; text-align: left; width: 100%; font: inherit; }
button.card.unit { cursor: pointer; }
button.card.unit:hover { border-color: var(--green); }
.unit-head { display: flex; gap: 12px; align-items: flex-start; }
.unit-icon { font-size: 1.6rem; line-height: 1.2; }
.unit-title { font-weight: 700; }
.unit-sub { color: var(--muted); font-size: 0.88rem; }
.unit.locked { background: #f4f2ec; }
.unit-status { font-size: 0.85rem; color: var(--green); font-weight: 600; margin-top: 6px; }

.progress { height: 7px; background: var(--line); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width 0.3s; }

.code-row { display: flex; gap: 8px; margin-top: 10px; }
.code-input {
  flex: 1; font: inherit; text-transform: uppercase; letter-spacing: 1px;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0;
}
.code-msg { color: var(--red); font-size: 0.85rem; margin-top: 6px; min-height: 1.1em; }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 22px; }
.foot a, .privacy-note a { color: var(--green-dark); }
.privacy-note { margin-top: 12px; font-size: 0.8rem; }

/* ---- unit flow ---- */
.dots { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.done { background: var(--green); }
.dot.cur { outline: 2px solid var(--green); outline-offset: 2px; }

.rule-box {
  background: var(--green-light); border: 1px solid var(--green);
  border-radius: 10px; padding: 12px 14px; font-weight: 600; margin: 14px 0 4px;
}
.big-badge { font-size: 3.4rem; margin-top: 6px; }

.task-count { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.task-text { font-size: 1.08rem; font-weight: 500; }
.txn-date { display: inline-block; background: var(--green-light); color: var(--green-dark); font-weight: 700; font-size: 0.8rem; border-radius: 6px; padding: 2px 9px; margin-bottom: 6px; }

.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.choice {
  font: inherit; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; padding: 11px 14px;
}
.choice:hover:not(:disabled) { border-color: var(--green); }
.choice.right { border-color: var(--green); background: var(--green-light); font-weight: 600; }
.choice.wrong { border-color: var(--red); background: #fdecea; opacity: 0.7; }
.choice:disabled { cursor: default; }

.num-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.num-dollar { font-weight: 700; color: var(--muted); }
#num-input {
  font: inherit; font-size: 1.1rem; width: 140px;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px;
}

.feedback { display: none; border-radius: 10px; padding: 11px 14px; margin-top: 12px; font-size: 0.95rem; }
.feedback.show { display: block; }
.feedback.good { background: var(--green-light); border: 1px solid var(--green); }
.feedback.bad { background: #fdecea; border: 1px solid var(--red); }
.feedback.neutral { background: #fff8e1; border: 1px solid var(--gold); }

/* ---- journal builder ---- */
.journal-grid {
  display: grid; grid-template-columns: 1fr 88px 88px; gap: 6px;
  margin: 12px 0 8px; align-items: center;
}
.jh { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.num-h { text-align: right; }
.j-acct, .j-amt {
  font: inherit; font-size: 0.92rem; width: 100%;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 8px; background: #fff;
}
.j-amt { text-align: right; }
.j-acct:focus, .j-amt:focus, .code-input:focus { outline: 2px solid var(--green); border-color: var(--green); }

/* ---- My Books panel ---- */
#books-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40;
}
#books-panel {
  display: none; position: fixed; z-index: 50;
  top: 0; right: 0; bottom: 0; width: min(480px, 100%);
  background: var(--paper); box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
  flex-direction: column;
}
body.books-open #books-overlay { display: block; }
body.books-open #books-panel { display: flex; }

.books-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 6px; }
.books-title { font-weight: 700; }
.books-tabs { display: flex; gap: 4px; padding: 6px 14px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.books-tabs button {
  font: inherit; font-size: 0.86rem; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px;
}
.books-tabs button.sel { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.books-body { overflow-y: auto; padding: 14px; flex: 1; }
.books-empty { color: var(--muted); text-align: center; margin-top: 40px; padding: 0 20px; }
.books-note { color: var(--muted); font-size: 0.8rem; margin-top: 8px; }

.ledger-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ledger-table th, .ledger-table td { padding: 7px 10px; font-size: 0.88rem; text-align: left; }
.ledger-table th { background: var(--green-light); color: var(--green-dark); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; }
.ledger-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.ledger-table .indent { padding-left: 28px; }
.entry-start td { border-top: 1px solid var(--line); }
.closing-row td { background: #f4f2ec; }
.tb-total td { border-top: 2px solid var(--ink); font-weight: 700; }
.tb-verdict { margin-top: 10px; font-weight: 600; padding: 8px 12px; border-radius: 8px; }
.tb-verdict.good { background: var(--green-light); color: var(--green-dark); }
.tb-verdict.bad { background: #fdecea; color: var(--red); }
.tb-toggle { display: flex; gap: 6px; margin-bottom: 10px; }
.tb-toggle button { font: inherit; font-size: 0.83rem; cursor: pointer; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; }
.tb-toggle button.sel { background: var(--green); border-color: var(--green); color: #fff; }

.t-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.t-acct { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.t-name { font-weight: 700; font-size: 0.85rem; text-align: center; border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin-bottom: 2px; }
.t-acct table { width: 100%; border-collapse: collapse; }
.t-acct td, .t-acct th { font-size: 0.83rem; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.t-acct td:first-child, .t-acct th:first-child { border-right: 2px solid var(--ink); }
.t-head th { color: var(--muted); font-size: 0.7rem; }
.t-bal td { border-top: 1.5px solid var(--ink); font-weight: 700; }

.stmt { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.stmt-title { text-align: center; font-weight: 700; margin-bottom: 10px; line-height: 1.35; }
.stmt-title span { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.stmt table { width: 100%; border-collapse: collapse; }
.stmt td { padding: 5px 8px; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.stmt .r { text-align: right; }
.stmt .total td { border-top: 2px solid var(--ink); font-weight: 700; }
.stmt-sec td { font-weight: 700; color: var(--green-dark); padding-top: 10px; }

/* ---- misc ---- */
.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@media (max-width: 460px) {
  .journal-grid { grid-template-columns: 1fr 72px 72px; }
  .j-acct, .j-amt { font-size: 0.85rem; padding: 8px 5px; }
}
