:root {
  --bg: #f7f9fc;
  --ink: #111827;
  --muted: #64748b;
  --line: #e2e8f0;
  --panel: rgba(255, 255, 255, .86);
  --solid: #ffffff;
  --field: #ffffff;
  --accent: #0f766e;
  --accent-soft: #e9f7f5;
  --danger: #d91f45;
  --danger-soft: #fff0f3;
  --good: #087f5b;
  --good-soft: #ecfdf5;
  --warn: #b7791f;
  --gold: #b88918;
  --radius: 8px;
  --shadow: 0 14px 34px rgba(15, 23, 42, .08);
}

/* Compact mobile operations layer */
@media (max-width: 820px) {
  main {
    width: 100%;
    padding: 0 8px 18px;
  }

  .appbar {
    position: sticky;
    top: 0;
    z-index: 18;
    min-height: 52px;
    padding: 6px 8px;
    margin: 0 -8px 8px;
    border-radius: 0;
  }

  .home-brand img {
    width: 34px;
    height: 34px;
  }

  .home-brand strong {
    font-size: 14px;
  }

  .home-brand span,
  #dbStatus,
  .topbar p,
  .section-head p {
    font-size: 11px;
    line-height: 1.25;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    margin-bottom: 8px;
  }

  .topbar h2 {
    font-size: 22px;
    line-height: 1;
  }

  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    top: 52px;
    margin-bottom: 7px;
    padding: 5px 0;
  }

  .quick-actions button,
  .top-actions button,
  .section-head button,
  .ledger-tools button,
  .ledger-tools select,
  input,
  select {
    min-height: 36px;
    border-radius: 8px;
    font-size: 12px;
    padding: 7px 8px;
  }

  .kpi-grid,
  #dashboard .kpi-grid,
  #profileStats.kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 8px;
  }

  .kpi,
  .debt-card {
    min-height: 62px;
    padding: 9px 10px;
    border-radius: 8px;
  }

  .kpi span {
    font-size: 10px;
  }

  .kpi strong,
  .debt-card strong {
    font-size: 17px;
    line-height: 1.05;
  }

  .panel {
    padding: 10px;
    margin-bottom: 9px;
    border-radius: 8px;
  }

  .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .section-head h3 {
    font-size: 15px;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    margin-bottom: 8px;
  }

  .filters label,
  .ledger-tools label {
    gap: 3px;
    font-size: 10px;
  }

  .filters #clearFilters {
    grid-column: 1 / -1;
  }

  .ledger-tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
    margin: 8px 0;
    border-radius: 8px;
  }

  .ledger-tools label:nth-child(1),
  .ledger-tools label:nth-child(2) {
    grid-column: span 2;
  }

  .ledger-tools label:nth-child(3) {
    grid-column: 1 / -1;
  }

  .ledger-tools #applyLedger,
  .ledger-tools #statementStyle,
  .ledger-tools .export-menu {
    grid-column: span 2;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    margin: 7px 0;
  }

  .tab {
    min-height: 34px;
    padding: 6px 4px;
    font-size: 10px;
    border-radius: 8px;
  }

  .ledger-report .report-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    margin-bottom: 8px;
  }

  .report-period {
    display: flex;
    justify-content: space-between;
    text-align: left;
    gap: 8px;
  }

  .report-period b {
    font-size: 15px;
  }

  .mini-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 7px 0;
  }

  .mini-kpis span {
    display: grid;
    gap: 2px;
    padding: 7px;
    font-size: 10px;
  }

  .mini-kpis b {
    margin: 0;
    font-size: 12px;
  }

  .profit-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .profit-summary span {
    min-height: 42px;
    padding: 6px;
  }

  .profit-summary small {
    font-size: 8px;
  }

  .profit-summary b {
    font-size: 11px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 7px;
  }

  tr {
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--solid);
  }

  td {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 6px;
    padding: 3px 0;
    border: 0;
    font-size: 12px;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .sales-bill {
    padding: 8px;
    gap: 4px;
    border-radius: 8px;
  }

  .sales-bill-money {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .sales-bill-money em,
  .sales-bill-extra {
    font-size: 10px;
  }

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

  .choice-grid button {
    min-height: 74px;
    padding: 10px;
  }

  .choice-grid strong {
    font-size: 13px;
  }

  .choice-grid span {
    font-size: 10px;
  }
}

@media (max-width: 390px) {
  .profit-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

/* Mobile-first finishing polish for daily shop use */
.status-line,
#dbStatus {
  max-width: 68ch;
}

.sales-bill-list {
  align-content: start;
}

.sales-bill {
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.sales-bill:active {
  transform: scale(.992);
}

.sales-bill-money em {
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: 8px;
  padding: 6px 8px;
  background: color-mix(in srgb, var(--solid) 92%, var(--accent-soft));
}

.bill-item-grid span,
.bill-summary span,
.profit-summary span {
  min-width: 0;
}

.bill-item-grid b,
.bill-summary b,
.profit-summary b {
  overflow-wrap: anywhere;
}

.wa-tone-choice {
  margin-top: 8px;
}

.wa-tone-choice button {
  min-height: 42px;
}

.wa-tone-choice button.active {
  background: linear-gradient(135deg, var(--gold), #ffd35c);
  color: #111827;
  border-color: transparent;
  font-weight: 900;
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.area-block {
  display: grid;
  gap: 10px;
}

@media (max-width: 720px) {
  body {
    -webkit-text-size-adjust: 100%;
  }

  .app-shell {
    padding-inline: 10px;
  }

  .status-line,
  #dbStatus {
    font-size: 12px;
    line-height: 1.35;
  }

  .sales-report {
    display: grid;
    gap: 10px;
  }

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

  .profit-summary span {
    min-height: 46px;
    padding: 7px 8px;
    border-radius: 9px;
  }

  .profit-summary small {
    font-size: 9px;
  }

  .profit-summary b {
    font-size: 12px;
    line-height: 1.15;
  }

  .sales-bill-list {
    gap: 7px;
  }

  .sales-bill {
    padding: 8px;
    border-radius: 9px;
    gap: 5px;
  }

  .sales-bill-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sales-bill-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sales-bill-money {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .sales-bill-money em {
    display: grid;
    gap: 2px;
    padding: 5px 6px;
    font-size: 10px;
    line-height: 1.1;
  }

  .sales-bill-extra {
    display: none;
  }

  .modal-card {
    height: calc(100dvh - 20px);
    overflow: auto;
  }

  .modal-card .topbar h2 {
    font-size: 22px;
  }

  .bill-summary.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .bill-item {
    padding: 8px;
  }

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

@media (max-width: 390px) {
  .profit-summary,
  .sales-bill-money,
  .bill-summary.compact,
  .bill-item-grid {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 24px;
  }
}

body[data-theme="dark"] {
  --bg: #0b111b;
  --ink: #edf3fb;
  --muted: #9aa8ba;
  --line: #253143;
  --panel: rgba(17, 24, 39, .86);
  --solid: #101826;
  --field: #0c1422;
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, .12);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, .11);
  --good: #34d399;
  --good-soft: rgba(52, 211, 153, .11);
  --warn: #fbbf24;
  --gold: #f0c75e;
  --shadow: 0 18px 48px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, .07), transparent 310px),
    var(--bg);
  color: var(--ink);
  font-family: Segoe UI, Inter, Arial, sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

button, input, select { font: inherit; max-width: 100%; }

button, input[type="search"], input[type="date"], input[type="number"], select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  padding: 10px 13px;
  outline: none;
}

button {
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 70px;
  margin-bottom: 22px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.home-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.home-brand img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 4px 18px rgba(15, 23, 42, .16);
}

.home-brand > div {
  display: grid;
  gap: 2px;
}

.appbar strong { font-size: 17px; }
.appbar span { color: var(--muted); font-size: 13px; }
.appbar-actions { margin-left: auto; }

.back-btn {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--ink);
  font-weight: 800;
}

