/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-app);
  background-image: 
    radial-gradient(at 0% 0%, rgba(30,58,95,0.06) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(5,150,105,0.06) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6, .brand-title, .saas-title, .panel-title {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ── Animations ── */
@keyframes tabEntrance {
  from { opacity: 0; transform: translateY(5px) scale(0.997); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalZoom {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateY(12px) translateX(4px); }
  to   { opacity: 1; transform: translateY(0) translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 var(--primary-glow); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   APP SHELL LAYOUT
   ══════════════════════════════════════════════════════════════ */
.saas-app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
}

/* ══════════════════════════════════════════════════════════════
   TOPBAR — compact 52px sticky
   ══════════════════════════════════════════════════════════════ */
.saas-topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px -4px rgba(8,100,120,0.08);
  gap: 12px;
}

/* Brand */
.topbar-left { display: flex; align-items: center; flex-shrink: 0; }

.saas-brand { display: flex; align-items: center; gap: 9px; cursor: default; }

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 12px rgba(30,58,95,0.35);
  transition: transform var(--t-normal) var(--ease-spring);
  flex-shrink: 0;
}
.saas-brand:hover .brand-icon { transform: scale(1.06) rotate(-3deg); }

.brand-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  letter-spacing: -0.025em;
  white-space: nowrap;
}
.brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-top: -1px;
}

/* Nav Toggle Group */
.topbar-center { display: flex; align-items: center; flex: 1; justify-content: center; }

.nav-group-toggles {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-muted);
  padding: 3px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-normal) var(--ease-spring);
  border: none;
  background: transparent;
  white-space: nowrap;
  font-family: inherit;
}
.nav-item:hover {
  background: rgba(255,255,255,0.7);
  color: var(--text-main);
}
.nav-item.active {
  background: #FFFFFF;
  color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.nav-item.active i { color: var(--primary); }
.nav-item i { flex-shrink: 0; }

/* Topbar Right */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-info-small {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.user-avatar-small {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  border: 2px solid var(--primary-border);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   TOOLBAR STRIP — greeting + actions (compact 44px)
   ══════════════════════════════════════════════════════════════ */
.saas-top-header {
  padding: 0 20px;
  min-height: var(--toolbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  flex-shrink: 0;
}

.greeting-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}
.greeting-sub {
  display: none; /* hidden on toolbar strip — too small */
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 0;
}

/* ══════════════════════════════════════════════════════════════
   BUTTON SYSTEM
   ══════════════════════════════════════════════════════════════ */
.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  color: var(--text-main);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  line-height: 1;
}
.tb-btn:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.tb-btn:active { transform: scale(0.97) translateY(0); box-shadow: var(--shadow-xs); }

.tb-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(30,58,95,0.3);
}
.tb-btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 5px 14px rgba(30,58,95,0.4);
}

.tb-btn.success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  box-shadow: 0 3px 10px rgba(5,150,105,0.25);
}
.tb-btn.success:hover { background: #047857; border-color: #047857; }

.tb-btn.secondary {
  background: var(--primary-light);
  color: var(--primary-hover);
  border-color: var(--primary-border);
}
.tb-btn.secondary:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.tb-btn.danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger-border);
}
.tb-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.tb-btn.sm { padding: 4px 9px; font-size: 11px; border-radius: var(--radius-sm); gap: 4px; }
.tb-btn.icon-only { padding: 6px 8px; }

