/* Tally: a personal ledger. Totals get the accountant's double underline. */
:root {
  --paper: #F4F6F3;
  --surface: #FFFFFF;
  --ink: #1B2420;
  --muted: #5F6B65;
  --line: #DCE2DE;
  --line-strong: #B9C3BD;
  --green: #2F6BD6;
  --green-ink: #1F4FA8;
  --green-soft: #E7EFFC;
  --ok: #1F7A4D;
  --ok-soft: #E1F2E8;
  --brand: #4A86E8;
  --red: #A3402C;
  --red-soft: #F6E6E1;
  --blue: #2D5A86;
  --blue-soft: #E3EBF4;
  --radius: 6px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15.5px; line-height: 1.6; letter-spacing: 0.005em; -webkit-font-smoothing: antialiased; }
a { color: var(--green); }
a:hover { color: var(--green-ink); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num, .amt { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; letter-spacing: 0; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.neg { color: var(--red); }
form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 28px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: flex-start; gap: 12px; font-weight: 600; font-size: 1rem; padding: 0 12px 28px; color: var(--ink); text-decoration: none; line-height: 1.35; }
.brand > span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.brand-mark { flex: none; margin-top: 1px; width: 20px; height: 20px; border-radius: 5px; background:
  linear-gradient(#fff, #fff) no-repeat 50% 11px / 10px 1.5px,
  linear-gradient(#fff, #fff) no-repeat 50% 14px / 10px 1.5px,
  var(--green); }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a { display: block; padding: 10px 14px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; line-height: 1.35; }
.nav a:hover { background: var(--paper); }
.nav a.is-active { background: var(--green-soft); color: var(--green-ink); font-weight: 600; }
.nav-user { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.nav-user-role { display: block; margin-top: 2px; font-size: .82rem; font-weight: 400; color: var(--muted); }
.nav-logout { margin: 0; }
.nav-logout button { width: 100%; text-align: left; background: none; border: 0; color: var(--muted); font: inherit; padding: 10px 14px; border-radius: 8px; cursor: pointer; }
.nav-logout button:hover { background: var(--paper); color: var(--ink); }
.side .nav-toggle { display: none; }
.main { padding: 40px 52px 80px; max-width: 1240px; width: 100%; }

/* ---------- Headings ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 30px; }
h1 { font-size: 1.85rem; line-height: 1.25; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 .badge { vertical-align: middle; margin-left: 6px; }
h2 { font-size: 1.08rem; line-height: 1.35; margin: 0 0 18px; font-weight: 600; }
.sub { margin: 8px 0 0; color: var(--muted); max-width: 70ch; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions select { width: auto; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 18px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--radius); font: inherit; font-size: .95rem; font-weight: 500; line-height: 1.3; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-ink); border-color: var(--green-ink); color: #fff; }
.btn-danger { color: var(--red); border-color: #E3C3BA; }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: .875rem; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 26px 30px; margin-bottom: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; }
.panel-head a { font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 24px; }

/* ---------- The ledger (signature element) ---------- */
.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 32px 24px; margin-bottom: 24px; }
.ledger-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); font-size: 1.02rem; }
.ledger-row small { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.ledger-row .amt { font-size: 1.85rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
.ledger-total { border-bottom: 0; padding-top: 20px; }
.ledger-total > span:first-child { font-weight: 600; }
.ledger-total .amt { font-size: 2.7rem; font-weight: 700; letter-spacing: -0.03em; padding-bottom: 3px; border-bottom: 5px double currentColor; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; margin-bottom: 24px; }
.stat { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; color: var(--ink); text-decoration: none; }
a.stat:hover { border-color: var(--line-strong); color: var(--ink); }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-note { color: var(--muted); font-size: .85rem; }
.stat.is-alert { border-color: #E3C3BA; }
.stat.is-alert .stat-value { color: var(--red); }

/* ---------- Category bars ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.bar-top { display: flex; justify-content: space-between; gap: 12px; font-size: .94rem; margin-bottom: 7px; }
.bar-track { height: 8px; background: var(--paper); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; min-width: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .84rem; letter-spacing: .01em; padding: 10px 14px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.data th.num { text-align: right; }
.data td { padding: 14px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tfoot td { border-top: 1px solid var(--line-strong); font-weight: 600; }
.data th:first-child, .data td:first-child { padding-left: 0; }
.data th:last-child, .data td:last-child { padding-right: 0; }
.cell-sub { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.row-link { color: var(--ink); font-weight: 500; text-decoration: none; }
.row-link:hover { color: var(--green); text-decoration: underline; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: .8rem; font-weight: 500; line-height: 1.5; white-space: nowrap; letter-spacing: .01em; }
.badge-draft { background: #ECEFED; color: var(--muted); }
.badge-sent { background: var(--blue-soft); color: var(--blue); }
.badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-overdue { background: var(--red-soft); color: var(--red); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 24px; max-width: 780px; }
.form-wide { max-width: none; }
.field { min-width: 0; }
.field > label, .totals-input label { display: block; font-weight: 500; font-size: .93rem; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: .86rem; line-height: 1.5; margin: 7px 0 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], input[type=file], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; line-height: 1.4; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; font: inherit; font-size: .95rem; color: var(--ink);
}
input[type=file] { padding: 7px; }
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: var(--green); }
input[type=color] { width: 44px; height: 38px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; cursor: pointer; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px 22px; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding-top: 8px; }
.spacer { flex: 1; }
.check { display: flex; gap: 10px; align-items: center; font-size: .94rem; margin: 2px 0 10px; font-weight: 400; line-height: 1.45; }
.check input { width: 17px; height: 17px; flex: none; accent-color: var(--green); }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 22px; }
legend { font-weight: 600; font-size: 1.05rem; padding: 0; margin-bottom: 12px; }
.logo-preview { display: block; max-height: 60px; margin-bottom: 10px; }

.errors { background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 14px 18px; margin-bottom: 24px; line-height: 1.55; }
.errors ul { margin: 0; padding-left: 18px; }
.flash { padding: 14px 18px; border-radius: 8px; margin-bottom: 24px; line-height: 1.55; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.flash-err { background: var(--red-soft); color: var(--red); }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end; margin-bottom: 24px; }
.filters .field { min-width: 150px; }
.filters .field-grow { flex: 1; min-width: 200px; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs { display: flex; gap: 10px; border-bottom: 1px solid var(--line); margin: -6px 0 24px; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--ink); border-bottom-color: var(--green); }
.tabs .muted { font-weight: 500; font-size: .78rem; color: var(--muted); background: #EEF1F4; border-radius: 999px; padding: 1px 8px; min-width: 24px; text-align: center; }
.tabs a.is-active .muted { background: var(--green-soft); color: var(--green-ink); }
.summary-line { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; color: var(--muted); font-size: .94rem; }
.summary-line strong { color: var(--ink); font-size: 1.1rem; font-variant-numeric: tabular-nums; border-bottom: 3px double var(--ink); }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 24px; }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* ---------- Invoice editor ---------- */
.items-table td { padding: 8px 8px; vertical-align: middle; }
.items-table td:first-child { padding-left: 0; }
.items-table input { padding: 7px 9px; }
.items-table .col-qty { width: 90px; }
.items-table .col-price { width: 140px; }
.items-table .col-amt { width: 130px; }
.items-table .col-x { width: 44px; text-align: right; }
.items-table .col-qty input, .items-table .col-price input { text-align: right; font-variant-numeric: tabular-nums; }
.remove-item { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.3rem; line-height: 1; padding: 4px 9px; border-radius: 4px; }
.remove-item:hover { color: var(--red); background: var(--red-soft); }
#add-item { margin-top: 4px; }
.totals-box { margin-left: auto; width: 100%; max-width: 360px; display: grid; gap: 14px; }
.totals-box > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.totals-input label { margin: 0; font-weight: 400; }
.totals-input input { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
.totals-box .grand { font-weight: 700; font-size: 1.25rem; padding-top: 10px; border-top: 1px solid var(--line-strong); }
.totals-box .grand .num { border-bottom: 4px double var(--ink); }

/* ---------- Invoice view ---------- */
.status-bar { display: flex; align-items: center; gap: 14px 18px; flex-wrap: wrap; padding: 18px 24px; }
.status-bar > span { flex: 1; min-width: 200px; color: var(--muted); }
.paid-form label { font-size: .9rem; color: var(--muted); }
.paid-form input { width: auto; padding: 5px 8px; }

.invoice-sheet { background: #fff; color: #1B2420; max-width: 820px; margin: 0 auto; padding: 52px 56px 48px; border: 1px solid var(--line); border-radius: 4px; font-size: 13.5px; line-height: 1.55; }
.invoice-sheet.is-exporting { border-color: transparent; border-radius: 0; }
.inv-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; padding-bottom: 22px; border-bottom: 2px solid #4A86E8; }
.inv-client-name { font-size: 22px; font-weight: 600; color: #4A86E8; letter-spacing: -0.01em; margin: 0 0 4px; line-height: 1.25; }
.inv-lines { color: #4F5B55; margin: 0; white-space: pre-line; }
.inv-meta { text-align: right; flex: none; }
.inv-logo { display: block; max-height: 56px; max-width: 200px; margin: 0 0 10px auto; }
.inv-number { font-size: 22px; font-weight: 400; color: #4A86E8; margin: 0; white-space: nowrap; letter-spacing: -0.01em; }
.inv-paid { display: inline-block; margin-top: 10px; padding: 3px 12px; border: 2px solid #4A86E8; color: #4A86E8; border-radius: 4px; font-weight: 700; transform: rotate(-3deg); }
.inv-from { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; padding: 20px 0 26px; }
.inv-from-name { margin: 0 0 2px; font-weight: 600; font-size: 14px; }
.inv-label { color: #5F6B65; font-weight: 400; }
.inv-dates { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; }
.inv-dates dt { color: #5F6B65; text-align: right; }
.inv-dates dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-items { width: 100%; border-collapse: collapse; }
.inv-items th { text-align: left; font-size: 12px; font-weight: 600; color: #fff; background: #4A86E8; padding: 9px 10px; }
.inv-items th:first-child { border-radius: 3px 0 0 3px; } .inv-items th:last-child { border-radius: 0 3px 3px 0; }
.inv-items td { padding: 11px 10px; border-bottom: 1px solid #DCE2DE; vertical-align: top; }
.inv-items .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-items tr { page-break-inside: avoid; }
.inv-totals { margin: 12px 0 0 auto; width: 300px; font-variant-numeric: tabular-nums; }
.inv-totals div { display: flex; justify-content: space-between; padding: 4px 10px; }
.inv-totals .inv-grand { font-weight: 700; font-size: 17px; margin-top: 6px; padding-top: 10px; border-top: 1px solid #1B2420; }
.inv-grand span:last-child { border-bottom: 4px double #1B2420; line-height: 1.35; }
.inv-tasks { margin-top: 30px; page-break-inside: auto; }
.inv-tasks h3 { font-size: 13px; font-weight: 700; margin: 0 0 10px; color: #4A86E8; }
.inv-task-groups.is-multi { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; }
.inv-task-group { page-break-inside: avoid; }
.inv-task-group h4 { font-size: 12.5px; font-weight: 600; margin: 0 0 4px; }
.inv-tasks ul { margin: 0; padding-left: 18px; }
.inv-tasks li { margin: 0 0 3px; padding-left: 2px; }
.inv-tasks li::marker { color: #4A86E8; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.label-row label { margin: 0; font-weight: 500; font-size: .92rem; }
.label-actions { display: flex; gap: 20px; font-size: .88rem; }
.btn-link { border: 0; background: none; padding: 0; color: var(--green); text-decoration: underline; cursor: pointer; font: inherit; }
.inv-notes { margin-top: 30px; color: #3A4540; page-break-inside: avoid; }
.inv-details { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 36px; padding-top: 20px; border-top: 1px solid #DCE2DE; page-break-inside: avoid; }
.inv-details h3 { font-size: 13px; font-weight: 700; margin: 0 0 8px; color: #4A86E8; }
.inv-details dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; font-size: 12.5px; }
.inv-details dt { color: #5F6B65; }
.inv-details dd { margin: 0; overflow-wrap: anywhere; }
.inv-details dd.full { grid-column: 1 / -1; }

/* ---------- Billing logic choices ---------- */
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.choice-card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 14px 44px; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; background: #fff; }
.choice-card input { position: absolute; left: 16px; top: 17px; width: 16px; height: 16px; accent-color: var(--green); margin: 0; }
.choice-card:has(input:checked) { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.choice-card:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: 2px; }
.choice-title { font-weight: 600; }
.choice-help { color: var(--muted); font-size: .86rem; line-height: 1.4; }
.choice-cards.compact .choice-card { padding: 11px 14px 11px 42px; }
.choice-cards.compact .choice-card input { top: 14px; left: 15px; }
fieldset.lines { display: block; }
.items-table .col-month { width: 160px; }
.items-table .col-month input { min-width: 140px; }
.items-table .line-base { color: var(--muted); }
.style-box { border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.style-box summary { cursor: pointer; font-weight: 500; }
.gen-table td { vertical-align: middle; }
.gen-table input[type=month] { width: 170px; }
.gen-table .gen-workdays { width: 64px; text-align: right; padding: 5px 7px; }
.gen-table tr.is-done td { color: var(--muted); }
.gen-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); }
[hidden] { display: none !important; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box-sm { height: 240px; margin-bottom: 16px; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 38px 40px; width: 100%; max-width: 400px; }
.auth-card.wide { max-width: 660px; }
.auth-card .brand { padding: 0 0 22px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .sub { margin-bottom: 20px; }
.auth-card .form { max-width: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 28px 24px 56px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 12px 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .side .nav-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; padding-top: 16px; }
  .nav.is-open { display: flex; }
  .main { padding: 24px 18px 56px; }
  h1 { font-size: 1.45rem; }
  .panel { padding: 20px 18px; }
  .tabs { gap: 4px; }
  .tabs a { padding: 10px 12px; }
  .data td { padding: 12px 10px; }
  .ledger { padding: 2px 18px 16px; }
  .ledger-row .amt { font-size: 1.35rem; }
  .ledger-total .amt { font-size: 1.9rem; }
  .invoice-sheet { padding: 28px 20px; }
  .inv-top, .inv-from { flex-direction: column; gap: 14px; }
  .inv-meta { text-align: left; }
  .inv-logo { margin-left: 0; }
  .inv-totals { width: 100%; }
  .inv-details, .inv-task-groups.is-multi { grid-template-columns: 1fr; }
  .inv-items { font-size: 12px; }
  .items-table .col-price { width: 110px; }
  .data td, .data th { white-space: nowrap; }
  .items-table { min-width: 560px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Print ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .side, .no-print, .flash { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .invoice-sheet { border: 0; padding: 0; max-width: none; }
}

/* ---------- Team and permissions ---------- */
.perm-table td, .perm-table th { vertical-align: middle; }
.perm-table th.lvl, .perm-table td.lvl { text-align: center; width: 110px; }
.perm-table input[type=radio] { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }
.perm-table.is-off { opacity: .45; pointer-events: none; }
.role-note { background: var(--green-soft); color: var(--green-ink); border-radius: var(--radius); padding: 10px 14px; font-size: .92rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: #ECEFED; color: var(--muted); white-space: nowrap; }
.chip-edit { background: var(--green-soft); color: var(--green-ink); }
.badge-admin { background: var(--green); color: #fff; }
.badge-off { background: #ECEFED; color: var(--muted); }
fieldset[disabled] input, fieldset[disabled] select, fieldset[disabled] textarea { background: var(--paper); color: var(--ink); }
.readonly-note { color: var(--muted); font-size: .92rem; margin: 0; }
.log-when { white-space: nowrap; color: var(--muted); font-size: .88rem; }

/* ---------- Monthly sheet (colour coding follows your spreadsheet) ---------- */
:root { --won: #9CCB4F; --opp: #F2DB2E; --lost: #C9463D; --sal: #E39A0B; --exp: #5E828E; --net: #7AD32F; }
.sheet-top { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.sheet-summary { padding: 16px 28px 22px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0 12px 18px; border-bottom: 1px solid var(--line); position: relative; }
.sum-row::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 5px; border-radius: 3px; }
.sum-row strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.sum-won::before { background: var(--won); } .sum-opp::before { background: var(--opp); } .sum-lost::before { background: var(--lost); }
.sum-sal::before { background: var(--sal); } .sum-exp::before { background: var(--exp); } .sum-net::before { background: var(--net); }
.sum-won strong { font-size: 1.6rem; }
.sum-net { border-bottom: 0; padding-top: 14px; }
.sum-net span { font-weight: 600; }
.sum-net strong { font-size: 1.7rem; font-weight: 700; border-bottom: 4px double currentColor; }
.sheet-side { display: grid; gap: 16px; }
.sheet-kpi { display: flex; justify-content: space-between; align-items: baseline; }
.sheet-kpi span { color: var(--muted); }
.sheet-kpi strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.rate-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rate-form input { width: 110px; text-align: right; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 24px; margin-top: 24px; align-items: start; }
.sheet-col { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; padding-bottom: 20px; }
.sheet-col > .hint, .sheet-col > form, .sheet-col > .sheet-add { margin-left: 20px; margin-right: 20px; }
.sheet-head { margin: 0; padding: 12px 20px; font-size: 1rem; font-weight: 600; letter-spacing: .02em; text-align: center; }
.sh-won { background: var(--won); color: #1B2420; } .sh-opp { background: var(--opp); color: #1B2420; } .sh-lost { background: var(--lost); color: #fff; }
.sh-sal { background: var(--sal); color: #1B2420; } .sh-exp { background: var(--exp); color: #fff; }
.sheet-table { margin: 0; }
.sheet-table td.num, .sheet-table th.num { white-space: nowrap; }
.sheet-table th, .sheet-table td { padding: 11px 10px; }
.sheet-table th:first-child, .sheet-table td:first-child { padding-left: 20px; }
.sheet-table th:last-child, .sheet-table td:last-child { padding-right: 20px; }
.sheet-table td.is-est { font-style: italic; color: var(--muted); }
.row-actions { white-space: nowrap; text-align: right; width: 1%; }
.row-actions form + form { margin-left: 4px; }
.row-actions .btn-link { font-size: .82rem; }
.sheet-add { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sheet-add input, .sheet-add select { flex: 1 1 120px; min-height: 38px; padding: 7px 10px; font-size: .92rem; }
.sheet-add .w-num { flex: 0 1 100px; text-align: right; }
.sheet-add .w-cur { flex: 0 0 84px; }
@media (max-width: 900px) { .sheet-top { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Selecting rows ---------- */
.col-check { width: 1%; padding-right: 4px !important; }
.col-check input { width: 17px; height: 17px; accent-color: var(--green); cursor: pointer; vertical-align: middle; }
.bulk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: 8px; background: var(--green-soft); }
.bulk-count { font-weight: 600; color: var(--green-ink); margin-right: auto; }
.data tr:has(input[name="ids[]"]:checked) td { background: #F4F8FE; }
.data .col-check + td { padding-left: 8px; }
