/* RoyaltyGrid — banker's-ledger identity: ink green, gilt accent, hairline rules, tabular numerals */
:root {
  --ink: #0b100d; --ink2: #10160f; --panel: #131a14; --panel2: #1a2319;
  --line: #24301f; --line-soft: rgba(213, 196, 138, .10);
  --gold: #d9b45b; --gold-dim: #9c8340; --green: #4fc487; --red: #e06c5a; --blue: #7fa8d9;
  --text: #e9e6da; --muted: #97a08c; --faint: #5c6653;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --r: 10px; --r-sm: 6px;
}
* { box-sizing: border-box; margin: 0; }
body { background: var(--ink); color: var(--text); font-family: var(--sans); font-size: 14.5px; line-height: 1.5; }
.mono, .pill, td.num, .stat .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.shell { display: grid; grid-template-columns: 218px 1fr; min-height: 100vh; }
.side { background: var(--ink2); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 0 8px 18px; border-bottom: 1px solid var(--line); }
.brand .b1 { font-weight: 800; letter-spacing: .04em; font-size: 19px; color: var(--text); }
.brand .b2 { font-weight: 800; letter-spacing: .04em; font-size: 19px; color: var(--gold); }
.brand .tag { font-family: var(--mono); font-size: 9.5px; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; margin-top: 5px; }
#nav { display: flex; flex-direction: column; gap: 2px; margin-top: 14px; flex: 1; }
#nav button { text-align: left; background: none; border: none; color: var(--muted); font: 600 13.5px var(--sans); padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; border-left: 2px solid transparent; }
#nav button:hover { color: var(--text); background: var(--panel); }
#nav button.active { color: var(--gold); background: var(--panel); border-left-color: var(--gold); }
.side-foot { border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); }

