:root {
  color-scheme: light;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #e5e9f2;
  --brand: #635bff;
  --brand-dark: #4f46e5;
  --brand-soft: #eef2ff;
  --green: #22c55e;
  --green-soft: #dcfce7;
  --blue: #3b82f6;
  --blue-soft: #dbeafe;
  --red: #f43f5e;
  --red-soft: #ffe4e6;
  --orange: #f97316;
  --orange-soft: #ffedd5;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 30px rgba(15, 23, 42, 0.05);
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --radius: 16px;
  --radius-sm: 12px;
  --control-height: 40px;
  --control-radius: 12px;
  --component-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.88)), var(--surface);
  --sidebar: 240px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  padding: 14px;
  background:
    radial-gradient(circle at top left, rgba(99, 91, 255, 0.07), transparent 31vw),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.06), transparent 34vw),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 54%, #edf1f7 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  text-rendering: geometricPrecision;
  overflow: hidden;
}

body.dark-mode {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #111827;
  --surface-soft: #182235;
  --text: #f8fafc;
  --muted: #b6c2d4;
  --line: #2b3850;
  --brand-soft: rgba(99, 91, 255, 0.18);
  --green-soft: rgba(34, 197, 94, 0.18);
  --blue-soft: rgba(59, 130, 246, 0.18);
  --red-soft: rgba(244, 63, 94, 0.18);
  --orange-soft: rgba(249, 115, 22, 0.18);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 14px 34px rgba(0, 0, 0, 0.22);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.18);
  --component-bg: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(24, 34, 53, 0.88)), var(--surface);
  background:
    radial-gradient(circle at top left, rgba(99, 91, 255, 0.16), transparent 32vw),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.1), transparent 34vw),
    linear-gradient(180deg, #070b14 0%, var(--bg) 58%, #111827 100%);
}

body.dark-mode .app-shell,
body.dark-mode .auth-card,
body.dark-mode .auth-brand-panel,
body.dark-mode .sidebar,
body.dark-mode .metric-card,
body.dark-mode .panel,
body.dark-mode .table-card,
body.dark-mode .form-card,
body.dark-mode .client-card,
body.dark-mode .invoice-card,
body.dark-mode .profile-card,
body.dark-mode .input,
body.dark-mode .select,
body.dark-mode .textarea,
body.dark-mode .icon-button,
body.dark-mode .secondary-button,
body.dark-mode .ghost-button,
body.dark-mode .modal-panel,
body.dark-mode .modal-header,
body.dark-mode .modal-actions,
body.dark-mode .page-section-header,
body.dark-mode .data-toolbar,
body.dark-mode .data-table,
body.dark-mode .action-menu summary,
body.dark-mode .action-menu div,
body.dark-mode .user-menu,
body.dark-mode .topbar,
body.dark-mode .global-search {
  color: var(--text);
  background-color: var(--surface);
  border-color: var(--line);
}

body.dark-mode .metric-head,
body.dark-mode .field label,
body.dark-mode .ghost-button,
body.dark-mode .nav-item {
  color: var(--muted);
}

body.dark-mode .nav-item span {
  background: var(--surface-soft);
  color: var(--muted);
}

body.dark-mode .nav-item.active,
body.dark-mode .nav-item.active span {
  color: #fff;
}

body.dark-mode .profile-card,
body.dark-mode .detail-card,
body.dark-mode .settings-panel,
body.dark-mode .modal-header,
body.dark-mode .modal-actions,
body.dark-mode .totals-box,
body.dark-mode .total-due {
  background: var(--surface);
}

body.dark-mode .settings-hero,
body.dark-mode .auth-benefits span,
body.dark-mode .business-profile-preview,
body.dark-mode .template-choice,
body.dark-mode .data-safety-strip span,
body.dark-mode .client-contact-grid span,
body.dark-mode .activity-item,
body.dark-mode .client-notes {
  background: var(--component-bg);
}

body.dark-mode .business-settings-panel::before {
  background: linear-gradient(135deg, rgba(99, 91, 255, 0.16), transparent);
}

body.dark-mode .template-choice.active {
  background: rgba(99, 91, 255, 0.16);
}

body.dark-mode .profile-card::before {
  border-color: var(--surface);
}

body.dark-mode .profile-card::after {
  color: #c4b5fd;
  background: rgba(99, 91, 255, 0.18);
}

body.dark-mode .topbar,
body.dark-mode .sidebar,
body.dark-mode .app-shell,
body.dark-mode .settings-nav,
body.dark-mode .settings-tabs,
body.dark-mode .page-section-header,
body.dark-mode .data-toolbar,
body.dark-mode .invoice-meta-grid,
body.dark-mode .invoice-notes-grid,
body.dark-mode .item-editor,
body.dark-mode .invoice-draft-panel,
body.dark-mode .hero-summary-card,
body.dark-mode .dashboard-hero > div:first-child {
  background: var(--component-bg);
  border-color: var(--line);
}

body.dark-mode .input,
body.dark-mode .select,
body.dark-mode .textarea,
body.dark-mode .toolbar-search,
body.dark-mode .global-search {
  color: var(--text);
  background: linear-gradient(180deg, #0f172a, #111827);
  border-color: var(--line);
  box-shadow: none;
}

body.dark-mode .input::placeholder,
body.dark-mode .textarea::placeholder,
body.dark-mode .toolbar-search input::placeholder,
body.dark-mode .global-search input::placeholder {
  color: #7f8ea3;
}

body.dark-mode .secondary-button,
body.dark-mode .ghost-button,
body.dark-mode .icon-button,
body.dark-mode .user-menu {
  color: var(--text);
  background: #111827;
  border-color: var(--line);
}

body.dark-mode .data-row:not(.data-head):hover,
body.dark-mode .table-row:not(.header):hover,
body.dark-mode .status-row,
body.dark-mode .due-row,
body.dark-mode .invoice-queue-meta span,
body.dark-mode .toolbar-count,
body.dark-mode .invoice-select-all,
body.dark-mode .line-total,
body.dark-mode .stat-stack span,
body.dark-mode .client-card-metrics span {
  background: rgba(24, 34, 53, 0.78);
  border-color: var(--line);
}

body.dark-mode .data-head,
body.dark-mode .preview-table th {
  color: #cbd5e1;
  background: #182235;
}

body.dark-mode .action-menu div,
body.dark-mode .topbar-popover,
body.dark-mode .mobile-more-panel,
body.dark-mode .toast {
  background: #111827;
  border-color: var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

body.dark-mode .action-menu button:hover,
body.dark-mode .topbar-popover button:hover,
body.dark-mode .mobile-more-panel > button:hover {
  background: #182235;
}

body.dark-mode .modal-panel,
body.dark-mode .modal-header,
body.dark-mode .modal-actions {
  background: linear-gradient(180deg, #111827, #0f172a);
  border-color: var(--line);
}

body.dark-mode .preview-stage {
  background: #0b1020;
}

body.dark-mode .preview-sheet {
  color: #111827;
  background:
    linear-gradient(180deg, #fff, #fbfcff 72%, #f8fafc),
    #fff;
  border-color: #e5e9f2;
}

body.dark-mode .preview-sheet p,
body.dark-mode .preview-sheet small,
body.dark-mode .preview-sheet .eyebrow {
  color: #64748b;
}

body.dark-mode .preview-sheet .bill-card,
body.dark-mode .preview-sheet .preview-table tr,
body.dark-mode .preview-sheet .totals-box,
body.dark-mode .preview-sheet .total-due {
  color: #111827;
  background: #f8fafc;
  border-color: #e5e9f2;
}

body.dark-mode .preview-sheet .preview-table th {
  color: #64748b;
  background: #f8fafc;
  border-color: #e5e9f2;
}

body.dark-mode .preview-sheet .preview-table td,
body.dark-mode .preview-sheet .preview-footer,
body.dark-mode .preview-sheet .preview-note-stack p {
  border-color: #e5e9f2;
}

body.dark-mode .nav-item:not(.active):hover,
body.dark-mode .settings-nav a:hover,
body.dark-mode .settings-tab:not(.active):hover,
body.dark-mode .template-choice:hover {
  color: #f8fafc;
  background: rgba(99, 91, 255, 0.16);
}

body.dark-mode .metric-head,
body.dark-mode .breadcrumb,
body.dark-mode .trend,
body.dark-mode .toolbar-count,
body.dark-mode .invoice-cell small,
body.dark-mode .invoice-queue-main small,
body.dark-mode .invoice-queue-meta small,
body.dark-mode .due-title small,
body.dark-mode .payment-row small,
body.dark-mode .settings-panel-header small,
body.dark-mode .template-choice em,
body.dark-mode .draft-panel-note,
body.dark-mode .toast span {
  color: var(--muted);
}

body.dark-mode .status-draft {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.16);
}

body.dark-mode .status-paid {
  color: #86efac;
}

body.dark-mode .status-sent,
body.dark-mode .status-viewed {
  color: #93c5fd;
}

body.dark-mode .status-overdue,
body.dark-mode .status-cancelled,
body.dark-mode .amount-danger {
  color: #fda4af;
}

body.dark-mode .amount-success,
body.dark-mode .payment-table .data-row > strong[data-label="Amount"] {
  color: #86efac;
}

body.dark-mode .template-choice.active,
body.dark-mode .invoice-queue-card.selected,
body.dark-mode .invoice-queue-card.bulk-selected {
  background: linear-gradient(135deg, rgba(99, 91, 255, 0.22), rgba(17, 24, 39, 0.95));
}

body.dark-mode .business-profile-preview b,
body.dark-mode .settings-title > .app-icon,
body.dark-mode .empty-icon,
body.dark-mode .mini-icon,
body.dark-mode .health-strip span,
body.dark-mode .insight-card > .app-icon,
body.dark-mode .report-spotlight > .app-icon {
  color: #c4b5fd;
  background: rgba(99, 91, 255, 0.18);
}

body.dark-mode .mobile-nav {
  background: rgba(17, 24, 39, 0.94);
  border-color: var(--line);
}

body.dark-mode .mobile-nav-item {
  color: var(--muted);
}

body.dark-mode .mobile-nav-item.active {
  color: #c4b5fd;
  background: rgba(99, 91, 255, 0.18);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(99, 91, 255, 0.25);
  outline-offset: 2px;
}

body.auth-pending {
  overflow-y: auto;
}

body.auth-pending .app-shell,
body.auth-pending .mobile-nav,
body.auth-pending .mobile-more-menu {
  display: none;
}

body.is-authenticated .auth-screen {
  display: none;
}

.auth-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 18px;
  min-height: calc(100vh - 28px);
  max-width: 1180px;
  margin: 0 auto;
}

.auth-brand-panel,
.auth-card {
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9)),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.auth-brand-panel {
  position: relative;
  display: grid;
  align-content: space-between;
  gap: 28px;
  overflow: hidden;
  padding: 34px;
}

.auth-brand-panel::before {
  content: "";
  position: absolute;
  inset: auto -120px -160px auto;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 91, 255, 0.18), transparent 64%);
}

