:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --secondary: #475569;
  --success: #16a34a;
  --danger: #dc2626;

  --bg-light: #f6f7fb;
  --white: #ffffff;
  --text-dark: #0f172a;
  --border: #e6e8ef;
  --ring: rgba(37, 99, 235, 0.35);

  --radius: 14px;
  --radius-sm: 12px;

  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    Arial,
    sans-serif;
  background:
    radial-gradient(
      1200px 600px at 30% 10%,
      rgba(37, 99, 235, 0.1),
      transparent 60%
    ),
    radial-gradient(
      800px 500px at 80% 30%,
      rgba(22, 163, 74, 0.08),
      transparent 65%
    ),
    var(--bg-light);
  margin: 0;
  height: 100vh;
  display: flex;
  overflow: hidden;
  color: var(--text-dark);
}

/* Sidebar */
.sidebar-menu {
  width: 78px;
  background: linear-gradient(180deg, #0b1220, #0f172a);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 14px;
  z-index: 200;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  gap: 6px;
}

.menu-item {
  width: 100%;
  padding: 14px 0;
  color: rgba(148, 163, 184, 0.95);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: 0.2s ease;
  font-size: 11px;
  text-align: center;
  border-left: 3px solid transparent;
  user-select: none;
}

.menu-item i {
  font-style: normal;
  font-size: 22px;
  margin-bottom: 6px;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.menu-item.active {
  background: rgba(37, 99, 235, 0.2);
  color: #fff;
  border-left-color: var(--primary);
}

.sidebar-menu a.menu-item {
  text-decoration: none;
  color: rgba(148, 163, 184, 0.95);
}
.sidebar-menu a.menu-item:hover,
.sidebar-menu a.menu-item.active {
  color: #fff;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top bar */
.top-bar {
  height: 54px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.18);
  box-shadow: var(--shadow-sm);
  color: var(--primary);
  font-size: 18px;
}

.brand-logo {
  height: 40px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.brand h3 {
  margin: 0;
  color: var(--primary);
  font-size: 16px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: #64748b;
  font-weight: 800;
  margin-top: 2px;
}

.status-badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.status-badge.connected {
  border-color: rgba(22, 163, 74, 0.25);
  background: rgba(22, 163, 74, 0.1);
  color: #14532d;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.view-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.view-section {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.view-section.active {
  display: flex;
}

/* Standalone master pages (parties, products, marks etc.) — scrollable */
.view-container.page-scroll {
  overflow: auto;
}

/* Bills list */
.bill-list-panel {
  width: 330px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-width: 0;
}

.panel-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.panel-sub {
  padding: 12px 14px 0;
}

.search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  font-size: 13px;
  transition: 0.18s ease;
  background: #fff;
}

.search:focus {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px var(--ring);
}

.bill-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 14px;
}

.bill-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  transition: 0.18s ease;
  background: #fff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.bill-card:hover {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.bill-card.selected {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.45);
}

.bill-card-delete {
  padding: 4px 6px;
  min-width: 28px;
  font-size: 12px;
  color: var(--muted);
}
.bill-card-delete:hover {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.1);
}

.bc-top {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 13px;
  gap: 10px;
  margin-bottom: 4px;
}