main { padding: 30px 34px 60px; max-width: 1240px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.page-head p { color: var(--muted); margin-top: 3px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.sheet-actions { display: flex; gap: 8px; }

.screen { display: none; }
.screen.active { display: block; }
.card { background: linear-gradient(170deg, var(--panel), var(--ink2)); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; }
.card-h { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-dim); margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.muted-inline { color: var(--faint); text-transform: none; letter-spacing: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } .shell { grid-template-columns: 64px 1fr; } .brand .tag, .side-foot { display: none; } }
@media (max-width: 720px) {
  .shell { display: block; padding-bottom: 62px; }
  .side { position: fixed; inset: auto 0 0 0; width: 100%; height: 62px; z-index: 80; padding: 6px; border: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
  .side .brand, .side-foot { display: none; }
  #nav { flex-direction: row; margin: 0; gap: 4px; flex: none; }
  #nav button { flex: 0 0 auto; white-space: nowrap; padding: 10px; border-left: 0; border-bottom: 2px solid transparent; font-size: 12px; }
  #nav button.active { border-left-color: transparent; border-bottom-color: var(--gold); }
  main { padding: 20px 14px 40px; }
  .row2 { grid-template-columns: 1fr; }
  .review-row, .connection-card, .song-card { grid-template-columns: 1fr; align-items: start; }
  .review-row { flex-direction: column; }
  table.ledger { display: block; overflow-x: auto; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}

/* forms */
input, select, textarea { background: var(--ink); border: 1px solid var(--line); color: var(--text); border-radius: var(--r-sm); padding: 9px 11px; font: 400 13.5px var(--sans); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--gold-dim); }
textarea { width: 100%; min-height: 110px; font-family: var(--mono); font-size: 12px; resize: vertical; }
button { background: var(--gold); color: #191405; border: none; border-radius: var(--r-sm); padding: 9px 16px; font: 700 13px var(--sans); cursor: pointer; }
button:hover { filter: brightness(1.08); }
.ghost-btn { display: inline-block; background: transparent; border: 1px solid var(--gold-dim); color: var(--gold); text-decoration: none; padding: 8px 14px; border-radius: var(--r-sm); font: 700 12.5px var(--sans); cursor: pointer; }
.inline-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-wrap input[name="title"], .inline-wrap input[name="name"], .inline-wrap input[name="person"] { flex: 1; min-width: 150px; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.w-xs { width: 76px; } .w-sm { width: 130px; } .w-md { width: 170px; }
.lbl { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }

/* stats */
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 980px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .k { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.stat .v { font-size: 23px; font-weight: 700; margin-top: 4px; }
.stat .v.gold { color: var(--gold); } .stat .v.green { color: var(--green); } .stat .v.red { color: var(--red); }
.stat .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* meter */
.meter { height: 26px; background: var(--ink); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.meter-owed { height: 100%; width: 0%; background: rgba(217, 180, 91, .18); border-right: 1px solid var(--gold-dim); transition: width .6s ease; }
.meter-owed i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--green), #2f9c66); transition: width .8s ease; }
.meter-legend { display: flex; gap: 18px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.meter-legend b { color: var(--text); font-family: var(--mono); }

/* tables */
table.ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ledger th { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.ledger td { padding: 8px; border-bottom: 1px solid var(--line-soft); }
table.ledger td.num, table.ledger th.num { text-align: right; }
table.ledger tr:last-child td { border-bottom: none; }
.pos { color: var(--green); } .neg { color: var(--red); } .gold-t { color: var(--gold); }

.empty { color: var(--faint); font-size: 13px; padding: 14px 4px; }
.pill { font-size: 10.5px; background: var(--ink); color: var(--gold); border: 1px solid var(--line); padding: 2px 9px; border-radius: 20px; }
.pill.ok { color: var(--green); } .pill.bad { color: var(--red); }
.warn-row { display: flex; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line-soft); font-size: 13px; color: var(--muted); cursor: pointer; }
.warn-row:hover { color: var(--text); }
.warn-row .dot { color: var(--red); }
.feed div { padding: 7px 4px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); }
.feed b { color: var(--text); font-weight: 600; }
.feed .ts { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-left: 6px; }

/* song cards */
.song-card { background: linear-gradient(170deg, var(--panel), var(--ink2)); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 18px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; cursor: pointer; }
.song-card:hover { border-color: var(--gold-dim); }
.song-card h3 { font-size: 15.5px; }
.song-card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.song-card .badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* splits rows */
.split-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.split-row .role { color: var(--faint); font-size: 11.5px; }
.split-row .x { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 15px; padding: 0 4px; }
.split-row .x:hover { color: var(--red); }
.split-form { margin-top: 10px; }
.sum-bar { height: 5px; background: var(--ink); border-radius: 4px; overflow: hidden; margin: 8px 0 2px; }
.sum-bar i { display: block; height: 100%; background: var(--gold); }
.sum-bar i.full { background: var(--green); }

/* people */
.person-card { background: linear-gradient(170deg, var(--panel), var(--ink2)); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; margin-bottom: 10px; }
.person-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.person-top h3 { font-size: 15px; }
.person-top .sub { color: var(--faint); font-size: 12px; }
.person-nums { display: flex; gap: 22px; margin-top: 8px; font-family: var(--mono); font-size: 13px; }
.person-nums span b { display: block; font-size: 10px; color: var(--faint); letter-spacing: .08em; font-weight: 400; }
.pay-form { display: none; margin-top: 10px; }
.pay-form.open { display: flex; }

/* statement */
.statement { display: none; }
.statement.on { display: block; background: #f4f0e4; color: #211d12; border-radius: var(--r); padding: 34px 40px; font-family: var(--sans); }
.statement h2 { font-size: 21px; letter-spacing: -.01em; }
.statement .st-head { display: flex; justify-content: space-between; border-bottom: 2px solid #211d12; padding-bottom: 12px; margin-bottom: 16px; }
.statement .st-head .mono { font-family: var(--mono); font-size: 12px; color: #6d654c; }
.statement table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.statement th { text-align: left; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #6d654c; border-bottom: 1px solid #c9c0a4; padding: 5px 6px; }
.statement td { padding: 6px; border-bottom: 1px solid #e2dcc8; font-variant-numeric: tabular-nums; }
.statement td.num, .statement th.num { text-align: right; font-family: var(--mono); }
.statement .totals { margin-top: 14px; margin-left: auto; width: 300px; font-family: var(--mono); font-size: 13px; }
.statement .totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.statement .totals .due { border-top: 2px solid #211d12; font-weight: 700; font-size: 15px; padding-top: 8px; }
.statement .sig { margin-top: 34px; display: flex; gap: 60px; }
.statement .sig div { flex: 1; border-top: 1px solid #211d12; padding-top: 5px; font-size: 11px; color: #6d654c; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--panel2); border: 1px solid var(--gold-dim); color: var(--text); padding: 11px 20px; border-radius: var(--r-sm); font-size: 13.5px; transition: transform .25s ease; z-index: 99; max-width: 80vw; }
#toast.show { transform: translateX(-50%) translateY(0); }

.auth-gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 70% 20%, #1a291e, var(--ink) 55%); }
.auth-gate.hidden { display: none; }
.auth-card { width: min(430px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(160deg, var(--panel2), var(--ink2)); box-shadow: 0 25px 80px rgba(0,0,0,.45); }
.auth-card .brand { padding: 0 0 20px; margin-bottom: 24px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card form { margin: 22px 0 14px; }
.auth-card input { width: 100%; }
.auth-card #auth-error { min-height: 22px; margin-top: 14px; font-size: 13px; }
.register-only { display: none; }
.auth-gate.registering .register-only { display: block; }

.connection-card { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; }
.connection-card h3 { text-transform: capitalize; margin-bottom: 3px; }
.freshness { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 5px; }
.source-badge { display: inline-block; font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; padding: 2px 6px; margin-left: 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }
.review-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 4px; border-bottom: 1px solid var(--line-soft); }
.review-row:last-child { border-bottom: 0; }
.danger-btn { background: transparent; color: var(--red); border: 1px solid var(--red); }
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 72px minmax(40px, 1fr) 100px; align-items: center; gap: 9px; font: 10px var(--mono); color: var(--muted); }
.bar-row i { display: block; height: 13px; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); border-radius: 3px; }
.bar-row b { text-align: right; color: var(--text); }
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.usage-grid span { background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; color: var(--muted); }
.usage-grid b { display: block; color: var(--text); font-family: var(--mono); }
#legal-view p { margin-bottom: 9px; }
.legal-page { max-width: 780px; margin: 0 auto; padding: 64px 28px; }
.legal-page h1 { color: var(--gold); margin-bottom: 6px; }
.legal-page h2 { margin-top: 28px; margin-bottom: 6px; }
.legal-page p { color: var(--muted); margin-bottom: 12px; }
.legal-page a { color: var(--gold); }

@media print {
  body { background: #fff; }
  .side, .page-head, #screen-statements .card, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .statement.on { border-radius: 0; padding: 10mm; background: #fff; }
}