.auth-brand-panel > * {
  position: relative;
}

.auth-brand {
  width: max-content;
  padding: 0;
}

.auth-brand-panel h1 {
  max-width: 620px;
  font-size: clamp(2rem, 4vw, 3.35rem);
}

.auth-brand-panel p:not(.eyebrow) {
  max-width: 560px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.auth-benefits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.auth-benefits span {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(99, 91, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
}

.auth-benefits strong,
.auth-benefits small {
  display: block;
}

.auth-benefits small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.auth-card {
  align-self: center;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.auth-tabs button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.18);
}

.auth-form {
  display: none;
  gap: 14px;
}

.auth-form.active {
  display: grid;
}

.auth-form p:not(.eyebrow):not(.auth-hint) {
  margin: 6px 0 0;
  color: var(--muted);
}

.auth-form .primary-button {
  width: 100%;
}

.auth-hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  height: calc(100vh - 28px);
  max-width: 1440px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.1);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
  padding: 22px 16px;
  overflow: hidden;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9)),
    rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 3px 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 16px rgba(79, 70, 229, 0.18));
}

.brand strong,
.profile-card strong {
  display: block;
  line-height: 1.1;
  font-size: 0.92rem;
}

.brand small,
.profile-card small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.side-nav {
  display: grid;
  gap: 5px;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 112, 133, 0.32) transparent;
}

.side-nav::-webkit-scrollbar,
.content::-webkit-scrollbar,
.modal-panel::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.side-nav::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track,
.modal-panel::-webkit-scrollbar-track {
  background: transparent;
}

.side-nav::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb,
.modal-panel::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(102, 112, 133, 0.34);
  background-clip: padding-box;
}

.side-nav::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover,
.modal-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 112, 133, 0.48);
  background-clip: padding-box;
}

.nav-item,
.mobile-nav-item {
  border: 0;
  background: transparent;
  color: #344054;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border-radius: 12px;
  font-weight: 740;
  font-size: 0.83rem;
  text-align: left;
}

.nav-item em {
  font-style: normal;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--surface-soft);
  color: #475467;
  font-size: 0.9rem;
}

.app-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, #6d5dfc, var(--brand-dark));
  box-shadow: 0 12px 26px rgba(79, 70, 229, 0.22);
}

.nav-item:not(.active):hover {
  color: var(--text);
  background: rgba(241, 245, 249, 0.82);
}

.nav-item.active span {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.profile-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  min-height: 62px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.96)),
    var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 24px rgba(15, 23, 42, 0.05);
}

.profile-card img {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  box-shadow: inset 0 0 0 1px rgba(99, 91, 255, 0.1);
}

.profile-card::before {
  content: "";
  position: absolute;
  left: 36px;
  bottom: 13px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--green);
}

.profile-card::after {
  content: "Admin";
  margin-left: auto;
  padding: 3px 6px;
  border-radius: 999px;
  color: #4338ca;
  background: var(--brand-soft);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0;
}

.profile-card span {
  min-width: 0;
}

.profile-card strong,
.profile-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upgrade-card {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  padding: 17px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  color: #fff;
  background:
    radial-gradient(circle at 86% 12%, rgba(255, 255, 255, 0.3), transparent 30%),
    linear-gradient(145deg, #20204d 0%, #4f46e5 56%, #7468ff 100%);
  box-shadow: 0 18px 42px rgba(79, 70, 229, 0.24);
}

.upgrade-card::before {
  content: "PRO";
  position: absolute;
  top: 15px;
  right: 15px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.upgrade-card strong {
  display: block;
  max-width: 142px;
  margin-bottom: 8px;
  font-size: 1rem;
  line-height: 1.18;
}

.upgrade-card p {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8rem;
  line-height: 1.46;
}

.upgrade-card .secondary-button {
  min-height: 36px;
  padding-inline: 14px;
  border-color: rgba(255, 255, 255, 0.22);
  color: #4338ca;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.workspace {
  --workspace-pad-x: 28px;
  --workspace-pad-y: 22px;
  --topbar-offset: 96px;
  position: relative;
  display: block;
  min-width: 0;
  height: 100%;
  padding: var(--workspace-pad-y) var(--workspace-pad-x);
  overflow: hidden;
  overscroll-behavior: contain;
}

.topbar {
  position: absolute;
  top: var(--workspace-pad-y);
  right: var(--workspace-pad-x);
  left: var(--workspace-pad-x);
  z-index: 130;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, auto);
  align-items: center;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(226, 232, 240, 0.88);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9)),
    var(--surface);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(18px);
  margin-bottom: 18px;
  min-height: 74px;
  overflow: visible;
  transform-origin: top;
  transition: opacity 180ms ease, transform 220ms ease, margin-bottom 220ms ease;
}

.workspace.topbar-hidden .topbar {
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-18px);
}

.page-heading {
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 4px;
  color: #697386;
  font-size: 0.75rem;
  font-weight: 800;
}

.breadcrumb span + span::before {
  content: "/";
  margin-right: var(--space-2);
  color: #98a2b3;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.38rem, 1.8vw, 1.66rem);
  letter-spacing: 0;
  line-height: 1.15;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.2;
}

h2 {
  font-size: 0.98rem;
}

h3 {
  font-size: 0.95rem;
}

#pageSubtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar-actions {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto 40px auto;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.topbar-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 120;
  width: min(340px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar-popover[hidden] {
  display: none;
}

.notification-popover {
  right: 52px;
}

.user-popover {
  right: 0;
  width: min(230px, calc(100vw - 24px));
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 8px 8px 10px;
}

.topbar-popover button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 42px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.topbar-popover button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.user-menu:hover,
.action-menu summary:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

.topbar-popover small {
  display: block;
  color: var(--muted);
}

.global-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-xs);
  color: var(--muted);
}

.global-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}

.user-menu img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
}

.date-range input {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: var(--control-height);
  border-radius: var(--control-radius);
  border: 1px solid transparent;
  font-weight: 780;
  font-size: 0.83rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, filter 160ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.2);
}

.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 14px;
  color: var(--brand-dark);
  background: var(--surface);
  border-color: var(--line);
}

.ghost-button {
  color: #344054;
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 12px;
  color: #be123c;
  background: var(--red-soft);
  border-color: #fecdd3;
}

.danger-button.confirming {
  color: #fff;
  background: #e11d48;
  border-color: #e11d48;
}

.icon-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
  font-size: 1rem;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--red);
}

.content {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--topbar-offset) 2px 24px 0;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.content::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 10px;
}

.dashboard-hero > div:first-child,
.hero-summary-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9)),
    var(--surface);
  box-shadow: var(--shadow-xs);
}

.dashboard-hero > div:first-child {
  padding: 18px 20px;
}

.dashboard-hero h2 {
  max-width: 720px;
  font-size: clamp(1.34rem, 2vw, 1.82rem);
  line-height: 1.08;
}

.dashboard-hero p:not(.eyebrow) {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.hero-summary-card {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 17px;
  position: relative;
  overflow: hidden;
}

.hero-summary-card::before {
  content: "";
  position: absolute;
  inset: auto -24px -44px auto;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(99, 91, 255, 0.1);
}

.hero-summary-card > * {
  position: relative;
}

.hero-summary-card > span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 7px;
  border-radius: 12px;
  color: #4338ca;
  background: var(--brand-soft);
}

.hero-summary-card small,
.hero-summary-card em {
  color: var(--muted);
  font-style: normal;
  font-weight: 760;
}

.hero-summary-card strong {
  font-size: 1.1rem;
  line-height: 1.16;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(142px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.metric-grid::after,
.insight-grid::after,
.settings-summary::after,
.health-strip::after,
.report-hero-grid::after,
.data-safety-strip::after {
  display: none;
  content: "";
}

.insight-grid,
.settings-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.settings-summary {
  margin-bottom: 0;
}

.settings-summary .metric-card {
  min-height: 92px;
  padding: 13px;
}

.settings-summary .metric-card strong {
  margin-top: 9px;
  font-size: 1.14rem;
}

.settings-summary .trend {
  margin-top: 6px;
}

.insight-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 92px;
  padding: 14px;
}

.insight-card > .app-icon {
  width: 36px;
  height: 36px;
  padding: 9px;
  border-radius: 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.insight-card small,
.insight-card em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.insight-card strong {
  display: block;
  margin: 3px 0;
  font-size: 1.16rem;
  line-height: 1.1;
}

.health-strip,
.report-hero-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.health-strip section,
.report-spotlight {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-xs);
}

.health-strip span,
.report-spotlight > .app-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.health-strip strong,
.health-strip small,
.report-spotlight small,
.report-spotlight em {
  display: block;
}

.health-strip strong,
.report-spotlight strong {
  display: block;
  font-size: 0.96rem;
  line-height: 1.1;
}

.health-strip small,
.report-spotlight small,
.report-spotlight em {
  color: var(--muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 780;
}

.report-hero-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-spotlight {
  padding: 14px;
}

.report-spotlight strong {
  margin: 2px 0;
  font-size: 1.2rem;
}

.report-spotlight.warning > .app-icon {
  color: #be123c;
  background: var(--red-soft);
}

.carousel-controls {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: -3px 0 10px;
}

.carousel-controls[hidden] {
  display: none !important;
}

.carousel-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand-dark);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-xs);
}

.carousel-button:disabled {
  color: #94a3b8;
  background: var(--surface-soft);
  opacity: 0.55;
  cursor: not-allowed;
}

.carousel-button .app-icon {
  width: 16px;
  height: 16px;
}

.carousel-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 44px;
}

.carousel-dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: width 160ms ease, background 160ms ease, opacity 160ms ease;
}

.carousel-dots span.active {
  width: 16px;
  background: var(--brand-dark);
}

.metric-card,
.panel,
.table-card,
.form-card,
.preview-sheet,
.client-card,
.invoice-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.88)),
    var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 34px rgba(15, 23, 42, 0.045);
}

.page-section .table-card {
  overflow: visible;
}

.dashboard-grid .table-card {
  overflow: hidden;
}

.panel,
.table-card,
.form-card,
.metric-card {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px rgba(15, 23, 42, 0.04);
}

.page-section {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.page-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-xs);
}

.page-section-header p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--muted);
}

.data-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: nowrap;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--component-bg);
  box-shadow: var(--shadow-xs);
}

.toolbar-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.78);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 320px;
  min-width: 220px;
  min-height: var(--control-height);
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
}

