@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* Color Variables & Design Tokens */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border-color: #475569;
  --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand svg {
  color: var(--accent);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-links li button {
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.nav-links li button:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.nav-links li.active button {
  background-color: var(--accent);
  color: var(--text-primary);
}

.sync-status-indicator {
  margin-top: auto;
  padding: 1rem;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.85rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

.status-badge.local {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.status-badge.synced {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
  height: 100vh;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

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

/* Dashboard Summary Cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-title {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-value {
  font-size: 2rem;
  font-weight: 700;
}

/* Dashboard Spreadsheet List View */
.table-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-bar {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 400px;
}

.search-input {
  flex-grow: 1;
  padding: 0.6rem 1rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  font-family: inherit;
}

.btn {
  padding: 0.6rem 1.2rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}

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

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

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

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

.btn-danger:hover {
  filter: brightness(0.9);
}

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

.btn-success:hover {
  filter: brightness(0.9);
}

/* Custom spreadsheet-style table for Listing */
.spreadsheet-container {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.spreadsheet-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.spreadsheet-table th, .spreadsheet-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.spreadsheet-table th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
}

.spreadsheet-table tr:hover {
  background-color: rgba(255, 255, 255, 0.01);
}

.action-btns {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s;
}

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

.action-btn.delete:hover {
  color: var(--danger);
}

/* Creator View (Editor + Live Preview Split) */
.creator-layout {
  display: flex;
  gap: 2rem;
  height: calc(100vh - 6rem);
}

.editor-panel {
  flex: 1;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  background-color: var(--bg-tertiary);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.full-width {
  grid-column: span 2;
}

label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

input, textarea, select {
  padding: 0.6rem 0.8rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

/* Line Items Editor Table */
.items-editor-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.items-table th, .items-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.items-table th {
  color: var(--text-secondary);
  text-align: left;
}

.items-table td input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

.items-table td input[readonly] {
  background-color: rgba(255, 255, 255, 0.02);
  border-color: transparent;
  color: var(--text-secondary);
}

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

.add-item-bar {
  display: flex;
  justify-content: flex-start;
}

/* Settings View */
.settings-panel {
  max-width: 800px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.instructions-box {
  background-color: var(--bg-primary);
  border-left: 4px solid var(--accent);
  padding: 1.5rem;
  border-radius: 0 8px 8px 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.instructions-box ol {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.code-snippet {
  background-color: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem;
  border-radius: 6px;
  font-family: 'Consolas', 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid var(--border-color);
}

/* A4 Live Preview Styles (Screen Simulation) */
.a4-page {
  background-color: #ffffff;
  color: #000000;
  width: 210mm;
  min-height: 297mm;
  padding: 15mm;
  box-sizing: border-box;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  font-family: Arial, Helvetica, sans-serif;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Reset font settings inside a4-page to enforce print layout matching screenshot */
.a4-page * {
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
}

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

.a4-page th, .a4-page td {
  border: 1px solid #000000;
  padding: 5px 8px;
  font-size: 10.5px;
  vertical-align: middle;
}

/* Print Header Styling matching exact layout */
.print-header-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0px;
}

.print-header-table td {
  padding: 0;
  border: 1px solid #000000;
}

.quotation-title-row td {
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  text-transform: uppercase;
  padding: 6px 0;
  background-color: #ffffff;
}

.company-info-cell {
  width: 60%;
  padding: 10px !important;
  text-align: center;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 5px;
}

.company-logo {
  width: 50px;
  height: auto;
}

.company-name {
  font-weight: bold;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.company-address {
  font-size: 8px;
  margin: 4px 0;
  line-height: 1.2;
}

.company-tax {
  font-size: 9.5px;
  margin-top: 6px;
  line-height: 1.3;
}

.quote-info-cell {
  width: 40%;
  vertical-align: top;
}

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

.info-table td {
  border: none;
  border-bottom: 1px solid #000000;
  border-left: 1px solid #000000;
  padding: 6px 8px;
}

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

.info-label {
  font-weight: bold;
  font-size: 10px;
  width: 35%;
}

.info-value {
  font-size: 10.5px;
  text-align: center;
}

/* Client box inside info-table */
.client-label-cell {
  font-weight: bold;
  font-size: 10px;
  width: 35%;
  vertical-align: middle;
}

.client-value-cell {
  font-size: 10.5px;
  height: 45px; /* height to match spacing */
  vertical-align: top;
  padding-top: 5px;
}

/* Address Row below company and quote details */
.address-row-cell {
  padding: 6px 10px !important;
  font-size: 10.5px;
  text-align: left;
}

.address-label {
  font-weight: bold;
}

/* Main items table headers */
.print-items-table {
  margin-top: -1px; /* collapse border with header table */
  margin-bottom: 0px;
}

.print-items-table th {
  text-align: center;
  font-weight: bold;
  font-size: 10px;
  padding: 5px;
  background-color: #ffffff;
}

.print-items-table td {
  font-size: 10px;
}

.col-sr { width: 6%; text-align: center; }
.col-desc { width: 35%; text-align: left; }
.col-unit { width: 8%; text-align: center; }
.col-nos { width: 6%; text-align: center; }
.col-length { width: 8%; text-align: center; }
.col-width { width: 8%; text-align: center; }
.col-qty { width: 9%; text-align: center; }
.col-rate { width: 12%; text-align: right; }
.col-amount { width: 13%; text-align: right; }

.sub-header-row th {
  font-size: 8px;
  padding: 2px 4px;
}

/* Table Totals Row */
.total-label-cell {
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.total-value-cell {
  text-align: right;
  font-weight: bold;
  font-size: 11px;
}

.grand-total-row .total-value-cell {
  color: #ef4444; /* Red color for Grand Total */
  font-size: 12px;
}

/* Payment terms box */
.payment-terms-box {
  margin-top: 15px;
  border: 1px solid #000000;
  min-height: 80px;
  padding: 8px;
}

.payment-terms-title {
  font-weight: bold;
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 6px;
  text-decoration: underline;
}

.payment-terms-content {
  font-size: 9.5px;
  line-height: 1.4;
  white-space: pre-line;
}

/* Print Preview Controls */
.preview-controls {
  margin-bottom: 1rem;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  width: 100%;
  max-width: 210mm;
}

/* PRINT MEDIA STYLES - CRITICAL FOR EXACT PDF */
@media print {
  @page {
    size: A4 portrait;
    margin: 5mm 8mm;
  }
  
  html, body {
    background-color: #ffffff;
    color: #000000;
    width: 100%;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Hide entire UI except preview panel content */
  .sidebar,
  .main-content > h2,
  .dashboard-grid,
  .table-header-row,
  .spreadsheet-container,
  .creator-layout > .editor-panel,
  .preview-controls,
  .settings-panel,
  .view-section:not(.active),
  .no-print {
    display: none !important;
  }

  .creator-layout {
    display: block !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .preview-panel {
    display: block !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  .a4-page {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 5mm !important;
    width: 100% !important;
    min-height: auto !important;
    background-color: #ffffff !important;
    page-break-after: avoid;
    page-break-inside: avoid;
    transform: none !important;
    margin-bottom: 0 !important;
  }

  .app-container {
    display: block !important;
    width: 100% !important;
  }

  .main-content {
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Force print background colors and text colors */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  .grand-total-row .total-value-cell {
    color: #ef4444 !important; /* Force red grand total text on print */
  }
}

/* ===== MOBILE ITEM CARDS (hidden on desktop by default) ===== */
.mobile-items-container {
  display: none; /* Hidden on desktop */
}

/* ===== CREATOR TABS (hidden on desktop) ===== */
.creator-tabs {
  display: none;
}

/* MOBILE & TABLET RESPONSIVE STYLES */
@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  
  .app-container {
    flex-direction: column;
    width: 100vw;
    min-height: 100vh;
    padding-bottom: 70px; /* space for bottom nav */
  }
  
  /* ===== BOTTOM TAB NAVIGATION ===== */
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 0;
    gap: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-right: none;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
  }
  
  .sidebar .brand {
    display: none;
  }
  
  .sidebar .nav-links {
    flex-direction: row;
    gap: 0;
    width: 100%;
    margin-top: 0;
  }
  
  .sidebar .nav-links li {
    flex: 1;
  }
  
  .sidebar .nav-links li button {
    width: 100%;
    padding: 0.9rem 0.5rem;
    font-size: 0.7rem;
    gap: 0.3rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 0;
    min-height: 60px;
  }
  
  .sidebar .nav-links li button svg {
    width: 22px;
    height: 22px;
  }
  
  .sidebar .sync-status-indicator {
    display: none;
  }
  
  /* ===== MAIN CONTENT ===== */
  .main-content {
    padding: 1rem;
    padding-bottom: 1rem;
    height: auto;
    overflow-y: visible;
    min-height: calc(100vh - 70px);
  }
  
  .main-content > section > h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem !important;
  }
  
  /* ===== DASHBOARD ===== */
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }
  
  .dashboard-grid .card {
    padding: 1rem;
    border-radius: 10px;
  }
  
  .dashboard-grid .card:nth-child(3) {
    grid-column: span 2;
  }
  
  .card-title {
    font-size: 0.75rem;
  }
  
  .card-value {
    font-size: 1.5rem;
  }
  
  .table-header-row {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }
  
  .search-bar {
    max-width: 100%;
  }
  
  .search-input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
  
  .table-header-row > div {
    display: flex;
    gap: 0.5rem;
  }
  
  .table-header-row > div .btn {
    flex: 1;
    justify-content: center;
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  
  /* ===== DASHBOARD: Card list instead of table on mobile ===== */
  .spreadsheet-container {
    overflow-x: visible;
    border: none;
    box-shadow: none;
    background: none;
  }
  
  .spreadsheet-table {
    display: block;
  }
  
  .spreadsheet-table thead {
    display: none;
  }
  
  .spreadsheet-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .spreadsheet-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    gap: 0.25rem;
    align-items: center;
    position: relative;
  }
  
  .spreadsheet-table tbody tr:hover {
    background-color: var(--bg-secondary);
  }
  
  .spreadsheet-table tbody td {
    border: none;
    padding: 0;
    font-size: 0.9rem;
  }
  
  /* Quote No */
  .spreadsheet-table tbody td:nth-child(1) {
    flex: 0 0 auto;
    font-size: 1.1rem;
  }
  
  /* Date */
  .spreadsheet-table tbody td:nth-child(2) {
    flex: 1;
    text-align: right;
    color: var(--text-secondary);
    font-size: 0.85rem;
  }
  
  /* Client */
  .spreadsheet-table tbody td:nth-child(3) {
    flex: 0 0 100%;
    font-size: 0.95rem;
    padding: 0.25rem 0;
    color: var(--text-primary);
  }
  
  /* Sub Total */
  .spreadsheet-table tbody td:nth-child(4) {
    flex: 1;
    text-align: left !important;
    color: var(--text-secondary);
    font-size: 0.85rem;
  }
  
  .spreadsheet-table tbody td:nth-child(4)::before {
    content: "Sub: ";
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.8rem;
  }
  
  /* Grand Total */
  .spreadsheet-table tbody td:nth-child(5) {
    flex: 1;
    text-align: right !important;
    font-size: 1rem;
  }
  
  .spreadsheet-table tbody td:nth-child(5)::before {
    content: "Total: ";
    font-weight: 400;
    font-size: 0.8rem;
  }
  
  /* Actions */
  .spreadsheet-table tbody td:nth-child(6) {
    flex: 0 0 100%;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
  }
  
  .action-btns {
    justify-content: flex-end;
    gap: 0.75rem;
  }
  
  .action-btn {
    padding: 0.5rem;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* ===== CREATOR VIEW ===== */
  .creator-tabs {
    display: flex;
    width: 100%;
    background-color: var(--bg-secondary);
    border-radius: 10px;
    padding: 0.3rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
  }
  
  .tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
  }
  
  .tab-btn.active {
    background-color: var(--accent);
    color: var(--text-primary);
  }
  
  .creator-layout {
    flex-direction: column;
    height: auto;
    gap: 1rem;
  }
  
  .creator-layout.show-preview .editor-panel {
    display: none !important;
  }
  
  .creator-layout:not(.show-preview) .preview-panel {
    display: none !important;
  }
  
  .editor-panel, .preview-panel {
    width: 100%;
    flex: none;
    height: auto;
    max-height: none;
  }
  
  .editor-panel {
    padding: 1rem;
    gap: 1rem;
    border-radius: 10px;
  }
  
  /* Editor header on mobile */
  .editor-panel > .table-header-row {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center !important;
  }
  
  .editor-panel > .table-header-row h3 {
    font-size: 1.1rem;
    flex: 1;
    min-width: 0;
  }
  
  .editor-panel > .table-header-row > div {
    flex: 0 0 auto;
  }
  
  .editor-panel > .table-header-row .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
  
  /* Form on mobile */
  .form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  
  .form-group.full-width {
    grid-column: span 2;
  }
  
  .form-group label {
    font-size: 0.8rem;
  }
  
  .form-group input,
  .form-group textarea,
  .form-group select {
    padding: 0.7rem 0.8rem;
    font-size: 1rem;
    border-radius: 8px;
  }
  
  /* ===== LINE ITEMS: Hide desktop table, show mobile cards ===== */
  .items-editor-container > div:first-of-type {
    /* "Line Items" header + Add Row button */
  }
  
  .items-editor-container > div[style*="overflow-x"] {
    display: none !important; /* Hide the desktop table wrapper */
  }
  
  .mobile-items-container {
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
  }
  
  /* ===== MOBILE ITEM CARD STYLING ===== */
  .mobile-item-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
  }
  
  .mobile-card-sr {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
    background-color: rgba(59, 130, 246, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
  }
  
  .mobile-card-amount {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
    text-align: right;
    margin-right: 0.5rem;
  }
  
  .mobile-card-delete {
    color: var(--danger) !important;
    padding: 0.4rem !important;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
  }
  
  .mobile-card-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
  }
  
  .mobile-card-field-full {
    width: 100%;
    flex: 0 0 100%;
  }
  
  .mobile-card-field label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
  }
  
  .mobile-card-field input,
  .mobile-card-field select {
    padding: 0.6rem 0.7rem;
    font-size: 0.95rem;
    border-radius: 8px;
    min-height: 40px;
    width: 100%;
  }
  
  .mobile-card-field input:disabled {
    opacity: 0.3;
    background-color: rgba(255, 255, 255, 0.02);
  }
  
  .mobile-card-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }
  
  /* ===== ITEMS HEADER (Add Row) on mobile ===== */
  .items-editor-container > div:first-child {
    margin-bottom: 0.25rem;
  }
  
  .items-editor-container .btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
  
  /* ===== TOTALS BOX on mobile ===== */
  .editor-panel > div[style*="margin-top: auto"] {
    margin-top: 0 !important;
    padding: 0.75rem !important;
    border-radius: 10px !important;
    gap: 0.4rem !important;
  }
  
  /* ===== PREVIEW PANEL on mobile ===== */
  .preview-panel {
    padding: 0.75rem;
    border-radius: 10px;
  }
  
  .preview-controls {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .preview-controls span {
    font-size: 0.8rem !important;
  }
  
  .preview-controls .btn {
    flex: 1;
    justify-content: center;
    padding: 0.7rem;
  }
  
  /* ===== SETTINGS VIEW ===== */
  .settings-panel {
    padding: 1.25rem;
    border-radius: 10px;
  }
  
  .instructions-box {
    padding: 1rem;
    font-size: 0.9rem;
  }
  
  .instructions-box ol {
    font-size: 0.85rem;
    padding-left: 1rem;
  }
}

/* ===== EXTRA SMALL PHONES (< 480px) ===== */
@media (max-width: 480px) {
  .main-content {
    padding: 0.75rem;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  
  .dashboard-grid .card:nth-child(3) {
    grid-column: span 1;
  }
  
  .card-value {
    font-size: 1.3rem;
  }
  
  .mobile-card-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }
  
  .mobile-card-field input,
  .mobile-card-field select {
    padding: 0.5rem 0.5rem;
    font-size: 0.85rem;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .editor-panel > .table-header-row h3 {
    font-size: 1rem;
  }
  
  .editor-panel > .table-header-row .btn {
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
  }
  
  .tab-btn {
    font-size: 0.85rem;
    padding: 0.65rem;
  }
}

