/* ---------------------------------------------------------------------------
   Accounts Receivable. A ledger tool for people who sit in it all day:
   dense, quiet, and legible. Colour is functional, never decorative, so a
   staff member can read status from across the desk.
   --------------------------------------------------------------------------- */

:root {
  --ink:      #131720;
  --muted:    #626C7D;
  --faint:    #8B94A3;
  --paper:    #F5F6F9;
  --surface:  #FFFFFF;
  --rule:     #DEE3EA;
  --rule-soft:#EDF0F4;

  --navy:     #1E3A5F;
  --navy-dk:  #152A46;
  --teal:     #0E7C86;

  --money:    #146B52;   /* paid, credit, good */
  --money-bg: #E6F2ED;
  --warn:     #A8560A;   /* at risk */
  --warn-bg:  #FBF0E2;
  --risk:     #91242A;   /* stalled, overdue */
  --risk-bg:  #FAEAEA;

  --radius:   6px;
  --shadow:   0 1px 2px rgba(19,23,32,.06), 0 1px 8px rgba(19,23,32,.04);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Every figure that represents money uses tabular figures so columns of
   numbers line up down the page the way they did on the spreadsheet. */
.num, td.num, .money, .stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  text-align: right;
  white-space: nowrap;
}
.money::before { content: "$"; color: var(--faint); margin-right: 1px; }
.money.neg { color: var(--risk); }
.money.zero { color: var(--faint); }