.toolbar-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.compact-control {
  width: auto !important;
  flex: 0 1 156px;
  min-width: 132px;
  max-width: 190px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.segmented-control button {
  min-height: 31px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented-control button.active {
  color: var(--brand-dark);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(16, 24, 40, 0.08);
}

.data-table {
  width: 100%;
  min-width: 0;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--component-bg);
  box-shadow: var(--shadow-xs);
}

.data-row {
  display: grid;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.83rem;
  min-width: 0;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.service-table .data-row {
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.45fr) minmax(80px, 0.55fr) minmax(58px, 0.42fr) minmax(70px, 0.45fr) minmax(78px, 0.5fr) 44px;
}

.payment-table .data-row {
  grid-template-columns: minmax(110px, 0.8fr) minmax(140px, 1fr) minmax(96px, 0.7fr) minmax(96px, 0.65fr) minmax(96px, 0.65fr) minmax(90px, 0.6fr);
}

.service-table .data-row > strong[data-label="Rate"],
.payment-table .data-row > strong[data-label="Amount"],
.client-table .data-row > strong[data-label="Total billed"],
.client-table .data-row > strong[data-label="Outstanding"] {
  font-variant-numeric: tabular-nums;
}

.payment-table .data-row > strong[data-label="Amount"] {
  color: #166534;
}

.data-row:last-child {
  border-bottom: 0;
}

.data-head {
  min-height: 38px;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.86);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.data-row:not(.data-head):hover,
.table-row:not(.header):hover {
  background: rgba(248, 250, 252, 0.76);
}

.data-row strong,
.table-row strong {
  font-weight: 850;
}

.client-table .data-row {
  grid-template-columns: minmax(190px, 1.45fr) minmax(130px, 0.85fr) minmax(120px, 0.75fr) minmax(94px, 0.62fr) minmax(98px, 0.65fr) minmax(100px, 0.66fr) minmax(88px, 0.56fr) 44px;
}

.data-row > * {
  min-width: 0;
}

.data-row > span,
.data-row > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-row > span[data-label="Status"],
.data-row > .row-actions {
  overflow: visible;
}

.data-row > [data-label]::before,
.table-row > [data-label]::before {
  display: none;
}

.data-row .status-badge,
.data-row .row-actions {
  overflow: visible;
}

.client-identity {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.client-identity strong,
.client-identity h3 {
  display: block;
  margin: 0;
}

.client-identity small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-initials {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 0.8rem;
  font-weight: 900;
}

.amount-danger {
  color: #be123c;
}

.amount-success {
  color: #166534;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  overflow: visible;
}

.action-menu {
  position: relative;
}

.action-menu[open] {
  z-index: 60;
}

.action-menu summary {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid var(--line);
  border-radius: 10px;
  list-style: none;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.action-menu[open] summary,
.action-menu summary:hover {
  border-color: rgba(99, 91, 255, 0.32);
  color: var(--brand-dark);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.1);
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu div {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  display: grid;
  min-width: 184px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

.action-menu button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  text-align: left;
}

.action-menu button:hover {
  background: var(--surface-soft);
}

.action-menu .danger-link {
  color: #be123c;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--muted);
  font-weight: 800;
}

.pagination-bar > div {
  display: flex;
  gap: var(--space-2);
}

.compact-client-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.client-card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.client-card-metrics span {
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.client-card-metrics small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.rich-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(240px, 0.8fr);
  gap: var(--space-3);
  padding: 20px;
}

.detail-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), #fbfcff);
  box-shadow: var(--shadow-xs);
}

.detail-card.wide {
  grid-column: 1 / -1;
}

.client-detail-hero {
  display: grid;
  gap: 14px;
}

.client-identity.large .avatar-initials {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.client-contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.client-contact-grid span {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.client-contact-grid .app-icon {
  width: 18px;
  height: 18px;
  color: var(--brand-dark);
}

.client-contact-grid small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.client-contact-grid strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.client-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.client-notes {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.72);
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.activity-item > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.activity-item.payment > span {
  color: #166534;
  background: var(--green-soft);
}

.activity-item strong,
.activity-item small {
  display: block;
  min-width: 0;
}

.activity-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.stat-stack {
  display: grid;
  gap: var(--space-3);
}

.stat-stack span {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.stat-stack small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.stat-stack strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.mini-list {
  display: grid;
  gap: var(--space-2);
}

.mini-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.mini-list > div:last-child {
  border-bottom: 0;
}

.mini-list small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.metric-card {
  min-height: 118px;
  padding: 15px 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.metric-card:hover,
.panel:hover,
.table-card:hover {
  border-color: rgba(99, 91, 255, 0.18);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 18px 38px rgba(15, 23, 42, 0.065);
}

.metric-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #475467;
  font-size: 0.7rem;
  font-weight: 820;
  line-height: 1.2;
  text-transform: uppercase;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  background: var(--brand);
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.metric-card strong {
  display: block;
  margin-top: 13px;
  font-size: 1.42rem;
  line-height: 1.05;
}

.trend {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 720;
}

.trend.up {
  color: #16a34a;
}

.trend.down {
  color: #e11d48;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(330px, 0.82fr);
  gap: 10px;
}

.panel,
.table-card,
.form-card {
  padding: 15px;
}

.panel-header,
.section-header,
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.panel-header h2,
.table-header h2 {
  font-size: 1rem;
}

.panel-header .eyebrow,
.table-header .eyebrow {
  margin-bottom: 4px;
}

.chart-wrap {
  min-height: 236px;
}

.line-chart {
  width: 100%;
  height: 236px;
}

.donut-layout {
  display: grid;
  grid-template-columns: minmax(160px, 210px) 1fr;
  align-items: center;
  gap: 14px;
}

.donut {
  width: 150px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: auto;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0deg 192deg, var(--blue) 192deg 282deg, var(--red) 282deg 360deg);
}

.donut-center {
  display: grid;
  place-items: center;
  width: 92px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-center strong {
  display: block;
  font-size: 1.24rem;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-row {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.68);
}

.status-row,
.due-row,
.payment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.due-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.status-row span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
}

.table-grid {
  display: grid;
  gap: 0;
}

.table-row {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 0.8fr 0.9fr 0.8fr;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  min-width: 0;
}

.table-row > * {
  min-width: 0;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row.header {
  min-height: auto;
  padding: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-badge,
.due-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  width: fit-content;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  max-width: 100%;
  white-space: nowrap;
}

.status-paid {
  color: #166534;
  background: var(--green-soft);
}

.status-sent,
.status-viewed {
  color: #1d4ed8;
  background: var(--blue-soft);
}

.status-overdue,
.status-cancelled {
  color: #be123c;
  background: var(--red-soft);
}

.status-draft {
  color: #475467;
  background: #f2f4f7;
}

.due-list {
  display: grid;
  gap: 9px;
}

.due-row {
  min-height: 66px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.68);
}

.due-row:last-child {
  border-bottom: 1px solid var(--line);
}

.due-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-weight: 900;
  font-size: 0;
}

.mini-icon::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.due-title strong,
.payment-row strong {
  display: block;
  font-size: 0.92rem;
}

.due-title small,
.payment-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
}

.invoice-workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 18px;
}

.invoice-history-panel,
.invoice-preview-panel {
  min-height: 0;
}

.invoice-history-panel {
  max-height: none;
  overflow: hidden;
}

.invoice-history-panel #invoiceListMount {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.invoice-preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  max-height: none;
  overflow: visible;
}

.invoice-preview-toolbar {
  margin-bottom: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.preview-stage {
  min-height: 0;
  overflow: visible;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface-soft);
}

.invoice-preview-panel .preview-sheet {
  width: min(100%, 860px);
  max-width: 860px;
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.invoice-queue-list {
  display: grid;
  gap: var(--space-3);
}

.invoice-select-all {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.72);
}

.invoice-select-all strong {
  margin-left: auto;
  color: var(--brand-dark);
  font-size: 0.76rem;
}

.invoice-queue-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(220px, auto) 40px;
  align-items: center;
  gap: var(--space-3);
  min-height: 72px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.invoice-queue-card.selected,
.invoice-queue-card.bulk-selected {
  border-color: rgba(99, 91, 255, 0.38);
  background: linear-gradient(135deg, var(--brand-soft), var(--surface));
  box-shadow: 0 12px 30px rgba(79, 70, 229, 0.12);
}

.invoice-queue-card:hover {
  border-color: rgba(99, 91, 255, 0.24);
  transform: translateY(-1px);
}

.invoice-queue-card.selected .invoice-queue-main strong {
  color: var(--brand-dark);
}

.invoice-queue-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  border-radius: 10px;
  padding: 4px 6px;
  margin: -4px -6px;
}

.invoice-queue-main:hover {
  background: rgba(99, 91, 255, 0.055);
}

.invoice-queue-main > span,
.invoice-queue-meta span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.invoice-queue-main strong,
.invoice-queue-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-queue-main small,
.invoice-queue-meta small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.invoice-queue-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: var(--space-3);
}

.invoice-queue-meta span {
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid rgba(226, 232, 240, 0.72);
}

.invoice-queue-meta strong {
  font-size: 0.88rem;
}

.recent-invoice-table .table-row {
  grid-template-columns: minmax(96px, 1fr) minmax(118px, 1.08fr) 76px minmax(72px, 0.75fr) 76px;
  gap: 8px;
}

.recent-invoice-table .invoice-cell strong,
.recent-invoice-table .invoice-cell small,
.recent-invoice-table .table-row > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-invoice-table .invoice-cell[data-label="Due"] strong {
  white-space: normal;
  line-height: 1.15;
}

@media (min-width: 1500px) {
  .invoice-workspace-grid {
    grid-template-columns: minmax(520px, 0.9fr) minmax(680px, 1.1fr);
  }

  .invoice-preview-panel {
    position: sticky;
    top: 0;
    max-height: min(820px, calc(100vh - 96px));
    overflow: hidden;
  }

  .invoice-preview-panel .preview-stage {
    overflow: auto;
  }
}