.icon-btn, .theme-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
}

.menu-icon {
  gap: 4px;
  align-content: center;
}

.menu-icon span {
  width: 17px;
  height: 2px;
  display: block;
  border-radius: 999px;
  background: var(--ink);
}

.theme-icon {
  position: relative;
}

.theme-icon::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  display: block;
}

.theme-icon::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--field);
  transform: translate(5px, -2px);
}

body[data-theme="dark"] .theme-icon::before {
  background: #fbbf24;
  box-shadow: 0 0 0 5px rgba(251, 191, 36, .16);
}

body[data-theme="dark"] .theme-icon::after {
  display: none;
}

.sidebar-shade {
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(15, 23, 42, .28);
  backdrop-filter: blur(2px);
}

.sidebar {
  position: fixed;
  z-index: 40;
  left: 16px;
  top: 16px;
  bottom: 16px;
  width: 274px;
  max-width: calc(100vw - 28px);
  transform: translateX(-320px);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--solid);
  box-shadow: var(--shadow);
  overflow: auto;
}

body.sidebar-open .sidebar { transform: translateX(0); }

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

.brand {
  cursor: pointer;
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 4px 18px rgba(15, 23, 42, .16);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

nav, .side-tools {
  display: grid;
  gap: 8px;
}

nav {
  align-content: start;
  overflow-y: auto;
  padding-right: 2px;
}

.submenu {
  display: grid;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.submenu button {
  text-align: left;
}

.cash-block {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--solid);
  border: 1px solid var(--line);
}

.cash-block label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.cash-block input {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border-radius: var(--radius);
  font-size: 12px;
}

.cash-block button,
.submenu > button {
  padding: 9px 10px;
  border-radius: var(--radius);
  text-align: center;
}

.nav-btn {
  text-align: left;
  background: transparent;
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
}

main {
  width: min(1160px, calc(100vw - 34px));
  margin: 0 auto;
  padding-bottom: 30px;
  min-width: 0;
}

.view { display: none; }
.view.active { display: block; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  min-width: 0;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.05;
}

.topbar p, .section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: min(440px, 100%);
}

input[type="search"] { width: min(440px, 100%); }

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

#dashboard .kpi-grid {
  grid-template-columns: minmax(240px, 440px);
}

.kpi, .panel, .table-wrap, .ledger-tools, .modal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.kpi {
  min-height: 104px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.debt-card {
  min-height: 118px;
}

.debt-card strong {
  font-size: 30px;
}

.kpi.action { cursor: pointer; }
.kpi.action:hover { border-color: color-mix(in srgb, var(--accent) 42%, var(--line)); }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { display: block; font-size: 27px; }
.kpi.danger { background: color-mix(in srgb, var(--danger-soft) 55%, var(--panel)); }
.kpi.good { background: color-mix(in srgb, var(--good-soft) 55%, var(--panel)); }

.panel {
  padding: 18px;
  margin-bottom: 16px;
  overflow: hidden;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h3 {
  margin: 0;
  font-size: 19px;
}

.warning-box {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--warn) 36%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
}

.warning-box span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.quick-actions button {
  min-height: 44px;
  font-weight: 800;
  background: var(--solid);
}

.filters, .ledger-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
  align-items: end;
}

.ledger-tools {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  padding: 12px;
  overflow: visible;
}

.export-menu {
  position: relative;
}

.export-menu > button {
  width: 100%;
}

#exportOptions {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 12;
  min-width: 170px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--solid);
  box-shadow: var(--shadow);
}

#exportOptions[hidden] {
  display: none;
}

#exportOptions button {
  text-align: left;
}

.pull-refresh {
  height: 0;
  overflow: hidden;
  opacity: 0;
  text-align: center;
  color: var(--muted);
  transition: height .18s ease, opacity .18s ease;
}

