/* ============================================
   GST BILLING SOFTWARE — DESIGN SYSTEM
   Sree Balaji Textile Spares Productions
   ============================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  /* Colors */
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-card-hover: #242840;
  --bg-input: #252838;
  --border-color: #2d3148;
  --border-light: #383d58;
  --text-primary: #e8eaf0;
  --text-secondary: #9498b0;
  --text-muted: #6b7094;
  --accent: #6c5ce7;
  --accent-hover: #7f72ea;
  --accent-light: rgba(108, 92, 231, 0.15);
  --success: #00c853;
  --success-light: rgba(0, 200, 83, 0.12);
  --warning: #ff9800;
  --warning-light: rgba(255, 152, 0, 0.12);
  --danger: #ff5252;
  --danger-light: rgba(255, 82, 82, 0.12);
  --info: #448aff;
  --info-light: rgba(68, 138, 255, 0.12);
  --gradient-1: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --gradient-2: linear-gradient(135deg, #00c853, #69f0ae);
  --gradient-3: linear-gradient(135deg, #ff9800, #ffcc02);

  /* Typography */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Sizing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.2);

  /* Transitions */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}



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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent);
  color: #fff;
}

/* ---------- App Shell ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header / Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.navbar-logo {
  width: 38px;
  height: 38px;
  background: var(--gradient-1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.navbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.navbar-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.navbar-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient-1);
  color: #fff;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 25px rgba(108, 92, 231, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 200, 83, 0.3);
}

.btn-success:hover {
  box-shadow: 0 6px 25px rgba(0, 200, 83, 0.45);
  transform: translateY(-1px);
}

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

.btn-danger:hover {
  opacity: 0.9;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover {
  background: var(--accent-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Page Views ---------- */
.page-view {
  display: none;
  animation: fadeIn 0.35s ease;
}

.page-view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Dashboard ---------- */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.5rem;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.stat-card.purple .stat-icon {
  background: var(--accent-light);
  color: var(--accent);
}

.stat-card.green .stat-icon {
  background: var(--success-light);
  color: var(--success);
}

.stat-card.orange .stat-icon {
  background: var(--warning-light);
  color: var(--warning);
}