.invoice-cell {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.invoice-cell strong,
.invoice-cell small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-cell small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.amount-cell {
  text-align: right;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: linear-gradient(180deg, var(--surface), rgba(248, 250, 252, 0.74));
  color: var(--text);
  padding: 8px 11px;
  font-size: 0.84rem;
  line-height: 1.35;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.input::placeholder,
.textarea::placeholder,
.toolbar-search input::placeholder,
.global-search input::placeholder {
  color: #98a2b3;
}

.input:hover,
.select:hover,
.textarea:hover,
.toolbar-search:hover,
.global-search:hover {
  border-color: #cbd5e1;
  background: var(--surface);
}

.input:focus,
.select:focus,
.textarea:focus,
.toolbar-search:focus-within,
.global-search:focus-within {
  border-color: rgba(99, 91, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(99, 91, 255, 0.1);
}

.filters .input {
  width: min(280px, 100%);
}

.filters .select {
  width: 170px;
}

.client-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.client-card,
.invoice-card {
  padding: 16px;
}

.client-card h3,
.invoice-card h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.client-card p,
.invoice-card p {
  margin: 4px 0;
  color: var(--muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.empty-state {
  padding: 34px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
}

.compact-empty {
  padding: 22px 14px;
  font-size: 0.84rem;
}

.invoice-list {
  display: grid;
  gap: 12px;
}

.invoice-card {
  display: grid;
  gap: 10px;
}

.invoice-card-top,
.invoice-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-sheet {
  max-width: 860px;
  margin: 0 auto;
  padding: 34px;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 20px;
  background:
    linear-gradient(180deg, #fff, #fbfcff 72%, #f8fafc),
    var(--surface);
}

.preview-sheet.template-modern {
  border-top: 6px solid var(--brand);
}

.preview-sheet.template-modern .total-due,
.preview-sheet.template-modern .totals-box {
  background: linear-gradient(135deg, var(--brand-soft), var(--surface-soft));
}

.preview-sheet.template-minimal {
  box-shadow: none;
  border-style: dashed;
}

.preview-sheet.template-minimal .preview-brand img,
.preview-sheet.template-minimal .signature {
  display: none;
}

.preview-sheet.template-executive {
  border-top: 0;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.13);
}

.preview-sheet.template-executive .preview-head {
  padding: 22px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, #111827, var(--brand-dark));
}

.preview-sheet.template-executive .preview-head p,
.preview-sheet.template-executive .preview-head small {
  color: rgba(255, 255, 255, 0.78);
}

.preview-stamp {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.preview-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-brand img {
  width: 48px;
  height: 48px;
}

.invoice-title {
  text-align: right;
}

.invoice-title h2 {
  margin-bottom: 2px;
  font-size: 2.05rem;
  letter-spacing: 0.04em;
}

.preview-meta-grid {
  display: grid;
  gap: 6px;
  margin: 14px 0 12px;
}

.preview-meta-grid span {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.preview-meta-grid small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.bill-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  margin-bottom: 24px;
}

.bill-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.7);
}

.bill-card p:last-child {
  margin-bottom: 0;
}

.total-due {
  min-width: 190px;
  padding: 18px 20px;
  border: 1px solid rgba(99, 91, 255, 0.14);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-soft), #f8fafc);
  text-align: center;
}

.total-due strong {
  display: block;
  margin-top: 4px;
  color: var(--brand-dark);
  font-size: 1.65rem;
}

.preview-payment-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: -8px 0 20px;
}

.preview-payment-strip span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.74);
}

.preview-payment-strip small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.preview-payment-strip strong {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.preview-table th,
.preview-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.preview-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.preview-table td:last-child,
.preview-table th:last-child {
  text-align: right;
}

.preview-footer {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 24px;
  align-items: start;
}

.preview-note-stack {
  display: grid;
  gap: 12px;
}

.preview-note-stack p {
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.preview-note-stack p:last-child {
  border-bottom: 0;
}

.totals-box {
  display: grid;
  gap: 9px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
}

.totals-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.totals-box .grand-total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--brand-dark);
  font-size: 1.1rem;
  font-weight: 900;
}

.signature {
  margin-top: 28px;
  color: var(--brand-dark);
  font-family: "Segoe Script", "Bradley Hand ITC", cursive;
  font-size: 1.25rem;
}

.modal {
  width: min(1060px, calc(100vw - 24px));
  max-height: calc(100vh - 30px);
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(8px);
}

.modal-panel {
  max-height: calc(100vh - 30px);
  overflow: auto;
  padding: 0;
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--surface), #fbfcff);
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.2);
}

.modal-panel.narrow {
  max-width: 720px;
  margin: 0 auto;
}

.confirm-modal {
  width: min(440px, calc(100vw - 24px));
}

.confirm-panel {
  padding: 22px;
}

.confirm-panel p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 16px 24px;
  background: var(--surface);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 252, 255, 0.94)),
    var(--surface);
  backdrop-filter: blur(14px);
}

.modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(251, 252, 255, 0.94), rgba(248, 250, 252, 0.98)),
    var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 24px rgba(16, 24, 40, 0.04);
}

.modal-actions .secondary-button {
  margin-right: auto;
}

#invoiceFormBody,
#clientFormBody,
#serviceFormBody,
#paymentFormBody {
  padding: 20px 24px;
}

.confirm-actions {
  position: static;
  margin: 22px -22px -22px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.invoice-workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
  padding: 16px 24px 0;
}

.invoice-form-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid rgba(99, 91, 255, 0.14);
  border-radius: 18px;
  background:
    radial-gradient(circle at 92% 10%, rgba(99, 91, 255, 0.14), transparent 30%),
    var(--component-bg);
  box-shadow: var(--shadow-xs);
}

.invoice-form-hero h3 {
  font-size: 1.12rem;
}

.invoice-form-hero p:not(.eyebrow) {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.draft-save-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(34, 197, 94, 0.18);
  border-radius: 999px;
  color: #15803d;
  background: var(--green-soft);
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.draft-save-state.changed {
  color: #92400e;
  border-color: rgba(249, 115, 22, 0.22);
  background: var(--orange-soft);
}

.draft-save-state .app-icon {
  width: 16px;
  height: 16px;
}

.invoice-workflow span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.74rem;
  font-weight: 900;
}

.invoice-builder-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  gap: 18px;
  align-items: start;
}

.invoice-editor-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.invoice-meta-grid,
.invoice-notes-grid {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--component-bg);
  box-shadow: var(--shadow-xs);
}

.invoice-draft-panel {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(99, 91, 255, 0.18);
  border-radius: 18px;
  background:
    radial-gradient(circle at 92% 8%, rgba(99, 91, 255, 0.16), transparent 32%),
    var(--component-bg);
  box-shadow: 0 16px 40px rgba(79, 70, 229, 0.1);
}

.invoice-draft-panel h3 {
  font-size: 1.04rem;
}

.draft-balance-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.draft-balance-card span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(99, 91, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
}

.draft-balance-card small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.draft-balance-card strong {
  overflow: hidden;
  color: var(--brand-dark);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-panel-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 740;
}

.invoice-workflow b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
}

.invoice-workflow span.active {
  color: var(--brand-dark);
  border-color: rgba(99, 91, 255, 0.24);
  background: var(--brand-soft);
}

.invoice-workflow span.active b {
  color: #fff;
  background: var(--brand-dark);
}

.form-grid .wide,
.item-editor,
.totals-editor {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field label,
.item-row label span {
  display: block;
  margin: 0;
  color: #475467;
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field-error {
  border-color: #fb7185 !important;
  background: linear-gradient(180deg, #fff7f8, var(--red-soft)) !important;
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.1) !important;
}

.form-error-list {
  display: grid;
  gap: 7px;
  padding: 12px 14px;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  color: #be123c;
  background: var(--red-soft);
  font-size: 0.84rem;
  font-weight: 800;
}

.form-error-list[hidden] {
  display: none;
}

.item-editor {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--component-bg);
  box-shadow: var(--shadow-xs);
}

.item-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(150px, 1.2fr) 64px 86px 76px 72px 98px 40px;
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.item-row label {
  display: grid;
  gap: 6px;
}

.item-row label span {
  display: none;
}

.item-row.header {
  align-items: center;
  min-height: 32px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.line-total {
  min-height: 40px;
  display: grid;
  place-items: center end;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface-soft);
  font-weight: 900;
}

.totals-editor {
  display: grid;
  justify-content: stretch;
  gap: 8px;
}

.totals-editor div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  min-height: 34px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 780;
}

.totals-editor div:last-child {
  border-bottom: 0;
}

.totals-editor strong {
  color: var(--brand-dark);
  white-space: nowrap;
}

.totals-editor .grand-total {
  margin-top: 4px;
  padding: 12px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}

.totals-editor .grand-total strong {
  color: #fff;
  font-size: 1.08rem;
}

.mobile-nav {
  display: none;
}

.mobile-more-menu {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  align-items: end;
  padding: 18px;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(8px);
}

.mobile-more-menu[hidden] {
  display: none;
}

.mobile-more-panel {
  display: grid;
  gap: var(--space-2);
  width: min(440px, 100%);
  margin: 0 auto 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mobile-more-panel > button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  color: var(--text);
  background: transparent;
  font-weight: 820;
  text-align: left;
}

.mobile-more-panel > button:hover {
  background: var(--surface-soft);
}

.toast-viewport {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 12px;
  align-items: start;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--brand);
}

.toast-success::before {
  background: var(--green);
}

.toast-error::before {
  background: var(--red);
}