.pull-refresh.ready,
.pull-refresh.active {
  height: 32px;
  opacity: 1;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.summary-line {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: 0 0 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.summary-line strong, .summary-line b { color: var(--ink); }
.table-wrap {
  overflow: auto;
  max-width: 100%;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: normal;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--solid);
  font-size: 12px;
}

th.sortable, th[data-customer-sort] {
  cursor: pointer;
  user-select: none;
}

th.sortable::after, th[data-customer-sort]::after {
  content: " sort";
  color: var(--muted);
  font-size: 10px;
}

th.sortable.up::after,
th[data-customer-sort].up::after { content: " asc"; color: var(--accent); }
th.sortable.down::after,
th[data-customer-sort].down::after { content: " desc"; color: var(--accent); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }

.money { font-weight: 800; }
.dr { color: var(--danger); }
.cr { color: var(--good); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tab.active {
  color: white;
  font-weight: 800;
  border-color: var(--accent);
  background: var(--accent);
}

.cash-sale-panel {
  display: grid;
  gap: 8px;
  padding: 26px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 84%, transparent), var(--panel)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.cash-sale-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.cash-sale-panel h3 {
  margin: 8px 0 6px;
  font-size: clamp(38px, 7vw, 76px);
  line-height: .95;
  letter-spacing: 0;
}

.cash-sale-panel p {
  margin: 0;
  color: var(--muted);
}

.cash-sale-meta {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.cash-sale-meta span {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.cash-sale-meta b {
  color: var(--ink);
}

.empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.empty.small {
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.bars {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.bar {
  display: grid;
  grid-template-columns: 80px 1fr 110px;
  gap: 10px;
  align-items: center;
}

.fill {
  height: 10px;
  border-radius: 99px;
  background: var(--accent);
}

.ledger-report .report-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.ledger-report h3 { margin: 0 0 8px; }
.ledger-report p { margin: 6px 0 0; color: var(--muted); }
.report-period { text-align: right; display: grid; align-content: start; gap: 6px; }
.report-period span { color: var(--muted); }
.report-period b { font-size: 22px; }

.mini-kpis {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 14px;
}

.mini-kpis span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--muted);
  background: var(--solid);
}

.mini-kpis b { color: var(--ink); margin-left: 6px; }

.sales-report .table-wrap table {
  min-width: 1040px;
}

.sales-report .mini-kpis span {
  flex: 1 1 180px;
}

.profit-summary {
  display: grid;
  grid-template-columns: repeat(7, minmax(82px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.profit-summary span {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--solid);
}

.profit-summary small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.profit-summary b {
  font-size: 14px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.profit-summary .good b { color: var(--good); }
.profit-summary .danger b { color: var(--danger); }

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

.sales-bill {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--solid);
  box-shadow: none;
}

.sales-bill-top,
.sales-bill-main,
.sales-bill-money {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.sales-bill-top b,
.sales-bill-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-bill-top strong {
  color: var(--good);
  white-space: nowrap;
}

.sales-bill-main small,
.sales-bill-extra {
  color: var(--muted);
  font-size: 12px;
}

.sales-bill-money em {
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.sales-bill-money em:last-child {
  color: var(--good);
}

.sales-bill.loss .sales-bill-money em:last-child {
  color: var(--danger);
}

.sales-bill-extra {
  overflow-wrap: anywhere;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(8px);
  isolation: isolate;
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(1080px, 96vw);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  background: var(--solid);
  position: relative;
  z-index: 1001;
}

.choice-card { width: min(720px, 96vw); }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.choice-grid button {
  min-height: 126px;
  display: grid;
  align-content: start;
  gap: 8px;
  text-align: left;
  background: var(--panel);
}

.choice-grid strong { font-size: 17px; }
.choice-grid span { color: var(--muted); line-height: 1.35; }
.modal-card .table-wrap { max-height: 58vh; }

.wa-app-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.wa-app-choice button {
  min-height: 44px;
  border-color: transparent;
  background: transparent;
  font-weight: 800;
}

.wa-app-choice button.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

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

.bill-summary.compact {
  grid-template-columns: repeat(6, minmax(84px, 1fr));
  gap: 8px;
}

.bill-summary span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--muted);
  background: var(--panel);
}

.bill-summary b {
  display: block;
  color: var(--ink);
  margin-top: 6px;
}

.bill-summary.compact span {
  padding: 9px 10px;
}

.bill-summary.compact b {
  font-size: 14px;
}

.bill-items {
  display: grid;
  gap: 10px;
}

.bill-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel);
}

.bill-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.bill-item-head b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bill-item-head strong {
  color: var(--good);
  white-space: nowrap;
}

.bill-item-code {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.bill-item-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(78px, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.bill-item-grid span {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--field);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.bill-item-grid b {
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  main { width: min(100vw - 22px, 1160px); }
  .appbar { height: auto; padding-top: 8px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .topbar, .section-head, .warning-box { align-items: flex-start; flex-direction: column; }
  .filters, .ledger-tools { grid-template-columns: 1fr 1fr; }
  .choice-grid, .bill-summary { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .kpi-grid, .filters, .ledger-tools { grid-template-columns: 1fr; }
  .topbar h2 { font-size: 28px; }
}

@media (max-width: 820px) {
  :root {
    --radius: 10px;
    --shadow: 0 10px 24px rgba(15, 23, 42, .08);
  }

  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    background:
      linear-gradient(180deg, rgba(184, 137, 24, .11), transparent 230px),
      var(--bg);
    font-size: 15px;
  }

  main {
    width: 100%;
    padding: 0 10px calc(28px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .appbar {
    min-height: 66px;
    margin: 0 -10px 16px;
    padding: 8px 10px;
    gap: 10px;
    position: sticky;
    color: #fff8e1;
    background: #050505;
    border-bottom: 1px solid rgba(245, 197, 66, .25);
  }

  .home-brand {
    min-width: 0;
  }

  .home-brand img {
    width: 38px;
    height: 38px;
    box-shadow: 0 0 0 1px rgba(245, 197, 66, .45), 0 6px 18px rgba(0, 0, 0, .35);
  }

  .home-brand strong,
  .home-brand span {
    max-width: 172px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-btn,
  .theme-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, .08);
    border-color: rgba(245, 197, 66, .32);
    color: #fff8e1;
  }

  .menu-icon span {
    background: #f5c542;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .topbar h2 {
    font-size: 30px;
    line-height: 1;
    letter-spacing: 0;
  }

  .topbar p,
  .section-head p {
    font-size: 14px;
  }

  .top-actions,
  .top-actions input,
  .section-head button,
  #sendAllPending,
  #backToCustomers {
    width: 100%;
  }

  .quick-actions {
    position: sticky;
    top: 66px;
    z-index: 10;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 -2px 12px;
    padding: 8px 2px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
  }

  .quick-actions button {
    min-height: 42px;
    padding: 8px 6px;
    font-size: 12px;
    border-color: color-mix(in srgb, var(--gold) 28%, var(--line));
  }

  .kpi-grid,
  #dashboard .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi {
    min-height: 92px;
    padding: 14px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, color-mix(in srgb, var(--solid) 94%, var(--accent-soft)), var(--panel));
  }

  .debt-card strong,
  .kpi strong {
    font-size: 26px;
  }

  .panel {
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .07);
  }

  .section-head {
    gap: 12px;
  }

  .section-head h3 {
    font-size: 18px;
  }

  .summary-line {
    display: grid;
    gap: 4px;
    font-size: 13px;
  }

  .filters,
  .ledger-tools {
    grid-template-columns: 1fr;
    padding: 12px;
    border-radius: var(--radius);
  }

  button,
  input[type="search"],
  input[type="date"],
  input[type="number"],
  select {
    width: 100%;
    min-height: 44px;
  }

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

  .tab {
    min-width: 0;
    padding: 10px 8px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tbody tr {
    display: grid;
    gap: 9px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--solid);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .07);
  }

  tbody tr:hover {
    background: var(--panel);
  }

  td {
    display: grid;
    grid-template-columns: minmax(82px, 32%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 0;
    border: 0;
    font-size: 14px;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  td:first-child strong {
    display: block;
    font-size: 16px;
    line-height: 1.2;
  }

  .mini-btn {
    width: 100%;
    min-height: 38px;
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 800;
  }

  td:empty {
    display: none;
  }

  td small {
    display: block;
    margin-top: 4px;
    line-height: 1.35;
  }

  .ledger-report .report-head {
    display: grid;
    gap: 12px;
  }

  .report-period {
    text-align: left;
  }

  .mini-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .mini-kpis span {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .profit-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .profit-summary span {
    min-height: 52px;
    padding: 8px;
  }

  .profit-summary b {
    font-size: 13px;
  }

  .sales-bill {
    gap: 4px;
    padding: 9px;
    border-radius: 10px;
  }

  .sales-bill-top,
  .sales-bill-main,
  .sales-bill-money {
    gap: 8px;
  }

  .sales-bill-top strong {
    font-size: 13px;
  }

  .sales-bill-main span {
    font-size: 13px;
    font-weight: 800;
  }

  .sales-bill-main small,
  .sales-bill-extra,
  .sales-bill-money em {
    font-size: 11px;
  }

  .bar {
    grid-template-columns: 68px 1fr;
  }

  .bar strong {
    grid-column: 1 / -1;
    font-size: 13px;
  }

  .modal {
    padding: 10px;
    align-items: start;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 14px;
    border-radius: var(--radius);
  }

  .modal-card .topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    padding-bottom: 10px;
    background: var(--solid);
  }

  .modal-card .table-wrap {
    max-height: none;
  }

  .modal th {
    position: static;
  }

  .export-menu {
    display: grid;
    gap: 8px;
  }

  #exportOptions {
    position: static;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-grid,
  .bill-summary {
    grid-template-columns: 1fr;
  }

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

  .bill-summary.compact span {
    padding: 8px;
  }

  .bill-item {
    padding: 10px;
    border-radius: 10px;
  }

  .bill-item-head {
    display: grid;
    gap: 5px;
  }

  .bill-item-head strong {
    white-space: normal;
  }

  .bill-item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .choice-grid button {
    min-height: 82px;
  }

  .wa-app-choice {
    grid-template-columns: 1fr;
  }

  .sidebar {
    left: 0;
    top: 0;
    bottom: 0;
    width: min(88vw, 340px);
    max-width: 88vw;
    padding: 16px;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: linear-gradient(180deg, #050505, #12100a);
    color: #fff8e1;
    border-color: rgba(245, 197, 66, .25);
    transform: translateX(-105%);
  }

  .sidebar .brand img {
    box-shadow: 0 0 0 1px rgba(245, 197, 66, .45), 0 8px 24px rgba(0, 0, 0, .4);
  }

  .sidebar .brand p,
  .sidebar label,
  .cash-block label {
    color: rgba(255, 248, 225, .68);
  }

  .sidebar .nav-btn,
  .sidebar .submenu button,
  .sidebar button {
    min-height: 46px;
  }

  .sidebar .nav-btn {
    color: #fff8e1;
    border-color: rgba(245, 197, 66, .12);
  }

  .sidebar .nav-btn.active,
  .sidebar .nav-btn:hover {
    color: #111827;
    background: linear-gradient(135deg, #ffd35c, #d89a00);
    border-color: transparent;
  }

  .submenu,
  .cash-block {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(245, 197, 66, .18);
  }

  .cash-block input,
  .sidebar select,
  .sidebar input {
    background: rgba(255, 255, 255, .08);
    color: #fff8e1;
    border-color: rgba(245, 197, 66, .2);
  }
}

/* Final compact mobile override */
@media (max-width: 820px) {
  main { width: 100%; padding: 0 8px 18px; }
  .appbar { position: sticky; top: 0; z-index: 18; min-height: 52px; padding: 6px 8px; margin: 0 -8px 8px; border-radius: 0; }
  .home-brand img { width: 34px; height: 34px; }
  .home-brand strong { font-size: 14px; }
  .home-brand span, #dbStatus, .topbar p, .section-head p { font-size: 11px; line-height: 1.25; }
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; margin-bottom: 8px; }
  .topbar h2 { font-size: 22px; line-height: 1; }
  .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; top: 52px; margin-bottom: 7px; padding: 5px 0; }
  .quick-actions button, .top-actions button, .section-head button, .ledger-tools button, .ledger-tools select, input, select { min-height: 36px; border-radius: 8px; font-size: 12px; padding: 7px 8px; }
  .kpi-grid, #dashboard .kpi-grid, #profileStats.kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
  .kpi, .debt-card { min-height: 62px; padding: 9px 10px; border-radius: 8px; }
  .kpi span { font-size: 10px; }
  .kpi strong, .debt-card strong { font-size: 17px; line-height: 1.05; }
  .panel { padding: 10px; margin-bottom: 9px; border-radius: 8px; }
  .section-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-bottom: 8px; }
  .section-head h3 { font-size: 15px; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px; margin-bottom: 8px; }
  .filters label, .ledger-tools label { gap: 3px; font-size: 10px; }
  .filters #clearFilters { grid-column: 1 / -1; }
  .ledger-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 7px; margin: 8px 0; border-radius: 8px; }
  .ledger-tools label:nth-child(1), .ledger-tools label:nth-child(2) { grid-column: span 2; }
  .ledger-tools label:nth-child(3) { grid-column: 1 / -1; }
  .ledger-tools #applyLedger, .ledger-tools #statementStyle, .ledger-tools .export-menu { grid-column: span 2; }
  .tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 7px 0; }
  .tab { min-height: 34px; padding: 6px 4px; font-size: 10px; border-radius: 8px; }
  .ledger-report .report-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 8px; }
  .report-period { display: flex; justify-content: space-between; text-align: left; gap: 8px; }
  .report-period b { font-size: 15px; }
  .mini-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 7px 0; }
  .mini-kpis span { display: grid; gap: 2px; padding: 7px; font-size: 10px; }
  .mini-kpis b { margin: 0; font-size: 12px; }
  .profit-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .profit-summary span { min-height: 42px; padding: 6px; }
  .profit-summary small { font-size: 8px; }
  .profit-summary b { font-size: 11px; }
  .table-wrap { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  table, thead, tbody, tr, th, td { display: block; width: 100%; min-width: 0; }
  thead { display: none; }
  tbody { display: grid; gap: 7px; }
  tr { padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--solid); }
  td { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 6px; padding: 3px 0; border: 0; font-size: 12px; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 9px; font-weight: 900; text-transform: uppercase; }
  .sales-bill { padding: 8px; gap: 4px; border-radius: 8px; }
  .sales-bill-money { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .sales-bill-money em, .sales-bill-extra { font-size: 10px; }
  .row-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .row-actions .mini-btn, .row-actions .call-btn { width: 100%; min-height: 34px; padding: 6px 4px; text-align: center; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .choice-grid button { min-height: 74px; padding: 10px; }
  .choice-grid strong { font-size: 13px; }
  .choice-grid span { font-size: 10px; }
}

@media (max-width: 390px) {
  .profit-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ledger-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* SR Fashion mobile-first receivables rebuild */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at top left, rgba(184, 137, 24, .16), transparent 28rem),
    linear-gradient(180deg, #050505 0, #090909 42%, #0d1117 100%);
}

.pull-refresh {
  display: none !important;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  text-align: left;
  justify-content: flex-start;
}

.back-btn {
  min-height: 38px;
  border: 1px solid rgba(245, 197, 66, .45);
  background: rgba(245, 197, 66, .13);
  color: #ffd35c;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 900;
}

.topbar h2,
.section-head h3,
.ledger-report h3 {
  letter-spacing: 0;
}

.mobile-debt-list,
.sales-bill-list {
  display: grid;
  gap: 8px;
}

.mobile-debt-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(245, 197, 66, .2);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015));
}