.stat-card.blue .stat-icon {
  background: var(--info-light);
  color: var(--info);
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 2px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Invoice Table (Dashboard) ---------- */
.dashboard-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.dashboard-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.dashboard-section-title {
  font-size: 1rem;
  font-weight: 700;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  padding: 9px 0;
  outline: none;
  width: 220px;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box .search-icon {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

.data-table tr:hover td {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.data-table .inv-number {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  font-size: 0.83rem;
}

.data-table .inv-amount {
  font-weight: 700;
  color: var(--text-primary);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.table-actions {
  display: flex;
  gap: 4px;
}

.table-actions .btn-icon {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.87rem;
  margin-bottom: 1.5rem;
}

/* ---------- Login Page ---------- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 1rem 0;
}

.login-card {
  width: 100%;
  max-width: 420px;
  text-align: left;
}

.login-header {
  text-align: center;
}

/* ---------- Invoice Form Page ---------- */
.invoice-form-page {
  max-width: 1100px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

/* Form Sections */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.2rem;
  transition: var(--transition);
}

.form-section:hover {
  border-color: var(--border-light);
}

.form-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--gradient-1);
  border-radius: 3px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 70px;
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239498b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- Products Table ---------- */
.products-section {
  overflow: visible;
}

.products-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.products-table th {
  background: var(--bg-secondary);
  padding: 10px 12px;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.products-table td {
  padding: 4px;
  border-bottom: 1px solid var(--border-color);
}

.products-table input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  width: 100%;
  outline: none;
  transition: var(--transition);
}

.products-table input:focus {
  background: var(--bg-input);
  border-color: var(--accent);
}

.products-table input:hover {
  background: var(--bg-input);
}

.products-table .sno {
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.83rem;
  padding: 9px;
}

.products-table .amount-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  padding: 9px 12px;
  font-size: 0.85rem;
}

.products-table .delete-row-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.products-table .delete-row-btn:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.add-row-btn {
  margin-top: 0.8rem;
}

/* ---------- Tax Summary ---------- */
.tax-summary-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  align-items: start;
}

.amount-words-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-style: italic;
  min-height: 60px;
}

.amount-words-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.tax-breakdown {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.tax-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.88rem;
}

.tax-row:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.tax-row .tax-label {
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tax-row .tax-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.tax-row.total {
  padding-top: 12px;
  margin-top: 4px;
  border-top: 2px solid var(--accent);
}

.tax-row.total .tax-label {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.tax-row.total .tax-value {
  font-size: 1.15rem;
  color: var(--accent);
  font-weight: 800;
}

.tax-row input[type="number"] {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.83rem;
  width: 60px;
  text-align: center;
  outline: none;
  transition: var(--transition);
}

.tax-row input[type="number"]:focus {
  border-color: var(--accent);
}

.roundoff-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.roundoff-toggle input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.roundoff-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.roundoff-toggle input[type="checkbox"]:checked::after {
  content: '✓';
  color: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.7rem;
  font-weight: bold;
}

/* ---------- Bank & Signature ---------- */
.bank-signature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.signature-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 120px;
}

.signature-line {
  border-top: 2px solid var(--border-light);
  padding-top: 8px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: auto;
}

/* ============================================
   INVOICE PREVIEW / PRINT STYLES
   ============================================ */
.preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  overflow-y: auto;
  padding: 2rem;
}

.preview-overlay.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

/* The actual printable invoice */
.invoice-print-area {
  width: 210mm;
  font-family: Arial, Helvetica, Roboto, sans-serif;
  font-size: 9pt;
  line-height: 1.4;
}

.invoice-copy {
  background: #fff;
  color: #000;
  width: 100%;
  min-height: 297mm;
  padding: 8mm 10mm;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  position: relative;
  page-break-after: always;
  margin-bottom: 2rem;
  box-sizing: border-box;
}

.invoice-copy:last-child {
  page-break-after: auto;
  margin-bottom: 0;
}

.invoice-copy * {
  color: #000 !important;
}

/* Invoice Header */
.inv-header {
  text-align: center;
  border: 2px solid #000;
  border-bottom: none;
  padding: 4mm 4mm 3mm;
  position: relative;
}

.inv-header h1 {
  font-size: 14pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 1mm;
  color: #000;
}

.inv-header .inv-company-details {
  font-size: 8.5pt;
  color: #000;
  line-height: 1.4;
}

.inv-header .inv-gstin {
  font-size: 9pt;
  font-weight: 700;
  margin-top: 1.5mm;
}

.inv-title-bar {
  background: #f0f0f0;
  text-align: center;
  padding: 1.5mm 0;
  font-size: 10pt;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-left: 2px solid #000;
  border-right: 2px solid #000;
}


/* Invoice Meta + Customer Grid */
.inv-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 2px solid #000;
  border-top: 2px solid #000;
}

.inv-details-grid .inv-col {
  padding: 2mm 3mm;
}

.inv-details-grid .inv-col:first-child {
  border-right: 1px solid #000;
}

.inv-field {
  display: flex;
  gap: 2mm;
  font-size: 8.5pt;
  padding: 0.5mm 0;
}

.inv-field .inv-label {
  font-weight: 800;
  white-space: nowrap;
  min-width: 25mm;
}

.invoice-print-area .inv-customer-highlight {
  background-color: #000;
  padding: 1.5mm 2mm;
  margin-bottom: 2mm;
  margin-top: 1mm;
  border-radius: 2px;
}

.invoice-print-area .inv-customer-highlight,
.invoice-print-area .inv-customer-highlight * {
  color: #fff !important;
}

.invoice-print-area .inv-customer-highlight .inv-label {
  font-weight: 800;
}