.toast-warning::before {
  background: var(--orange);
}

.toast strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.toast span {
  color: var(--muted);
  font-size: 0.84rem;
}

.settings-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}

.settings-hero {
  background:
    radial-gradient(circle at 92% 12%, rgba(99, 91, 255, 0.16), transparent 30%),
    radial-gradient(circle at 12% 110%, rgba(59, 130, 246, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
}

.settings-nav {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--component-bg);
  box-shadow: var(--shadow-xs);
}

.settings-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #344054;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 850;
}

.settings-nav a:hover {
  color: var(--brand-dark);
  border-color: rgba(99, 91, 255, 0.2);
  background: var(--brand-soft);
}

.settings-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 980px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--component-bg);
  box-shadow: var(--shadow-xs);
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #475569;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 880;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.settings-tab .app-icon {
  width: 18px;
  height: 18px;
}

.settings-tab:hover {
  color: var(--brand-dark);
  border-color: rgba(99, 91, 255, 0.2);
  background: var(--brand-soft);
}

.settings-tab:focus-visible {
  outline: 3px solid rgba(99, 91, 255, 0.24);
  outline-offset: 2px;
}

.settings-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 12px 26px rgba(79, 70, 229, 0.2);
}

.settings-tab-panels {
  display: grid;
  gap: 12px;
  max-width: 980px;
}

.settings-tab-panels .settings-panel {
  display: none;
}

.settings-tab-panels .settings-panel.active {
  display: block;
}

.settings-tab-panels .template-preview-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.data-safety-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.settings-panel {
  min-width: 0;
  background: var(--component-bg);
  scroll-margin-top: 120px;
}

.settings-panel-header {
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.settings-panel-header span:first-child {
  display: grid;
  gap: 4px;
}

.settings-title {
  display: flex !important;
  align-items: flex-start;
  gap: 9px !important;
}

.settings-title > .app-icon {
  width: 32px;
  height: 32px;
  padding: 8px;
  border-radius: 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.settings-panel-header small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
  line-height: 1.35;
}

.business-settings-panel {
  position: relative;
  overflow: hidden;
}

.business-settings-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 78px;
  background: linear-gradient(135deg, rgba(99, 91, 255, 0.1), rgba(59, 130, 246, 0.04));
  pointer-events: none;
}

.business-settings-panel > * {
  position: relative;
}

.business-profile-preview {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(99, 91, 255, 0.14);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(248, 250, 252, 0.8)),
    var(--surface);
  box-shadow: var(--shadow-xs);
}

.business-profile-preview img {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.14);
}

.business-profile-preview span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.business-profile-preview b {
  margin-left: auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 0.72rem;
  font-weight: 900;
}

.business-profile-preview strong,
.business-profile-preview small,
.business-profile-preview em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.business-profile-preview strong {
  font-size: 0.98rem;
  font-weight: 850;
}

.business-profile-preview small,
.business-profile-preview em {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
}

.template-preview-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.template-choice {
  display: grid;
  gap: 7px;
  min-width: 0;
  min-height: 112px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: linear-gradient(180deg, var(--surface), rgba(248, 250, 252, 0.72));
  text-align: left;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.template-choice:hover {
  border-color: rgba(99, 91, 255, 0.35);
  background: #fbfcff;
  transform: translateY(-1px);
}

.template-choice.active {
  border-color: rgba(99, 91, 255, 0.42);
  background: linear-gradient(180deg, var(--brand-soft), #fff);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.12);
}

.template-choice span {
  display: grid;
  gap: 4px;
  min-height: 46px;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.template-choice span i {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: #cbd5e1;
}

.template-choice span i:first-child {
  width: 56%;
  background: var(--brand);
}

.template-choice span i:nth-child(2) {
  width: 82%;
}

.template-choice span i:nth-child(3) {
  width: 68%;
}

.template-choice strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.76rem;
  font-weight: 850;
}

.template-choice em {
  color: var(--muted);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 760;
  line-height: 1.25;
}

.data-safety-panel .form-grid {
  align-items: end;
}

.data-safety-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.data-safety-strip span {
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 88px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, var(--surface), rgba(248, 250, 252, 0.8)),
    var(--surface-soft);
  box-shadow: var(--shadow-xs);
}

.data-safety-strip .app-icon {
  width: 20px;
  height: 20px;
  color: var(--brand-dark);
}

.data-safety-strip strong {
  font-size: 1.1rem;
  line-height: 1;
}

.data-safety-strip small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.wide-panel {
  grid-column: 1 / -1;
}

.report-card {
  display: grid;
  gap: var(--space-2);
  min-height: 140px;
}

.report-card > .app-icon {
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 100;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 8px;
  color: #fff;
  background: #111827;
  font-size: 0.75rem;
  font-weight: 800;
}

.color-swatch {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
}

@media (max-width: 1180px) {
  :root {
    --sidebar: 84px;
  }

  body {
    padding: 10px;
  }

  .app-shell {
    height: calc(100vh - 20px);
  }

  .sidebar {
    height: 100%;
    min-height: 0;
    padding: 18px 12px;
    align-items: center;
  }

  .brand {
    justify-content: center;
  }

  .brand span,
  .nav-item em,
  .profile-card span,
  .upgrade-card {
    display: none;
  }

  .nav-item {
    justify-content: center;
    width: 48px;
    padding: 8px;
  }

  .nav-item span {
    background: transparent;
  }

  .profile-card {
    padding: 6px;
  }

  .profile-card::before,
  .profile-card::after {
    display: none;
  }

  .workspace {
    --workspace-pad-x: 24px;
    --workspace-pad-y: 24px;
    padding: 24px;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  .dashboard-grid {
    gap: 12px;
  }

  .chart-wrap {
    min-height: 220px;
  }

  .line-chart {
    height: 220px;
  }

  .insight-grid,
  .settings-summary {
    grid-template-columns: 1fr;
  }

  .health-strip,
  .report-hero-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split-layout,
  .invoice-workspace-grid {
    grid-template-columns: 1fr;
  }

  .invoice-builder-shell {
    grid-template-columns: 1fr;
  }

  .invoice-draft-panel {
    position: static;
  }

  .invoice-preview-panel {
    position: static;
    max-height: none;
  }

  .invoice-history-panel {
    max-height: none;
  }

  .invoice-history-panel #invoiceListMount {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .client-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .template-preview-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-toolbar {
    flex-wrap: wrap;
  }

  .toolbar-search {
    flex: 1 1 100%;
  }

  .client-table .data-row {
    grid-template-columns: minmax(180px, 1.3fr) minmax(120px, 0.8fr) minmax(112px, 0.75fr) minmax(96px, 0.64fr) minmax(92px, 0.6fr) 44px;
  }

  .service-table .data-row {
    grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.5fr) 100px 80px 96px 44px;
  }

  .service-table .data-row span:nth-child(5),
  .service-table .data-head span:nth-child(5) {
    display: none;
  }

  .payment-table .data-row {
    grid-template-columns: minmax(130px, 0.9fr) minmax(160px, 1fr) 130px 120px 110px;
  }

  .payment-table .data-row span:nth-child(4),
  .payment-table .data-head span:nth-child(4) {
    display: none;
  }

  .client-table .data-row span:nth-child(6),
  .client-table .data-row span:nth-child(7),
  .client-table .data-head span:nth-child(6),
  .client-table .data-head span:nth-child(7) {
    display: none;
  }

  .item-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
  }

  .item-row.header {
    display: none;
  }

  .item-row label span {
    display: block;
  }
}

@media (max-width: 1320px) and (min-width: 1181px) {
  .workspace {
    padding: 24px;
  }

  .client-table .data-row {
    grid-template-columns: minmax(180px, 1.45fr) minmax(120px, 0.8fr) minmax(112px, 0.74fr) minmax(92px, 0.6fr) minmax(96px, 0.62fr) minmax(88px, 0.56fr) 44px;
  }

  .client-table .data-row span:nth-child(7),
  .client-table .data-head span:nth-child(7) {
    display: none;
  }
}