/* Paper Size Group */
.size-group {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}
.size-group .tb-btn {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border-subtle);
  padding: 5px 10px;
  font-size: 11.5px;
  box-shadow: none;
}
.size-group .tb-btn:last-child { border-right: none; }
.size-group .tb-btn.active { background: var(--primary); color: #fff; font-weight: 700; }

.sep { width: 1px; height: 22px; background: var(--border-subtle); margin: 0 2px; }

/* ══════════════════════════════════════════════════════════════
   MAIN CONTAINER & CANVAS
   ══════════════════════════════════════════════════════════════ */
.saas-main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.saas-canvas {
  padding: 24px 32px 48px;
  flex: 1;
}

.tab-view { display: none; }
.tab-view.active {
  display: block;
  animation: tabEntrance 0.22s var(--ease-spring) forwards;
}

/* ══════════════════════════════════════════════════════════════
   WORKBENCH GRID — 55/45 split desktop
   ══════════════════════════════════════════════════════════════ */
.workbench-grid {
  display: grid;
  grid-template-columns: 55fr 45fr;
  gap: 24px;
  align-items: start;
}
.workbench-grid > * {
  min-width: 0;
}

/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */
.saas-card {
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  transition: box-shadow var(--t-normal) var(--ease-out),
              border-color var(--t-normal) var(--ease-out),
              transform var(--t-normal) var(--ease-out);
}
.saas-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: -0.01em;
}
.card-header-title i { color: var(--primary); flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════
   FORM FIELDS
   ══════════════════════════════════════════════════════════════ */
.sb-row { margin-bottom: 10px; }
.sb-row label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.sb-row input,
.sb-row textarea,
.sb-row select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-elevated);
  transition: border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out);
  outline: none;
  color: var(--text-main);
}
.sb-row input:focus,
.sb-row textarea:focus,
.sb-row select:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.sb-row textarea { resize: vertical; min-height: 52px; }
.sb-row-sm { display: flex; gap: 10px; }
.sb-row-sm .sb-row { flex: 1; min-width: 0; }

/* Quick Picker */
.quick-picker-box {
  background: linear-gradient(135deg, var(--primary-light) 0%, #F0FEFF 100%);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary-border);
  margin-bottom: 14px;
  box-shadow: 0 2px 6px rgba(8,145,178,0.06);
}
.quick-picker-box label {
  color: var(--primary-hover);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
}
.quick-picker-box .picker-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.quick-picker-box input,
.quick-picker-box select {
  width: 100%;
  flex: 1;
  min-width: 140px;
  padding: 7px 10px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out);
}
.quick-picker-box input:focus,
.quick-picker-box select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.custom-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(30, 58, 95, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  flex-direction: column;
}
.custom-autocomplete-dropdown.active {
  display: flex;
}
.custom-autocomplete-dropdown .dd-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background var(--t-fast);
  color: #fff;
}
.custom-autocomplete-dropdown .dd-item:last-child {
  border-bottom: none;
}
.custom-autocomplete-dropdown .dd-item:hover,
.custom-autocomplete-dropdown .dd-item.focused {
  background: rgba(255, 255, 255, 0.1);
}
.custom-autocomplete-dropdown .dd-name {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 2px;
  color: #fff;
}
.custom-autocomplete-dropdown .dd-details {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
}

/* ══════════════════════════════════════════════════════════════
   COUNTER SUMMARY CARD (right column top)
   ══════════════════════════════════════════════════════════════ */
.counter-summary-card {
  background: var(--dark-slate);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  color: #fff;
  margin-bottom: 6px;
}
.counter-summary-card .csc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 6px;
  gap: 8px;
}
.counter-summary-card .csc-row strong,
.counter-summary-card .csc-row span:last-child {
  color: #fff;
  font-weight: 600;
  max-width: 65%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.counter-summary-card .csc-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-top: 10px;
  margin-top: 4px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  gap: 8px;
}
.counter-summary-card .csc-total .grand {
  color: var(--secondary);
  font-size: clamp(14px, 4vw, 18px);
  font-weight: 800;
  white-space: nowrap;
  text-align: right;
}

/* Mobile Summary Strip Styling */
.mobile-summary-strip {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--dark-slate);
  color: #fff;
  padding: 8px 12px;
  font-size: 11px;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  position: fixed;
  bottom: var(--bottomnav-h);
  left: 0;
  width: 100%;
  z-index: 90;
  border-top: 1px solid var(--dark-border);
}
.mobile-summary-strip .ms-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.mobile-summary-strip .ms-col span:first-child {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
}
.mobile-summary-strip .ms-col span:last-child {
  font-weight: 700;
  color: #fff;
  font-size: 11.5px;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-summary-strip .ms-col.total span:last-child {
  color: var(--secondary);
  font-size: 13px;
  font-weight: 800;
  max-width: none;
}
.mobile-summary-strip .ms-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.mobile-summary-strip .ms-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   EXCEL-STYLE BILLING GRID
   ══════════════════════════════════════════════════════════════ */
.excel-grid-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: 0 2px 8px -2px rgba(8,100,120,0.06);
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.excel-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.excel-grid-table thead {
  background: var(--bg-muted);
  border-bottom: 2px solid var(--border-subtle);
}
.excel-grid-table th {
  padding: 12px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
  border-right: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.excel-grid-table th:last-child { border-right: none; }
.excel-grid-table td {
  padding: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: middle;
  background: #fff;
  transition: background var(--t-fast) var(--ease-out);
}
.excel-grid-table td:last-child { border-right: none; }
.excel-grid-table tr:hover td { background: var(--primary-light); }

.excel-cell-input {
  width: 100%;
  height: 40px;
  padding: 6px 12px;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-main);
}
.excel-cell-input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--primary);
  border-radius: 2px;
}
.excel-cell-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════════════════════
   LIVE PREVIEW AREA
   ══════════════════════════════════════════════════════════════ */