.invoice-print-area .inv-customer-highlight .inv-value {
  font-weight: normal;
}

.inv-customer-section {
  border: 2px solid #000;
  border-top: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.inv-customer-section .inv-col {
  padding: 2mm 3mm;
}

.inv-customer-section .inv-col:first-child {
  border-right: 1px solid #000;
}

.inv-customer-section .inv-col-title {
  font-size: 10pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1.5mm;
  border-bottom: 1px solid #000;
  padding-bottom: 1mm;
}

/* Products Table (Print) */
.inv-products-table {
  width: 100%;
  border-collapse: collapse;
  border-left: 2px solid #000;
  border-right: 2px solid #000;
}

.inv-products-table th {
  background: #f0f0f0;
  padding: 1.5mm 2mm;
  font-size: 8pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid #000;
  text-align: center;
}

.inv-products-table td {
  padding: 1.2mm 2mm;
  font-size: 9pt;
  border: 1px solid #000;
  height: 22px;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
}

.inv-products-table td.text-right {
  text-align: right;
}

.inv-products-table td.text-center {
  text-align: center;
}

.inv-products-table tfoot td {
  border: 1px solid #000;
  font-weight: 800;
}

/* Tax Section (Print) */
.inv-tax-section {
  border: 2px solid #000;
  border-top: none;
  display: grid;
  grid-template-columns: 1fr 200px;
}

.inv-tax-section .inv-amount-words {
  padding: 2mm 3mm;
  border-right: 1px solid #000;
  font-size: 10.5pt;
}

.inv-tax-section .inv-amount-words .label {
  font-weight: 800;
  font-size: 8pt;
  text-transform: uppercase;
  margin-bottom: 1px;
}

.inv-tax-section .inv-amount-words .words {
  font-weight: 600;
}

.inv-totals {
  padding: 0;
}

.inv-total-row {
  display: flex;
  justify-content: space-between;
  padding: 1.5mm 3mm;
  font-size: 9pt;
  border-bottom: 1px solid #000;
}

.inv-total-row:last-child {
  border-bottom: none;
}

.inv-total-row.grand {
  background: #f0f0f0;
  font-weight: 800;
  font-size: 11pt;
  padding: 2mm 3mm;
  border-top: 2px solid #000;
}

/* Bank & Signature (Print) */
.inv-footer-grid {
  border: 2px solid #000;
  border-top: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.inv-footer-grid .inv-col {
  padding: 2mm 3mm;
}

.inv-footer-grid .inv-col:first-child {
  border-right: 1px solid #000;
}

.inv-footer-col-title {
  font-size: 10pt;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 1.5mm;
  border-bottom: 1px solid #000;
  padding-bottom: 1mm;
}

.inv-bank-detail {
  font-size: 13pt;
  padding: 0.5mm 0;
}

.inv-bank-detail span {
  font-weight: 800;
}

.inv-signature-area {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 18mm;
  text-align: center;
}

.inv-signature-label {
  font-size: 8.5pt;
  font-weight: 800;
  border-top: 1px solid #000;
  padding-top: 1mm;
  margin-top: auto;
}

.inv-auth-for {
  font-size: 8.5pt;
  font-weight: 800;
  text-align: right;
  margin-bottom: 1.5mm;
}

.inv-terms {
  border: 2px solid #000;
  border-top: none;
  padding: 2mm 3mm;
  font-size: 10pt;
}

.inv-terms p {
  margin-bottom: 1px;
}

.inv-computer-gen {
  text-align: center;
  font-size: 8pt;
  padding: 1mm 0;
  border: 2px solid #000;
  border-top: none;
}

/* ---------- Settings Page ---------- */
.settings-page {
  max-width: 800px;
  margin: 0 auto;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.87rem;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.35s ease;
  min-width: 280px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--info);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ---------- Confirm Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  animation: fadeIn 0.25s ease;
}

.modal h3 {
  font-size: 1.15rem;
  margin-bottom: 0.7rem;
}

.modal p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  html,
  body {
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .navbar,
  .main-content,
  .preview-toolbar,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }

  .preview-overlay {
    display: block !important;
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
  }

  .invoice-print-area {
    width: 210mm !important;
    height: auto !important;
    min-height: auto !important;
    padding: 0 !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    page-break-after: auto !important;
    page-break-before: auto !important;
  }

  .invoice-copy {
    width: 210mm !important;
    height: 297mm !important;
    min-height: auto !important;
    padding: 0 !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    page-break-after: always !important;
  }

  .invoice-copy:last-child {
    page-break-after: auto !important;
  }

  .inv-header,
  .inv-title-bar,
  .inv-details-grid,
  .inv-customer-section,
  .inv-products-table,
  .inv-tax-section,
  .inv-footer-grid,
  .inv-terms,
  .inv-computer-gen {
    page-break-inside: avoid !important;
  }
}