.debt-open {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.debt-open span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.debt-open b {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.debt-open small,
.debt-meta {
  color: var(--muted);
  font-size: 10px;
}

.debt-open strong {
  color: #ff6b8a;
  font-size: 13px;
  white-space: nowrap;
}

.debt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.debt-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
}

@media (max-width: 820px) {
  :root {
    --radius: 8px;
    --shadow: none;
  }

  body {
    min-width: 0;
    color: var(--ink);
  }

  main {
    min-width: 0;
  }

  .appbar {
    border-bottom: 1px solid rgba(245, 197, 66, .2);
    background: rgba(5, 5, 5, .96);
    backdrop-filter: blur(12px);
  }

  .menu-icon {
    width: 40px;
    min-width: 40px;
    height: 40px;
  }

  .home-brand {
    min-width: 0;
  }

  .home-brand div {
    min-width: 0;
  }

  .home-brand strong,
  .home-brand span {
    display: block;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .appbar-actions {
    display: none;
  }

  .view {
    min-width: 0;
  }

  .topbar {
    padding: 0 2px;
  }

  .topbar h2 {
    font-size: 24px;
    margin-bottom: 3px;
  }

  .quick-actions {
    position: static;
    background: transparent;
  }

  .quick-actions button {
    font-weight: 900;
  }

  .kpi-grid {
    align-items: stretch;
  }

  .kpi {
    border-color: rgba(255, 255, 255, .09);
    background: rgba(255, 255, 255, .045);
  }

  .kpi.action {
    border-color: rgba(245, 197, 66, .32);
  }

  .panel {
    border: 1px solid rgba(255, 255, 255, .09);
    background: rgba(255, 255, 255, .035);
  }

  .section-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-head button,
  #sendAllPending {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .top-actions input {
    grid-column: 1 / -1;
  }

  .top-actions button {
    min-width: 0;
  }

  #customers .top-actions {
    grid-template-columns: minmax(0, 1fr) 56px 56px;
  }

  #customers .top-actions input {
    grid-column: auto;
  }

  .filters {
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .025);
  }

  .summary-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    margin: 6px 0 8px;
  }

  .summary-line span {
    display: inline-flex;
  }

  .customer-row td:first-child strong {
    font-size: 14px;
    line-height: 1.15;
  }

  .customer-row td:first-child small {
    display: block;
    margin-top: 2px;
    overflow-wrap: anywhere;
  }

  #profileName {
    overflow-wrap: anywhere;
  }

  #profileMeta {
    overflow-wrap: anywhere;
  }

  #profileContent > .topbar .top-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #profileContent > .topbar .top-actions button {
    padding-left: 4px;
    padding-right: 4px;
    font-size: 11px;
  }

  #profileStats .kpi:nth-child(n+5) {
    display: none;
  }

  .tabs {
    position: sticky;
    top: 53px;
    z-index: 12;
    padding: 5px 0;
    background: rgba(5, 5, 5, .96);
  }

  .ledger-tools {
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .025);
  }

  .ledger-tools label {
    min-width: 0;
  }

  .export-menu {
    position: relative;
  }

  #exportOptions {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    width: min(78vw, 220px);
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(245, 197, 66, .3);
    border-radius: 8px;
    background: #101010;
  }

  #exportOptions[hidden] {
    display: none;
  }

  .ledger-report {
    min-width: 0;
  }

  .ledger-report .table-wrap tbody tr,
  #customers .table-wrap tbody tr {
    box-shadow: none;
  }

  .ledger-report .table-wrap td,
  #customers .table-wrap td {
    overflow-wrap: anywhere;
  }

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

  .bill-item-code,
  .bill-item-head b {
    overflow-wrap: anywhere;
  }

  .modal {
    align-items: stretch;
    padding: 8px;
  }

  .modal-card {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 16px);
    margin: 0;
    overflow: auto;
    border-radius: 8px;
  }

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

  .wa-app-choice {
    grid-template-columns: 1fr 1fr;
  }

  .sidebar {
    width: min(84vw, 318px);
    max-width: 84vw;
    padding: 14px 12px;
  }

  .sidebar .brand h1 {
    font-size: 18px;
  }

  .sidebar .nav-btn {
    min-height: 44px;
    font-size: 14px;
    padding: 10px 12px;
  }

  .submenu {
    padding: 8px;
  }
}