.bc-party {
  font-size: 13px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bc-date {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.bc-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.bc-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.bc-badge.bc-tally {
  background: rgba(124, 58, 237, 0.15);
  color: #6d28d9;
}

.bc-badge.bc-lorry {
  background: rgba(217, 119, 6, 0.15);
  color: #b45309;
}

.bc-badge.bc-delivery {
  background: rgba(14, 165, 233, 0.15);
  color: #0284c7;
}

.bill-filters {
  flex-direction: column;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.bill-list-empty {
  padding: 24px 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

/* Invoice full page */
.invoice-workspace {
  flex: 1;
  padding: 0;
  overflow-y: auto;
  display: block;
  min-width: 0;
}

.paper-sheet {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 54px);
  background: var(--white);
  padding: 16px;
  border-radius: 0;
  box-shadow: none;
  border: none;
}

/* Invoice toolbar: title + Bills, Views, Save, Print, WhatsApp */
.invoice-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.invoice-toolbar-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-dark);
  flex-shrink: 0;
}

.invoice-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.invoice-toolbar-actions .btn {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
  border: none;
}

.btn-whatsapp:hover {
  background: #20bd5a;
  color: #fff;
}

/* Standalone pages: better padding, auto height */
.view-container.page-scroll .paper-sheet {
  padding: 20px 24px 32px;
  min-height: auto;
}

label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input,
select,
button {
  font-family: inherit;
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  outline: none;
  transition: 0.18s ease;
  background: #fff;
  min-width: 0;
}

input:focus,
select:focus {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px var(--ring);
}

input[readonly] {
  background: rgba(241, 245, 249, 0.7);
  cursor: default;
}

.hint {
  margin-top: 6px;
  font-size: 11px;
  color: #64748b;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(241, 245, 249, 0.7);
  white-space: nowrap;
}

.btn {
  height: 42px;
  padding: 9px 14px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.18s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary:hover {
  background: var(--primary-600);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}

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

.btn-sm {
  height: auto;
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 10px;
  box-shadow: none;
}

.btn-ghost {
  background: rgba(15, 23, 42, 0.04);
  color: #0f172a;
  border: 1px solid var(--border);
  box-shadow: none;
}

/* Index fields */
.inv-index {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.inv-index .span-2 {
  grid-column: span 2;
}

/* City + State: desktop = two separate grid cells */
.inv-city-state-row {
  display: contents;
}

/* Short label hidden by default; shown only in responsive */
.inv-no-row .label-short {
  display: none;
}

/* Entry container */
.entry-box {
  background: rgba(37, 99, 235, 0.06);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(37, 99, 235, 0.14);
  margin-bottom: 10px;
}

/* Base row (requested order) */
.entry-row {
  display: grid;
  grid-template-columns:
    2.2fr /* Product */
    1fr /* Mark */
    1fr /* Master Unit */
    1fr /* Packing Type */
    1fr /* Unit KG */
    1fr /* Inner Packing */
    1fr /* Actual Weight */
    1fr /* Price */
    1.2fr /* Action */;
  gap: 8px;
  align-items: stretch;
  overflow-x: auto;
}

.entry-row > div,
.entry-adv-row > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Entry row: same border-radius and focus ring for Product, Unit QTY, ACT WEIGHT, PRICE and Add button */
.entry-row input,
.entry-row select,
.entry-row .btn-line .btn {
  border-radius: 5px;
  outline: none;
}
.entry-row input:focus,
.entry-row select:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
.entry-row input[readonly]:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
.entry-row .btn-line .btn:focus {
  outline: 1px solid rgba(37, 99, 235, 0.7);
  outline-offset: px;
}

/* ✅ Action area */
.btn-line {
  display: flex;
  gap: 8px;
  width: 100%;
  height: 42px;
  margin-top: auto;
}
.btn-line .btn {
  flex: 1;
  height: 42px;
}

/* Advanced row (Disc/Tax) */
.entry-adv-row {
  display: none;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

/* ✅ show/hide views controls BOTH: adv inputs + table columns */
.show-views .entry-adv-row {
  display: grid;
}

/* Editing indicator */
.edit-indicator {
  display: none;
  margin: 10px 0 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  background: rgba(37, 99, 235, 0.08);
  color: #0f172a;
  font-weight: 800;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.edit-indicator.show {
  display: flex;
}
.edit-indicator small {
  font-weight: 800;
  color: #475569;
}

/* Table wrap */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
  min-width: 1180px;
}

th {
  background: rgba(241, 245, 249, 0.9);
  color: #475569;
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  white-space: nowrap;
}

td {
  padding: 9px 8px;
  text-align: center;
  color: #334155;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

.text-left {
  text-align: left;
}
.text-right {
  text-align: right;
}

/* Column widths */
.col-prod {
  width: 130px;
}
.col-mark {
  width: 90px;
}
.col-qtytype {
  width: 90px;
}
.col-unitkg {
  width: 60px;
}
.col-inner {
  width: 70px;
}
.col-wt {
  width: 90px;
}
.col-rate {
  width: 60px;
}
.col-disc {
  width: 90px;
}
.col-tax {
  width: 100px;
}
.col-taxable {
  width: 120px;
}
.col-total {
  width: 130px;
}
.col-x {
  width: 120px;
}

/* ✅ Disc/Tax columns hide by default */
.col-disc,
.col-tax {
  display: none;
}
.show-views .col-disc,
.show-views .col-tax {
  display: table-cell;
}

.row-clickable {
  cursor: pointer;
}
.row-clickable:hover td {
  background: rgba(37, 99, 235, 0.06);
}

/* Editing row highlight */
tr.is-editing td {
  background: rgba(37, 99, 235, 0.12) !important;
}

/* Multi-line cells */
.cell-2line {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}
.cell-2line .top {
  font-weight: 800;
  color: #0f172a;
}
.cell-2line .sub {
  font-size: 11px;
  font-weight: 850;
  color: #64748b;
}

/* Totals */
.totals-wrapper {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.totals-card {
  width: min(560px, 100%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.totals-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 8px 12px;
  align-items: center;
}

.totals-label {
  font-weight: 800;
  color: #000;
  font-size: 13px;
}

.totals-val {
  text-align: right;
  font-weight: 800;
  color: #000;
  font-size: 14px;
  white-space: nowrap;
}

.totals-divider {
  grid-column: 1 / -1;
  border-top: 1px solid rgba(226, 232, 240, 1);
  margin-top: 4px;
  padding-top: 10px;
}

.grand-label {
  font-size: 14px;
}
.grand-val {
  font-size: 18px;
  color: #000;
}

/* HSN Summary (END) */
.hsn-wrap {
  margin-top: 12px;
}

.hsn-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.hsn-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.hsn-title {
  font-weight: 800;
  font-size: 14px;
  color: #0f172a;
}

.hsn-sub {
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

.hsn-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hsn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 820px;
}

.hsn-table th {
  background: rgba(241, 245, 249, 0.95);
  color: #475569;
  padding: 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  white-space: nowrap;
}

.hsn-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  color: #334155;
  white-space: nowrap;
}

.hsn-table tfoot td {
  background: rgba(241, 245, 249, 0.6);
  border-top: 1px solid rgba(226, 232, 240, 1);
  border-bottom: none;
  font-weight: 800;
  color: #000;
}

/* Overlay */
#overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      800px 500px at 30% 20%,
      rgba(37, 99, 235, 0.35),
      transparent 60%
    ),
    radial-gradient(
      700px 450px at 75% 40%,
      rgba(22, 163, 74, 0.25),
      transparent 65%
    ),
    rgba(2, 6, 23, 0.92);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  padding: 18px;
  text-align: center;
}

.overlay-card {
  width: min(640px, 92vw);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.overlay-card code {
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 8px;
}

.overlay-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.overlay-note {
  text-align: left;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(226, 232, 240, 0.9);
  margin-top: 12px;
}

.filepick {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 10px 12px;
}

.filepick input[type="file"] {
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: #fff;
}

/* Toast */
.toasts {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  pointer-events: none;
  min-width: 260px;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow-md);
  color: #0f172a;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: pop 0.18s ease;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.danger {
  border-left-color: var(--danger);
}

@keyframes pop {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Drawer overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1200;
  display: none;
}

.drawer-overlay.show {
  display: block;
}

#openListBtn,
#closeListBtn {
  display: none;
}

/* Print */
@media print {
  .no-print,
  .sidebar-menu,
  .bill-list-panel,
  .top-bar,
  .toasts {
    display: none !important;
  }

  .invoice-workspace {
    padding: 0;
    overflow: visible;
  }

  .paper-sheet {
    padding: 0;
    min-height: auto;
  }

  body {
    background: #fff;
  }

  @page {
    size: A4 landscape;
    margin: 5mm;
  }

  .entry-box {
    display: none;
  }

  input,
  select {
    border: none;
    padding: 0;
    background: transparent;
    -webkit-appearance: none;
    box-shadow: none;
  }

  .table-wrap,
  .hsn-card,
  .totals-card {
    border: none;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
  }
}

/* Responsive */
@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .invoice-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .invoice-toolbar-title {
    text-align: center;
    font-size: 1.1rem;
  }

  .invoice-toolbar-actions {
    justify-content: center;
    gap: 6px;
  }

  .invoice-toolbar-actions .btn {
    flex: 1;
    min-width: 0;
    max-width: 120px;
  }

  /* Responsive: show only icon in buttons (including Views) */
  .btn-icon-text .btn-text {
    display: none;
  }
  .btn-icon-text .btn-icon {
    display: inline;
  }
  .btn-icon-text {
    min-width: 36px;
    padding-left: 10px;
    padding-right: 10px;
  }

  /* Invoice No -> Inv No on small screens */
  .inv-no-row .label-full {
    display: none;
  }
  .inv-no-row .label-short {
    display: inline;
  }

  /* Hide Mobile, Address, Pin Code on small screens */
  .inv-hide-on-mobile {
    display: none !important;
  }

  /* Responsive inv-index: Row1 = Inv No (fixed) | Date (auto), Row2 = Select Party 100%, Row3 = GSTIN 100%, Row4 = City 50% | State 50% */
  .inv-index {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 12px;
  }
  .inv-index .inv-no-row {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  .inv-index .inv-no-row input {
    width: 90px;
    max-width: 100%;
  }
  .inv-index > div:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  .inv-index > div:nth-child(3) {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .inv-index > div:nth-child(5) {
    grid-column: 1 / -1;
    grid-row: 3;
  }
  .inv-city-state-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    grid-column: 1 / -1;
    grid-row: 4;
  }

  .sidebar-menu {
    width: 70px;
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .bill-list-panel {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(92vw, 360px);
    z-index: 1300;
    transform: translateX(-110%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--border);
  }

  .bill-list-panel.open {
    transform: translateX(0);
  }

  #openListBtn {
    display: inline-flex;
  }
  #closeListBtn {
    display: inline-flex;
  }

  .entry-row {
    grid-template-columns: 1fr;
  }
  .entry-adv-row {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 980px;
  }

  .totals-wrapper {
    justify-content: stretch;
  }

  .totals-card {
    width: 100%;
  }

  .totals-grid {
    grid-template-columns: 1fr 170px;
  }
}

/* Auth pages (login, forgot-password, reset-password) */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.auth-card .brand-badge {
  width: 48px;
  height: 48px;
  font-size: 24px;
  margin: 0 auto 16px;
  display: block;
}
.auth-card .auth-logo {
  height: 56px;
  max-width: 140px;
  margin: 0 auto 16px;
  display: block;
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
}
.auth-card .sub {
  text-align: center;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 24px;
}
.auth-card label {
  margin-bottom: 6px;
}
.auth-card input {
  margin-bottom: 16px;
}
.auth-card .btn {
  width: 100%;
  margin-top: 8px;
  margin-bottom: 16px;
}
.auth-card .auth-link {
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}
.auth-card .auth-link:hover {
  text-decoration: underline;
}
.auth-card .auth-error {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
  display: none;
}
.auth-card .auth-error.show {
  display: block;
}
.auth-card .auth-success {
  background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--success);
  margin-bottom: 16px;
  display: none;
}
.auth-card .auth-success.show {
  display: block;
}
.auth-card .back-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: #64748b;
  text-decoration: none;
}
.auth-card .back-link:hover {
  color: var(--primary);
}
