:root { --kt: #c0392b; --ok: #1e8449; --bad: #c0392b; --okbg: #d4efdf; --badbg: #f5b7b1; --grid: #000; }
body { padding-bottom: 4rem; }
main { width: 100%; max-width: none; padding: 0; margin: 0; }
header.bar, .stats, .hint { padding: .5rem .75rem; }
header.bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 0; }

.tabs { display: flex; gap: .25rem; width: 100%; }
.tabs a { flex: 1; text-align: center; padding: .5rem; text-decoration: none;
          color: var(--color); border: 1px solid var(--muted-border-color); border-radius: var(--border-radius); }
.tabs a.on { background: var(--kt); color: #fff; border-color: var(--kt); }

.controls { display: flex; gap: .4rem; width: 100%; margin-top: .5rem; }

.controls .menu { flex: 1; position: relative; }
.controls .menu > summary { list-style: none; cursor: pointer; padding: .5rem 1rem; display: block; text-align: center;
                  border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; background: transparent; }
.controls .menu > summary::-webkit-details-marker { display: none; }
.controls .menu > summary::marker { content: ""; }
.controls .menu > summary::after { display: none; }
.controls .menu[open] > summary { background: var(--kt); color: #fff; border-color: var(--kt); }
.controls .menu ul { position: absolute; left: 0; z-index: 20; margin: .25rem 0 0; padding: .25rem; list-style: none;
           min-width: 100%; background: #1b2129;
           border: 1px solid var(--muted-border-color); border-radius: var(--border-radius);
           box-shadow: 0 8px 24px rgba(0, 0, 0, .55); }
.controls .menu li a { display: block; padding: .35rem .6rem; cursor: pointer; text-decoration: none;
             color: var(--color); border-radius: var(--border-radius); white-space: nowrap; }
.controls .menu li a:hover { background: var(--kt); color: #fff; }

#grid { margin: 0 .75rem; }
/* without touch-action the browser claims the drag for scrolling and paint never gets a move */
.tabulator-cell.cell { cursor: pointer; user-select: none; touch-action: none; }
.tabulator-cell.cell:hover { background: var(--muted-border-color); }
.tabulator-cell.cell.on { background: rgba(30, 132, 73, .28); }
.tabulator-cell.cell.on::after { content: "✓"; color: var(--ok); font-weight: 700; }
.dh { display: inline-flex; align-items: center; gap: .3rem; }
.masstoggle { display: none; margin: 0; }
.tabulator-col:hover .masstoggle { display: inline-block; }

.stats { display: flex; gap: 1.5rem; margin: .25rem 0 .75rem; color: var(--muted-color); }
.stats b { font-weight: 700; }
.ok { color: var(--ok); } .bad { color: var(--bad); }

main.login { max-width: 320px; margin: 4rem auto; padding: 0 1rem; text-align: center; }
.login .logo { display: block; width: 96px; height: auto; margin: 0 auto 1rem; }
.bar .brand { height: 32px; width: 32px; }
.bar .logout { margin-left: auto; font-size: .85rem; }

.bycat p { margin: .6rem 0 .15rem; font-weight: 600; }
.bycat ul { margin: 0 0 .4rem 1.2rem; }
.byname { display: none; }
.lacktoggle:checked ~ .bycat { display: none; }
.lacktoggle:checked ~ .byname { display: table; }

.tablesearch { max-width: 20rem; margin: .25rem .75rem .5rem; }
.tabulator { font-size: .9rem; }
.bar .scope { margin-left: auto; font-size: .8rem; color: var(--muted-color); display: inline-flex; align-items: center; gap: .3rem; }
.bar .scope + .logout { margin-left: 1rem; }

/* drop tabulator's own backgrounds — inherit the page */
.tabulator,
.tabulator-header,
.tabulator .tabulator-header .tabulator-col,
.tabulator-row,
.tabulator-row.tabulator-row-even,
.tabulator-row .tabulator-cell { background: transparent; background-color: transparent; }

table { font-size: .9rem; }
table th, table td { border-color: var(--grid); }

/* tables: bold text, never recolor the font (no green/red) */
table th, table td, .tabulator-cell { font-weight: 700; }
table .ok, table .bad, .tabulator-cell.ok, .tabulator-cell.bad { color: inherit; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--kt); color: #fff; font-weight: 600; }
.avatar.big { width: 96px; height: 96px; font-size: 2.2rem; }
.belt { display: inline-flex; align-items: center; gap: .4rem; }
.belt::before { content: ""; width: 14px; height: 14px; border-radius: 3px; background: var(--c); border: 1px solid rgba(0,0,0,.3); }

.deck { max-width: 420px; margin: 1rem auto; text-align: center; }
.cardstack { position: relative; height: 340px; margin: 1rem 0; }
.card { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
        justify-content: center; gap: .75rem; cursor: grab; touch-action: none; user-select: none;
        border: 1px solid var(--muted-border-color); border-radius: 1rem; background: var(--card-background-color); }
.card h3 { margin: 0; } .card p { margin: 0; color: var(--muted-color); }
.hint { color: var(--muted-color); font-size: .85rem; }

.dir-received { color: var(--ok); font-weight: 600; }
.dir-owed     { color: var(--bad); font-weight: 600; }
tr.owe td { background: var(--badbg); }

details.add > summary { display: inline-block; width: auto; padding: .4rem 1rem; border-radius: var(--border-radius); background: var(--kt); color: #fff; }
details.add article { margin-top: .5rem; }