@media (max-width: 360px) {
  .home-brand strong,
  .home-brand span {
    max-width: 34vw;
  }

  .quick-actions,
  .profit-summary,
  .mini-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #customers .top-actions {
    grid-template-columns: minmax(0, 1fr) 48px 48px;
  }

  td {
    grid-template-columns: 62px minmax(0, 1fr);
  }
}

/* v35: full SR Recovery mobile cockpit */
:root {
  --sr-bg: #050608;
  --sr-ink: #f8fafc;
  --sr-muted: #94a3b8;
  --sr-panel: rgba(15, 23, 42, .76);
  --sr-panel-2: rgba(255, 255, 255, .055);
  --sr-line: rgba(255, 255, 255, .11);
  --sr-gold: #ffd24a;
  --sr-teal: #2dd4bf;
  --sr-rose: #fb7185;
  --sr-blue: #60a5fa;
}

body[data-theme="dark"] {
  --bg: var(--sr-bg);
  --ink: var(--sr-ink);
  --muted: var(--sr-muted);
  --line: var(--sr-line);
  --panel: var(--sr-panel);
  --solid: #0b0f16;
  --field: #10151f;
  --accent: var(--sr-teal);
  --accent-soft: rgba(45, 212, 191, .14);
  --danger: var(--sr-rose);
  --danger-soft: rgba(251, 113, 133, .13);
  --good: #22c55e;
  --good-soft: rgba(34, 197, 94, .14);
  --warn: var(--sr-gold);
  --gold: var(--sr-gold);
}

body {
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 210, 74, .13), transparent 190px),
    radial-gradient(circle at 14% 2%, rgba(45, 212, 191, .22), transparent 220px),
    radial-gradient(circle at 96% 10%, rgba(251, 113, 133, .14), transparent 210px),
    #050608;
}

main {
  padding-bottom: 86px;
}

.appbar {
  background: rgba(5, 6, 8, .82);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 10px 36px rgba(0, 0, 0, .26);
}

.home-brand img,
.sidebar .brand img {
  border-radius: 50%;
  border: 1px solid rgba(255, 210, 74, .42);
}