@media (max-width: 860px) {
  html {
    height: auto;
  }

  body {
    height: auto;
    min-height: 100vh;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.auth-pending {
    padding: 12px;
  }

  .auth-screen {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .auth-brand-panel {
    padding: 22px;
  }

  .auth-brand-panel h1 {
    font-size: 1.9rem;
  }

  .auth-benefits {
    grid-template-columns: 1fr;
  }

  .auth-card {
    align-self: stretch;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    display: block;
    height: auto;
    min-height: 100vh;
    padding: 22px 16px 128px;
    overflow: visible;
  }

  .workspace.topbar-hidden .topbar {
    margin-bottom: 18px;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .content {
    min-height: 0;
    overflow: visible;
    padding: 0;
  }

  .topbar {
    position: static;
    align-items: stretch;
    grid-template-columns: 1fr;
    padding: 14px;
    margin-bottom: 14px;
  }

  .topbar-actions {
    grid-template-columns: minmax(0, 1fr) auto 42px;
    justify-content: stretch;
  }

  .topbar-actions .primary-button {
    white-space: nowrap;
  }

  .global-search {
    width: 100%;
  }

  .user-menu {
    display: none;
  }

  .metric-grid,
  .insight-grid,
  .settings-summary,
  .health-strip,
  .report-hero-grid,
  .data-safety-strip {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(232px, 72vw);
    grid-template-columns: none;
    gap: 10px;
    margin-right: -8px;
    margin-left: -8px;
    padding: 0 8px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-padding-inline: 24px;
    scroll-behavior: smooth;
    scroll-snap-type: inline proximity;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  .metric-grid::-webkit-scrollbar,
  .insight-grid::-webkit-scrollbar,
  .settings-summary::-webkit-scrollbar,
  .health-strip::-webkit-scrollbar,
  .report-hero-grid::-webkit-scrollbar,
  .data-safety-strip::-webkit-scrollbar {
    display: none;
  }

  .metric-grid::after,
  .insight-grid::after,
  .settings-summary::after,
  .health-strip::after,
  .report-hero-grid::after,
  .data-safety-strip::after {
    display: none;
  }

  .metric-grid > *,
  .insight-grid > *,
  .settings-summary > *,
  .health-strip > *,
  .report-hero-grid > *,
  .data-safety-strip > * {
    scroll-snap-align: center;
    scroll-snap-stop: normal;
  }

  .insight-card,
  .health-strip section,
  .report-spotlight,
  .data-safety-strip span {
    min-height: 92px;
  }

  .carousel-controls {
    display: flex;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dashboard-hero > div:first-child,
  .hero-summary-card {
    border-radius: 16px;
  }

  .dashboard-hero > div:first-child {
    padding: 15px;
  }

  .dashboard-hero h2 {
    font-size: 1.2rem;
  }

  .metric-card {
    min-height: auto;
    padding: 15px;
  }

  .metric-card strong {
    font-size: 1.25rem;
  }

  .chart-wrap {
    min-height: 204px;
  }

  .line-chart {
    height: 204px;
  }

  .donut-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .client-grid,
  .settings-grid,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .template-preview-row,
  .settings-tab-panels .template-preview-row,
  .data-safety-panel .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .settings-tabs::-webkit-scrollbar {
    display: none;
  }

  .settings-tab {
    flex: 0 0 auto;
  }

  .settings-tab-panels,
  .settings-tabs {
    max-width: none;
  }

  .page-section-header,
  .data-toolbar,
  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .compact-control,
  .segmented-control {
    width: 100% !important;
    max-width: none;
  }

  .compact-control {
    flex-basis: 100%;
    min-width: 0;
  }

  .segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented-control button {
    width: auto;
    min-width: 0;
  }

  .data-table {
    display: grid;
    gap: var(--space-3);
    border: 0;
    background: transparent;
  }

  .table-grid,
  .recent-invoice-table {
    display: grid;
    gap: var(--space-3);
  }

  .data-row,
  .client-table .data-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-height: auto;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .data-head {
    display: none !important;
  }

  .service-table .data-row,
  .payment-table .data-row {
    grid-template-columns: 1fr;
  }

  .data-row > span,
  .data-row > strong,
  .table-row > span,
  .table-row > strong {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .data-row > [data-label],
  .table-row > [data-label] {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    gap: var(--space-3);
    min-height: 40px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    overflow-wrap: anywhere;
  }

  .data-row > [data-label]:last-child,
  .table-row > [data-label]:last-child {
    border-bottom: 0;
  }

  .data-row > [data-label]::before,
  .table-row > [data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .data-row > .client-identity[data-label] {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .data-row > .client-identity[data-label]::before {
    padding-top: 10px;
  }

  .data-row > [data-label] > .status-badge,
  .data-row > [data-label].status-badge,
  .table-row > [data-label] > .status-badge {
    margin-left: auto;
  }

  .data-row > .row-actions[data-label],
  .table-row > .row-actions[data-label] {
    justify-content: space-between;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .client-contact-grid {
    grid-template-columns: 1fr;
  }

  .client-quick-actions,
  .client-quick-actions button {
    width: 100%;
  }

  .service-table .data-row span:nth-child(5),
  .payment-table .data-row span:nth-child(4) {
    display: block;
  }

  .client-table .data-row span:nth-child(6),
  .client-table .data-row span:nth-child(7) {
    display: inline-flex;
  }

  .row-actions {
    justify-content: flex-end;
  }

  .action-menu div {
    left: auto;
    right: 0;
    max-width: calc(100vw - 48px);
  }

  .table-row {
    grid-template-columns: 1fr !important;
    gap: 0;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .due-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
  }

  .due-row > strong {
    justify-self: start;
  }

  .table-row.header,
  .recent-invoice-table .table-row.header {
    display: none !important;
  }

  .recent-invoice-table .table-row {
    grid-template-columns: 1fr !important;
    gap: 0;
    min-height: auto;
  }

  .recent-invoice-table .table-row > [data-label] {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    gap: var(--space-3);
  }

  .recent-invoice-table .invoice-cell strong,
  .recent-invoice-table .invoice-cell small,
  .recent-invoice-table .table-row > strong,
  .recent-invoice-table .invoice-cell[data-label="Due"] strong {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .invoice-list-table .table-row {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 4px 14px;
  }

  .invoice-queue-card {
    grid-template-columns: 28px minmax(0, 1fr) 40px;
    align-items: start;
  }

  .invoice-queue-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-queue-meta {
    grid-column: 2 / 3;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .invoice-queue-card .row-actions {
    grid-column: 3;
    grid-row: 1;
  }

  .invoice-cell strong,
  .invoice-cell small {
    white-space: normal;
  }

  .amount-cell {
    text-align: left;
  }

  .invoice-preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .invoice-preview-toolbar .card-actions,
  .invoice-preview-toolbar .card-actions button {
    width: 100%;
  }

  .preview-stage {
    padding: 0;
    overflow: visible;
    background: transparent;
  }

  .invoice-preview-panel .preview-sheet {
    max-width: none;
    padding: 20px 14px;
  }

  .preview-head,
  .bill-grid,
  .preview-footer {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .invoice-title {
    text-align: left;
  }

  .preview-sheet {
    padding: 22px 16px;
  }

  .preview-table,
  .preview-table thead,
  .preview-table tbody,
  .preview-table tr,
  .preview-table td {
    display: block;
    width: 100%;
  }

  .preview-table thead {
    display: none;
  }

  .preview-table tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
  }

  .preview-table td {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
  }

  .preview-table td:last-child {
    border-bottom: 0;
    text-align: left;
  }

  .preview-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .invoice-workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-inline: 18px;
  }

  .invoice-form-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .draft-save-state {
    align-self: flex-start;
  }

  .preview-payment-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-panel {
    max-height: calc(100vh - 18px);
  }

  .modal {
    width: min(720px, calc(100vw - 18px));
  }

  #detailModal {
    width: min(760px, calc(100vw - 18px));
  }

  .modal-header,
  .modal-actions,
  #invoiceFormBody,
  #clientFormBody,
  #serviceFormBody,
  #paymentFormBody {
    padding-left: 18px;
    padding-right: 18px;
  }

  .mobile-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr 1fr 58px 1fr 1fr;
    align-items: center;
    min-height: 70px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  .modal-actions {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .toast-viewport {
    top: auto;
    right: 12px;
    bottom: 94px;
    left: 12px;
    width: auto;
  }

  body.dark-mode .mobile-nav {
    background: rgba(17, 24, 39, 0.94);
  }

  .mobile-nav-item {
    display: grid;
    place-items: center;
    gap: 2px;
    min-height: 52px;
    border-radius: 14px;
    font-size: 0.72rem;
    font-weight: 900;
  }

  .mobile-nav-item span {
    font-size: 1rem;
  }

  .mobile-nav-item .app-icon,
  .mobile-add-button .app-icon {
    margin: 0 auto;
  }

  .topbar-popover,
  .notification-popover {
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    width: 100%;
  }

  .mobile-nav-item.active {
    color: var(--brand-dark);
    background: var(--brand-soft);
  }

  .mobile-add-button {
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.28);
    font-size: 1.8rem;
    line-height: 1;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 12px 10px 124px;
  }

  body.auth-pending {
    padding: 8px;
  }

  .auth-brand-panel,
  .auth-card {
    border-radius: 20px;
  }

  .auth-brand-panel {
    padding: 18px;
  }

  .auth-brand-panel h1 {
    font-size: 1.52rem;
  }

  .auth-card {
    padding: 12px;
  }

  h1 {
    font-size: 1.24rem;
    line-height: 1.12;
  }

  h2 {
    font-size: 0.94rem;
  }

  #pageSubtitle {
    margin-top: 4px;
    font-size: 0.78rem;
  }

  .breadcrumb {
    margin-bottom: 3px;
    font-size: 0.68rem;
  }

  .topbar {
    gap: 10px;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 16px;
  }

  .topbar-actions,
  .global-search,
  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .global-search,
  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button,
  .icon-button {
    min-height: 38px;
    border-radius: 11px;
  }

  .topbar-popover {
    position: static;
    width: 100%;
  }

  .icon-button {
    flex: 0 0 44px;
  }

  .metric-grid,
  .insight-grid,
  .settings-summary,
  .health-strip,
  .report-hero-grid,
  .data-safety-strip {
    grid-auto-columns: minmax(214px, 82vw);
    gap: 9px;
    margin-right: -6px;
    margin-left: -6px;
    padding-right: 6px;
    padding-left: 6px;
    scroll-padding-inline: 18px;
  }

  .carousel-controls {
    gap: 7px;
    margin: -4px 0 8px;
  }

  .carousel-button {
    width: 28px;
    height: 28px;
  }

  .carousel-dots span {
    width: 4px;
    height: 4px;
  }

  .carousel-dots span.active {
    width: 14px;
  }

  .dashboard-hero,
  .insight-grid,
  .health-strip,
  .dashboard-grid,
  .settings-summary {
    gap: 10px;
  }

  .dashboard-hero > div:first-child,
  .hero-summary-card,
  .metric-card,
  .panel,
  .table-card,
  .form-card {
    border-radius: 14px;
  }

  .metric-card {
    min-height: auto;
    padding: 12px;
  }

  .metric-card strong {
    margin-top: 10px;
    font-size: 1.18rem;
  }

  .metric-head {
    gap: 8px;
    font-size: 0.66rem;
  }

  .metric-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .trend {
    margin-top: 6px;
    font-size: 0.7rem;
  }

  .data-row,
  .client-table .data-row,
  .table-row,
  .invoice-list-table .table-row {
    padding: 3px 11px;
    border-radius: 14px;
  }

  .data-row > [data-label],
  .table-row > [data-label] {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    min-height: 38px;
    padding: 9px 0;
  }

  .data-row > [data-label]::before,
  .table-row > [data-label]::before {
    font-size: 0.68rem;
  }

  .table-grid,
  .data-table {
    gap: 8px;
  }

  .invoice-queue-card {
    grid-template-columns: 24px minmax(0, 1fr) 36px;
    gap: 9px;
    min-height: auto;
    padding: 10px;
    border-radius: 14px;
  }

  .invoice-queue-meta {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .invoice-queue-meta span {
    padding: 7px 8px;
  }

  .invoice-select-all {
    align-items: flex-start;
    flex-wrap: wrap;
    min-height: auto;
    padding: 8px;
  }

  .invoice-select-all strong {
    width: 100%;
    margin-left: 0;
  }

  .settings-tabs {
    gap: 6px;
    padding: 6px;
    border-radius: 15px;
  }

  .settings-tab {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .settings-tab .app-icon {
    width: 16px;
    height: 16px;
  }

  .invoice-workflow {
    grid-template-columns: 1fr;
  }

  .invoice-form-hero {
    padding: 13px;
    border-radius: 14px;
  }

  .invoice-form-hero h3 {
    font-size: 1rem;
  }

  .preview-payment-strip {
    gap: 7px;
  }

  .preview-payment-strip span {
    padding: 9px;
  }

  .invoice-meta-grid,
  .invoice-notes-grid {
    grid-template-columns: 1fr;
    padding: 12px;
    border-radius: 14px;
  }

  .item-editor {
    padding: 12px;
    border-radius: 14px;
  }

  .invoice-draft-panel {
    padding: 13px;
    border-radius: 14px;
  }

  .item-editor .section-header,
  .item-editor .card-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .item-editor .card-actions,
  .item-editor .card-actions button,
  .item-editor .compact-control {
    width: 100% !important;
    max-width: none;
  }

  .filters,
  .filters .input,
  .filters .select {
    width: 100%;
  }

  .invoice-card-top,
  .invoice-card-bottom,
  .panel-header,
  .section-header,
  .table-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .item-row {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 10px;
  }

  .preview-sheet {
    padding: 16px 12px;
    border-radius: 14px;
  }

  .preview-head,
  .bill-grid,
  .preview-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .invoice-title {
    text-align: left;
  }

  .preview-meta-grid span {
    justify-content: flex-start;
  }

  .total-due {
    min-width: 0;
  }

  .modal {
    width: 100vw;
    max-height: 100vh;
  }

  .modal-panel {
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .modal-header,
  .modal-actions,
  #invoiceFormBody,
  #clientFormBody,
  #serviceFormBody,
  #paymentFormBody {
    padding-left: 14px;
    padding-right: 14px;
  }

  .modal-header,
  .modal-actions {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .confirm-modal {
    width: calc(100vw - 24px);
  }

  .confirm-modal .modal-panel {
    min-height: auto;
    border-radius: 20px;
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-actions .secondary-button {
    margin-right: 0;
  }

  .modal-actions button {
    width: 100%;
  }

  .detail-grid {
    padding: 12px;
  }

  .detail-card {
    padding: 13px;
  }

  .activity-item {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .activity-item > span {
    width: 30px;
    height: 30px;
  }

  .template-preview-row,
  .settings-tab-panels .template-preview-row {
    grid-template-columns: 1fr;
  }

  .data-safety-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .data-safety-strip span {
    min-height: 82px;
    padding: 11px;
  }

  .data-safety-strip {
    grid-template-columns: none;
  }

  .insight-card,
  .health-strip section,
  .report-spotlight {
    padding: 11px;
  }

  .insight-card > .app-icon,
  .health-strip span,
  .report-spotlight > .app-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  .insight-card strong,
  .report-spotlight strong {
    font-size: 1.02rem;
  }

  .business-profile-preview {
    align-items: flex-start;
  }

  .business-profile-preview b {
    align-self: flex-start;
  }

  .mobile-nav {
    left: 8px;
    right: 8px;
    bottom: 8px;
    min-height: 62px;
    padding: 6px;
    border-radius: 17px;
  }

  .mobile-add-button {
    width: 50px;
    height: 50px;
  }

  .mobile-nav-item {
    min-height: 48px;
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .metric-grid,
  .insight-grid,
  .settings-summary,
  .health-strip,
  .report-hero-grid,
  .data-safety-strip {
    scroll-behavior: auto;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .mobile-nav,
  .mobile-more-menu,
  .toolbar,
  .panel:not(.printable-panel),
  .table-card,
  .form-card,
  .modal {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .content,
  .view.active {
    display: block;
    padding: 0;
  }

  .preview-sheet {
    box-shadow: none;
    border: 0;
    max-width: none;
    padding: 0;
  }

  .preview-sheet.template-executive .preview-head {
    color: #111827;
    background: #fff;
    border: 1px solid #e5e7ef;
  }
}
