/* Shia Bazaar - Main Styles */
:root {
  --accent: #4F46E5;
  --accent-dark: #3730A3;
  --accent-light: #818CF8;
  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --info: #0284C7;
  --bg: #F8FAFC;
  --surface: #ffffff;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --sidebar-width: 240px;
  --sidebar-collapsed: 72px;
  --topbar-height: 60px;
  --bottom-nav-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.12);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-dark); }

/* ===== APP SHELL ===== */
.app-shell { display: flex; min-height: 100vh; }

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: 0;
  transition: var(--transition);
}

.main-content {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(var(--bottom-nav-height) + 1rem);
}

/* Page enter animation */
.page-enter {
  opacity: 0;
  transform: translateY(16px);
  animation: pageEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

.page-exit {
  opacity: 1;
  transform: translateY(0);
  animation: pageExit 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pageExit {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}

.sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand-link {
  display: block;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.sidebar-brand-link:hover {
  opacity: 0.92;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  line-height: 1.1;
}

.brand-mark__name {
  font-weight: 800;
  font-size: 1.125rem;
  color: #1B7340;
  letter-spacing: -0.01em;
  white-space: nowrap;
  line-height: 1.1;
}

.brand-mark--sidebar {
  width: 100%;
  justify-content: center;
}

.brand-mark--sidebar .brand-mark__name {
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.brand-mark--login {
  justify-content: center;
}

.brand-mark--login .brand-mark__name {
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.sidebar-brand { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 1.125rem; color: var(--accent); }
.brand-tag { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  transition: var(--transition);
  position: relative;
  min-height: 44px;
}

.nav-item i { width: 20px; text-align: center; font-size: 1.1rem; transition: var(--transition); }

.nav-item:hover {
  background: rgba(79, 70, 229, 0.08);
  color: var(--accent);
}

.nav-item.active {
  background: rgba(79, 70, 229, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  transition: var(--transition);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.sidebar-overlay.visible { opacity: 1; visibility: visible; }

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--topbar-height);
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-title {
  flex: 1;
  font-size: 1.125rem;
  font-weight: 600;
}

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }

.topbar-alert {
  position: relative;
  color: var(--warning);
  padding: 0.5rem;
  transition: var(--transition);
}

.topbar-alert:hover { transform: scale(1.1); }

.alert-count {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--text-muted);
  font-size: 0.65rem;
  transition: var(--transition);
  min-height: 44px;
  position: relative;
}

.bottom-nav-item i {
  font-size: 1.25rem;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.25s ease;
}

.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item.active i { transform: scale(1.15); }

.bottom-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 20px);
  background: var(--danger);
  color: white;
  font-style: normal;
  font-size: 0.6rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  min-height: 44px;
  font-family: inherit;
}

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

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

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

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

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

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

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; min-height: 36px; }

.btn-block { width: 100%; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { background: var(--bg); color: var(--accent); }
.btn-icon:active { transform: scale(0.97); }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 1rem);
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
  cursor: pointer;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: var(--transition);
}

.fab:hover { background: var(--accent-dark); transform: scale(1.05); }
.fab:active { transform: scale(0.95) rotate(45deg); }
.fab.rotated { transform: rotate(45deg); }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: var(--transition);
  border: 1px solid var(--border);
}

