:root {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --surface-soft: #f8faff;
  --text: #172033;
  --heading: #101828;
  --muted: #667085;
  --line: #e5e9f2;
  --line-strong: #d6dce8;
  --primary: #635bff;
  --primary-dark: #4b45d6;
  --primary-soft: #eeecff;
  --accent: #18b6a4;
  --danger: #d92d20;
  --success: #079455;
  --warning: #b54708;
  --sidebar: #11152a;
  --sidebar-soft: #1a203a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);
  --shadow: 0 18px 45px rgba(27, 36, 66, 0.08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-x: clip;
  background:
    radial-gradient(circle at 88% 8%, rgba(99, 91, 255, 0.10), transparent 24rem),
    radial-gradient(circle at 45% 100%, rgba(24, 182, 164, 0.07), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color .18s ease, opacity .18s ease; }
a:hover { color: var(--primary-dark); }
button, a, input, select, textarea { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(99, 91, 255, .28);
  outline-offset: 2px;
}
h1, h2, h3 { color: var(--heading); line-height: 1.18; margin-top: 0; letter-spacing: -.025em; }
h1 { font-size: clamp(1.9rem, 3vw, 2.65rem); margin-bottom: .35rem; font-weight: 760; }
h2 { font-size: 1.16rem; font-weight: 720; }
h3 { font-size: 1rem; }
p { margin-top: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

.topbar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 20px;
  overflow-y: auto;
  color: #fff;
  background:
    radial-gradient(circle at 15% 0, rgba(99, 91, 255, .34), transparent 18rem),
    linear-gradient(180deg, #151a33 0%, #0d1123 100%);
  box-shadow: 12px 0 45px rgba(18, 24, 47, .12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 34px;
  color: #fff;
}
.brand:hover { color: #fff; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: block;
  flex: 0 0 auto;
  filter: drop-shadow(0 9px 12px rgba(99, 91, 255, .25));
}
.brand strong { display: block; font-size: 1.15rem; letter-spacing: -.025em; }
.brand small { display: block; color: #9da7c7; font-size: .72rem; font-weight: 520; margin-top: -2px; }

.topbar nav { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 5px; }
.nav-label {
  margin: 0 13px 8px;
  color: #7e88aa;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.topbar nav > a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #abb5d1;
  font-size: .91rem;
  font-weight: 590;
}
.topbar nav > a:hover {
  color: #fff;
  background: rgba(255, 255, 255, .055);
}
.topbar nav > a.active {
  color: #fff;
  border-color: rgba(255, 255, 255, .07);
  background: linear-gradient(90deg, rgba(99, 91, 255, .24), rgba(99, 91, 255, .10));
  box-shadow: inset 3px 0 #7770ff;
}
.nav-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  opacity: .72;
}
.active .nav-dot { border-color: #8d87ff; background: #8d87ff; box-shadow: 0 0 0 4px rgba(141, 135, 255, .13); }
.nav-account {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 20px 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, #2f385d, #222a49);
  font-weight: 750;
}
.account-copy { min-width: 0; }
.account-copy strong, .account-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-copy strong { color: #eef1fb; font-size: .82rem; }
.account-copy small { color: #7f89aa; font-size: .7rem; }
.signout-form { margin: 0 8px; }
.link-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #929cba;
  padding: 7px 0;
  text-align: left;
  font: inherit;
  font-size: .79rem;
  cursor: pointer;
}
.link-button:hover { color: #fff; }
.nav-toggle { display: none; }

.shell {
  width: calc(100% - 260px);
  max-width: calc(100vw - 260px);
  min-width: 0;
  margin: 0 0 72px 260px;
  padding: 48px 44px 0;
}
.public-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto 64px;
}
.public-page .public-shell { padding-top: 24px; }
.public-shell-wide { width: min(1280px, calc(100% - 32px)); }
.guest-page .shell {
  width: min(100%, 1320px);
  margin: 0 auto 72px;
  padding: 0 24px;
}
.footer {
  width: calc(100% - 260px);
  max-width: calc(100vw - 260px);
  margin-left: 260px;
  padding: 24px 40px 34px;
  color: #8991a4;
  text-align: center;
  font-size: .76rem;
}
.public-page .footer, .guest-page .footer { margin-left: 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}
.page-head > div { min-width: 0; max-width: 100%; }
.page-head .page-head { margin-bottom: 0; }
.page-head p { color: var(--muted); margin: .25rem 0 0; }
.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }

.card {
  position: relative;
  min-width: 0;
  margin-bottom: 22px;
  padding: 25px;
  overflow: hidden;
  border: 1px solid rgba(224, 228, 239, .9);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { border-color: #daddf1; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 19px; }
.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat { min-height: 134px; padding: 23px; }
.stat::after {
  content: "";
  position: absolute;
  width: 72px;
  height: 72px;
  right: -22px;
  top: -22px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(99, 91, 255, .14), rgba(24, 182, 164, .05));
}
.stat span { display: block; color: var(--muted); font-size: .78rem; font-weight: 650; letter-spacing: .015em; }
.stat strong { display: block; margin-top: 14px; color: var(--heading); font-size: 1.72rem; line-height: 1.1; letter-spacing: -.04em; }
.stat:nth-child(2) strong { color: var(--success); }
.stat:nth-child(3) strong { color: var(--primary); }
.stat:nth-child(4) strong { color: var(--warning); }
.stat small { display: block; margin-top: 9px; color: var(--muted); font-size: .74rem; font-weight: 600; }
.stat-primary strong { color: var(--heading) !important; }
.stat-success strong { color: var(--success) !important; }
.stat-purple strong { color: var(--primary) !important; }
.stat-warm strong { color: var(--warning) !important; }
.muted, .help { color: var(--muted); }
.help { font-size: .83rem; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, #6c63ff, #554ddb);
  box-shadow: 0 7px 17px rgba(99, 91, 255, .22);
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn:hover {
  color: #fff;
  transform: translateY(-1px);
  background: linear-gradient(135deg, #5e56ee, #4740ca);
  box-shadow: 0 10px 22px rgba(99, 91, 255, .28);
}
.btn-secondary {
  color: #344054;
  border-color: var(--line-strong);
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.btn-secondary:hover { color: #202939; background: #f9faff; box-shadow: 0 5px 14px rgba(16, 24, 40, .08); }
.btn-danger { color: var(--danger); border-color: #f3b8b3; background: #fff; box-shadow: none; }
.btn-danger:hover { color: #fff; background: var(--danger); }
.btn-small { min-height: 35px; padding: 6px 11px; border-radius: 9px; font-size: .8rem; box-shadow: none; }

label { display: block; margin-bottom: 7px; color: #344054; font-size: .82rem; font-weight: 680; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: .9rem;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:hover, select:hover, textarea:hover { border-color: #bec6d5; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 91, 255, .12);
}
input[type="color"] { padding: 5px; }
textarea { min-height: 96px; resize: vertical; }
.field { margin-bottom: 17px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 540; }
.check input, .payment-option input { width: auto; min-height: 0; accent-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.customer-form-head, .customer-form { width: min(100%, 1120px); }
.form-back-link {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .79rem;
  font-weight: 680;
}
.form-back-link:hover { color: var(--primary); }
.customer-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch;
}
.customer-form-section { height: 100%; margin: 0; }
.customer-form-section-wide { grid-column: 1 / -1; }
.customer-form-section-head {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.customer-form-section-head > div { min-width: 0; }
.customer-form-section-head h2 { margin: 0 0 4px; font-size: 1rem; }
.customer-form-section-head p { margin: 0; color: var(--muted); font-size: .77rem; line-height: 1.45; }
.customer-form-step {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: .78rem;
  font-weight: 800;
}
.customer-form-section .field:last-child { margin-bottom: 0; }
.label-optional {
  margin-left: 4px;
  color: #98a0b2;
  font-size: .68rem;
  font-weight: 620;
}
.customer-form-actions {
  position: sticky;
  bottom: 14px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 20px;
  padding: 15px 18px;
  border: 1px solid rgba(214, 220, 232, .94);
  border-radius: 15px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 15px 38px rgba(27, 36, 66, .13);
  backdrop-filter: blur(16px);
}
.customer-form-actions > div:first-child { min-width: 0; }
.customer-form-actions strong, .customer-form-actions span { display: block; }
.customer-form-actions strong { color: var(--heading); font-size: .84rem; }
.customer-form-actions span { margin-top: 3px; color: var(--muted); font-size: .73rem; }
.customer-form-actions .actions { flex: 0 0 auto; }
.filter-card { padding: 20px; }
.filter-bar {
  display: grid;
  grid-template-columns: minmax(230px, 1.7fr) repeat(3, minmax(130px, .8fr)) auto;
  align-items: end;
  gap: 12px;
}
.invoice-filter-bar {
  grid-template-columns: minmax(210px, 1.45fr) minmax(130px, .78fr) repeat(2, minmax(135px, .8fr)) minmax(145px, .9fr) auto;
}
.receipt-filter-bar {
  grid-template-columns: minmax(190px, 1.35fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(165px, 1fr);
}
.receipt-filter-bar .filter-search { grid-column: span 2; }
.report-filter-bar { grid-template-columns: repeat(4, minmax(145px, 1fr)); }
.report-filter-bar .filter-actions { grid-column: span 2; }
.filter-bar .field { min-width: 0; margin: 0; }
.filter-bar label { margin-bottom: 5px; font-size: .72rem; }
.filter-actions { display: flex; gap: 7px; align-items: center; }
.filter-actions .btn { min-height: 44px; white-space: nowrap; }
.settings-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.settings-nav {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 5px;
  margin-bottom: 0;
  padding: 17px;
}
.settings-nav .eyebrow { padding: 5px 10px 8px; }
.settings-nav a {
  padding: 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 660;
}
.settings-nav a:hover { color: var(--primary); background: var(--primary-soft); }
.settings-content { min-width: 0; }
.settings-section { scroll-margin-top: 24px; }
.settings-section .section-head { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.brand-logo-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.brand-logo-preview img {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 7px;
}
.brand-logo-preview p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.settings-options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-options-grid .payment-option { margin: 0; }
.settings-note-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-note {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.settings-note strong { color: var(--heading); }
.settings-note ul { margin: 10px 0 0; padding-left: 19px; color: var(--muted); }
.settings-save-bar {
  position: sticky;
  bottom: 14px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 15px 18px;
  border: 1px solid rgba(214, 220, 232, .92);
  border-radius: 15px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 15px 38px rgba(27, 36, 66, .13);
  backdrop-filter: blur(16px);
}
.settings-save-bar span { color: var(--muted); font-size: .78rem; }
.access-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.access-list { display: grid; gap: 10px; }
.access-list form { margin: 0; }
.access-choice {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: var(--surface-soft);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.access-choice:hover { transform: translateY(-1px); border-color: #bbb6fa; background: #fff; }
.access-choice-mark {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 800;
}
.portal-mark { display: block; border-radius: 0; background: transparent; filter: drop-shadow(0 7px 8px rgba(99, 91, 255, .16)); }
.access-choice span { min-width: 0; }
.access-choice strong, .access-choice small { display: block; overflow-wrap: anywhere; }
.access-choice small { margin-top: 3px; color: var(--muted); font-size: .74rem; }
.access-choice b { color: var(--primary); font-size: .78rem; white-space: nowrap; }
.portal-invite-shell { padding-top: 28px; }
.portal-invite-account { margin: 18px 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.portal-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  margin-bottom: 24px;
  padding: 30px;
  overflow: hidden;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, #171c37 0%, #31335e 58%, #315f68 100%);
  box-shadow: 0 20px 45px rgba(24, 29, 58, .17);
}
.portal-hero h1 { margin: 4px 0 6px; color: #fff; font-size: clamp(1.75rem, 4vw, 2.45rem); }
.portal-hero p { margin: 0; color: #cbd2e8; }
.portal-hero .eyebrow { color: #86e4d1; }
.portal-hero .btn-secondary { border-color: rgba(255,255,255,.2); color: #fff; background: rgba(255,255,255,.1); }
.portal-document-list { display: grid; }
.portal-document-list > a {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.portal-document-list > a:last-child { border-bottom: 0; }
.portal-document-list > a:hover strong { color: var(--primary); }
.portal-document-list > a > span { min-width: 0; }
.portal-document-list > a > span:last-child { display: grid; justify-items: end; gap: 5px; flex: 0 0 auto; }
.portal-document-list strong, .portal-document-list small { display: block; }
.portal-document-list small { margin-top: 4px; color: var(--muted); font-size: .73rem; }
.portal-document-list .badge { margin-top: 0; color: inherit; }
.portal-filter { grid-template-columns: minmax(210px, 1.5fr) minmax(145px, .8fr) repeat(2, minmax(135px, .8fr)) auto; }
.portal-receipt-filter { grid-template-columns: minmax(210px, 1.45fr) repeat(2, minmax(150px, 1fr)); }
.portal-receipt-filter .filter-search { grid-column: span 2; }
.member-list { display: grid; }
.member-list > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.member-list > div:last-child { border-bottom: 0; }
.member-list > div > span:nth-child(2) { min-width: 0; flex: 1 1 auto; }
.member-list strong, .member-list small { display: block; overflow-wrap: anywhere; }
.member-list small { margin-top: 3px; color: var(--muted); font-size: .74rem; }
.member-list form { flex: 0 0 auto; margin: 0; }
.member-list .actions { justify-content: flex-end; }
.tenant-create-card { scroll-margin-top: 24px; }
.tenant-create-card .section-head { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.tenant-form-address { grid-column: 1 / -1; }
.tenant-list > div { align-items: flex-start; }
.tenant-list > div > .badge { flex: 0 0 auto; margin-top: 2px; }
.tenant-list small { line-height: 1.45; }
.tenant-list .actions { align-self: center; }
.receipt-brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  margin-bottom: 15px;
  filter: drop-shadow(0 8px 10px rgba(99, 91, 255, .18));
}
.receipt-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.receipt-parties > div { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.receipt-parties strong { display: block; margin-top: 6px; }
.receipt-parties p { margin-bottom: 0; color: var(--muted); }
.receipt-amount-panel { padding: 22px; border-radius: 16px; color: #fff; background: linear-gradient(145deg, #625add, #4d46b9); }
.receipt-amount-panel span, .receipt-amount-panel small, .receipt-amount-panel strong { display: block; }
.receipt-amount-panel span, .receipt-amount-panel small { color: #dcdafd; }
.receipt-amount-panel strong { margin: 9px 0; font-size: 1.8rem; }
.receipt-balance-strip { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.receipt-balance-strip span { display: grid; gap: 4px; }
.receipt-balance-strip small { color: var(--muted); }

.table-wrap {
  overflow: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
table { width: 100%; max-width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px 15px; border-bottom: 1px solid #edf0f5; text-align: left; vertical-align: middle; }
th {
  color: #7a8499;
  background: #f8f9fc;
  font-size: .68rem;
  font-weight: 760;
  letter-spacing: .075em;
  text-transform: uppercase;
}
td { color: #344054; font-size: .86rem; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #fafaff; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 99px;
  color: #596275;
  background: #f0f2f6;
  font-size: .7rem;
  font-weight: 740;
  text-transform: capitalize;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge-paid, .badge-sent, .badge-active, .badge-success, .badge-issued { color: #067647; background: #e5f9ee; }
.badge-overdue, .badge-failed, .badge-void { color: #b42318; background: #ffebe9; }
.badge-draft, .badge-pending, .badge-processing, .badge-trialing { color: #a15c07; background: #fff4d9; }
.badge-viewed, .badge-partially_paid { color: #534ace; background: #efedff; }

.alert {
  position: relative;
  margin-bottom: 20px;
  padding: 14px 17px 14px 42px;
  border: 1px solid;
  border-radius: 13px;
  font-size: .88rem;
  box-shadow: var(--shadow-sm);
}
.alert::before { content: ""; position: absolute; left: 18px; top: 20px; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.alert-success { color: #067647; border-color: #a9e5c4; background: #edfcf3; }
.alert-error { color: #b42318; border-color: #fac5c1; background: #fff1f0; }

.auth-shell { width: min(470px, calc(100% - 28px)); margin: 0 auto 40px; }
.auth-brand { margin-bottom: 27px; text-align: center; }
.auth-brand b {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--heading);
  font-size: 2.05rem;
  font-weight: 820;
  letter-spacing: -.055em;
}
.auth-brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  filter: drop-shadow(0 9px 11px rgba(99, 91, 255, .2));
}
.auth-shell .card { padding: 34px; }
.guest-page { background: radial-gradient(circle at 50% -10%, rgba(99, 91, 255, .14), transparent 30rem), #f7f8fc; }
.auth-page {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-rows: minmax(0, 1fr) auto;
}
.auth-page .shell {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  padding: clamp(42px, 8vh, 88px) 24px;
}
.login-page .auth-shell { margin: 0; }
.login-page .auth-brand { margin-bottom: 30px; }
.login-page .auth-brand .muted { margin-top: 8px; line-height: 1.45; }
.auth-shell-login .card { margin: 0; padding: 38px; }
.auth-heading { margin-bottom: 28px; }
.auth-heading h1 { margin-bottom: 8px; }
.auth-heading p { margin: 0; }
.auth-login-form {
  display: grid;
  gap: 20px;
}
.auth-login-form .field { margin: 0; }
.auth-login-form .btn { width: 100%; margin-top: 4px; }
.auth-links {
  display: grid;
  gap: 10px;
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.auth-links p { margin: 0; }
.empty { padding: 48px 20px; color: var(--muted); text-align: center; }

.invoice-paper {
  padding: clamp(25px, 5vw, 55px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}
.invoice-head { display: flex; justify-content: space-between; gap: 30px; margin-bottom: 38px; }
.invoice-total { text-align: right; }
.invoice-total h1 { color: var(--primary); }
.invoice-party-summary {
  margin-bottom: 34px;
  padding-bottom: 34px;
  border-bottom: 1px solid var(--line);
}
.invoice-items { margin-bottom: 34px; }
.invoice-summary { align-items: start; }
.invoice-summary p:last-child { margin-bottom: 0; }
.invoice-payment-link {
  margin: 30px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.invoice-support-grid { margin-top: 24px; }
.invoice-support-grid > .card { margin-bottom: 0; }
.public-page {
  background:
    radial-gradient(circle at 10% 5%, rgba(99, 91, 255, .13), transparent 27rem),
    radial-gradient(circle at 95% 40%, rgba(24, 182, 164, .09), transparent 28rem),
    #f6f7fb;
}
.public-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 20px 4px;
  color: var(--heading);
  font-size: 1.32rem;
  font-weight: 820;
  letter-spacing: -.04em;
}
.public-brand img {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  filter: drop-shadow(0 7px 9px rgba(99, 91, 255, .18));
}
.public-invoice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 360px);
  gap: 24px;
  align-items: start;
}
.public-invoice-layout-single { grid-template-columns: minmax(0, 1fr); }
.public-invoice-paper { min-width: 0; }
.public-invoice-actions {
  margin: 30px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.public-payment-panel {
  position: sticky;
  top: 24px;
  margin-bottom: 0;
  padding: 26px;
}
.public-payment-panel form { margin: 0; }
.public-payment-panel .payment-option { margin: 12px 0; }
.public-payment-panel form > .btn { width: 100%; margin-top: 8px; }
.fpx-options {
  margin: 18px 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.fpx-options[hidden] { display: none; }
.fpx-options legend { padding: 0 6px; color: var(--heading); font-size: .82rem; font-weight: 720; }
.fpx-options .payment-option { background: #fff; }
.fpx-options .field { margin: 14px 0 0; }
.fpx-account-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.fpx-account-types .payment-option { margin: 0; padding: 11px; }
.fpx-account-types .muted { font-size: .72rem; }
.public-pay-button { margin-top: 12px !important; }
.public-pay-button:disabled { cursor: wait; opacity: .78; transform: none; }
.payment-field-error { margin: 7px 0 0; color: var(--danger); font-size: .76rem; font-weight: 650; }
.payment-field-error[hidden] { display: none; }
.receipt-paper { margin-bottom: 24px; }
.receipt-document-head {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 34px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.receipt-document-head h1 { margin: 5px 0 8px; }
.receipt-paid-mark {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 99px;
  color: var(--success);
  background: #e8f8ef;
  font-size: .72rem;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.receipt-meta { display: grid; align-content: start; justify-items: end; gap: 3px; color: var(--muted); text-align: right; }
.receipt-meta strong { color: var(--heading); font-size: 1rem; }
.receipt-parties { margin-bottom: 30px; }
.receipt-parties h3 { margin: 4px 0 5px; }
.receipt-items { margin-bottom: 30px; }
.receipt-payment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .75fr);
  gap: 28px;
  align-items: start;
}
.receipt-totals, .receipt-public-summary {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
}
.receipt-totals > div, .receipt-public-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.receipt-totals > div:last-child, .receipt-public-summary > div:last-child { border-bottom: 0; }
.receipt-totals span, .receipt-public-summary span { color: var(--muted); font-size: .78rem; }
.receipt-grand-total strong { color: var(--primary); font-size: 1.18rem; }
.receipt-public-link {
  display: grid;
  gap: 5px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.receipt-public-link a { overflow-wrap: anywhere; }
.public-receipt { max-width: 900px; margin-inline: auto; }
.receipt-public-summary { margin-top: 30px; }
.receipt-download-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.receipt-footnote { margin: 26px 0 0; color: var(--muted); font-size: .79rem; }
.payment-option {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin: 10px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.payment-option > span, .payment-option > div { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.payment-option > form { flex: 0 0 auto; }
.payment-option:hover { transform: translateY(-1px); border-color: #bcb6ff; background: #fbfaff; }
.payment-option input { margin-top: 5px; }
.payment-notice {
  margin-bottom: 18px;
  padding: 12px 15px;
  border: 1px solid #f2d394;
  border-radius: 11px;
  color: #8a5204;
  background: #fff8e7;
  font-size: .84rem;
}
.qr { display: block; width: 280px; max-width: 100%; margin: 22px auto; border-radius: 15px; box-shadow: var(--shadow-sm); }
.invoice-item-list { display: grid; gap: 16px; }
.item-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(230px, 3fr) minmax(105px, .7fr) minmax(145px, 1fr) minmax(105px, .7fr);
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.item-grid:last-child { padding-bottom: 0; border-bottom: 0; }
.item-field { min-width: 0; margin: 0; }
.item-field label { min-height: 18px; margin-bottom: 6px; font-size: .74rem; }
.add-item-button { margin-top: 16px; }
.item-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  width: 28px;
  min-height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid #e0e3eb;
  border-radius: 50%;
  color: #7a8499;
  background: #fff;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.item-remove:hover { color: var(--danger); border-color: #f3b8b3; background: #fff5f4; }
.item-remove:focus-visible { outline: 3px solid rgba(99, 91, 255, .18); outline-offset: 2px; }
.catalog-reference { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.catalog-reference-label { display: block; margin-bottom: 10px; color: #344054; font-size: .82rem; font-weight: 700; }
.catalog-reference-items { display: flex; flex-wrap: wrap; gap: 8px; }
.catalog-reference-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid #d8d5ff;
  border-radius: 10px;
  color: #4338b8;
  background: #f6f5ff;
  font: inherit;
  font-size: .76rem;
  cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.catalog-reference-item:hover {
  transform: translateY(-1px);
  border-color: #aaa4f5;
  background: #eeecff;
  box-shadow: 0 5px 12px rgba(99, 91, 255, .1);
}
.catalog-reference-item:focus-visible { outline: 3px solid rgba(99, 91, 255, .2); outline-offset: 2px; }
.catalog-reference-item span { color: var(--muted); font-size: .7rem; font-weight: 520; }
.catalog-reference-item.catalog-selected { border-color: #18b6a4; background: #eafaf7; }
.catalog-reference-help { margin: 9px 0 0; }
.item-grid.catalog-added input { border-color: #49bcae; box-shadow: 0 0 0 3px rgba(24, 182, 164, .1); }
.pill { display: inline-flex; margin: 2px; padding: 5px 10px; border-radius: 99px; color: #534ace; background: var(--primary-soft); font-size: .76rem; font-weight: 650; }
.danger-text { color: var(--danger); }
code { padding: 2px 6px; border-radius: 6px; color: #4a456f; background: #f0efff; }

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: #7c85a0;
  font-size: .67rem;
  font-weight: 780;
  letter-spacing: .105em;
  text-transform: uppercase;
}
.dashboard-head { align-items: center; }
.workspace-switcher { display: flex; align-items: center; gap: 8px; }
.workspace-switcher select { min-width: 190px; }
.trend-up { color: var(--success) !important; }
.trend-down { color: var(--danger) !important; }
.dashboard-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
  align-items: center;
  gap: 38px;
  min-width: 0;
  margin-bottom: 22px;
  padding: 34px 38px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(circle at 84% 20%, rgba(129, 120, 255, .34), transparent 18rem),
    linear-gradient(135deg, #171c38 0%, #242858 58%, #303169 100%);
  box-shadow: 0 24px 55px rgba(22, 27, 64, .18);
}
.dashboard-hero::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -105px;
  bottom: -155px;
  border: 35px solid rgba(255, 255, 255, .045);
  border-radius: 50%;
}
.dashboard-hero-copy, .dashboard-health { position: relative; z-index: 1; min-width: 0; }
.dashboard-hero .eyebrow { color: #aeb6dc; }
.dashboard-hero h1 { max-width: 720px; margin-bottom: 9px; color: #fff; font-size: clamp(1.55rem, 2.25vw, 2.15rem); }
.dashboard-hero-copy > p { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; color: #bfc6e2; }
.workspace-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #46d3b8; box-shadow: 0 0 0 5px rgba(70, 211, 184, .11); }
.dashboard-hero-actions { align-items: stretch; }
.dashboard-hero .btn { box-shadow: none; }
.btn-ghost {
  color: #f3f4ff;
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .075);
  box-shadow: none;
}
.btn-ghost:hover { color: #fff; border-color: rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .13); box-shadow: none; }
.dashboard-hero .workspace-switcher select {
  min-width: 170px;
  color: #fff;
  border-color: rgba(255, 255, 255, .15);
  background: rgba(255, 255, 255, .08);
}
.dashboard-hero .workspace-switcher select option { color: var(--text); background: #fff; }
.dashboard-health {
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 17px;
  background: rgba(255, 255, 255, .075);
  box-shadow: inset 0 1px rgba(255, 255, 255, .06);
  backdrop-filter: blur(8px);
}
.dashboard-health > span { display: block; color: #bfc6e2; font-size: .72rem; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.dashboard-health > strong { display: block; margin: 10px 0 14px; color: #fff; font-size: 2.25rem; line-height: 1; letter-spacing: -.05em; }
.dashboard-health > small { display: block; margin-top: 11px; color: #bfc6e2; font-size: .71rem; line-height: 1.45; }
.health-track { height: 7px; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, .12); }
.health-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #31c8af, #75ead4); box-shadow: 0 0 15px rgba(49, 200, 175, .45); }
.metric-card { isolation: isolate; }
.metric-card::after { z-index: -1; }
.stat .metric-icon {
  position: absolute;
  top: 20px;
  right: 20px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  color: #625add;
  background: #f0efff;
  font-size: .92rem;
}
.metric-card.stat-success .metric-icon { color: #07845a; background: #e8f8f1; }
.metric-card.stat-warm .metric-icon { color: #b05c0c; background: #fff2df; }
.dashboard-analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1.08fr) minmax(245px, .84fr);
  gap: 20px;
}
.dashboard-analysis-grid > * { min-width: 0; max-width: 100%; }
.analytics-detail-card { min-height: 315px; }
.analytics-detail-card .section-head > strong { flex: 0 0 auto; color: var(--heading); font-size: .88rem; }
.bar-list { display: grid; gap: 17px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: 7px 12px; align-items: center; }
.bar-row > div:first-child { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .75rem; }
.bar-row > div:first-child strong { color: var(--heading); font-size: .76rem; }
.bar-row > small { color: var(--muted); font-size: .67rem; text-align: right; }
.bar-track { height: 7px; overflow: hidden; border-radius: 99px; background: #edf0f6; }
.bar-track i { display: block; height: 100%; min-width: 2px; border-radius: inherit; }
.bar-primary { background: linear-gradient(90deg, #635bff, #8c86ff); }
.bar-warning { background: linear-gradient(90deg, #e5a019, #f6c25c); }
.bar-orange { background: linear-gradient(90deg, #ef7b45, #f4a074); }
.bar-danger { background: linear-gradient(90deg, #df4b53, #f0787e); }
.payment-mix-list { display: grid; }
.payment-mix-list > div {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.payment-mix-list > div:last-child { border-bottom: 0; }
.payment-method-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #5d54d8;
  background: #eeecff;
  font-size: .78rem;
  font-weight: 800;
}
.payment-method-1 { color: #07845a; background: #e8f8f1; }
.payment-method-2 { color: #a45a0c; background: #fff1de; }
.payment-method-3 { color: #2461c5; background: #eaf2ff; }
.payment-mix-list strong, .payment-mix-list small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.payment-mix-list strong { color: var(--heading); font-size: .79rem; }
.payment-mix-list small { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.payment-mix-list b { color: var(--heading); font-size: .76rem; font-variant-numeric: tabular-nums; }
.performance-list { display: grid; }
.performance-list > div { display: flex; justify-content: space-between; gap: 15px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.performance-list > div:last-child { border-bottom: 0; }
.performance-list span { color: var(--muted); font-size: .76rem; }
.performance-list strong { color: var(--heading); font-size: .82rem; }
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(300px, .85fr);
  gap: 20px;
}
.analytics-grid > *, .dashboard-lower-grid > * { min-width: 0; max-width: 100%; }
.chart-card { min-height: 378px; }
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.section-head h2 { margin-bottom: 4px; }
.section-head p { margin: 0; color: var(--muted); font-size: .82rem; }
.chart-legend { display: flex; align-items: center; gap: 13px; color: var(--muted); font-size: .73rem; font-weight: 650; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i, .status-color { width: 8px; height: 8px; border-radius: 50%; }
.legend-billed { background: #c8c4ff; }
.legend-collected { background: var(--accent); }
.chart-shell { position: relative; width: 100%; max-width: 100%; height: 285px; overflow: hidden; }
.chart-shell canvas, .doughnut-shell canvas { display: block; width: 100%; max-width: 100%; height: 100%; }
.status-chart-wrap { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: center; gap: 18px; min-width: 0; max-width: 100%; overflow: hidden; }
.doughnut-shell { position: relative; width: 100%; height: 215px; }
.doughnut-shell > span {
  position: absolute;
  inset: 50% auto auto 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.doughnut-shell > span strong { color: var(--heading); font-size: 1.5rem; line-height: 1; }
.doughnut-shell > span small { margin-top: 4px; color: var(--muted); font-size: .68rem; }
.status-list { display: grid; min-width: 0; gap: 9px; }
.status-list > div { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--muted); font-size: .76rem; }
.status-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-list strong { color: var(--heading); }
.status-color-0 { background: #635bff; }
.status-color-1 { background: #18b6a4; }
.status-color-2 { background: #f59e0b; }
.status-color-3 { background: #ef4444; }
.status-color-4 { background: #3b82f6; }
.status-color-5 { background: #a855f7; }
.insight-grid { margin-top: 0; }
.mini-stat { min-height: 126px; }
.mini-stat > span:first-child { display: block; color: var(--muted); font-size: .76rem; font-weight: 650; }
.mini-stat > strong { display: block; margin: 10px 0 12px; color: var(--heading); font-size: 1.35rem; letter-spacing: -.035em; }
.mini-stat > a, .mini-stat > span:last-child { font-size: .75rem; font-weight: 650; }
.dashboard-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr);
  gap: 20px;
}
.dashboard-lower-grid > .card { margin-bottom: 0; }
.dashboard-side-stack { display: grid; align-content: start; gap: 20px; min-width: 0; }
.dashboard-side-stack > .card { margin-bottom: 0; }
.attention-list { display: grid; }
.attention-list > a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.attention-list > a:last-child { border-bottom: 0; }
.attention-list strong, .attention-list small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attention-list strong { color: var(--heading); font-size: .78rem; }
.attention-list small { margin-top: 2px; color: var(--danger); font-size: .67rem; }
.attention-list b { color: var(--heading); font-size: .74rem; font-variant-numeric: tabular-nums; }
.leader-list { display: grid; }
.leader-list > div {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.leader-list > div:last-child { border-bottom: 0; }
.leader-rank {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #625add;
  background: var(--primary-soft);
  font-size: .7rem;
  font-weight: 800;
}
.leader-list strong, .leader-list small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-list strong { color: var(--heading); font-size: .8rem; }
.leader-list small { color: var(--muted); font-size: .69rem; }
.leader-list b { color: var(--heading); font-size: .78rem; font-variant-numeric: tabular-nums; }
.detail-list { display: grid; margin: 0; }
.detail-list > div {
  display: grid;
  grid-template-columns: minmax(110px, .45fr) minmax(0, 1fr);
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: .76rem; font-weight: 680; }
.detail-list dd { min-width: 0; margin: 0; color: var(--heading); overflow-wrap: anywhere; }

img, svg, video, canvas { max-width: 100%; }
.page-head, .section-head, .actions, form, main { min-width: 0; max-width: 100%; }
.shell > *, .card > *, .grid > *, .actions > *, form > * { max-width: 100%; }
.actions > *, form, fieldset { min-width: 0; }
.card p, .card li, td, th, code { overflow-wrap: anywhere; }
.actions select { max-width: 100%; }
.invoice-paper p, .invoice-paper a, .help, .muted { overflow-wrap: anywhere; }

@media (max-width: 1080px) {
  body.nav-open { overflow: hidden; }
  body.nav-open::before {
    content: "";
    position: fixed;
    inset: 68px 0 0;
    z-index: 14;
    background: rgba(11, 15, 31, .48);
    backdrop-filter: blur(3px);
  }
  .topbar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    min-height: 68px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
  }
  .brand { margin: 0; }
  .brand small { display: none; }
  .nav-toggle {
    display: flex;
    width: 42px;
    height: 42px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 11px;
    background: rgba(255, 255, 255, .06);
  }
  .nav-toggle span { width: 17px; height: 2px; border-radius: 2px; background: #fff; }
  .topbar nav {
    display: none;
    position: fixed;
    top: 76px;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    padding: 15px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 15px;
    background: #12172d;
    box-shadow: 0 22px 50px rgba(9, 12, 26, .35);
  }
  .topbar nav.open { display: flex; }
  .nav-account { margin-top: 15px; }
  .shell { width: min(calc(100% - 32px), 1320px); max-width: calc(100vw - 32px); margin: 0 auto 70px; padding: 34px 0 0; }
  .footer { width: 100%; max-width: 100%; margin-left: 0; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-nav { top: 88px; }
}

@media (max-width: 900px) {
  .access-grid { grid-template-columns: 1fr; }
  .customer-form-grid { grid-template-columns: 1fr; }
  .customer-form-section-wide { grid-column: auto; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-nav .eyebrow { grid-column: 1 / -1; }
  .settings-nav a { text-align: center; }
  .public-invoice-layout { grid-template-columns: 1fr; gap: 16px; }
  .public-payment-panel { position: static; order: -1; }
  .analytics-grid, .dashboard-lower-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-search { grid-column: 1 / -1; }
  .dashboard-hero { grid-template-columns: 1fr; gap: 24px; }
  .dashboard-health { max-width: 430px; }
  .dashboard-analysis-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .performance-card { grid-column: 1 / -1; min-height: 0; }
  .chart-card { min-height: 350px; }
  .status-chart-wrap { grid-template-columns: minmax(0, 220px) minmax(0, 1fr); justify-content: center; }
}

@media (max-width: 700px) {
  body { font-size: 14px; }
  .brand-mark { width: 38px; height: 38px; }
  .shell, .public-shell { width: min(100% - 20px, 980px); padding-top: 22px; margin-top: 0; }
  .public-shell { padding-top: 0; }
  .guest-page .shell { width: 100%; padding-inline: 10px; }
  .page-head, .invoice-head { flex-direction: column; }
  .page-head { gap: 15px; margin-bottom: 20px; }
  .page-head > .actions { width: 100%; }
  .page-head > .actions > a,
  .page-head > .actions > button,
  .page-head > .actions > form { flex: 1 1 auto; }
  .page-head > .actions > form .btn { width: 100%; }
  .grid-2, .grid-3, .grid-4, .form-row { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-search { grid-column: auto; }
  .filter-actions .btn { flex: 1 1 auto; }
  .settings-options-grid { grid-template-columns: 1fr; }
  .grid { gap: 13px; }
  .item-grid { grid-template-columns: 1fr 1fr; }
  .item-field:first-child { grid-column: 1 / -1; }
  .card, .invoice-paper, .auth-shell .card { padding: 19px; border-radius: 15px; }
  .card { margin-bottom: 14px; }
  .actions { gap: 7px; }
  .invoice-total { text-align: left; }
  .receipt-document-head { flex-direction: column; gap: 16px; margin-bottom: 24px; padding-bottom: 22px; }
  .receipt-meta { justify-items: start; text-align: left; }
  .receipt-parties { margin-bottom: 22px; }
  .receipt-payment-grid { grid-template-columns: 1fr; gap: 18px; }
  .receipt-download-row { align-items: stretch; flex-direction: column; }
  .receipt-download-row .btn { width: 100%; }
  .settings-nav {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 12px;
    scrollbar-width: thin;
  }
  .settings-nav .eyebrow { display: none; }
  .settings-nav a { flex: 0 0 auto; white-space: nowrap; }
  .settings-note-grid { grid-template-columns: 1fr; }
  .settings-save-bar { align-items: stretch; flex-direction: column; bottom: 8px; }
  .settings-save-bar .btn { width: 100%; }
  .customer-form-head > .btn { display: none; }
  .customer-form-grid { gap: 14px; }
  .customer-form-actions { align-items: stretch; flex-direction: column; bottom: 8px; }
  .customer-form-actions .actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .customer-form-actions .btn { width: 100%; }
  .portal-hero { align-items: flex-start; flex-direction: column; padding: 24px 20px; }
  .portal-hero .actions { width: 100%; }
  .portal-hero .actions .btn { flex: 1 1 auto; }
  .portal-filter, .portal-receipt-filter { grid-template-columns: 1fr; }
  .report-filter-bar .filter-actions { grid-column: auto; }
  .portal-document-list > a { align-items: flex-start; flex-direction: column; }
  .portal-document-list > a > span:last-child { justify-items: start; }
  .member-list > div { align-items: flex-start; flex-wrap: wrap; }
  .member-list > div > span:nth-child(2) { flex-basis: calc(100% - 56px); }
  .member-list .actions { width: 100%; }
  .receipt-parties, .receipt-balance-strip { grid-template-columns: 1fr; }
  .stat { min-height: 112px; }
  .stat strong { font-size: 1.5rem; }
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.08rem; }
  input, select, textarea { font-size: 16px; }
  input[type="file"] { padding: 7px; }
  .btn, button.btn { min-height: 46px; }
  .btn-small { min-height: 42px; }
  .payment-option { min-height: 58px; padding: 14px; }
  .table-wrap {
    position: relative;
    border-radius: 12px;
    scrollbar-width: thin;
    scrollbar-color: #b7b9d8 transparent;
  }
  .table-wrap table { min-width: 650px; }
  .table-wrap th, .table-wrap td { padding: 12px; }
  .invoice-paper .table-wrap table { min-width: 560px; }
  .auth-shell { width: min(100% - 20px, 470px); margin: 0 auto 32px; }
  .auth-brand { margin-bottom: 18px; }
  .auth-page.login-page .shell { padding: 30px 12px; }
  .login-page .auth-shell { margin: 0; }
  .login-page .auth-brand { margin-bottom: 22px; }
  .auth-shell-login .card { padding: 24px 20px; }
  .auth-heading { margin-bottom: 24px; }
  .auth-login-form { gap: 17px; }
  .auth-links { margin-top: 22px; padding-top: 20px; }
  .public-page .public-shell { padding-top: 16px; }
  .public-brand { margin-top: 0; }
  .footer { padding: 18px 15px calc(24px + env(safe-area-inset-bottom)); }
  .nav-account { padding-top: 16px; }
  .signout-form .link-button { min-height: 42px; }
  .payment-notice { line-height: 1.5; }
  .invoice-head { margin-bottom: 24px; }
  .invoice-party-summary { margin-bottom: 24px; padding-bottom: 24px; }
  .invoice-items { margin-bottom: 24px; }
  .invoice-payment-link { margin-top: 24px; padding-top: 20px; }
  .invoice-support-grid { margin-top: 16px; }
  .public-invoice-actions { margin-top: 24px; padding-top: 20px; }
  .public-payment-panel { padding: 19px; }
  .fpx-account-types { grid-template-columns: 1fr; }
  .dashboard-head { align-items: flex-start; }
  .dashboard-hero { padding: 25px 22px; border-radius: 18px; }
  .dashboard-hero-copy > p { align-items: flex-start; }
  .dashboard-hero-actions { width: 100%; }
  .dashboard-hero-actions > a { flex: 1 1 auto; }
  .dashboard-health { max-width: none; }
  .workspace-switcher { width: 100%; flex-wrap: wrap; }
  .workspace-switcher select { min-width: 0; flex: 1 1 180px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid .stat { min-height: 118px; }
  .analytics-grid { gap: 13px; }
  .dashboard-analysis-grid { grid-template-columns: 1fr; gap: 13px; }
  .performance-card { grid-column: auto; }
  .analytics-detail-card { min-height: 0; }
  .chart-card { min-height: 335px; }
  .chart-shell { height: 250px; }
  .status-chart-wrap { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 10px; }
  .doughnut-shell { height: 180px; }
  .section-head { gap: 10px; margin-bottom: 14px; }
  .chart-legend { gap: 8px; }
  .dashboard-lower-grid { gap: 13px; }
  .detail-list > div { grid-template-columns: 1fr; gap: 3px; }
}

@media (max-width: 430px) {
  .topbar { padding-inline: 12px; }
  .topbar nav { left: 8px; right: 8px; }
  .brand { gap: 9px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .nav-toggle { width: 40px; height: 40px; }
  .shell, .public-shell { width: calc(100% - 16px); }
  .shell { padding-top: 18px; }
  .card, .invoice-paper, .auth-shell .card { padding: 16px; }
  .stat { min-height: 102px; }
  .stat strong { margin-top: 9px; }
  .item-grid { grid-template-columns: 1fr; gap: 10px; }
  .item-field:first-child { grid-column: auto; }
  .catalog-reference-item { width: 100%; justify-content: space-between; text-align: left; }
  .page-head > .actions { display: grid; grid-template-columns: 1fr; }
  .page-head > .actions > * { width: 100%; }
  .page-head > .actions .btn { width: 100%; }
  .dashboard-hero-actions { display: grid; grid-template-columns: 1fr; }
  .dashboard-hero-actions > *, .dashboard-hero-actions .btn { width: 100%; }
  .dashboard-hero .workspace-switcher { display: grid; grid-template-columns: 1fr; }
  .public-shell { margin-bottom: 48px; }
  .qr { width: min(250px, 100%); }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-grid .stat { min-height: 105px; }
  .status-chart-wrap { grid-template-columns: 1fr; }
  .doughnut-shell { width: min(210px, 100%); margin: 0 auto; }
  .chart-legend { flex-direction: column; align-items: flex-start; }
  .section-head { align-items: flex-start; }
  .leader-list b { font-size: .72rem; }
}

@media (max-height: 620px) and (max-width: 1080px) {
  .topbar nav { top: 70px; }
  .topbar nav > a { min-height: 40px; padding-block: 8px; }
  .nav-account { margin-top: 8px; padding-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