/* Landscape Print Override */
@media print and (orientation: landscape) {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }
  .invoice-copy {
    width: 277mm !important; /* 297mm - 20mm margins */
    height: 190mm !important; /* 210mm - 20mm margins */
  }
  .invoice-print-area {
    width: 277mm !important;
  }
}

/* ============================================
   HAMBURGER MENU (Mobile Navigation)
   ============================================ */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  line-height: 1;
  z-index: 110;
}

.hamburger-btn:hover {
  background: var(--bg-card);
}

/* Mobile nav overlay */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-nav-overlay.active {
  display: block;
  opacity: 1;
}

/* Slide-in mobile menu panel */
.mobile-nav-panel {
  display: none;
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  z-index: 160;
  padding: 1.5rem;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
}

.mobile-nav-panel.active {
  right: 0;
}

.mobile-nav-panel .mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.mobile-nav-panel .mobile-nav-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.mobile-nav-panel .mobile-nav-close:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.mobile-nav-panel .mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-nav-panel .mobile-nav-links .btn {
  width: 100%;
  justify-content: flex-start;
  padding: 14px 16px;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

/* ============================================
   MOBILE PRODUCT CARDS (replaces table on small screens)
   ============================================ */
.mobile-product-cards {
  display: none;
}

.mobile-product-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.8rem;
  position: relative;
  transition: var(--transition);
}

.mobile-product-card:hover {
  border-color: var(--border-light);
}

.mobile-product-card .mobile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.mobile-product-card .mobile-card-sno {
  background: var(--accent-light);
  color: var(--accent);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.mobile-product-card .mobile-card-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.mobile-product-card .mobile-card-delete {
  background: var(--danger-light);
  border: none;
  color: var(--danger);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
}

.mobile-product-card .mobile-card-delete:hover {
  background: var(--danger);
  color: #fff;
}

.mobile-product-card .mobile-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.mobile-product-card .mobile-card-grid .full-width {
  grid-column: 1 / -1;
}

.mobile-product-card .mobile-card-field label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 4px;
}