.card:hover { transform: scale(1.01); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title { font-size: 1rem; font-weight: 600; }

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

.dashboard-main-grid {
  align-items: stretch;
}

/* Stat cards */
.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stat-icon.primary { background: rgba(79,70,229,.12); color: var(--accent); }
.stat-icon.success { background: rgba(5,150,105,.12); color: var(--success); }
.stat-icon.warning { background: rgba(217,119,6,.12); color: var(--warning); }
.stat-icon.danger  { background: rgba(220,38,38,.12); color: var(--danger); }

.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

.stat-sublabel {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-body { flex: 1; min-width: 0; }

.stat-value-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-privacy-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: var(--transition);
}

.stat-privacy-toggle:hover {
  color: var(--accent);
  background: rgba(79, 70, 229, 0.08);
}

.stat-value.is-private {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  min-height: 44px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

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

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

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table th,
table.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.data-table tr { transition: background 0.2s ease; }
table.data-table tbody tr:hover { background: rgba(79,70,229,.04); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.badge-success { background: rgba(5,150,105,.12); color: var(--success); }
.badge-warning { background: rgba(217,119,6,.12); color: var(--warning); }
.badge-danger  { background: rgba(220,38,38,.12); color: var(--danger); }
.badge-info    { background: rgba(2,132,199,.12); color: var(--info); }
.badge-primary { background: rgba(79,70,229,.12); color: var(--accent); }
.badge-secondary { background: var(--bg); color: var(--text-muted); }

/* ===== STOCK PROGRESS ===== */
.stock-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.stock-bar-fill {
  height: 100%;
  border-radius: 99px;
  width: 0;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.stock-bar-fill.success { background: var(--success); }
.stock-bar-fill.warning { background: var(--warning); }
.stock-bar-fill.danger  { background: var(--danger); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 1.5rem;
}

.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-title { font-size: 1.125rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.5rem;
  transition: var(--transition);
}

.modal-close:hover { color: var(--danger); }

.modal-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  animation: toastIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast.hiding {
  animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

@keyframes toastOut {
  to { transform: translateX(120%); opacity: 0; }
}

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

/* ===== FILTERS & SEARCH ===== */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box input {
  width: 100%;
  padding: 0.625rem 0.875rem 0.625rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: border-color 0.25s ease;
  min-height: 44px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-box i {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-select {
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  min-height: 44px;
  background: var(--surface);
  transition: border-color 0.25s ease;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== CUSTOMER SEARCH ===== */
.customer-search {
  position: relative;
  z-index: 50;
}

.customer-search input,
.product-search input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  min-height: 44px;
  transition: border-color 0.25s ease;
}

.customer-search input:focus,
.product-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.customer-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 200;
  display: none;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  max-height: 260px;
  overflow-y: auto;
}

.customer-search-dropdown.is-open {
  display: block;
}

.customer-search-item {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  transition: background 0.15s ease;
}

.customer-search-item:hover,
.customer-search-item.active {
  background: var(--bg-muted, rgba(79, 70, 229, 0.08));
}

.customer-search-name {
  display: block;
  font-weight: 500;
  color: var(--text);
}

.customer-search-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.customer-search-empty {
  padding: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== CHART ===== */
.chart-card {
  overflow: hidden;
}

.chart-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chart-card-header {
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}

.chart-card-header__top {
  width: 100%;
}

.chart-title-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-title-row .card-title {
  margin: 0;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.period-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.period-toggle__btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: var(--transition);
  min-height: 34px;
}

.period-toggle__btn:hover {
  color: var(--accent);
  background: rgba(79, 70, 229, 0.06);
}

.period-toggle__btn.active {
  background: var(--accent);
  color: #fff;
}

.chart-custom-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.chart-custom-range[hidden] {
  display: none !important;
}

.chart-custom-range input[type="date"] {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
}

.chart-custom-range__sep {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-private-wrap.is-private {
  filter: blur(10px);
  user-select: none;
  pointer-events: none;
}

.chart-container {
  position: relative;
  height: 300px;
  padding: 0.5rem 0.25rem 0.75rem;
  transition: filter 0.2s ease;
}

@media (max-width: 640px) {
  .chart-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .period-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .period-toggle__btn {
    flex: 1;
    text-align: center;
  }

  .chart-custom-range {
    width: 100%;
  }

  .chart-custom-range input[type="date"] {
    flex: 1;
    min-width: 0;
  }

  .chart-container {
    height: 240px;
  }
}

/* ===== TAGS ===== */
.tags { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: rgba(79,70,229,.1);
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.75rem;
  transition: var(--transition);
}

.tag:hover { background: rgba(79,70,229,.2); }

/* ===== ALERTS ===== */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert-danger  { background: rgba(220,38,38,.1); color: var(--danger); border: 1px solid rgba(220,38,38,.2); }
.alert-success { background: rgba(5,150,105,.1); color: var(--success); border: 1px solid rgba(5,150,105,.2); }
.alert-warning { background: rgba(217,119,6,.1); color: var(--warning); border: 1px solid rgba(217,119,6,.2); }

/* ===== LINE ITEMS TABLE ===== */
.line-items-table input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.875rem;
  transition: border-color 0.25s ease;
}

.line-items-table input:focus {
  outline: none;
  border-color: var(--accent);
}

.totals-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 0.375rem 0;
  font-size: 0.875rem;
}

.totals-row.grand {
  font-size: 1.125rem;
  font-weight: 700;
  border-top: 2px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  color: var(--accent);
}

.top-products-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 480px;
  overflow-y: auto;
}

.top-products-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.top-products-rank {
  flex-shrink: 0;
  width: 1.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.top-products-thumb,
.top-products-thumb.product-thumb-placeholder {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: cover;
}

.top-products-info {
  flex: 1;
  min-width: 0;
}

.top-products-name {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-products-sku {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.top-products-metrics {
  flex-shrink: 0;
  text-align: right;
  line-height: 1.15;
}

.top-products-metrics strong {
  display: block;
  font-size: 0.9375rem;
  color: var(--accent);
}

.top-products-metrics small {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.top-products-empty {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
}

.top-products-empty i {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.top-products-empty p {
  margin: 0;
  font-size: 0.875rem;
}

.analytics-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
}

.analytics-toolbar__title {
  margin: 0;
  font-size: 1.125rem;
}

.analytics-toolbar__subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.analytics-stats-grid {
  margin-bottom: 1rem;
}

.analytics-charts-grid,
.analytics-tables-grid,
.analytics-secondary-grid {
  margin-top: 1rem;
}

.chart-container--compact {
  min-height: 260px;
}

.analytics-empty-note {
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.ledger-side-row {
  align-items: flex-start;
  gap: 0.75rem;
}

.ledger-side-row span {
  min-width: 0;
}

.ledger-side-row a {
  font-weight: 600;
  font-size: 0.8125rem;
}

.ledger-main-grid {
  margin-top: 1rem;
}

.ledger-list-card {
  margin-top: 1rem;
}

.backup-card {
  max-width: 640px;
}

.backup-page {
  display: grid;
  gap: 1rem;
}

.backup-intro-card__desc,
.backup-intro__desc {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.backup-intro__hint {
  margin: 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: var(--surface-alt, #f8f9fb);
  border-radius: var(--radius-sm);
}

.backup-auto-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.backup-auto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.backup-auto-grid small {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.backup-auto-grid strong {
  font-size: 0.875rem;
}

.backup-sections-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 640px) {
  .backup-sections-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .backup-sections-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .backup-auto-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.backup-section-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.backup-section-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(27, 115, 64, 0.1);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.backup-section-card__title {
  margin: 0;
  font-size: 1rem;
}

.backup-section-card__desc {
  margin: 0;
  flex: 1;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.backup-section-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.backup-sql-card .btn {
  margin-top: 0.25rem;
}

.backup-period-toggle {
  width: 100%;
  flex-wrap: wrap;
}

/* ===== SETTINGS PAGE ===== */
.settings-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-intro__desc,
.settings-hint {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.settings-hint {
  margin-top: 0.5rem;
}

.settings-grid {
  display: grid;
  gap: 1rem;
}

.settings-card .card-header {
  margin-bottom: 0.75rem;
}

.settings-card textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  min-height: 88px;
  resize: vertical;
}

.settings-check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-size: 0.875rem;
  font-weight: 500;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

@media (min-width: 900px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-actions {
    grid-column: 1 / -1;
  }
}

.backup-custom-range {
  margin-bottom: 1rem;
}

.backup-custom-range input[type="date"] {
  min-height: 40px;
  padding: 0.5rem 0.65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.ledger-list-card .table-wrapper {
  border: none;
  border-radius: 0;
}

.ledger-list-table td[data-label="Amount"],
.ledger-list-table td[data-label="Balance"] {
  font-weight: 600;
}

.ledger-panels-grid {
  margin-top: 1rem;
  margin-bottom: 1.25rem;
}

.ledger-expenses-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ledger-expenses-card__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ledger-expenses-card .card-title {
  min-width: 0;
}

.modal--wide {
  max-width: 760px;
}

.ledger-expenses-modal__subtitle {
  margin: -0.35rem 0 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ledger-expenses-modal__filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(148, 163, 184, 0.08);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}

.ledger-expenses-modal__search {
  min-width: 0;
  width: 100%;
}

.ledger-expenses-modal__dates {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ledger-expenses-modal__dates input[type="date"] {
  flex: 1 1 130px;
  min-width: 0;
  min-height: 44px;
  padding: 0.625rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  color-scheme: light;
}

.ledger-expenses-modal__dates input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.ledger-expenses-modal__sep {
  font-size: 0.8125rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ledger-expenses-modal__clear {
  min-height: 44px;
  justify-self: stretch;
}

.ledger-expenses-modal__meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.ledger-expenses-modal__table {
  max-height: 50vh;
  overflow: auto;
  margin-bottom: 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}

.ledger-expenses-modal__total {
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

@media (min-width: 640px) {
  .ledger-expenses-modal__filters {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
  }

  .ledger-expenses-modal__dates {
    flex-wrap: nowrap;
  }

  .ledger-expenses-modal__dates input[type="date"] {
    flex: 0 0 148px;
    width: 148px;
  }

  .ledger-expenses-modal__clear {
    justify-self: auto;
    min-width: 88px;
  }
}

.ledger-expense-form {
  padding: 0.75rem 0 0;
  margin-bottom: 0.75rem;
  border-top: 1px solid var(--border);
}

.ledger-expense-form .form-group {
  margin-bottom: 0.65rem;
}

.ledger-expense-form .form-group input {
  width: 100%;
}

.ledger-expense-form .form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

@media (min-width: 480px) {
  .ledger-expense-form .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.ledger-expense-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.ledger-expense-row {
  align-items: flex-start;
  gap: 0.75rem;
}

.ledger-expense-row__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.ledger-expense-delete {
  color: var(--danger);
}

.ledger-expense-edit {
  color: var(--accent);
}

.ledger-expense-form--modal {
  padding-top: 0;
  margin-bottom: 0;
  border-top: none;
}

.ledger-expense-form--modal .modal-footer {
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
}

.ledger-expenses-list {
  max-height: 320px;
  overflow-y: auto;
}

@media (min-width: 1024px) {
  .ledger-panels-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.ledger-stats-grid {
  margin-bottom: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ledger-stats-grid .stat-card {
  min-width: 0;
}

@media (min-width: 768px) {
  .ledger-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .analytics-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .ledger-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .ledger-panels-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-charts-grid {
    grid-template-columns: 1.5fr 1fr;
  }

  .analytics-secondary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.totals-row-input {
  align-items: center;
  gap: 0.75rem;
}

.totals-row-input .totals-input {
  width: 130px;
  max-width: 45vw;
  padding: 0.375rem 0.625rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  text-align: right;
  min-height: 38px;
}

.totals-row-input .totals-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===== LOGIN ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}

.login-card:hover { transform: none; }

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .brand-mark { margin-bottom: 0.35rem; }
.login-logo p { color: var(--text-muted); font-size: 0.875rem; margin: 0.65rem 0 0; }

.login-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

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

/* ===== PROFILE ===== */
.profile-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(79,70,229,.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
}

.profile-meta { flex: 1; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

/* ===== ORDERS PAGE ===== */
.orders-toolbar form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
  align-items: center;
}

.orders-toolbar .search-box {
  flex: 1 1 260px;
}

.orders-date-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.orders-date-group input[type="date"] {
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  min-height: 44px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.25s ease;
}

.orders-date-group input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.orders-list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.orders-list-meta strong {
  color: var(--text);
}

table.data-table .status-select {
  width: auto;
  min-width: 118px;
  max-width: 140px;
  padding: 0.35rem 0.75rem;
  min-height: 34px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

table.data-table .status-select.status-pending { border-color: rgba(217,119,6,.35); background: rgba(217,119,6,.08); color: var(--warning); }
table.data-table .status-select.status-confirmed { border-color: rgba(2,132,199,.35); background: rgba(2,132,199,.08); color: var(--info); }
table.data-table .status-select.status-shipped { border-color: rgba(79,70,229,.35); background: rgba(79,70,229,.08); color: var(--accent); }
table.data-table .status-select.status-delivered { border-color: rgba(5,150,105,.35); background: rgba(5,150,105,.08); color: var(--success); }
table.data-table .status-select.status-cancelled { border-color: rgba(220,38,38,.35); background: rgba(220,38,38,.08); color: var(--danger); }

.order-number-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.order-number-link:hover { text-decoration: underline; }

.orders-empty-row td {
  padding: 3rem 1rem !important;
  text-align: center;
}

.orders-empty-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.orders-empty-inline i {
  font-size: 2.25rem;
  opacity: 0.35;
}

.orders-loading-row td {
  padding: 2.5rem 1rem !important;
  text-align: center;
  color: var(--text-muted);
}

.orders-loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
}

.orders-loading-inline i {
  color: var(--accent);
}

.actions-cell {
  white-space: nowrap;
}

.orders-list-table .col-num {
  width: 44px;
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
}

.order-id-hint {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.orders-list-card .table-wrapper {
  border: none;
  border-radius: 0;
}

td[data-label="Total"] {
  font-weight: 600;
  color: var(--text);
}

/* ===== PRODUCT IMAGES ===== */
.product-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.product-thumb-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

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

.product-image-field {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.product-image-preview {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.product-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-actions {
  flex: 1;
  min-width: 180px;
}

.product-search-item {
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
}

.product-search-item-body {
  flex: 1;
  min-width: 0;
}

.product-search-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.product-search-thumb.product-thumb-placeholder {
  font-size: 0.8rem;
}

.product-thumb-inline {
  width: 32px;
  height: 32px;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.line-items-table .item-name {
  vertical-align: middle;
}

/* ===== PAYMENT OPTIONS ===== */
.payment-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.payment-opt {
  flex: 1;
  min-width: 90px;
  padding: 0.625rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  min-height: 44px;
  font-family: inherit;
}

.payment-opt:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.payment-opt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.payment-opt:active {
  transform: scale(0.97);
}

.payment-invoice-summary {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.payment-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.payment-summary-grid small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 0.15rem;
}

.payment-summary-grid strong {
  font-size: 0.9375rem;
}

.order-payment-card {
  margin-top: 1rem;
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .bottom-nav, .topbar, .fab, .btn, .filters-bar, .modal-overlay { display: none !important; }
  .main-content { padding: 0 !important; }
  .main-wrapper { margin: 0 !important; }
  body { background: white; }
  .card:not(.invoice-print) { box-shadow: none; border: 1px solid #ddd; }
  .card:not(.invoice-print):hover { transform: none; }
  .invoice-print { box-shadow: none !important; border: none !important; }
}

/* ===== TABLET ===== */
@media (min-width: 768px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: repeat(2, 1fr); }
  .form-row-3 { grid-template-columns: repeat(3, 1fr); }
  .profile-stats { grid-template-columns: repeat(4, 1fr); }

  .modal-overlay { align-items: center; }
  .modal {
    max-width: 560px;
    border-radius: var(--radius);
    transform: translateY(20px) scale(0.95);
  }
  .modal.modal--wide {
    max-width: min(760px, calc(100vw - 2rem));
  }
  .modal-overlay.open .modal { transform: translateY(0) scale(1); }

  .fab { bottom: 2rem; }
  .main-content { padding-bottom: 2rem; }
}

/* ===== DESKTOP ===== */
@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0);
    box-shadow: none;
  }

  .main-wrapper { margin-left: var(--sidebar-width); }
  .hamburger { display: none; }
  .bottom-nav { display: none; }
  .sidebar-overlay { display: none; }

  .main-content {
    padding: 1.5rem 2rem;
    padding-bottom: 2rem;
  }

  .card-grid.stats-grid { grid-template-columns: repeat(4, 1fr); }
  .card-grid.stats-grid.ledger-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .ledger-stats-grid .stat-value {
    font-size: 1.2rem;
  }

  .ledger-stats-grid .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .ledger-stats-grid .stat-sublabel {
    font-size: 0.62rem;
    line-height: 1.25;
  }

  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid.dashboard-main-grid { grid-template-columns: 1.4fr 1fr; }

  .fab { bottom: 2rem; right: 2rem; }
}
