/* Tally-Up — base stylesheet
 * Dark professional UI, mirrors the Cobblestone Digital aesthetic.
 */

:root {
  --bg:        #0d1017;
  --surface:   #161a23;
  --surface-2: #1c2230;
  --surface-3: #232a3b;
  --border:    #2a3142;
  --border-2:  #3a4257;
  --text:      #e6e8ee;
  --text-dim:  #99a1b3;
  --text-mute: #6e768a;
  --accent:    #4f8ef7;
  --accent-2:  #2d4f8e;
  --accent-3:  #1a3060;
  --good:      #5dbf7e;
  --warn:      #e4a34a;
  --bad:       #e25a5a;
  --mono:      "Consolas", "Cascadia Code", "Menlo", monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5; min-height: 100vh;
}
body { display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.mono, code { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--text-dim); font-size: 13px; }
.warn { color: var(--warn); }

/* ----- Top bar ----- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-minimal { justify-content: center; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-link { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand-link:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.brand-mark { color: var(--accent); font-size: 24px; line-height: 1; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.brand-tag { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.brand-divider { color: var(--text-mute); margin: 0 4px; }
.entity-name { color: var(--text-dim); font-size: 14px; font-weight: 500; }
.topnav { display: flex; gap: 14px; align-items: center; }
.topnav a {
  padding: 6px 10px; border-radius: 4px; color: var(--text); font-size: 13px;
}
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.nav-divider { color: var(--text-mute); }
.nav-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  background: rgba(220, 80, 80, 0.18); color: #e96a6a;
  border-radius: 9px; font-size: 11px; font-weight: 500;
  vertical-align: 1px;
}
.filters-row {
  display: flex; gap: 6px; margin: 12px 0 16px 0; flex-wrap: wrap;
}
.filter-chip {
  display: inline-block; padding: 4px 12px;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 14px;
  font-size: 12px; text-decoration: none; text-transform: capitalize;
}
.filter-chip:hover { background: var(--surface); color: var(--text); }
.filter-chip.active {
  background: var(--accent); color: white; border-color: var(--accent);
}
.eh-error-row td { padding: 0 12px 8px 12px; background: transparent; }

/* Payments panel — invoice show page */
.payment-summary {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px;
  font-size: 13px;
}
.payment-summary > div { display: flex; justify-content: space-between; }
.payment-balance strong { color: var(--accent); }
.payment-list { list-style: none; margin: 0; padding: 0; }
.payment-item {
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.payment-item:last-child { border-bottom: none; }
.payment-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.payment-amount {
  font-weight: 600; color: var(--good); font-variant-numeric: tabular-nums;
}
.payment-method { color: var(--text); flex: 1; }
.payment-sub {
  font-size: 12px; color: var(--text-dim); margin-top: 3px;
}
.payment-void-note { color: var(--bad); }
.payment-voided .payment-amount,
.payment-voided .payment-method {
  text-decoration: line-through; opacity: 0.5;
}
.payment-actions { margin-top: 4px; }

/* Overdue status pill — separate from the normal status pills */
.status-pill-overdue {
  background: rgba(220, 80, 80, 0.18); color: #e96a6a;
  border: 1px solid rgba(220, 80, 80, 0.35);
}

/* Radio-group for payment method selection */
.radio-group {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px;
}
.radio-option {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 14px;
  font-size: 13px; cursor: pointer;
}
.radio-option:hover { background: var(--surface); color: var(--text); }
.radio-option input[type=radio] { margin: 0; }
.radio-option:has(input:checked) {
  background: var(--accent); color: white; border-color: var(--accent);
}

/* Bookkeeping — Phase 4 */
.bk-tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px; margin: 16px 0;
}
.bk-coa-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.bk-coa-head h2 { margin: 0 0 2px 0; font-size: 14px; }
.acct-nb {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.acct-nb-debit  { background: rgba(80, 160, 220, 0.15); color: #4a9fd4; }
.acct-nb-credit { background: rgba(80, 200, 130, 0.15); color: #4ab87d; }
.je-detail-table tfoot .je-totals-row td {
  border-top: 2px solid var(--accent); background: var(--surface-2);
  padding: 10px 12px;
}
.tb-type-header td { border-top: 1px solid var(--border); }
.tb-totals-row td {
  border-top: 2px solid var(--accent); background: var(--surface-2);
  padding: 10px 12px;
}
.nav-user { color: var(--text-dim); font-size: 13px; }
.nav-action { color: var(--text-dim) !important; }

/* ----- Content ----- */
.content { flex: 1; max-width: 1100px; width: 100%; margin: 0 auto; padding: 24px; }
.content-narrow { max-width: 720px; }
.auth-body .content { display: flex; align-items: flex-start; justify-content: center; padding-top: 48px; }
.page > h1 { margin: 0 0 4px 0; font-size: 28px; font-weight: 600; }
.page > .subtitle, .card .subtitle { margin: 0 0 24px 0; color: var(--text-dim); }

/* ----- Cards ----- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 24px 28px; margin-bottom: 16px;
}
.card h1 { margin: 0 0 12px 0; font-size: 24px; font-weight: 600; }
.card h2 { margin: 0 0 12px 0; font-size: 16px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.card h3 { margin: 24px 0 12px 0; font-size: 14px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.card-narrow { width: 100%; max-width: 420px; }
.card-wide   { width: 100%; max-width: 720px; }
.card-header { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }

/* ----- Panel (inline) ----- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px 20px; margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 12px 0; font-size: 15px; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px;
}

/* ----- Forms ----- */
.section { border: none; padding: 0; margin: 0 0 24px 0; }
.section legend {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1px; padding: 0; margin: 0 0 10px 0;
}
.section-help {
  font-size: 12px; color: var(--text-dim); margin: -4px 0 12px 0; line-height: 1.5;
}
.section-vault {
  background: var(--surface-2); padding: 16px; border-radius: 8px;
  border: 1px solid var(--border);
}

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.field .hint { color: var(--text-mute); font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field-checkbox { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.field-checkbox > span { font-size: 13px; color: var(--text); }
.hint-text { font-size: 12px; color: var(--text-dim); margin: 4px 0 0 0; }

input[type="text"], input[type="password"], input[type="email"], select, textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 6px;
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus,
select:focus, textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface-3);
}
input.mono { font-family: var(--mono); font-size: 16px; letter-spacing: 4px; text-align: center; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
select { appearance: auto; }

/* ----- Buttons ----- */
.btn {
  display: inline-block; padding: 10px 18px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--accent); background: var(--accent); color: white;
  border-radius: 6px; cursor: pointer; font-family: inherit;
  transition: background 0.12s ease;
}
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn-block { width: 100%; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-secondary {
  background: transparent; border-color: var(--border-2); color: var(--text);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger {
  background: var(--bad); border-color: var(--bad); color: white;
}
.btn-danger:hover { filter: brightness(1.1); }
.btn-link {
  background: transparent; border: none; color: var(--text-dim); padding: 10px 12px;
  cursor: pointer; font-family: inherit; font-size: 13px;
}
.btn-link:hover { color: var(--text); text-decoration: underline; }
.btn-primary { background: var(--accent); border-color: var(--accent); }

.form-actions { margin-top: 16px; display: flex; gap: 12px; align-items: center; }
.form-actions form { margin: 0; display: inline; }
.form-secondary { text-align: center; margin-top: 16px; font-size: 13px; }

/* ----- Alerts / flash ----- */
.alert {
  padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px;
  border: 1px solid transparent;
}
.alert-error   { background: rgba(226, 90, 90, 0.12); border-color: rgba(226, 90, 90, 0.35); color: #f5b3b3; }
.alert-success { background: rgba(93, 191, 126, 0.12); border-color: rgba(93, 191, 126, 0.35); color: #b8e8c4; }
.flash {
  padding: 10px 24px; font-size: 13px; text-align: center;
}
.flash-error { background: rgba(226, 90, 90, 0.18); color: #f5b3b3; border-bottom: 1px solid rgba(226, 90, 90, 0.35); }
.flash-success { background: rgba(93, 191, 126, 0.18); color: #b8e8c4; border-bottom: 1px solid rgba(93, 191, 126, 0.35); }

/* ----- Status dots ----- */
.status-line { display: flex; align-items: center; gap: 8px; margin: 0 0 12px 0; font-size: 14px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-good { background: var(--good); box-shadow: 0 0 6px rgba(93,191,126,0.6); }
.status-warn { background: var(--warn); }

/* ----- Dashboard ----- */
.welcome-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.welcome-row h1 { margin: 0 0 4px 0; }

.metric-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px 18px;
}
.metric-card-info { background: linear-gradient(180deg, var(--surface), var(--accent-3)); }
.metric-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.metric-value { font-size: 28px; font-weight: 600; line-height: 1.2; }
.metric-value.metric-warn { color: var(--warn); }
.metric-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 800px) { .dashboard-grid { grid-template-columns: 1fr; } }
.next-list { padding-left: 18px; margin: 0 0 12px 0; }
.next-list li { padding: 4px 0; font-size: 14px; }

.audit-list { list-style: none; padding: 0; margin: 0; }
.audit-list li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.audit-list li:last-child { border-bottom: none; }
.audit-action { color: var(--text); }
.audit-time { color: var(--text-mute); font-family: var(--mono); font-size: 12px; }

/* ----- Audit table ----- */
.audit-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.audit-table th, .audit-table td {
  padding: 8px 12px 8px 0; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.audit-table th { color: var(--text-dim); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }

/* ----- Settings tiles ----- */
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px; margin-top: 16px;
}
.settings-tile {
  display: block; padding: 18px 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.settings-tile:hover { border-color: var(--accent); text-decoration: none; }
.settings-tile h2 { margin: 0 0 6px 0; font-size: 15px; font-weight: 600; }
.settings-tile p { margin: 0; color: var(--text-dim); font-size: 13px; }
.settings-tile-disabled { opacity: 0.55; cursor: not-allowed; }
.settings-tile-disabled:hover { border-color: var(--border); }
.badge {
  display: inline-block; font-size: 10px; padding: 2px 6px; margin-left: 6px;
  background: var(--accent-3); color: var(--text); border-radius: 3px;
  text-transform: uppercase; letter-spacing: 1px; font-weight: 500;
}

/* ----- Entity picker ----- */
.entity-list { list-style: none; padding: 0; margin: 0 0 16px 0; }
.entity-list li {
  border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px;
}
.entity-list label {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
}
.entity-list label:hover { background: var(--surface-2); }
.entity-pick { display: flex; flex-direction: column; gap: 2px; }
.entity-pick-name { font-weight: 500; font-size: 14px; }
.entity-pick-legal { color: var(--text-dim); font-size: 12px; }
.entity-pick-prefix { color: var(--text-mute); font-size: 11px; font-family: var(--mono); margin-top: 2px; }

/* ----- MFA enrollment ----- */
.qr-block {
  display: flex; gap: 24px; align-items: flex-start; margin: 16px 0;
  padding: 16px; background: white; border-radius: 8px;
}
.qr-image { width: 200px; height: 200px; display: block; }
.qr-meta { flex: 1; padding-top: 8px; }
.kv-pair { margin-bottom: 12px; color: #1c2230; }
.kv-label { display: block; font-size: 11px; color: #5f6373; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.kv-value { font-family: var(--mono); font-size: 13px; color: #1c2230; word-break: break-all; }
.bypass-code {
  display: block; font-family: var(--mono); font-size: 18px; letter-spacing: 2px;
  padding: 12px 16px; background: var(--surface-3); border: 1px dashed var(--border-2);
  border-radius: 6px; margin: 12px 0; text-align: center; color: var(--accent);
}

/* ----- Errors ----- */
.page-error h1 { font-size: 64px; color: var(--accent); margin-bottom: 16px; }

/* ----- Footer ----- */
.footer {
  display: flex; justify-content: space-between; padding: 16px 24px;
  color: var(--text-dim); font-size: 12px;
  border-top: 1px solid var(--border); background: var(--surface);
}

/* ----- Health page (inherits panel + kv table) ----- */
.page-health table.kv {
  width: 100%; border-collapse: collapse;
}
.page-health table.kv th, .page-health table.kv td {
  padding: 6px 12px 6px 0; text-align: left;
  border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top;
}
.page-health table.kv th { color: var(--text-dim); font-weight: 500; width: 240px; white-space: nowrap; }
.page-health table.kv td { font-family: var(--mono); word-break: break-all; }
.page-health table.kv tr:last-child th, .page-health table.kv tr:last-child td { border-bottom: none; }

/* ============================================================
   PHASE 1.1 — Customers
   ============================================================ */

/* Page head with right-side actions */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px 0; }
.page-head .subtitle { margin: 0; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.form-actions-row { gap: 12px; flex-wrap: wrap; }

/* Filter bar */
.filter-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px;
}
.filter-search { flex: 1; min-width: 200px; }
.filter-select { min-width: 130px; }
.filter-checkbox { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-dim); margin: 0; }
.filter-checkbox input { margin: 0; }
.filter-checkbox > span { font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Data tables */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.data-table thead th {
  background: var(--surface-2); color: var(--text-dim); font-weight: 500;
  text-transform: uppercase; font-size: 11px; letter-spacing: 1px;
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.data-table thead th.num { text-align: right; }
.data-table tbody tr {
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.08s ease;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td { padding: 10px 14px; vertical-align: middle; }
.data-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .row-archived { opacity: 0.55; }
.row-link { color: var(--text); font-weight: 500; }
.row-link:hover { color: var(--accent); text-decoration: none; }

.data-table-compact { font-size: 12px; }
.data-table-compact thead th { padding: 8px 10px; }
.data-table-compact tbody td { padding: 8px 10px; }

/* Pills */
.type-pill, .status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 500; border: 1px solid transparent; line-height: 1.5;
}
.type-pill { background: var(--surface-3); color: var(--text-dim); border-color: var(--border-2); }
.type-business    { background: rgba(79, 142, 247, 0.15); color: #9bb8ec; border-color: rgba(79, 142, 247, 0.3); }
.type-individual  { background: rgba(93, 191, 126, 0.15); color: #9ed4af; border-color: rgba(93, 191, 126, 0.3); }
.type-nonprofit   { background: rgba(228, 163, 74, 0.15); color: #e2bd80; border-color: rgba(228, 163, 74, 0.3); }
.type-government  { background: rgba(173, 132, 220, 0.15); color: #c2a5e2; border-color: rgba(173, 132, 220, 0.3); }

.status-pill-active   { background: rgba(93, 191, 126, 0.15); color: #9ed4af; border-color: rgba(93, 191, 126, 0.3); }
.status-pill-archived { background: var(--surface-3); color: var(--text-mute); border-color: var(--border-2); }
.status-pill-draft    { background: var(--surface-3); color: var(--text-dim); border-color: var(--border-2); }
.status-pill-sent     { background: rgba(79, 142, 247, 0.15); color: #9bb8ec; border-color: rgba(79, 142, 247, 0.3); }
.status-pill-partial  { background: rgba(228, 163, 74, 0.15); color: #e2bd80; border-color: rgba(228, 163, 74, 0.3); }
.status-pill-paid     { background: rgba(93, 191, 126, 0.15); color: #9ed4af; border-color: rgba(93, 191, 126, 0.3); }
.status-pill-overdue  { background: rgba(226, 90, 90, 0.18); color: #f5b3b3; border-color: rgba(226, 90, 90, 0.35); }
.status-pill-void     { background: var(--surface-3); color: var(--text-mute); border-color: var(--border-2); text-decoration: line-through; }

/* Quote-specific status pills */
.status-pill-accepted  { background: rgba(45, 142, 106, 0.18); color: #80d3aa; border-color: rgba(45, 142, 106, 0.35); }
.status-pill-declined  { background: rgba(180, 90, 90, 0.18); color: #e2a5a5; border-color: rgba(180, 90, 90, 0.35); }
.status-pill-expired   { background: var(--surface-3); color: var(--text-mute); border-color: var(--border-2); }
.status-pill-converted { background: rgba(140, 100, 200, 0.18); color: #bda6e0; border-color: rgba(140, 100, 200, 0.35); }

/* Time entry statuses */
.status-pill-running   { background: rgba(228, 163, 74, 0.18); color: #e2bd80; border-color: rgba(228, 163, 74, 0.35); animation: pulse-gentle 2s ease-in-out infinite; }
.status-pill-unbilled  { background: rgba(79, 142, 247, 0.15); color: #9bb8ec; border-color: rgba(79, 142, 247, 0.3); }
.status-pill-billed    { background: rgba(93, 191, 126, 0.15); color: #9ed4af; border-color: rgba(93, 191, 126, 0.3); }

@keyframes pulse-gentle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* Dashboard quick-actions list */
.quick-actions {
  list-style: none; padding: 0; margin: 0 0 12px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.quick-actions li { margin: 0; }

/* Reports hub grid */
.report-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.report-card {
  display: block; padding: 20px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 8px; text-decoration: none; color: var(--text);
  transition: border-color 120ms, transform 120ms;
}
.report-card:hover {
  border-color: var(--accent); transform: translateY(-2px);
  text-decoration: none;
}
.report-card h2 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.report-card p { margin: 0; font-size: 13px; }
.report-card-pop {
  background: linear-gradient(to bottom right, rgba(79, 142, 247, 0.08), var(--surface));
  border-color: rgba(79, 142, 247, 0.3);
}

/* Net income banner on P&L report */
.net-income-banner {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-radius: 8px; font-size: 18px;
}
.net-income-banner.net-positive {
  background: rgba(93, 191, 126, 0.12); color: #9ed4af; border: 1px solid rgba(93, 191, 126, 0.3);
}
.net-income-banner.net-negative {
  background: rgba(226, 90, 90, 0.12); color: #f5b3b3; border: 1px solid rgba(226, 90, 90, 0.35);
}
.net-income-banner strong { font-size: 24px; }

/* Bar chart for percentage breakdowns */
.bar-chart {
  background: var(--surface-3); border-radius: 4px; overflow: hidden;
  height: 14px; position: relative;
}
.bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 4px;
}

/* metric-card-warn for emphasizing losses */
.metric-card-warn {
  border-color: rgba(226, 90, 90, 0.4);
  background: linear-gradient(to bottom, rgba(226, 90, 90, 0.05), var(--surface));
}

/* Print styles for year-end pack */
@media print {
  nav, .page-actions, .filter-bar { display: none !important; }
  .card { break-inside: avoid; border: 1px solid #ccc !important; }
  body { background: white !important; color: black !important; }
  .data-table th, .data-table td { color: black !important; }
}

/* Expense payment method pills */
.status-pill-cash   { background: rgba(93, 191, 126, 0.15); color: #9ed4af; border-color: rgba(93, 191, 126, 0.3); }
.status-pill-check  { background: rgba(79, 142, 247, 0.15); color: #9bb8ec; border-color: rgba(79, 142, 247, 0.3); }
.status-pill-card   { background: rgba(180, 120, 70, 0.18); color: #d8a878; border-color: rgba(180, 120, 70, 0.35); }
.status-pill-bank   { background: rgba(140, 100, 200, 0.18); color: #bda6e0; border-color: rgba(140, 100, 200, 0.35); }
.status-pill-owner  { background: rgba(228, 163, 74, 0.18); color: #e2bd80; border-color: rgba(228, 163, 74, 0.35); }
.status-pill-other  { background: var(--surface-3); color: var(--text-dim); border-color: var(--border-2); }

/* Voided/muted row in tables */
.muted-row { opacity: 0.55; }
.muted-row td { color: var(--text-mute); }

/* Timer banner (running timer at top of /time page) */
.timer-banner {
  display: flex; align-items: center; gap: 16px;
  border-left: 4px solid rgba(228, 163, 74, 0.7);
  background: linear-gradient(to right, rgba(228, 163, 74, 0.08), var(--surface-2));
}
.timer-banner h2 { margin: 0; font-size: 18px; }

/* Filter bar (above filtered tables) */
.filter-bar {
  display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.filter-bar select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 6px;
  padding: 6px 10px; font-size: 13px;
}

/* Inline form (timer-start, etc.) */
.inline-form .form-actions { margin-top: 12px; }

/* Empty state */
.empty-state {
  text-align: center; padding: 48px 24px;
  background: var(--surface); border: 1px dashed var(--border-2); border-radius: 8px;
}
.empty-state p { margin: 8px 0; color: var(--text-dim); }
.empty-state p:first-child { color: var(--text); font-size: 16px; }

/* Customer detail page — kv tables and address */
.kv-list {
  width: 100%; border-collapse: collapse;
}
.kv-list th, .kv-list td {
  padding: 6px 12px 6px 0; text-align: left;
  border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top;
}
.kv-list th {
  color: var(--text-dim); font-weight: 500; width: 140px; white-space: nowrap;
  text-transform: uppercase; font-size: 11px; letter-spacing: 1px;
}
.kv-list tr:last-child th, .kv-list tr:last-child td { border-bottom: none; }

/* Email history panel — invoice show page */
.email-history-list {
  list-style: none; margin: 0; padding: 0;
}
.email-history-item {
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.email-history-item:last-child { border-bottom: none; }
.eh-row {
  display: flex; align-items: center; gap: 8px;
}
.eh-row.eh-sub {
  margin-top: 3px; font-size: 12px; color: var(--text-dim);
}
.eh-kind {
  font-weight: 500; color: var(--text);
}
.eh-status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.eh-pill-pending   { background: rgba(255, 200, 80, 0.15); color: #d4a533; }
.eh-pill-sending   { background: rgba(80, 160, 220, 0.15); color: #4a9fd4; }
.eh-pill-sent      { background: rgba(80, 200, 130, 0.15); color: #4ab87d; }
.eh-pill-failed    { background: rgba(220, 80, 80, 0.15); color: #d65a5a; }
.eh-pill-cancelled { background: rgba(140, 140, 140, 0.15); color: #8a8a8a; }
.eh-to { font-family: var(--mono); font-size: 12px; }
.eh-error {
  margin-top: 4px; padding: 6px 8px;
  background: rgba(220, 80, 80, 0.07);
  border-left: 2px solid rgba(220, 80, 80, 0.5);
  font-size: 12px; color: #d65a5a; font-family: var(--mono);
  border-radius: 2px;
}
.eh-actions { margin-top: 4px; }

address.postal {
  font-style: normal; line-height: 1.6; color: var(--text); font-size: 13px;
}
.notes-block { margin: 0; white-space: pre-wrap; color: var(--text); font-size: 13px; }

.metric-row-stacked { grid-template-columns: 1fr 1fr; gap: 8px; }

textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 6px;
  padding: 9px 12px; font-size: 13px; font-family: inherit;
  resize: vertical; min-height: 80px;
}
textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface-3);
}

/* ============================================================
   PHASE 1.2 — Invoices
   ============================================================ */

.alert-info {
  background: rgba(79, 142, 247, 0.12);
  border-color: rgba(79, 142, 247, 0.35);
  color: #c2d5f4;
}

.card-row-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.card-row-head h2 { margin: 0; }

/* Line items form table */
.tax-context {
  font-size: 12px; color: var(--text-dim); padding: 8px 12px;
  background: var(--surface-2); border-radius: 6px; margin-bottom: 12px;
}
.tax-context strong { color: var(--accent); }

.line-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.line-items-table th {
  text-align: left; padding: 8px 6px; font-size: 11px;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px;
  font-weight: 500; border-bottom: 1px solid var(--border);
}
.line-items-table th.num { text-align: right; }
.line-items-table td { padding: 4px 6px; vertical-align: middle; }
.line-items-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.line-items-table input.li-desc {
  width: 100%; padding: 6px 9px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 4px; color: var(--text);
}
.line-items-table input.num-input {
  width: 100%; padding: 6px 9px; font-size: 13px; text-align: right;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 4px; color: var(--text); font-variant-numeric: tabular-nums;
}
.line-items-table input.li-desc:focus,
.line-items-table input.num-input:focus {
  outline: none; border-color: var(--accent); background: var(--surface-3);
}
.line-items-table .li-num { width: 32px; color: var(--text-mute); font-family: var(--mono); font-size: 12px; text-align: center; }
.line-items-table .li-type  { width: 100px; }
.line-items-table .li-qty   { width: 80px; }
.line-items-table .li-price { width: 110px; }
.line-items-table .li-disc  { width: 90px; }
.line-items-table .li-tax   { width: 50px; text-align: center; }
.line-items-table .li-total { width: 110px; }
.line-items-table .li-x     { width: 36px; text-align: center; }
.line-items-table .li-tax input { margin: 0; }
.line-items-table tfoot td { padding: 6px 6px; }
.line-items-table select.li-type-select {
  width: 100%; padding: 5px 8px; font-size: 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 4px;
}
.line-items-table select.li-type-select:focus { outline: none; border-color: var(--accent); }
.line-items-table input:disabled {
  background: var(--surface); color: var(--text-mute); cursor: not-allowed;
}
/* Visually mute the qty/discount cells when the row is a Fixed-type line */
.line-items-table tr.line-row[data-line-type="fixed"] .li-qty,
.line-items-table tr.line-row[data-line-type="fixed"] .li-disc {
  opacity: 0.5;
}
.btn-remove {
  background: transparent; border: 1px solid var(--border-2);
  color: var(--text-mute); width: 28px; height: 28px; border-radius: 4px;
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0;
}
.btn-remove:hover { color: var(--bad); border-color: var(--bad); }

.totals-row td { border-top: 1px solid var(--border); padding: 6px 6px; font-size: 13px; }
.totals-row-final td { border-top: 2px solid var(--accent); font-size: 15px; padding: 10px 6px; }

/* Invoice render (the "what the customer would see" preview) */
.invoice-render { background: var(--surface); }
.invoice-render-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 16px; margin-bottom: 16px;
  border-bottom: 2px solid var(--accent);
}
.invoice-render-title {
  font-size: 24px; font-weight: 700; letter-spacing: 2px;
  color: var(--accent); margin-bottom: 4px;
}
.invoice-render-entity { text-align: right; font-size: 14px; }
.invoice-render-meta {
  display: grid; grid-template-columns: 1fr auto; gap: 32px; margin-bottom: 24px;
}
.meta-label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 6px;
}
.meta-right .kv-list th { width: 100px; }

.invoice-render-lines {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 24px;
}
.invoice-render-lines thead th {
  text-align: left; padding: 8px 12px; font-size: 11px;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px;
  font-weight: 500; border-bottom: 1px solid var(--border);
}
.invoice-render-lines thead th.num { text-align: right; }
.invoice-render-lines tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.invoice-render-lines tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.li-render-desc { font-weight: 500; color: var(--text); }
.li-render-sub  { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.invoice-totals-row td {
  padding: 6px 12px; font-size: 13px; vertical-align: top;
}
.invoice-totals-row td.num { font-variant-numeric: tabular-nums; }
.invoice-totals-final td {
  border-top: 2px solid var(--accent); font-size: 16px; padding: 10px 12px;
}

.invoice-terms {
  padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px;
  color: var(--text-dim);
}
.invoice-terms p { margin: 0; line-height: 1.6; }

/* ============================================================
 * v1.0.0 — addendum banner, related panel, P&L / Balance Sheet,
 * manual JE balance indicator, credit memo emphasis.
 * ============================================================ */

/* Addendum banner — sits above the form/show grid to make the parent
 * relationship visually unmissable. */
.addendum-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 16px;
  background: rgba(120, 95, 200, 0.10);
  border: 1px solid rgba(120, 95, 200, 0.30);
  border-radius: 8px;
}
.addendum-banner-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  color: #b39ddb; background: rgba(120, 95, 200, 0.20);
  padding: 3px 8px; border-radius: 4px;
}
.addendum-banner-link {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 15px; font-weight: 600; color: var(--accent);
}
.addendum-banner-hint {
  font-size: 12px; color: var(--text-dim); flex: 1 1 auto;
}

/* Related panel — addendums & credit memos on parent invoices */
.related-subhead {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-dim); margin: 8px 0 4px 0;
}
.related-list {
  list-style: none; margin: 0 0 8px 0; padding: 0;
}
.related-list li {
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.related-list li:last-child { border-bottom: none; }
.related-list .mono { margin-right: 8px; }
.related-credit { color: var(--bad); font-weight: 600; }

/* Totals row in data tables (P&L, balance sheet, trial balance) */
.totals-row td {
  border-top: 1.5px solid var(--accent);
  padding-top: 10px;
  background: rgba(80, 130, 220, 0.06);
}

/* Net income emphasis (P&L) */
.net-income-card { text-align: center; padding: 24px; }
.net-income-card h2 { margin: 0 0 8px 0; }
.net-income-amount {
  font-size: 32px; font-weight: 700; margin: 0;
  font-variant-numeric: tabular-nums;
}

/* Balance check (Balance Sheet) */
.balance-check-card { padding: 18px 20px; margin-top: 16px; }
.balance-check-card.balanced {
  border-color: rgba(80, 180, 110, 0.4);
  background: rgba(80, 180, 110, 0.08);
}
.balance-check-card.balanced h2 { color: var(--good); margin: 0 0 6px 0; }
.balance-check-card.unbalanced {
  border-color: rgba(220, 90, 90, 0.45);
  background: rgba(220, 90, 90, 0.10);
}
.balance-check-card.unbalanced h2 { color: var(--bad); margin: 0 0 6px 0; }

/* Manual JE balance indicator (footer of the lines table) */
.balance-ok  { color: var(--good); font-weight: 600; }
.balance-bad { color: var(--bad);  font-weight: 600; }

/* Computed row (Current Year Earnings in equity) — italic + dimmer */
.computed-row td { font-style: italic; color: var(--text-dim); }
.computed-row .mono { color: var(--text-dim); }

/* ============================================================
 * v1.1.0 — recurring schedules + dashboard widget
 * ============================================================ */
.upcoming-runs {
  list-style: none; margin: 0; padding: 0;
}
.upcoming-runs li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.upcoming-runs li:last-child { border-bottom: none; }
.upcoming-runs .mono { min-width: 90px; color: var(--text-dim); }

/* Status pills for recurring template line types in show view */
.status-pill-service { background: rgba(80, 130, 220, 0.18); color: #8db4f0; border: 1px solid rgba(80, 130, 220, 0.35); }
.status-pill-product { background: rgba(180, 120, 70, 0.18); color: #d8a878; border: 1px solid rgba(180, 120, 70, 0.35); }
.status-pill-fixed   { background: rgba(150, 150, 150, 0.18); color: #c0c0c0; border: 1px solid rgba(150, 150, 150, 0.35); }

/* ============================================================
 * v1.2.0 — A/R aging, statements, backup, multi-entity polish
 * ============================================================ */

/* A/R aging — 6-tile summary grid + per-customer table */
.aging-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.aging-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}
.aging-tile-total {
  border-color: var(--accent);
  background: rgba(80, 130, 220, 0.08);
}
.aging-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 0 0 6px 0;
}
.aging-amount {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.aging-customer-row { cursor: default; }
.aging-detail-row { background: rgba(0, 0, 0, 0.15); }
.aging-detail-row td { padding: 8px 14px; }
.toggle-aging-details {
  margin-left: 6px;
  padding: 0;
  background: transparent;
  font-size: 11px;
  color: var(--text-dim);
}
.toggle-aging-details:hover { color: var(--accent); text-decoration: underline; }

/* Aging table — keep totals row distinct */
.aging-table tr.totals-row {
  background: rgba(80, 130, 220, 0.08);
  border-top: 2px solid var(--accent);
}
.aging-table tr.totals-row td {
  font-size: 14px;
  padding-top: 12px;
  padding-bottom: 12px;
}

/* Multi-entity — active row highlight */
.entity-active-row {
  background: rgba(80, 130, 220, 0.08);
}
.entity-active-row td:first-child {
  border-left: 3px solid var(--accent);
}
/* Make entity-name in header look interactive */
.entity-name {
  text-decoration: none;
  color: var(--text-dim);
  transition: color 0.15s ease;
}
.entity-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Backup — file input + danger-styled restore */
input[type="file"] {
  background: var(--input-bg, #1a1a1a);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--text);
  width: 100%;
  font-family: inherit;
  font-size: 13px;
}
input[type="file"]::file-selector-button {
  background: var(--btn-secondary-bg, #2a2a2a);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 10px;
  margin-right: 10px;
  cursor: pointer;
}