.mobile-product-card .mobile-card-field input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.88rem;
  width: 100%;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.mobile-product-card .mobile-card-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ============================================
   MOBILE BOTTOM ACTION BAR
   ============================================ */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 100;
  gap: 8px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.mobile-bottom-bar .btn {
  flex: 1;
  justify-content: center;
  padding: 12px 8px;
  font-size: 0.82rem;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* ---------- Tablets & Small Laptops ---------- */
@media (max-width: 1024px) {
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .bank-signature-grid {
    grid-template-columns: 1fr;
  }

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

  .invoice-form-page {
    max-width: 100%;
  }
}

/* ---------- Tablets Portrait & Large Phones ---------- */
@media (max-width: 768px) {

  /* Hamburger menu visible */
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-nav-panel {
    display: block;
  }

  /* Hide desktop nav actions */
  .navbar-actions {
    display: none;
  }

  .navbar {
    padding: 0 1rem;
    height: 56px;
  }

  .navbar-subtitle {
    display: none;
  }

  .navbar-logo {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }

  .navbar-title {
    font-size: 1rem;
  }

  /* Main content */
  .main-content {
    padding: 1rem;
    padding-bottom: 80px;
    /* space for bottom bar */
  }

  /* Dashboard stats */
  .dashboard-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-card .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    margin-bottom: 0.7rem;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .stat-label {
    font-size: 0.72rem;
  }

  /* Dashboard table header */
  .dashboard-section-header {
    flex-direction: column;
    gap: 0.8rem;
    padding: 1rem;
    align-items: stretch;
  }

  .dashboard-section-header>div {
    flex-direction: column;
    gap: 8px;
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }

  /* Data table on mobile — horizontal scroll hint */
  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  /* Form layout */
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-section {
    padding: 1.1rem;
  }

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

  /* Page header */
  .page-header {
    flex-direction: column;
    gap: 0.8rem;
    align-items: stretch;
  }

  .page-header>div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-header>div .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
    font-size: 0.75rem;
    padding: 10px 12px;
  }

  /* Invoice preview */
  .preview-overlay {
    padding: 1rem;
  }

  .preview-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }

  .preview-toolbar .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
    font-size: 0.82rem;
    padding: 10px 10px;
  }

  .invoice-print-area {
    width: 100%;
    padding: 5mm;
    font-size: 8pt;
    min-height: auto;
  }

  .inv-header h1 {
    font-size: 12pt;
  }

  .inv-details-grid {
    grid-template-columns: 1fr;
  }

  .inv-details-grid .inv-col:first-child {
    border-right: none;
    border-bottom: 1px solid #333;
  }

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

  .inv-customer-section .inv-col:first-child {
    border-right: none;
    border-bottom: 1px solid #333;
  }

  .inv-tax-section {
    grid-template-columns: 1fr;
  }

  .inv-tax-section .inv-amount-words {
    border-right: none;
    border-bottom: 1px solid #333;
  }

  .inv-footer-grid {
    grid-template-columns: 1fr;
  }

  .inv-footer-grid .inv-col:first-child {
    border-right: none;
    border-bottom: 1px solid #333;
  }

  /* Touch-optimized inputs */
  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 12px;
    font-size: 16px;
    /* prevents iOS zoom on focus */
    min-height: 44px;
    /* touch target */
  }

  /* Buttons touch target */
  .btn {
    min-height: 44px;
    padding: 10px 18px;
  }

  .btn-sm {
    min-height: 38px;
    padding: 8px 14px;
  }

  /* Toast on mobile */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }

  /* Modal */
  .modal {
    padding: 1.5rem;
    margin: 0 1rem;
  }
}