.home-brand strong,
.sidebar .brand h1 {
  color: var(--sr-gold);
  font-weight: 1000;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.menu-icon,
.back-btn,
.theme-icon,
.nav-btn,
button,
.mini-btn,
.call-btn {
  border-radius: 999px;
}

.menu-icon {
  border-color: rgba(255, 210, 74, .28);
  background: linear-gradient(145deg, rgba(255, 210, 74, .18), rgba(45, 212, 191, .06));
}

.menu-icon span {
  background: var(--sr-gold);
}

.back-btn {
  background: #ffd24a;
  color: #111827;
  border: 0;
  box-shadow: 0 6px 18px rgba(255, 210, 74, .2);
}

.topbar h2 {
  font-size: clamp(26px, 6vw, 44px);
  color: #fff;
}

.topbar p,
.section-head p,
.home-brand span {
  color: var(--sr-muted);
}

.action-ribbon {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.action-ribbon button {
  display: grid;
  gap: 2px;
  min-height: 56px;
  background:
    linear-gradient(145deg, rgba(255, 210, 74, .92), rgba(255, 170, 37, .86));
  color: #111827;
  border: 0;
  box-shadow: 0 10px 24px rgba(255, 210, 74, .15);
}

.action-ribbon button:nth-child(2) {
  background: linear-gradient(145deg, rgba(45, 212, 191, .96), rgba(20, 184, 166, .86));
}

.action-ribbon button:nth-child(3) {
  background: linear-gradient(145deg, rgba(96, 165, 250, .96), rgba(59, 130, 246, .8));
  color: #07111f;
}

.action-ribbon b {
  font-size: 14px;
}

.action-ribbon span {
  font-size: 10px;
  opacity: .82;
  text-transform: uppercase;
  font-weight: 900;
}

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

.kpi {
  border: 1px solid rgba(255, 255, 255, .08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .025));
  border-radius: 18px;
}

.kpi span {
  color: var(--sr-muted);
}

.kpi strong {
  color: #fff;
}

.kpi.danger strong,
.debt-card strong {
  color: var(--sr-rose);
}

.kpi.good strong {
  color: #4ade80;
}

.recovery-panel {
  border: 1px solid rgba(255, 210, 74, .2);
  background:
    linear-gradient(180deg, rgba(255, 210, 74, .08), rgba(15, 23, 42, .78));
}

.mobile-debt-list {
  counter-reset: recovery;
}

.mobile-debt-card {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .09);
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .92), rgba(2, 6, 23, .88));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.mobile-debt-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--sr-gold), var(--sr-rose));
}

.debt-open {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
}

.debt-open em {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #111827;
  background: var(--sr-gold);
  font-style: normal;
  font-size: 12px;
  font-weight: 1000;
}

.debt-open b {
  color: #fff;
}

.debt-open strong {
  color: var(--sr-rose);
}

.debt-meta span {
  color: #cbd5e1;
  background: rgba(255, 255, 255, .06);
}

.row-actions .mini-btn,
.row-actions .call-btn {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  color: #f8fafc;
}

.row-actions [data-wa-code] {
  background: rgba(34, 197, 94, .18);
  border-color: rgba(34, 197, 94, .35);
}

.row-actions [data-sms-code] {
  background: rgba(96, 165, 250, .18);
  border-color: rgba(96, 165, 250, .35);
}

.row-actions .call-btn {
  background: rgba(255, 210, 74, .16);
  border-color: rgba(255, 210, 74, .35);
  color: var(--sr-gold);
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 210, 74, .1), transparent 26%),
    #070707;
}

.sidebar .nav-btn {
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
}

.sidebar .nav-btn.active,
.sidebar .nav-btn:hover {
  background: #ffd24a;
  color: #111827;
}

.bottom-dock {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 40;
  width: min(520px, calc(100vw - 20px));
  transform: translateX(-50%);
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 24px;
  background: rgba(8, 8, 10, .92);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .45);
  backdrop-filter: blur(18px);
}

.bottom-dock button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 1000;
}

.bottom-dock button:nth-child(2) {
  color: var(--sr-rose);
}

.bottom-dock button:nth-child(4) {
  color: var(--sr-teal);
}

.table-wrap tr,
.sales-bill,
.bill-item {
  border-radius: 18px;
  border-color: rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .04);
}

.modal-card {
  background:
    linear-gradient(180deg, rgba(255, 210, 74, .08), transparent 160px),
    #07090f;
  border-color: rgba(255, 210, 74, .18);
}

@media (max-width: 820px) {
  main {
    padding: 0 10px 92px;
  }

  .bottom-dock {
    display: grid;
  }

  .appbar {
    min-height: 58px;
    margin-bottom: 14px;
    border-left: 0;
    border-right: 0;
    border-top: 0;
  }

  .home-brand img {
    width: 38px;
    height: 38px;
  }

  .home-brand strong,
  .home-brand span {
    max-width: 48vw;
  }

  .topbar h2 {
    font-size: 34px;
  }

  #dbStatus {
    display: inline-flex;
    max-width: 100%;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(45, 212, 191, .12);
    color: #99f6e4;
    font-size: 10px;
    overflow-wrap: anywhere;
  }

  .warning-box {
    border-radius: 18px;
    background: rgba(251, 113, 133, .12);
    border-color: rgba(251, 113, 133, .28);
  }

  .action-ribbon {
    margin: 10px 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-grid,
  #dashboard .kpi-grid,
  #profileStats.kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi {
    min-height: 82px;
    border-radius: 20px;
    padding: 12px;
  }

  .kpi strong {
    font-size: 18px;
  }

  .panel {
    padding: 12px;
    border-radius: 22px;
  }

  .section-head h3 {
    font-size: 18px;
  }

  .mobile-debt-card {
    padding: 12px 12px 12px 14px;
  }

  .debt-open strong {
    font-size: 12px;
  }

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

  .row-actions .mini-btn,
  .row-actions .call-btn {
    min-height: 38px;
    border-radius: 999px;
  }

  .filters,
  .ledger-tools {
    border-radius: 20px;
  }

  .tabs {
    border-radius: 999px;
    padding: 6px;
  }

  .tab {
    border-radius: 999px;
  }

  tr {
    border-radius: 20px;
    padding: 11px;
  }

  td {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .sidebar {
    border-radius: 0 26px 26px 0;
  }
}

@media (max-width: 380px) {
  main {
    padding-left: 8px;
    padding-right: 8px;
  }

  .topbar h2 {
    font-size: 30px;
  }

  .action-ribbon button {
    min-height: 50px;
  }

  .action-ribbon b {
    font-size: 12px;
  }

  .action-ribbon span,
  .bottom-dock button {
    font-size: 9px;
  }

  .kpi {
    min-height: 74px;
  }

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

  .debt-open strong {
    grid-column: 2;
    justify-self: start;
  }

  td {
    grid-template-columns: 66px minmax(0, 1fr);
  }
}

/* v36 repair: compact phone layout, no floating overlap */
main {
  padding-bottom: 24px !important;
}

.bottom-dock {
  display: none !important;
}

.back-btn {
  flex: 0 0 auto !important;
  width: auto !important;
  max-width: 76px !important;
  min-width: 56px !important;
  padding: 0 10px !important;
}

.sidebar {
  will-change: transform;
}