/* --- shell ---------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex: 0 0 210px;
  background: var(--navy-dk);
  color: #C9D4E2;
  padding: 18px 0;
  display: flex;
  flex-direction: column;
}
.brand {
  padding: 0 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 12px;
}
.brand-mark {
  font-size: 15px; font-weight: 650; color: #fff; letter-spacing: -.01em;
  display: block;
}
.brand-sub { font-size: 11px; color: #7E93AC; text-transform: uppercase; letter-spacing: .08em; }

.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 18px; color: #C9D4E2; font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--teal); font-weight: 550; }
.nav .pill {
  background: var(--risk); color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 10px; padding: 1px 7px; font-variant-numeric: tabular-nums;
}
.sidebar-foot {
  margin-top: auto; padding: 14px 18px 0; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: #7E93AC;
}
.sidebar-foot a { color: #A9BACE; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
h1 { font-size: 20px; font-weight: 640; margin: 0; letter-spacing: -.015em; }
h2 { font-size: 14px; font-weight: 620; margin: 0 0 10px; letter-spacing: -.005em; }
.sub { color: var(--muted); font-size: 13px; margin: 3px 0 0; }

/* --- cards ---------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card.tight { padding: 0; overflow: hidden; }
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--rule-soft);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

/* --- stats ---------------------------------------------------------------- */
.stat { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
        padding: 13px 15px; box-shadow: var(--shadow); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat-value { font-size: 23px; font-weight: 620; letter-spacing: -.02em; margin-top: 3px; text-align: left; }
.stat-note { font-size: 12px; color: var(--faint); margin-top: 2px; }
.stat.accent { border-left: 3px solid var(--navy); }
.stat.good   { border-left: 3px solid var(--money); }
.stat.warn   { border-left: 3px solid var(--warn); }
.stat.risk   { border-left: 3px solid var(--risk); }

/* --- funding bar : the signature element -----------------------------------
   Shows how close a case is to the amount it must reach before the firm will
   file it, split by fee bucket. Paid portions are solid; what remains is
   hatched, so an underfunded case reads as visibly unfinished.
   --------------------------------------------------------------------------- */
.funding {
  display: flex; height: 22px; border-radius: 3px; overflow: hidden;
  border: 1px solid var(--rule); background: var(--rule-soft);
}
.funding span { display: block; height: 100%; }
.funding .paid  { background: var(--money); }
.funding .paid.b2 { background: #2E8B6E; }
.funding .paid.b3 { background: #55A487; }
.funding .paid.b4 { background: #7CBBA4; }
.funding .owed {
  background-image: repeating-linear-gradient(
    45deg, #D7DDE5, #D7DDE5 3px, #E9EDF2 3px, #E9EDF2 6px);
}
.funding-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); }
.funding-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.bar-mini {
  height: 6px; background: var(--rule-soft); border-radius: 3px; overflow: hidden;
  min-width: 62px; display: block;
}
.bar-mini span { display: block; height: 100%; background: var(--money); }

/* --- tables --------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; padding: 9px 12px;
  border-bottom: 1px solid var(--rule); background: #FAFBFC;
  position: sticky; top: 0; z-index: 1;
}
thead th.num { text-align: right; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFBFD; }
.t-name { font-weight: 560; }
.t-sub { font-size: 12px; color: var(--faint); }

/* --- badges --------------------------------------------------------------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 3px; letter-spacing: .01em; white-space: nowrap;
  background: var(--rule-soft); color: var(--muted);
}
.badge.good { background: var(--money-bg); color: var(--money); }
.badge.warn { background: var(--warn-bg);  color: var(--warn); }
.badge.risk { background: var(--risk-bg);  color: var(--risk); }
.badge.ch7  { background: #E8EEF6; color: var(--navy); }
.badge.ch13 { background: #EDE9F5; color: #4A3B7A; }

/* --- forms ---------------------------------------------------------------- */
label { display: block; font-size: 12px; font-weight: 580; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--rule); border-radius: 4px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: none;
  box-shadow: 0 0 0 3px rgba(14,124,134,.12); }
input.amount { font-family: var(--mono); text-align: right; font-size: 15px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1; min-width: 130px; margin-bottom: 0; }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: 4px; border: 1px solid var(--navy);
  background: var(--navy); color: #fff; font: inherit; font-weight: 560; cursor: pointer;
}
.btn:hover { background: var(--navy-dk); text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; color: var(--navy); }
.btn.ghost:hover { background: #F2F5F9; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.danger { background: #fff; color: var(--risk); border-color: #E3C4C4; }
.btn.danger:hover { background: var(--risk-bg); }

/* --- flash ---------------------------------------------------------------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 520;
         border: 1px solid; }
.flash.ok  { background: var(--money-bg); border-color: #BFDDD0; color: var(--money); }
.flash.err { background: var(--risk-bg);  border-color: #E6C6C6; color: var(--risk); }

/* --- ledger --------------------------------------------------------------- */
.ledger td { font-size: 13px; }
.ledger .kind-charge td { background: #FCFCFD; }
.ledger .reversed { color: var(--faint); text-decoration: line-through; }
.ledger .rev-row td { background: var(--risk-bg); }
.ledger .running { font-weight: 600; }

/* --- misc ----------------------------------------------------------------- */
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 14px; }
.filters { display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end;
           padding: 12px 16px; background: #FAFBFC; border-bottom: 1px solid var(--rule-soft); }
.filters .field { margin: 0; }
.hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.split { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr); gap: 16px; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 350px; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; }
  .nav a.on { border-left: 0; border-bottom-color: var(--teal); }
  .sidebar-foot { margin-top: 10px; }
  .grid.c4, .grid.c3, .grid.c2, .split { grid-template-columns: 1fr; }
  .main { padding: 16px 14px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* --- per-firm branding ---------------------------------------------------- */
.brand-logo { max-width: 150px; max-height: 40px; display: block; margin-bottom: 5px; }

.vendor {
  margin-top: 10px; padding-top: 9px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: #6E8299; letter-spacing: .01em;
}
.vendor a { color: #8FA4BB; }

/* --- support access ------------------------------------------------------
   Deliberately loud and not dismissible. A firm should never have to wonder
   whether someone outside the practice is looking at their client data.
   ------------------------------------------------------------------------- */
.support-banner {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  background: #FFF6E5; border: 1px solid #E4C489; border-left: 4px solid #B26B00;
  color: #6B4200; border-radius: var(--radius); padding: 11px 14px; margin-bottom: 16px;
}
.support-banner strong { color: #8A5400; }
.support-reason { font-size: 12.5px; margin-top: 3px; opacity: .9; }

.role-pill {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 3px;
  background: var(--rule-soft); color: var(--muted);
}
.role-pill.admin  { background: #E8EEF6; color: var(--navy); }
.role-pill.viewer { background: #EFEFF2; color: var(--faint); }
