/* =====================================================================
   BillCasey Studio
   ===================================================================== */

:root {
  --brand:        #2f6fed;
  --brand-dark:   #2558c4;
  --brand-soft:   #eaf1fe;

  --ink:          #16202e;
  --ink-2:        #3d4859;
  --muted:        #6b7585;
  --faint:        #96a0b0;

  --bg:           #f3f5f9;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --line:         #e3e8f0;
  --line-strong:  #cfd7e4;

  --green:        #16845a;
  --green-soft:   #e5f6ee;
  --red:          #c0392b;
  --red-soft:     #fdeceb;
  --amber:        #a66a00;
  --amber-soft:   #fff5e0;
  --indigo:       #5b4bd6;
  --indigo-soft:  #eeecfc;
  --blue:         #1f6fd0;
  --blue-soft:    #e7f1fd;
  --gray:         #5c6675;
  --gray-soft:    #eef1f5;

  --radius:       10px;
  --radius-lg:    14px;
  --shadow-sm:    0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.04);
  --shadow:       0 4px 16px rgba(16,24,40,.08);
  --shadow-lg:    0 12px 36px rgba(16,24,40,.14);

  --sidebar-w:    232px;
  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:         ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 23px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.muted  { color: var(--muted); }
.faint  { color: var(--faint); }
.small  { font-size: 12.5px; }
.tiny-text { font-size: 11.5px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.right  { text-align: right; }
.center { text-align: center; }
.mono   { font-family: var(--mono); font-size: .92em; }
.danger-text { color: var(--red); }
.green-text  { color: var(--green); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

.icon { width: 1.05em; height: 1.05em; flex: none; vertical-align: -.16em; }
.icon.xl { width: 44px; height: 44px; }

/* ------------------------------------------------------------- layout */

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

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: #141b26;
  color: #c3ccda;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 16px 14px 12px;
}

.logo { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.logo:hover { text-decoration: none; }
.logo-text { font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logo-mark {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 12.5px; letter-spacing: .02em;
}
.logo-mark.big { width: 46px; height: 46px; border-radius: 12px; font-size: 18px; }

.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 8px;
  color: #aab4c4; font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--brand); color: #fff; }
.nav-link .icon { width: 17px; height: 17px; opacity: .95; }

.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.searchbox {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px; padding: 0 11px;
  color: var(--muted);
}
.searchbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.searchbox input {
  flex: 1; border: 0; background: none; padding: 8px 0;
  font: inherit; font-size: 14px; color: var(--ink); outline: none; min-width: 0;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { flex: 1; padding: 22px 20px 48px; max-width: 1360px; width: 100%; }

.appfoot {
  padding: 16px 20px 26px; color: var(--faint); font-size: 12.5px;
  display: flex; gap: 8px; align-items: center;
}

.scrim { display: none; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 13.8px; font-weight: 600; line-height: 1.3;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .13s, border-color .13s, color .13s, box-shadow .13s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-default { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn-default:hover { background: var(--surface-2); border-color: var(--muted); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--gray-soft); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a93226; }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #126c49; }

.btn-sm { padding: 5px 10px; font-size: 12.8px; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 15.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }

.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 0; background: transparent; color: var(--ink-2);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--gray-soft); }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn.tiny { width: 24px; height: 24px; }
.icon-btn.tiny .icon { width: 13px; height: 13px; }

.linkish {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--brand); font: inherit; font-size: 12.5px; text-decoration: underline;
}

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff;
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  display: grid; place-items: center;
}

.dot {
  position: absolute; top: 2px; right: 1px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.end { justify-content: flex-end; }

/* ---------------------------------------------------------- dropdowns */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
  min-width: 212px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: none;
}
.dropdown.is-open .dropdown-menu { display: block; }
.dropdown-wide { min-width: 340px; max-height: 420px; overflow-y: auto; }
.dropdown-menu > a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  color: var(--ink-2); font-size: 13.6px; font-weight: 500;
}
.dropdown-menu > a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.dropdown-menu > a .icon { color: var(--muted); width: 16px; height: 16px; }

.dropdown-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.dropdown-head.column { display: block; }
.dropdown-empty { padding: 18px 12px; color: var(--muted); text-align: center; font-size: 13px; margin: 0; }