@media (max-width: 820px) {
  main {
    padding: 0 8px 24px !important;
  }

  .sidebar {
    visibility: hidden;
    pointer-events: none;
  }

  body.sidebar-open .sidebar {
    visibility: visible;
    pointer-events: auto;
  }

  .appbar {
    min-height: 52px !important;
    margin-bottom: 8px !important;
    padding: 5px 8px !important;
  }

  .home-brand img {
    width: 32px !important;
    height: 32px !important;
  }

  .home-brand strong,
  .home-brand span {
    max-width: 44vw !important;
  }

  .topbar {
    gap: 4px !important;
    margin-bottom: 6px !important;
  }

  .topbar h2 {
    font-size: 24px !important;
    line-height: 1 !important;
  }

  #dbStatus {
    font-size: 9px !important;
    padding: 3px 7px !important;
  }

  .warning-box {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 5px 7px !important;
    margin: 4px 0 !important;
    border-radius: 10px !important;
    min-height: 0 !important;
  }

  .warning-box button,
  #sendAllPending {
    min-height: 26px !important;
    font-size: 11px !important;
  }

  .warning-box strong {
    font-size: 10px !important;
  }

  .warning-box span {
    display: none !important;
  }

  .action-ribbon {
    gap: 6px !important;
    margin: 7px 0 !important;
  }

  .action-ribbon button {
    min-height: 40px !important;
    padding: 6px !important;
  }

  .action-ribbon b {
    font-size: 12px !important;
  }

  .action-ribbon span {
    font-size: 8px !important;
  }

  .kpi-grid,
  #dashboard .kpi-grid,
  #profileStats.kpi-grid {
    gap: 6px !important;
  }

  .kpi {
    min-height: 44px !important;
    padding: 7px !important;
    border-radius: 12px !important;
  }

  .kpi span {
    font-size: 9px !important;
  }

  .kpi strong {
    font-size: 14px !important;
    line-height: 1.05 !important;
  }

  .panel {
    padding: 8px !important;
    margin-bottom: 7px !important;
    border-radius: 12px !important;
  }

  .section-head {
    gap: 5px !important;
    margin-bottom: 6px !important;
  }

  .section-head h3 {
    font-size: 14px !important;
  }

  .section-head p {
    display: none !important;
  }

  .mobile-debt-list {
    gap: 6px !important;
  }

  .mobile-debt-card {
    padding: 7px 7px 7px 10px !important;
    border-radius: 12px !important;
    gap: 5px !important;
  }

  .debt-open {
    grid-template-columns: 26px minmax(0, 1fr) !important;
    gap: 6px !important;
  }

  .debt-open em {
    width: 22px !important;
    height: 22px !important;
    font-size: 10px !important;
  }

  .debt-open b {
    font-size: 12px !important;
  }

  .debt-open small {
    font-size: 9px !important;
  }

  .debt-open strong {
    grid-column: 2 !important;
    justify-self: start !important;
    font-size: 12px !important;
  }

  .debt-meta {
    gap: 4px !important;
    padding-left: 32px !important;
  }

  .debt-meta span {
    padding: 2px 5px !important;
    font-size: 9px !important;
  }

  .row-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }

  .row-actions .mini-btn,
  .row-actions .call-btn {
    min-height: 29px !important;
    padding: 4px !important;
    font-size: 10px !important;
  }

  #customers .top-actions {
    grid-template-columns: minmax(0, 1fr) 44px 44px !important;
    gap: 5px !important;
  }

  .filters {
    grid-template-columns: 1fr 1fr !important;
    gap: 5px !important;
    padding: 7px !important;
    border-radius: 12px !important;
  }

  .filters label,
  .ledger-tools label {
    font-size: 9px !important;
  }

  input,
  select,
  .top-actions button,
  .filters button,
  .ledger-tools button,
  .ledger-tools select {
    min-height: 32px !important;
    font-size: 11px !important;
    padding: 5px 7px !important;
  }

  .summary-line {
    font-size: 10px !important;
    margin: 5px 0 !important;
  }

  tr {
    padding: 7px !important;
    border-radius: 12px !important;
  }

  td {
    grid-template-columns: 58px minmax(0, 1fr) !important;
    gap: 5px !important;
    padding: 2px 0 !important;
    font-size: 10px !important;
  }

  td::before {
    font-size: 8px !important;
  }

  .customer-row td:nth-child(4),
  .customer-row td:nth-child(5),
  .customer-row td:nth-child(6) {
    display: none !important;
  }

  .customer-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 4px 8px !important;
  }

  .customer-row td {
    display: block !important;
    padding: 0 !important;
  }

  .customer-row td::before {
    display: none !important;
  }

  .customer-row td:nth-child(1) {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
  }

  .customer-row td:nth-child(2) {
    grid-column: 1 !important;
    grid-row: 3 !important;
    color: var(--sr-muted) !important;
    font-size: 9px !important;
  }

  .customer-row td:nth-child(3) {
    grid-column: 2 !important;
    grid-row: 1 / span 3 !important;
    align-self: center !important;
    text-align: right !important;
  }

  .customer-row td:first-child strong {
    font-size: 12px !important;
  }

  .customer-row td:first-child small {
    display: block !important;
    max-height: 12px !important;
    overflow: hidden !important;
    font-size: 9px !important;
    color: var(--sr-muted) !important;
  }

  .customer-more {
    display: grid !important;
    margin-top: 8px !important;
  }

  .customer-more button {
    min-height: 38px !important;
    border: 1px solid rgba(255, 210, 74, .34) !important;
    background: rgba(255, 210, 74, .14) !important;
    color: var(--sr-gold) !important;
  }

  #profileContent > .topbar .top-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  #backToCustomers {
    display: none !important;
  }

  .tabs {
    position: static !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
    padding: 4px !important;
    margin: 5px 0 !important;
    border-radius: 12px !important;
  }

  .tab {
    min-height: 30px !important;
    font-size: 9px !important;
    padding: 4px !important;
  }

  .ledger-tools {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 150px 120px !important;
    gap: 5px !important;
    padding: 6px !important;
    border-radius: 12px !important;
  }

  .ledger-tools .export-menu {
    grid-column: auto !important;
  }

  .mini-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .bill-summary.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 5px !important;
  }

  .bill-summary span {
    min-width: 0 !important;
    padding: 6px !important;
    border-radius: 10px !important;
    font-size: 9px !important;
  }

  .bill-summary b {
    display: block !important;
    margin-top: 2px !important;
    color: #fff !important;
    font-size: 12px !important;
    line-height: 1.05 !important;
    overflow-wrap: anywhere !important;
  }

  .bill-summary span:nth-child(3) b,
  .money.dr,
  .mobile-debt-card .debt-open strong,
  .customer-row .money.dr {
    color: #ff5d78 !important;
    font-size: 15px !important;
  }

  .bill-items {
    display: grid !important;
    gap: 6px !important;
  }

  .bill-item {
    padding: 7px !important;
    border-radius: 12px !important;
  }

  .bill-item-head {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px !important;
    align-items: start !important;
  }

  .bill-item-head b {
    display: flex !important;
    gap: 6px !important;
    min-width: 0 !important;
    font-size: 12px !important;
    line-height: 1.15 !important;
  }

  .bill-item-head em {
    display: inline-grid !important;
    place-items: center !important;
    flex: 0 0 20px !important;
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    background: var(--sr-gold) !important;
    color: #111827 !important;
    font-style: normal !important;
    font-size: 9px !important;
    font-weight: 1000 !important;
  }

  .bill-item-head strong {
    color: var(--sr-teal) !important;
    font-size: 12px !important;
    white-space: nowrap !important;
  }

  .bill-item-code {
    margin: 3px 0 !important;
    color: var(--sr-muted) !important;
    font-size: 9px !important;
  }

  .bill-item-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }

  .bill-item-grid span {
    min-width: 0 !important;
    padding: 5px !important;
    border-radius: 8px !important;
    font-size: 8px !important;
  }

  .bill-item-grid b {
    display: block !important;
    font-size: 9px !important;
    line-height: 1.05 !important;
    overflow-wrap: anywhere !important;
  }

  #billModal .modal-card {
    padding: 9px !important;
  }

  #billModal .topbar {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #billModal .top-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