.preview-area {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: var(--bg-muted);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ══════════════════════════════════════════════════════════════
   INVOICE PAPER
   ══════════════════════════════════════════════════════════════ */
.invoice-paper {
  background: #fff;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(8,100,120,0.05);
  border-radius: 4px;
  overflow: hidden;
  transition: width var(--t-slow) var(--ease-spring);
  display: flex;
  flex-direction: column;
}
.invoice-paper.size-a4     { width: 210mm; min-height: 297mm; }
.invoice-paper.size-a5     { width: 148.5mm; min-height: 210mm; }
.invoice-paper.size-letter { width: 8.5in; min-height: 11in; }
.invoice-paper.size-legal  { width: 8.5in; min-height: 14in; }
.invoice-paper.size-a4 .inv-inner { padding: 10mm 12mm; }
.invoice-paper.size-a5 .inv-inner { padding: 8mm 8mm; font-size: 10.5px; }

.inv-inner {
  font-size: 11.5px;
  line-height: 1.45;
  color: #111;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Invoice internals (unchanged from original – these are print-output) */
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 16px; }
.inv-head-left { flex: 1; }
.inv-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 4px; color: #0C2631; }
.inv-head h2 { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.inv-head p  { font-size: 10px; color: #5a7a84; line-height: 1.5; max-width: 360px; }
.inv-head-right { text-align: right; min-width: 170px; }
.inv-head-right .inv-title { font-size: 17px; font-weight: 700; color: #0C2631; margin-bottom: 8px; letter-spacing: -0.02em; }
.inv-meta-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 3px; font-size: 10.5px; }
.inv-meta-row .label { color: #5a7a84; font-weight: 500; }
.inv-meta-row .value { font-weight: 700; color: #111; }
.status-pill { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
.status-pill.paid    { background: var(--success-light); color: var(--success); border: 1px solid var(--accent-border); }
.status-pill.unpaid  { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger-border); }
.status-pill.partial { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }

.buyer-box { border: 1px solid var(--border-subtle); border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; background: var(--bg-app); }
.buyer-box .bb-title  { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--primary); margin-bottom: 4px; }
.buyer-box .bb-name   { font-weight: 700; font-size: 12.5px; margin-bottom: 2px; color: #0C2631; }
.buyer-box .bb-addr   { font-size: 10px; color: var(--text-main); line-height: 1.45; word-break: break-word; }
.buyer-box .bb-info   { font-size: 10px; color: var(--text-muted); margin-top: 4px; line-height: 1.6; }
.buyer-box .bb-info strong { color: #111; }

.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 10px; }
.inv-table thead { background: #0C2631; color: #fff; }
.inv-table thead th { padding: 7px 5px; text-align: left; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.inv-table thead th:nth-child(n+5) { text-align: right; }
.inv-table tbody td { padding: 6px 5px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; line-height: 1.35; }
.inv-table tbody td.desc { max-width: 220px; word-break: break-word; font-weight: 500; }
.inv-table tbody td:nth-child(n+5) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-table tbody tr:last-child td { border-bottom: 2px solid #0C2631; }
.inv-table .sno { width: 24px; text-align: center; }

.tax-summary { margin-bottom: 12px; page-break-inside: avoid; }
.tax-summary h4 { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #0C2631; margin-bottom: 4px; }
.ts-box { margin-bottom: 12px; }
.ts-table { width: 100%; border-collapse: collapse; font-size: 9.5px; border-top: 2px solid #0C2631; border-bottom: 2px solid #0C2631; }
.ts-table thead th { padding: 5px; text-align: left; font-size: 8.5px; text-transform: uppercase; color: #0C2631; font-weight: 700; border-bottom: 1px solid var(--border-subtle); }
.ts-table tbody td { padding: 5px; vertical-align: middle; border-bottom: 1px dotted var(--border-subtle); color: var(--text-main); }
.ts-table tbody tr:last-child td { border-bottom: none; }
.ts-table .amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-hsn { font-weight: 700; color: #0C2631; }
.ts-tot-amt { font-weight: 700; color: #0C2631; }
.ts-grand-box { display: flex; flex-direction: column; align-items: flex-end; padding-top: 2px; margin-bottom: 12px; }
.ts-discount { display: flex; justify-content: flex-end; width: 100%; max-width: 300px; font-size: 10px; margin-bottom: 4px; }
.ts-discount .lbl { color: var(--text-muted); margin-right: 12px; text-align: right; flex: 1; }
.ts-discount .amt { font-weight: 700; min-width: 120px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.ts-grand { display: flex; justify-content: flex-end; width: 100%; max-width: 300px; font-size: 13px; font-weight: 800; color: #0C2631; margin-top: 2px; }
.ts-grand .lbl { margin-right: 12px; text-align: right; flex: 1; }
.ts-grand .amt { text-align: right; min-width: 120px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.amt-words { background: var(--bg-app); border-radius: 6px; padding: 8px 12px; margin-bottom: 12px; font-size: 10px; font-style: italic; color: var(--text-main); page-break-inside: avoid; }
.amt-words strong { color: #0C2631; font-style: normal; }

.terms-bank { display: flex; gap: 16px; margin-bottom: 16px; font-size: 10px; page-break-inside: avoid; }
.terms-bank .tb-col { flex: 1; }
.terms-bank h4 { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #0C2631; margin-bottom: 4px; }
.terms-bank p, .terms-bank li { color: var(--text-main); line-height: 1.5; font-size: 9.5px; }
.terms-bank ul { list-style: none; padding: 0; }
.terms-bank ul li::before { content: attr(data-num) ". "; font-weight: 700; color: #0C2631; }
.bank-detail { line-height: 1.7; }
.bank-detail strong { color: #111; }

.sig-block { display: flex; justify-content: flex-end; margin-top: 20px; page-break-inside: avoid; }
.sig-block .sig-line { text-align: center; font-size: 10.5px; }
.sig-block .sig-line .line { width: 170px; border-bottom: 1px solid #0C2631; margin-bottom: 4px; padding-top: 24px; }
.sig-block .sig-line .name { font-weight: 700; }
.sig-block .sig-line .role { color: var(--text-muted); font-size: 9.5px; }

/* ══════════════════════════════════════════════════════════════
   BILL SUMMARY CARD (dark version inside saas-card)
   ══════════════════════════════════════════════════════════════ */
.bill-summary-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}
.bill-summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  font-size: 12.5px;
  color: #CBD5E1;
}
.bill-summary-row.total {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 9px;
  margin-top: 4px;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

/* ══════════════════════════════════════════════════════════════
   DIRECTORIES (Customers, Items, History tabs)
   ══════════════════════════════════════════════════════════════ */
.directory-layout { width: 100%; }
.directory-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.directory-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}
.directory-header p { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.directory-header .dir-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.search-toolbar { margin-bottom: 14px; }
.search-toolbar input {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-surface);
  outline: none;
  color: var(--text-main);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.search-toolbar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.dir-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-normal) var(--ease-spring),
              box-shadow var(--t-normal) var(--ease-out),
              border-color var(--t-normal) var(--ease-out);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.dir-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-border); }
.dir-card .card-title { font-weight: 700; font-size: 14px; color: var(--text-main); margin-bottom: 5px; }
.dir-card .card-body { font-size: 12px; color: var(--text-body); line-height: 1.6; margin-bottom: 12px; flex: 1; }
.dir-card .card-body strong { color: var(--text-main); }
.dir-card .card-actions { display: flex; gap: 6px; border-top: 1px solid var(--border-subtle); padding-top: 10px; justify-content: flex-end; }

/* ══════════════════════════════════════════════════════════════
   BILL WINDOW OVERLAY (fullscreen)
   ══════════════════════════════════════════════════════════════ */
.bill-window-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 30, 0.9);
  backdrop-filter: blur(16px);
  z-index: 500;
  display: none;
  align-items: stretch;
  justify-content: stretch;
}
.bill-window-overlay.active { display: flex; }

.bill-window-container {
  display: flex;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.bill-paper-view {
  flex: 1;
  background: #0A1820;
  padding: 28px;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}

.bill-sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--dark-surface);
  color: #fff;
  border-left: 1px solid var(--dark-border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: -8px 0 24px rgba(0,0,0,0.3);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.bill-sidebar h3 { font-size: 17px; font-weight: 700; margin-bottom: 3px; display: flex; align-items: center; gap: 8px; color: #fff; }
.bill-sidebar p  { color: #7FAEBB; font-size: 11.5px; margin-bottom: 16px; }

.bill-control-group { margin-bottom: 12px; }
.bill-control-group label { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #7FAEBB; margin-bottom: 5px; }
.bill-control-group select,
.bill-control-group input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--dark-border);
  background: rgba(255,255,255,0.07);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.bill-control-group select:focus,
.bill-control-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8,145,178,0.25);
}
.bill-control-group select option { background: var(--dark-surface); color: #fff; }

.key-hints {
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 10.5px;
  color: #5A8A9A;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.key-hints kbd {
  background: rgba(255,255,255,0.1);
  color: #8AABB8;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 10px;
}

/* ══════════════════════════════════════════════════════════════
   FLOATING ACTION BUTTON
   ══════════════════════════════════════════════════════════════ */
.floating-pos-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 8px 22px rgba(8,145,178,0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  transition: all var(--t-normal) var(--ease-spring);
}
.floating-pos-btn:hover {
  transform: scale(1.1) translateY(-2px);
  background: var(--primary-hover);
  box-shadow: 0 12px 28px rgba(8,145,178,0.5);
}

/* ══════════════════════════════════════════════════════════════
   TOAST & MODALS
   ══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 20px;
  right: 84px;
  background: var(--dark-slate);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--t-normal) var(--ease-spring);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255,255,255,0.08);
}
.toast.show { opacity: 1; transform: translateY(0); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 30, 0.55);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  padding: 16px;
}
.modal-overlay.active { display: flex; animation: fadeIn 0.18s ease forwards; }

.modal-box {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 480px;
  max-width: 100%;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-subtle);
  animation: modalZoom 0.22s var(--ease-spring) forwards;
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-box h3 { font-size: 16px; font-weight: 700; margin-bottom: 5px; color: var(--text-main); letter-spacing: -0.02em; }
.modal-box p  { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.modal-box input,
.modal-box textarea,
.modal-box select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 8px;
  outline: none;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-elevated);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.modal-box input:focus,
.modal-box textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* ══════════════════════════════════════════════════════════════
   BOTTOM NAVIGATION (mobile only)
   ══════════════════════════════════════════════════════════════ */
.bottom-nav {
  display: none; /* shown only on mobile via media query */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottomnav-h);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  align-items: stretch;
  box-shadow: 0 -4px 16px rgba(8,100,120,0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  transition: color var(--t-fast) var(--ease-out);
  padding: 4px 2px;
  position: relative;
  min-height: 44px;
}
.bottom-nav-item:hover { color: var(--primary); }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2.5px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}
.bottom-nav-item i { transition: transform var(--t-fast) var(--ease-spring); }
.bottom-nav-item.active i { transform: scale(1.12); }

/* ══════════════════════════════════════════════════════════════
   MOBILE ACCORDION CARDS
   ══════════════════════════════════════════════════════════════ */
.accordion-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-normal);
}
.accordion-card.open { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  text-align: left;
  gap: 10px;
}
.accordion-trigger .acc-left { display: flex; align-items: center; gap: 8px; }
.accordion-trigger .acc-left i { color: var(--primary); flex-shrink: 0; }
.accordion-chevron {
  color: var(--text-muted);
  transition: transform var(--t-normal) var(--ease-spring);
  flex-shrink: 0;
}
.accordion-card.open .accordion-chevron { transform: rotate(180deg); }

.accordion-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--t-slow) var(--ease-spring);
}
.accordion-card.open .accordion-body { max-height: 2000px; }
.accordion-body-inner { padding: 0 16px 16px; }