.notice-row { display: flex; align-items: flex-start; gap: 6px; padding: 2px; }
.notice-row > a { flex: 1; display: block; padding: 8px 10px; border-radius: 7px; color: var(--ink-2); }
.notice-row > a:hover { background: var(--surface-2); text-decoration: none; }
.notice-row strong { display: block; font-size: 13.2px; font-weight: 600; }
.notice-row span { display: block; font-size: 12.2px; color: var(--muted); }
.notice-row.is-unread > a { background: var(--brand-soft); }
.notice-row form { align-self: center; }

/* ------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }
.card-foot {
  padding: 13px 18px; border-top: 1px solid var(--line);
  background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}

/* ------------------------------------------------------- page header */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.crumb {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 12.8px; margin-bottom: 6px;
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--brand); }

/* --------------------------------------------------------- stat tiles */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }

.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 15px 16px; box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 25px; font-weight: 680; letter-spacing: -.02em; margin-top: 5px; line-height: 1.15; }
.stat-note { font-size: 12.4px; color: var(--muted); margin-top: 4px; }
.stat.accent-red   .stat-value { color: var(--red); }
.stat.accent-green .stat-value { color: var(--green); }
.stat a.stat-value:hover { text-decoration: none; }

/* ------------------------------------------------------------ badges */

.badge {
  display: inline-block; padding: 2.5px 9px; border-radius: 999px;
  font-size: 11.6px; font-weight: 650; letter-spacing: .01em; white-space: nowrap;
}
.badge-gray   { background: var(--gray-soft);   color: var(--gray); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue); }
.badge-indigo { background: var(--indigo-soft); color: var(--indigo); }
.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-red    { background: var(--red-soft);    color: var(--red); }
.badge-amber  { background: var(--amber-soft);  color: var(--amber); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}

/* ------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.8px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; vertical-align: middle; }
table.data thead th {
  font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data tbody tr { border-bottom: 1px solid var(--line); }
table.data tbody tr:last-child { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td {
  padding: 11px 14px; font-weight: 650; border-top: 2px solid var(--line-strong);
  background: var(--surface-2); font-variant-numeric: tabular-nums;
}
table.data .row-actions { text-align: right; white-space: nowrap; }
table.data .row-actions form { display: inline; }
table.data a.primary-cell { font-weight: 600; color: var(--ink); }
table.data a.primary-cell:hover { color: var(--brand); text-decoration: none; }
table.data tr.is-overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }

.cell-stack { display: flex; flex-direction: column; gap: 1px; }
.cell-stack .sub { font-size: 12.2px; color: var(--muted); }

/* ------------------------------------------------------------ filters */

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end;
  padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.filters .field { margin: 0; min-width: 130px; }
.filters label { font-size: 11.5px; }

