/*
  Unified interface layer.
  Keep role differences in data and navigation; keep shared controls, panels,
  cards, tables, and mobile shell on one visual system.
*/

:root {
  --bg: #eef3f2;
  --surface: #ffffff;
  --surface-raised: #fbfdfc;
  --surface-muted: #f3f7f6;
  --ink: #17201f;
  --ink-soft: #334240;
  --muted: #697371;
  --line: #d5dfdc;
  --line-strong: #b8c7c3;
  --primary: #0b6f68;
  --primary-dark: #084e49;
  --primary-soft: #dcefed;
  --accent: #365caa;
  --accent-soft: #e5ecff;
  --warn: #b45309;
  --warn-soft: #fff2cf;
  --danger: #b91c1c;
  --danger-soft: #fde2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 0 rgba(20, 32, 31, 0.04), 0 8px 22px rgba(20, 32, 31, 0.06);
  --shadow-md: 0 18px 38px rgba(20, 32, 31, 0.11);
  --shadow: var(--shadow-md);
  --page-gutter: 24px;
  --page-gap: 22px;
  --mobile-bottom-nav-space: calc(71px + env(safe-area-inset-bottom));
  color-scheme: light;
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
  letter-spacing: 0;
}

html,
body,
#app {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(circle at 72% -8%, rgba(11, 111, 104, 0.08), transparent 28%), var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

.app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.main {
  min-width: 0;
  min-height: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 160px);
}

.sidebar {
  background: linear-gradient(180deg, #f9fcfb 0%, #eef5f3 100%);
  border-right-color: var(--line-strong);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.82) inset;
}

.brand-lockup {
  min-height: 60px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  box-shadow: 0 8px 18px rgba(11, 95, 89, 0.18);
}

.nav {
  min-width: 0;
}