/* ---------- Phones (Landscape & Portrait) ---------- */
@media (max-width: 600px) {

  /* Products table: switch to card layout */
  .products-table-wrapper {
    display: none;
  }

  .mobile-product-cards {
    display: block;
  }

  /* Mobile bottom action bar */
  .mobile-bottom-bar {
    display: flex;
  }

  /* Hide desktop bottom action buttons */
  .desktop-bottom-actions {
    display: none;
  }

  /* Company Name in form — smaller */
  #companyNameDisplay {
    font-size: 1.05rem !important;
  }

  #companyAddressDisplay,
  #companyContactDisplay {
    font-size: 0.78rem !important;
  }

  /* Tax summary — stack fully */
  .tax-summary-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .tax-breakdown {
    padding: 1rem;
  }

  .tax-row {
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 4px;
  }

  .tax-row .tax-label {
    flex-wrap: wrap;
    gap: 6px;
  }

  .tax-row.total .tax-value {
    font-size: 1.05rem;
  }

  /* Signature grid */
  .bank-signature-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Small Phones ---------- */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .navbar {
    height: 52px;
    padding: 0 0.8rem;
  }

  .navbar-logo {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
    border-radius: 7px;
  }

  .navbar-brand {
    gap: 8px;
  }

  .navbar-title {
    font-size: 0.92rem;
  }

  .main-content {
    padding: 0.7rem;
    padding-bottom: 80px;
  }

  /* Stats — single column */
  .dashboard-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.8rem;
  }

  .stat-card .stat-icon {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .stat-value {
    font-size: 1rem;
  }

  .stat-label {
    font-size: 0.68rem;
  }

  /* Form sections */
  .form-section {
    padding: 0.9rem;
    margin-bottom: 0.8rem;
    border-radius: var(--radius-md);
  }

  .form-section-title {
    font-size: 0.75rem;
    margin-bottom: 0.9rem;
  }

  /* Buttons */
  .btn {
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  /* State code field in customer details */
  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 11px;
    font-size: 16px;
  }

  /* Product cards adjustments */
  .mobile-product-card {
    padding: 0.8rem;
  }

  .mobile-product-card .mobile-card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  /* Preview print area */
  .invoice-print-area {
    font-size: 7pt;
    padding: 3mm;
  }

  .inv-header h1 {
    font-size: 10pt;
    letter-spacing: 0;
  }

  .inv-header .inv-company-details {
    font-size: 7pt;
  }

  .inv-field {
    font-size: 7pt;
  }

  .inv-products-table th {
    font-size: 5.5pt;
    padding: 1.5mm 2mm;
  }

  .inv-products-table td {
    font-size: 7pt;
    padding: 1.5mm 2mm;
  }

  /* Search box */
  .dashboard-section-header {
    padding: 0.8rem;
  }
}

/* ---------- Very Small Phones (320px) ---------- */
@media (max-width: 360px) {
  html {
    font-size: 13px;
  }

  .navbar {
    height: 48px;
    padding: 0 0.6rem;
  }

  .navbar-title {
    font-size: 0.85rem;
  }

  .navbar-logo {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .main-content {
    padding: 0.5rem;
    padding-bottom: 76px;
  }

  .dashboard-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .stat-card {
    padding: 0.7rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .form-section {
    padding: 0.7rem;
    border-radius: var(--radius-sm);
  }

  .mobile-product-card .mobile-card-grid {
    grid-template-columns: 1fr;
  }

  .mobile-bottom-bar {
    padding: 8px 10px;
  }

  .mobile-bottom-bar .btn {
    padding: 10px 6px;
    font-size: 0.75rem;
  }

  .preview-overlay {
    padding: 0.5rem;
  }

  .preview-toolbar {
    padding: 8px;
    gap: 6px;
    border-radius: var(--radius-md);
  }

  .preview-toolbar .btn {
    padding: 8px 8px;
    font-size: 0.75rem;
  }
}

/* ============================================
   TOUCH & INTERACTION ENHANCEMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse) {

  /* Disable hover transforms on touch devices — they stick */
  .stat-card:hover {
    transform: none;
    box-shadow: none;
  }

  .btn-primary:hover,
  .btn-success:hover {
    transform: none;
  }

  /* Larger tap targets */
  .table-actions .btn-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  /* Add active states for buttons */
  .btn:active {
    transform: scale(0.95);
    opacity: 0.9;
  }

  /* Products table delete button */
  .products-table .delete-row-btn {
    padding: 10px;
    font-size: 1.2rem;
  }
}

/* ============================================
   SAFE AREA (Notch devices / iOS)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-bottom-bar {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .navbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* ============================================
   LANDSCAPE PHONE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .navbar {
    height: 44px;
  }

  .navbar-logo {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  .main-content {
    padding: 0.5rem 1rem 70px;
  }

  .stat-card {
    padding: 0.6rem;
  }

  .stat-card .stat-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 0.4rem;
  }

  .stat-value {
    font-size: 0.95rem;
  }

  .dashboard-stats {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }

  .form-section {
    padding: 0.8rem;
  }
}

/* ---------- Utilities ---------- */
.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.gap-1 {
  gap: 0.5rem;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.w-full {
  width: 100%;
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: block !important;
  }
}