/* v37 dense recovery cockpit: less scrolling, no wasted space */
body {
  min-height: 100dvh;
}

main {
  width: min(100vw - 12px, 1160px) !important;
  padding-top: 6px !important;
}

.appbar {
  min-height: 48px !important;
  margin-bottom: 8px !important;
}

.topbar {
  margin: 0 0 6px !important;
}

.topbar h2 {
  font-size: 28px !important;
  line-height: .95 !important;
  margin: 0 !important;
}

#dbStatus {
  margin-top: 2px !important;
}

.warning-box {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  min-height: 34px !important;
  margin: 5px 0 7px !important;
  padding: 5px 8px !important;
  border-radius: 10px !important;
}

.warning-box div {
  min-width: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.warning-box strong {
  font-size: 12px !important;
  white-space: nowrap !important;
}

.warning-box span {
  display: inline !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 11px !important;
}

.warning-box button {
  flex: 0 0 auto !important;
  min-height: 26px !important;
  padding: 4px 10px !important;
  font-size: 11px !important;
}

.action-ribbon {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 7px !important;
  margin: 0 0 8px !important;
}

.action-ribbon button {
  min-height: 38px !important;
  padding: 5px 8px !important;
  box-shadow: none !important;
}

.action-ribbon b {
  font-size: 12px !important;
}

.action-ribbon span {
  font-size: 8px !important;
}

#dashboard .kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 7px !important;
  margin-bottom: 8px !important;
}

#dashboard .kpi {
  min-height: 54px !important;
  padding: 8px 10px !important;
  border-radius: 12px !important;
}

#dashboard .kpi span {
  font-size: 10px !important;
}

#dashboard .kpi strong {
  font-size: 17px !important;
}

#dashboard .kpi:first-child {
  grid-column: span 1 !important;
}

.recovery-panel {
  padding: 9px !important;
  border-radius: 12px !important;
}

.recovery-panel .section-head {
  display: flex !important;
  align-items: center !important;
  margin-bottom: 6px !important;
}

.recovery-panel .section-head h3 {
  font-size: 14px !important;
}

.recovery-panel .section-head p {
  display: none !important;
}

.mobile-debt-list {
  gap: 5px !important;
}

.mobile-debt-card {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  gap: 4px 8px !important;
  padding: 6px 7px 6px 10px !important;
  border-radius: 10px !important;
}

.mobile-debt-card::before {
  width: 3px !important;
}

.debt-open {
  grid-column: 1 / -1 !important;
  display: grid !important;
  grid-template-columns: 22px minmax(0, 1fr) auto !important;
  gap: 6px !important;
  min-height: 24px !important;
}

.debt-open em {
  width: 19px !important;
  height: 19px !important;
  font-size: 9px !important;
}

.debt-open b {
  font-size: 12px !important;
  line-height: 1.05 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.debt-open small {
  display: none !important;
}

.debt-open strong {
  grid-column: auto !important;
  align-self: center !important;
  font-size: 15px !important;
  white-space: nowrap !important;
}

.debt-meta {
  grid-column: 1 !important;
  display: flex !important;
  gap: 4px !important;
  padding-left: 28px !important;
}

.debt-meta span {
  padding: 1px 5px !important;
  font-size: 8px !important;
}

.mobile-debt-card .row-actions {
  grid-column: 2 !important;
  grid-row: 2 !important;
  display: grid !important;
  grid-template-columns: repeat(3, 48px) !important;
  gap: 4px !important;
  align-self: center !important;
}

.mobile-debt-card .row-actions .mini-btn,
.mobile-debt-card .row-actions .call-btn {
  min-height: 24px !important;
  padding: 2px 3px !important;
  font-size: 8px !important;
}

#customers .table-wrap tbody {
  gap: 5px !important;
}

#customers .customer-row {
  min-height: 46px !important;
  padding: 6px 8px !important;
  border-radius: 10px !important;
}

#customers .customer-row td:first-child strong {
  font-size: 12px !important;
}

#customers .customer-row td:first-child small,
#customers .customer-row td:nth-child(2) {
  max-height: 10px !important;
  line-height: 1 !important;
  font-size: 8px !important;
}

#customers .customer-row .money.dr {
  font-size: 14px !important;
}

@media (max-width: 520px) {
  main {
    width: 100% !important;
    padding: 0 6px 18px !important;
  }

  .appbar {
    min-height: 44px !important;
  }

  .menu-icon {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
  }

  .home-brand img {
    width: 28px !important;
    height: 28px !important;
  }

  .home-brand strong {
    font-size: 12px !important;
  }

  .home-brand span {
    font-size: 9px !important;
  }

  .topbar h2 {
    font-size: 22px !important;
  }

  .warning-box span {
    display: none !important;
  }

  #dashboard .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #dashboard .kpi {
    min-height: 42px !important;
  }

  #dashboard .kpi strong {
    font-size: 14px !important;
  }

  .mobile-debt-card {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .debt-open {
    grid-template-columns: 20px minmax(0, 1fr) auto !important;
  }

  .mobile-debt-card .row-actions {
    grid-column: 1 !important;
    grid-row: auto !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    padding-left: 26px !important;
  }

  .ledger-tools {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .ledger-tools > * {
    grid-column: auto !important;
  }

  .ledger-tools label,
  .ledger-tools select,
  .ledger-tools .export-menu,
  .ledger-tools #exportToggle {
    min-width: 0 !important;
  }

  .ledger-tools label {
    font-size: 8px !important;
  }

  .ledger-tools input,
  .ledger-tools select,
  .ledger-tools button {
    min-height: 30px !important;
    padding: 4px !important;
    font-size: 9px !important;
  }
}

.ledger-range {
  display: inline-flex;
  margin: 0 0 5px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 999px;
  color: var(--sr-muted);
  background: rgba(255, 255, 255, .04);
  font-size: 11px;
  font-weight: 800;
}

.party-items {
  display: grid;
  gap: 8px;
}

.party-item-search input {
  width: 100%;
}

.party-item-list {
  display: grid;
  gap: 6px;
}

.party-item {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) repeat(4, minmax(72px, .7fr));
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
}

.party-item div {
  min-width: 0;
}

.party-item b,
.party-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-item small {
  color: var(--sr-muted);
  font-size: 10px;
}

.party-item span {
  display: grid;
  gap: 2px;
  color: var(--sr-muted);
  font-size: 9px;
}

.party-item span b {
  color: var(--ink);
  font-size: 12px;
}

@media (max-width: 520px) {
  .party-item {
    grid-template-columns: minmax(0, 1fr) repeat(2, 54px) !important;
    gap: 4px !important;
    padding: 6px !important;
  }

  .party-item span:nth-child(4),
  .party-item span:nth-child(5) {
    display: none !important;
  }

  .party-item b {
    font-size: 11px !important;
  }
}
