@font-face {
  font-family: 'RupeeFix';
  src: local('Arial'), local('Helvetica'), local('sans-serif');
  unicode-range: U+20B9;
}

:root {
    --bg: #f8fafc; --surface: #ffffff; --surface2: #f1f5f9;
    --border: #e2e8f0; --border2: #cbd5e1;
    --text: #0f172a; --text2: #475569; --text3: #94a3b8;
    --accent: #4f46e5; --accent-light: #e0e7ff; --accent-dark: #312e81;
    --green: #16a34a; --green-light: #dcfce7;
    --amber: #d97706; --amber-light: #fef3c7;
    --red: #dc2626; --red-light: #fee2e2;
    --radius: 12px; --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    font-family: 'RupeeFix', 'Inter', system-ui, sans-serif;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { background: var(--bg); color: var(--text); min-height: 100vh; }

  .app { display: flex; height: 100vh; overflow: hidden; }

  /* Sidebar */
  .sidebar { width: 220px; background: #0f172a; display: flex; flex-direction: column; flex-shrink: 0; box-shadow: var(--shadow-md); z-index: 10; }
  .sidebar-logo { padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
  .sidebar-logo .logo-title { font-size: 15px; font-weight: 600; color: #fff; line-height: 1.3; }
  .sidebar-logo .logo-sub { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 2px; }
  .sidebar-logo .logo-icon { width: 32px; height: 32px; background: #4a8bc4; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; font-size: 16px; }
  .nav { padding: 12px 8px; flex: 1; }
  .nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: rgba(255,255,255,0.65); font-size: 13px; cursor: pointer; margin-bottom: 2px; transition: all 0.15s; }
  .nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
  .nav-item.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 500; }
  .nav-icon { font-size: 15px; width: 20px; text-align: center; }
  .sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 11px; color: rgba(255,255,255,0.35); }

  /* Main */
  .main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
  .topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
  .topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
  .topbar-right { display: flex; align-items: center; gap: 10px; }
  .content { flex: 1; overflow-y: auto; padding: 20px 24px; }

  /* Cards */
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); transition: transform 0.2s ease, box-shadow 0.2s ease; }
  .card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }

  /* Stats grid */
  .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
  .stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); transition: transform 0.2s, box-shadow 0.2s; }
  .stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
  .stat-label { font-size: 11px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
  .stat-value { font-size: 26px; font-weight: 600; color: var(--text); margin: 4px 0 2px; }
  .stat-sub { font-size: 11px; color: var(--text2); }
  .stat-card.blue { border-left: 3px solid var(--accent); }
  .stat-card.green { border-left: 3px solid var(--green); }
  .stat-card.amber { border-left: 3px solid #c4810a; }
  .stat-card.red { border-left: 3px solid var(--red); }

  /* Buttons */
  .btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all 0.2s; transform: translateY(0); }
  .btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
  .btn:active { transform: translateY(0); }
  .btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, 0.4); }
  .btn-primary:hover { background: var(--accent-dark); box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3); }
  .btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border2); }
  .btn-secondary:hover { background: var(--surface2); }
  .btn-danger { background: var(--red-light); color: var(--red); border-color: #fca5a5; }
  .btn-success { background: var(--green-light); color: var(--green); border-color: #86efac; }
  .btn-sm { padding: 4px 10px; font-size: 12px; }
  .btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }

  /* Form elements */
  label { font-size: 12px; color: var(--text2); font-weight: 500; display: block; margin-bottom: 4px; }
  input, select, textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--border2); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); background: var(--surface); outline: none; transition: all 0.2s; box-shadow: var(--shadow-sm); }
  input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
  .form-row { display: grid; gap: 12px; margin-bottom: 12px; }
  .form-row.cols2 { grid-template-columns: 1fr 1fr; }
  .form-row.cols3 { grid-template-columns: 1fr 1fr 1fr; }

  /* Table */
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th { background: var(--surface2); color: var(--text2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
  td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--surface2); }

  /* Badges */
  .badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
  .badge-blue { background: var(--accent-light); color: var(--accent-dark); }
  .badge-green { background: var(--green-light); color: var(--green); }
  .badge-amber { background: var(--amber-light); color: var(--amber); }
  .badge-red { background: var(--red-light); color: var(--red); }
  .badge-gray { background: var(--surface2); color: var(--text2); }

  /* Pages */
  .page { display: none; }
  .page.active { display: block; }

  /* Invoice */
  .invoice-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-width: 600px; }
  .invoice-header { background: var(--accent-dark); color: #fff; padding: 20px; border-radius: var(--radius) var(--radius) 0 0; }
  .invoice-header h2 { font-size: 18px; font-weight: 600; }
  .invoice-header p { font-size: 12px; opacity: 0.7; margin-top: 2px; }
  .invoice-meta { padding: 16px 20px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; }
  .invoice-meta .key { color: var(--text2); }
  .invoice-meta .val { font-weight: 500; }
  .invoice-items { padding: 16px 20px; }
  .invoice-total { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface2); border-radius: 0 0 var(--radius) var(--radius); }
  .total-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
  .total-row.grand { font-size: 15px; font-weight: 600; color: var(--accent-dark); border-top: 1px solid var(--border2); margin-top: 6px; padding-top: 8px; }
  .refund-banner { background: var(--green-light); border: 1px solid #9fd6b0; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; color: var(--green); margin-bottom: 12px; font-weight: 500; }

  /* Sale steps */
  .step-indicator { display: flex; align-items: center; gap: 0; margin-bottom: 20px; }
  .step { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .step-num { width: 22px; height: 22px; border-radius: 50%; background: var(--border); color: var(--text2); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px; }
  .step.done .step-num { background: var(--green); color: #fff; }
  .step.active .step-num { background: var(--accent); color: #fff; }
  .step.active .step-label { color: var(--accent); font-weight: 500; }
  .step-divider { flex: 1; height: 1px; background: var(--border); margin: 0 8px; min-width: 20px; }

  /* Packages */
  .pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
  .pkg-card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; transition: all 0.15s; }
  .pkg-card:hover { border-color: var(--accent); background: var(--accent-light); }
  .pkg-card.selected { border-color: var(--accent); background: var(--accent-light); }
  .pkg-card .pkg-class { font-size: 15px; font-weight: 600; color: var(--accent-dark); }
  .pkg-card .pkg-price { font-size: 13px; color: var(--green); font-weight: 500; margin-top: 2px; }
  .pkg-card .pkg-items { font-size: 11px; color: var(--text2); margin-top: 6px; line-height: 1.5; }

  /* Cart table */
  .cart-qty { width: 60px; padding: 4px 8px; text-align: center; }

  /* Inventory */
  .inv-form { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; }

  /* Modal */
  .modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100; align-items: center; justify-content: center; }
  .modal-overlay.open { display: flex; }
  .modal { background: var(--surface); border-radius: var(--radius); max-width: 640px; width: 95%; max-height: 90vh; overflow-y: auto; }
  .modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
  .modal-header h3 { font-size: 15px; font-weight: 600; }
  .modal-body { padding: 20px; }
  .modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
  .close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text2); padding: 2px 6px; }

  /* Recent sales */
  .sales-filters { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
  .search-input { max-width: 220px; }

  /* Tooltip for low stock */
  .low-stock { color: var(--red); font-weight: 600; }

  /* Two-col layout */
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
  @media (max-width: 900px) { .stats-grid { grid-template-columns: 1fr 1fr; } .two-col { grid-template-columns: 1fr; } .inv-form { grid-template-columns: 1fr 1fr; } }
  @media (max-width: 600px) { .sidebar { display: none; } }
/* Authentication UI */
#auth-overlay {
    position: fixed; inset: 0; background: var(--bg);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.login-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 30px; width: 350px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.login-box h2 { text-align: center; margin-bottom: 20px; font-weight: 600; color: var(--accent-dark); }
.error-msg { color: var(--red); font-size: 12px; margin-bottom: 15px; text-align: center; font-weight: 500; min-height: 15px; }

/* Print Styles */
@media print {
  @page {
    size: A4;
    margin: 15mm;
  }
  body, html {
    background: #fff !important;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color: #000 !important;
  }
  
  /* Hide non-printable UI elements */
  .sidebar,
  .topbar,
  .btn,
  .step-indicator,
  .sales-filters,
  #cart-empty,
  .modal-header,
  .modal-footer {
    display: none !important;
  }
  
  /* Un-constrain scrolling areas */
  .app, .main, .content {
    display: block !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    background: #fff !important;
  }

  /* Make the invoice perfectly aligned on A4 */
  #invoice-preview > div, 
  .modal-body > div {
    max-width: 100% !important;
    margin: 0 auto !important;
    border: none !important;
  }
  
  /* Modal print specific adjustments */
  body:has(.modal-overlay.open) .app {
    display: none !important;
  }
  
  .modal-overlay {
    position: static !important;
    display: none !important;
  }
  
  .modal-overlay.open {
    display: block !important;
    background: transparent !important;
  }
  
  .modal {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  
  .modal-body {
    padding: 0 !important;
  }
  
  /* Better table handling for print */
  table {
    page-break-inside: auto;
  }
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  thead {
    display: table-header-group;
  }
  tfoot {
    display: table-footer-group;
  }

  /* Strip card styling for full-bleed printing */
  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}