.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  padding: 9px 14px; font-size: 13.8px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { font-size: 11.5px; color: var(--faint); margin-left: 4px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 999px; font-size: 12.8px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.chip:hover { border-color: var(--muted); text-decoration: none; }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ------------------------------------------------------------- forms */

.field { margin-bottom: 14px; }
.field > label, .label {
  display: block; font-size: 12.4px; font-weight: 650;
  color: var(--ink-2); margin-bottom: 5px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.req { color: var(--red); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], input[type=tel], input[type=url],
input[type=month], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
input[readonly], input[disabled], select[disabled], textarea[disabled] {
  background: var(--surface-2); color: var(--muted);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7585' d='M1.4 1.4 6 6l4.6-4.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 11px;
  padding-right: 30px;
}
input[type=color] { width: 54px; height: 36px; padding: 3px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
.split  { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.split-even { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 9px; font-size: 13.8px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.check label { font-weight: 500; color: var(--ink-2); margin: 0; }
.check .hint { margin-top: 2px; }

.input-prefix { position: relative; }
.input-prefix span {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}
.input-prefix input { padding-left: 25px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }

fieldset { border: 0; padding: 0; margin: 0 0 22px; }
fieldset legend {
  padding: 0; margin-bottom: 12px;
  font-size: 11.8px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}

/* -------------------------------------------------------- line editor */

.lines { width: 100%; border-collapse: collapse; }
.lines th {
  font-size: 11.4px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); text-align: left; padding: 0 8px 7px; white-space: nowrap;
}
.lines th.num { text-align: right; }
.lines td { padding: 4px 8px 4px 0; vertical-align: top; }
.lines td:first-child { padding-left: 0; }
.lines tbody tr { border-bottom: 1px solid var(--line); }
.lines tbody tr:last-child { border-bottom: 0; }
.lines input, .lines textarea { font-size: 13.6px; padding: 7px 9px; }
.lines textarea { min-height: 34px; }
.lines .col-desc  { width: auto; min-width: 230px; }
.lines .col-qty   { width: 92px; }
.lines .col-rate  { width: 118px; }
.lines .col-amt   { width: 116px; text-align: right; }
.lines .col-drag  { width: 26px; }
.lines .col-del   { width: 36px; }
.lines .amount-cell {
  text-align: right; font-weight: 650; font-variant-numeric: tabular-nums;
  padding-top: 15px; white-space: nowrap;
}
.lines .handle { cursor: grab; color: var(--faint); padding-top: 14px; user-select: none; text-align: center; }
.lines tr.dragging { opacity: .45; }
.line-row td { padding-top: 8px; padding-bottom: 8px; }

.totals-box { margin-left: auto; width: 100%; max-width: 330px; }
.totals-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 6px 0; font-size: 14px;
}
.totals-row.grand {
  border-top: 2px solid var(--line-strong); margin-top: 6px; padding-top: 11px;
  font-size: 18px; font-weight: 700;
}
.totals-row .amt { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ flashes */

.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 9px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius); font-size: 13.8px;
  border: 1px solid transparent;
}
.flash span { flex: 1; }
.flash .icon { margin-top: 2px; }
.flash .icon-btn { margin: -4px -6px -4px 0; }
.flash-success { background: var(--green-soft); border-color: #b9e3d0; color: #0f5f41; }
.flash-error   { background: var(--red-soft);   border-color: #f3c4c0; color: #8f2a21; }
.flash-warning { background: var(--amber-soft); border-color: #f0dba8; color: #7a5100; }
.flash-info    { background: var(--blue-soft);  border-color: #bfdcfa; color: #19538f; }

.callout {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-2);
}
.callout .icon { color: var(--muted); margin-top: 2px; }
.callout.warn  { background: var(--amber-soft); border-color: #f0dba8; color: #7a5100; }
.callout.warn .icon { color: var(--amber); }
.callout.info  { background: var(--blue-soft); border-color: #bfdcfa; color: #19538f; }
.callout.info .icon { color: var(--blue); }

/* ------------------------------------------------------- empty states */

.empty-state { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty-state .icon { color: var(--line-strong); margin-bottom: 10px; }
.empty-state h3 { color: var(--ink); margin-bottom: 4px; }
.empty-state p { margin-bottom: 16px; }
.empty-state.big { padding: 90px 20px; }
.empty-state.big h1 { font-size: 46px; color: var(--line-strong); margin-bottom: 8px; }

/* ------------------------------------------------------------- lists */

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.6px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 15px 20px;
  border-left: 2px solid var(--line); margin-left: 5px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -5px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong);
}
.timeline .when { font-size: 12px; color: var(--faint); }
.timeline .what { font-size: 13.4px; }

/* -------------------------------------------------------------- chart */

.bars { display: flex; align-items: flex-end; gap: 5px; height: 140px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; min-width: 0; }
.bar {
  width: 100%; max-width: 44px; min-height: 2px; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--brand), #6fa0f5);
  position: relative;
}
.bar:hover { background: var(--brand-dark); }
.bar-label { font-size: 10.5px; color: var(--faint); white-space: nowrap; }

.meter { height: 8px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--brand); }

/* -------------------------------------------------------------- auth */

body.centered { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-wrap { width: 100%; max-width: 410px; }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .logo-mark { margin: 0 auto 12px; }
.auth-brand h1 { font-size: 20px; margin-bottom: 2px; }
.auth-card { padding: 26px; }
.auth-card h2 { margin-bottom: 16px; }
.auth-foot { text-align: center; margin-top: 18px; }

/* ------------------------------------------------------------ public */

body.public { background: #eef1f6; }
.public-inner { max-width: 820px; margin: 0 auto; padding: 0 18px; }
.public-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 0; }
.public-head .public-inner { display: flex; align-items: center; gap: 11px; }
.public-logo { max-height: 44px; max-width: 230px; }
.public-main { padding: 26px 0 42px; }
.public-foot { padding: 20px 0 40px; color: var(--muted); font-size: 12.8px; text-align: center; }

.pay-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; padding: 18px 22px; margin-bottom: 18px;
  background: var(--ink); color: #fff; border-radius: var(--radius-lg);
}
.pay-banner .amount { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.pay-banner .label { font-size: 12.5px; opacity: .72; text-transform: uppercase; letter-spacing: .05em; }
.pay-banner.is-paid { background: var(--green); }

/* ---------------------------------------------------- document / print */

.doc { background: #fff; }
.doc-head { display: flex; justify-content: space-between; gap: 26px; flex-wrap: wrap; margin-bottom: 30px; }
.doc-title { font-size: 30px; font-weight: 700; letter-spacing: -.02em; color: var(--brand); margin: 0 0 10px; }
.doc-meta { font-size: 13.4px; min-width: 215px; }
.doc-meta dl { display: grid; grid-template-columns: auto auto; gap: 4px 16px; justify-content: end; margin: 0; }
.doc-meta dt { color: var(--muted); text-align: right; }
.doc-meta dd { margin: 0; font-weight: 600; text-align: right; }
.doc-parties { display: flex; gap: 40px; flex-wrap: wrap; margin-bottom: 26px; }
.doc-party { min-width: 210px; }
.doc-party h4 {
  font-size: 11.2px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.doc-party .name { font-weight: 650; font-size: 15px; }
.doc-party address { font-style: normal; font-size: 13.4px; color: var(--ink-2); line-height: 1.6; }

table.doc-lines { width: 100%; border-collapse: collapse; font-size: 13.6px; }
table.doc-lines thead th {
  background: var(--ink); color: #fff; padding: 10px 12px; text-align: left;
  font-size: 11.2px; letter-spacing: .06em; text-transform: uppercase; font-weight: 650;
}
table.doc-lines thead th.num { text-align: right; }
table.doc-lines td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.doc-lines td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.doc-lines .item-name { font-weight: 600; }
table.doc-lines .item-desc { color: var(--muted); font-size: 12.8px; margin-top: 2px; }
table.doc-lines tbody tr:nth-child(even) { background: var(--surface-2); }

.doc-totals { display: flex; justify-content: flex-end; margin-top: 20px; }
.doc-totals .totals-box { max-width: 320px; }
.doc-notes { margin-top: 30px; display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.doc-notes h4 {
  font-size: 11.2px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px;
}
.doc-notes p { font-size: 13.2px; white-space: pre-line; color: var(--ink-2); }

.sheet {
  max-width: 850px; margin: 24px auto; background: #fff; padding: 46px;
  border-radius: 8px; box-shadow: var(--shadow);
}
.print-toolbar {
  max-width: 850px; margin: 18px auto 0; display: flex; gap: 8px; justify-content: flex-end;
  padding: 0 18px;
}

/* ------------------------------------------------------------ helpers */

.stack-sm > * + * { margin-top: 8px; }
.stack    > * + * { margin-top: 16px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.only-mobile { display: none; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ------------------------------------------------------------ mobile */

@media (max-width: 980px) {
  .split, .split-even { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .only-mobile { display: inline-grid; }
  .hide-sm { display: none; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(12,18,28,.45);
  }

  .content { padding: 16px 14px 40px; }
  .topbar { padding: 9px 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }
  .sheet { padding: 22px; margin: 12px; }
  .doc-title { font-size: 24px; }
  table.data th, table.data td { padding: 9px 10px; }
  .page-head { gap: 10px; }
  .lines .col-desc { min-width: 160px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .dropdown-wide { min-width: 280px; }
  .dropdown-menu { right: -6px; }
}

/* ------------------------------------------------------------- print */

@media print {
  body { background: #fff; font-size: 11.5pt; }
  .no-print, .sidebar, .topbar, .appfoot, .print-toolbar, .flashes, .page-actions { display: none !important; }
  .sheet { box-shadow: none; margin: 0; padding: 0; max-width: none; border-radius: 0; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  table.doc-lines thead th { background: #222 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; text-decoration: none; }
  .doc-title { color: #000 !important; }
}