.nav-group-label {
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-button {
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  font-weight: 700;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.nav-button:hover {
  background: #e8f0ee;
  transform: translateX(1px);
}

.nav-button.active {
  background: #d8ece9;
  border-color: #a9d5cf;
  box-shadow: inset 3px 0 0 var(--primary);
  color: var(--primary-dark);
}

.nav-badge {
  position: absolute;
  top: -7px;
  right: -9px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border: 1px solid var(--surface);
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.topbar {
  background: rgba(253, 255, 254, 0.94);
  border-bottom-color: var(--line-strong);
  box-shadow: 0 8px 26px rgba(20, 32, 31, 0.05);
  backdrop-filter: blur(12px);
}

.page-title {
  letter-spacing: 0;
}

.topbar-meta {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.content {
  gap: var(--page-gap);
  padding: var(--page-gutter);
}

.content-band {
  gap: 14px;
}

.section-heading {
  align-items: end;
  min-height: 34px;
}

.section-heading h2 {
  margin: 2px 0 0;
  font-size: 19px;
  letter-spacing: 0;
}

.section-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-shell {
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.06), transparent 34%), var(--bg);
}

.auth-panel {
  width: min(860px, 100%);
  grid-template-columns: minmax(240px, 0.72fr) minmax(320px, 1fr);
  border-color: var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.auth-brand {
  min-height: 0;
  padding: 34px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbfb, #edf5f4);
  color: var(--ink);
  overflow: hidden;
}

.auth-brand::after,
.auth-kicker {
  display: none !important;
}

.auth-brand h1 {
  max-width: 8ch;
  margin: 0 0 10px;
  color: var(--ink);
  font-size: clamp(30px, 3.8vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.auth-form {
  padding: 34px;
  background: var(--surface);
}

.filter-bar,
.stat-card,
.customer-card,
.notice-card,
.record-panel,
.staff-card,
.sales-summary-card,
.sales-profile-panel,
.sales-data-panel,
.sales-customer-panel,
.excel-panel,
.payment-code-panel,
.detail-item,
.preview-item,
.payment-preview,
.auto-field,
.modal {
  border-color: var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.filter-bar {
  padding: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.stat-card {
  min-height: 118px;
  background: linear-gradient(180deg, #fff 0%, #f9fbfa 100%);
  position: relative;
  overflow: hidden;
}

.ops-stats-grid .stat-card.exposure-card {
  grid-column: 1 / -1;
  min-height: 82px;
  display: grid;
  gap: 6px;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.ops-stats-grid .stat-card.exposure-card strong {
  width: 100%;
  text-align: center;
  font-size: clamp(22px, 2.8vw, 32px);
  overflow-wrap: normal;
  white-space: nowrap;
}

.stat-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), rgba(11, 111, 104, 0.12));
}

.stat-card strong,
.summary-lines strong,
.sales-data-cell strong,
td {
  font-variant-numeric: tabular-nums;
}

.sales-summary-grid {
  gap: 14px;
}

.sales-summary-card {
  padding: 18px;
  overflow: hidden;
}

.sales-summary-button {
  width: 100%;
  border: 1px solid var(--line-strong);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.sales-summary-button:hover {
  border-color: #99cfc8;
  transform: translateY(-1px);
}

.donut {
  background: conic-gradient(var(--primary) calc(var(--percent) * 1%), #dfe9e6 0);
  box-shadow: inset 0 0 0 1px rgba(11, 111, 104, 0.08);
}

.donut-inner {
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px #cfdfdb;
}

.sales-home {
  gap: 16px;
}

.sales-profile-panel,
.sales-data-panel,
.sales-customer-panel {
  border: 1px solid var(--line-strong);
  overflow: hidden;
}

.sales-profile-panel {
  min-height: 164px;
}

.sales-data-cell {
  background: linear-gradient(180deg, #fff, #fbfdfc);
}

.sales-data-cell.overdue strong {
  color: var(--danger);
}

.sales-table-head {
  background: var(--surface-raised);
}

.customer-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.customer-card {
  position: relative;
  min-height: 318px;
  background: #fff;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.customer-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.customer-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--primary);
}

.customer-card[data-status="overdue"]::before {
  background: var(--danger);
}

.customer-card[data-status="today"]::before,
.customer-card[data-status="soon"]::before {
  background: var(--warn);
}

.customer-card[data-status="settled"]::before {
  background: var(--accent);
}

.customer-card.inactive-card {
  opacity: 1;
  background: #fffafa;
  border-color: #e7b8b8;
}

.customer-card.inactive-card::before,
.customer-card[data-status="inactive"]::before {
  background: #b26868;
}

.customer-card .card-head,
.card-actions,
.modal-head,
.modal-foot {
  background: var(--surface-raised);
}

.customer-card .card-head {
  padding-left: 20px;
}

.customer-card h3 {
  font-size: 19px;
  letter-spacing: 0;
}

.phone-line {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.card-meta-line,
.metric,
.detail-item,
.preview-item,
.payment-preview,
.auto-field {
  border-color: var(--line);
  background: var(--surface-raised);
}

.bar-copy strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #edf4f2;
}

.bar-fill.principal {
  background: linear-gradient(90deg, #7fcaa7, #2b9a78);
}

.bar-fill.interest {
  background: linear-gradient(90deg, #f0c85f, #c98115);
}

.due-line {
  border-top-style: dashed;
}

.card-actions .btn[data-action="open-payment"],
.staff-settings-btn,
.audit-table summary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 820;
}

.card-actions .btn[data-action="open-payment"]:hover,
.staff-settings-btn:hover,
.audit-table summary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.pill {
  border: 1px solid transparent;
  font-weight: 830;
}

.pill.ok {
  border-color: #b7e4c8;
}

.pill.soon,
.pill.today {
  border-color: #efd69b;
}

.pill.overdue,
.pill.danger {
  border-color: #efb5b5;
}

.pill.settled {
  border-color: #c7d4ff;
}

.record-panel.table-wrap,
.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

table {
  min-width: max(760px, 100%);
  table-layout: auto;
}

.audit-table {
  min-width: max(860px, 100%);
}

.excel-panel table,
.payment-record-table {
  min-width: max(920px, 100%);
}

.excel-panel .staff-management-table {
  min-width: 1080px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf4f2;
  color: #3d4d4a;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  color: var(--ink-soft);
  overflow-wrap: normal;
  word-break: normal;
}

td:nth-child(3),
td:nth-child(4),
td:nth-child(5),
td:nth-child(6) {
  white-space: nowrap;
}

tbody tr:hover td,
.selectable-table tbody tr.row-selected td {
  background: #f7fbfa;
}

.audit-table details {
  display: inline-grid;
  min-width: max-content;
  padding: 0;
  border: 0;
  background: transparent;
}

.audit-table summary {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: var(--radius-md);
  white-space: nowrap;
  list-style: none;
}

.audit-table summary::-webkit-details-marker {
  display: none;
}

pre {
  overflow-x: auto;
  white-space: pre-wrap;
}

.modal-backdrop {
  backdrop-filter: blur(5px);
}

.payment-code-panel {
  background: linear-gradient(180deg, #fbfdfc, #f3f8f6);
  padding: 14px;
}

.btn {
  border-radius: var(--radius-md);
  font-weight: 760;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(20, 32, 31, 0.08);
}

.btn:disabled {
  transform: none;
  box-shadow: none;
}

button:focus-visible,
.btn:focus-visible,
.nav-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(11, 111, 104, 0.26);
  outline-offset: 2px;
}

.theme-settings-panel {
  max-width: 760px;
}

.theme-setting-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 58px;
  padding: 10px 0;
}

.theme-toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.theme-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-toggle-track {
  position: relative;
  width: 104px;
  height: 36px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-items: center;
}

.theme-toggle-track i,
.theme-toggle-track svg {
  width: 16px;
  height: 16px;
  z-index: 1;
  color: var(--muted);
}

.theme-toggle-thumb {
  position: absolute;
  left: 3px;
  top: 50%;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(20, 32, 31, 0.16);
  transform: translateY(-50%);
  transition: transform 160ms ease, background 160ms ease;
}

.theme-toggle input:checked + .theme-toggle-track .theme-toggle-thumb {
  transform: translate(50px, -50%);
  background: var(--primary);
}

.theme-toggle input:checked + .theme-toggle-track .theme-icon-moon,
.theme-toggle input:not(:checked) + .theme-toggle-track .theme-icon-sun {
  color: var(--ink);
}

.theme-toggle input:focus-visible + .theme-toggle-track {
  outline: 3px solid rgba(11, 111, 104, 0.26);
  outline-offset: 2px;
}

.theme-mode-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

:root[data-theme="dark"] {
  --bg: #121918;
  --surface: #1b2422;
  --surface-raised: #202a28;
  --surface-muted: #24302e;
  --ink: #edf5f3;
  --ink-soft: #c8d4d1;
  --muted: #98a8a4;
  --line: #31413d;
  --line-strong: #465c56;
  --primary: #4ccbc0;
  --primary-dark: #8be0d8;
  --primary-soft: #173f3b;
  --accent: #9aa8ff;
  --accent-soft: #252b4c;
  --warn: #f3b554;
  --warn-soft: #3a2b12;
  --danger: #fca5a5;
  --danger-soft: #3a1d1d;
  --ok: #7ddf9f;
  --ok-soft: #173523;
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.03), 0 10px 26px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 18px 42px rgba(0, 0, 0, 0.32);
  color-scheme: dark;
}

:root[data-theme="dark"] body {
  background: radial-gradient(circle at 72% -8%, rgba(76, 203, 192, 0.08), transparent 30%), var(--bg);
}

:root[data-theme="dark"] .app-shell,
:root[data-theme="dark"] .auth-shell,
:root[data-theme="dark"] .main {
  background: var(--bg);
}

:root[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #18211f 0%, #121918 100%);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.04) inset;
}

:root[data-theme="dark"] .topbar {
  background: rgba(16, 23, 22, 0.96);
  border-bottom-color: rgba(139, 224, 216, 0.22);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.24);
}

:root[data-theme="dark"] .nav-button:hover {
  background: var(--surface-muted);
}

:root[data-theme="dark"] .nav-button.active {
  background: var(--primary-soft);
  color: #9ce9e1;
  border-color: #2f6962;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .filter-bar,
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .customer-card,
:root[data-theme="dark"] .notice-card,
:root[data-theme="dark"] .record-panel,
:root[data-theme="dark"] .staff-card,
:root[data-theme="dark"] .sales-summary-card,
:root[data-theme="dark"] .sales-profile-panel,
:root[data-theme="dark"] .sales-data-panel,
:root[data-theme="dark"] .sales-customer-panel,
:root[data-theme="dark"] .excel-panel,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .modal-body,
:root[data-theme="dark"] .auth-form,
:root[data-theme="dark"] .auth-panel,
:root[data-theme="dark"]

:root[data-theme="dark"] .auth-brand,
:root[data-theme="dark"] .modal-head,
:root[data-theme="dark"] .modal-foot,
:root[data-theme="dark"] .customer-card .card-head,
:root[data-theme="dark"] .card-actions,
:root[data-theme="dark"] .sales-table-head,
:root[data-theme="dark"] th {
  background: var(--surface-raised);
  color: var(--ink);
}

:root[data-theme="dark"] .card-meta-line,
:root[data-theme="dark"] .metric,
:root[data-theme="dark"] .detail-item,
:root[data-theme="dark"] .preview-item,
:root[data-theme="dark"] .payment-preview,
:root[data-theme="dark"] .auto-field,
:root[data-theme="dark"] .sales-data-cell,
:root[data-theme="dark"] .payment-code-panel,
:root[data-theme="dark"] .empty-state {
  border-color: rgba(139, 224, 216, 0.18);
  background: var(--surface-muted);
  color: var(--ink-soft);
}

:root[data-theme="dark"] .sales-data-cell.overdue strong {
  color: #ff8686;
}

:root[data-theme="dark"] .btn {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  color: var(--ink);
}

:root[data-theme="dark"] .btn.primary,
:root[data-theme="dark"] .staff-settings-btn,
:root[data-theme="dark"] .card-actions .btn[data-action="open-payment"],
:root[data-theme="dark"] .audit-table summary {
  border-color: var(--primary);
  background: var(--primary);
  color: #071312;
}

:root[data-theme="dark"] .selectable-table tbody tr:hover td,
:root[data-theme="dark"] .selectable-table tbody tr.row-selected td {
  background: var(--surface-muted);
  color: var(--ink);
}

:root[data-theme="dark"] .customer-card.inactive-card {
  border-color: rgba(252, 165, 165, 0.62);
  background: linear-gradient(180deg, #3a2424 0%, #271b1b 100%);
}

:root[data-theme="dark"] .customer-card[data-status="soon"],
:root[data-theme="dark"] .customer-card[data-status="today"] {
  border-color: rgba(243, 181, 84, 0.58);
  background: linear-gradient(180deg, #33281b 0%, #211c15 100%);
}

@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sales-profile-panel {
    grid-template-columns: 1fr;
  }

  .sales-total-amount {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 0 0;
    justify-items: start;
    text-align: left;
  }

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

@media (max-width: 820px) {
  :root {
    --page-gutter: 18px 16px;
  }

  html,
  body,
  #app {
    width: 100%;
    height: 100%;
    min-height: 100dvh;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    width: 100%;
    min-height: 0;
    height: var(--mobile-bottom-nav-space);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: rgba(248, 252, 250, 0.98);
    box-shadow: 0 -12px 30px rgba(20, 32, 31, 0.12);
  }

  .brand-lockup,
  .sidebar-footer,
  .nav-group-label {
    display: none;
  }

  .nav {
    height: 58px;
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .nav-group {
    display: contents;
  }

  .nav-group + .nav-group {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .nav-button {
    flex: 0 0 86px;
    width: 86px;
    min-width: 86px;
    min-height: 56px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 5px 4px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
    transform: none;
  }

  .nav-button:hover {
    transform: none;
  }

  .nav-button.active {
    box-shadow: inset 0 -3px 0 var(--primary);
  }

  .main {
    height: calc(100dvh - var(--mobile-bottom-nav-space));
    max-height: calc(100dvh - var(--mobile-bottom-nav-space));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0;
  }

  .topbar {
    position: relative;
    top: auto;
    flex: 0 0 auto;
    z-index: 30;
    min-height: 56px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  }

  .topbar > div:first-child {
    min-width: 0;
    display: flex;
    align-items: center;
  }

  .page-title,
  .page-title.notice-title {
    min-height: 34px;
    display: flex;
    align-items: center;
    font-size: 20px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .topbar-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
  }

  .topbar-meta {
    display: grid;
    justify-items: end;
    gap: 1px;
    max-width: 128px;
    font-size: 10px;
    line-height: 1.15;
    text-align: right;
  }

  .topbar-meta span {
    max-width: 128px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-logout {
    min-height: 32px;
    padding: 0 8px;
    font-size: 11px;
    white-space: nowrap;
  }

  .content,
  .app-shell .content {
    flex: 1 1 0;
    min-height: 0;
    height: 0;
    align-content: start;
    grid-auto-rows: max-content;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    padding: var(--page-gutter);
    padding-bottom: calc(138px + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(128px + env(safe-area-inset-bottom));
  }

  .content > .content-band {
    align-self: start;
    align-content: start;
  }

  .content > .content-band:last-child {
    margin-bottom: 10px;
  }

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

  .sales-summary-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .notification-test-heading {
    min-height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
  }
}

@media (max-width: 760px) {
  .auth-shell {
    min-height: 100dvh;
    height: 100dvh;
    align-content: center;
    place-items: center;
    gap: 18px;
    padding: clamp(22px, 7dvh, 58px) 22px;
    overflow-y: auto;
    background: linear-gradient(180deg, #edf6f4 0%, #f7fbfa 100%);
  }

  .auth-panel {
    width: min(100%, 360px);
    max-width: 360px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .auth-brand {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: center;
  }

  .auth-brand::after,
  .auth-brand p {
    display: none !important;
  }

  .auth-brand h1 {
    max-width: none;
    margin: 0;
    font-size: 30px;
    line-height: 1.18;
    font-weight: 820;
  }

  .auth-form {
    width: 100%;
    padding: 0;
    background: transparent;
    overflow: visible;
  }

  #login-form {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  #login-form input,
  #login-form .btn.primary {
    min-height: 48px;
    width: 100%;
  }

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

  .filter-bar,
  .details-grid,
  .preview-grid,
  .payment-entry-grid,
  .form-grid,
  .form-grid.three,
  .loan-primary-grid,
  .assign-form,
  .settings-row,
  .theme-setting-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  :root {
    --page-gap: 18px;
  }

  .ops-summary-band {
    gap: 8px;
  }

  .ops-summary-band .section-heading h2 {
    font-size: 16px;
  }

  .ops-summary-band .section-kicker {
    font-size: 10px;
  }

  .ops-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .ops-stats-grid .stat-card {
    min-height: 58px;
    padding: 7px 5px;
    border-radius: var(--radius-sm);
  }

  .ops-stats-grid .stat-card span {
    font-size: 10px;
    line-height: 1.15;
  }

  .ops-stats-grid .stat-card strong {
    font-size: clamp(13px, 4vw, 17px);
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .ops-stats-grid .stat-card.exposure-card {
    grid-column: 1 / -1;
    min-height: 54px;
    gap: 6px;
    align-content: center;
    justify-items: center;
    text-align: center;
  }

  .ops-stats-grid .stat-card.exposure-card strong {
    text-align: center;
    font-size: clamp(18px, 6vw, 24px);
    overflow-wrap: normal;
    white-space: nowrap;
  }

  .sales-profile-panel {
    padding: 16px;
  }

  .sales-profile-main h2 {
    font-size: 22px;
  }

  .sales-total-amount strong {
    font-size: 26px;
  }

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

  .sales-data-cell,
  .sales-data-cell:nth-child(3n),
  .sales-data-cell:nth-child(2n) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .sales-summary-card {
    min-height: 118px;
    grid-template-columns: minmax(0, 1fr) 64px;
    padding: 12px;
  }

  .sales-summary-card h3 {
    font-size: 16px;
  }

  .donut {
    width: 62px;
    height: 62px;
  }

  .donut-inner {
    width: 44px;
    height: 44px;
    font-size: 13px;
  }

  .customer-card .card-head {
    padding-left: 17px;
  }

  .card-meta-line {
    display: grid;
    gap: 4px;
  }
}

.stats-grid.ops-stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
}

.stats-grid.ops-stats-grid .stat-card.exposure-card {
  grid-column: 1 / -1;
  justify-items: stretch;
  text-align: left;
}

.stats-grid.ops-stats-grid .stat-card.exposure-card span {
  width: 100%;
  justify-self: start;
  text-align: left;
}

.stats-grid.ops-stats-grid .stat-card.exposure-card strong {
  width: 100%;
  justify-self: center;
  text-align: center;
}

@media (max-width: 520px) {
  .stats-grid.ops-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .stats-grid.ops-stats-grid .stat-card.exposure-card span {
    text-align: left;
  }

  .stats-grid.ops-stats-grid .stat-card.exposure-card strong {
    text-align: center;
  }
}

.auth-form .auth-loading-state {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

:root[data-theme="dark"] .auth-panel {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

:root[data-theme="dark"] .auth-brand,
:root[data-theme="dark"] .auth-form {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

:root[data-theme="dark"] .auth-brand {
  border-right: 0;
  border-bottom: 0;
}
