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

:root {
  --primary: #007AFF;
  --primary-dark: #005FCC;
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --surface-2: #F9F9FB;
  --text: #1C1C1E;
  --text-secondary: #6E6E73;
  --border: #E5E5EA;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --bottom-nav-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }

/* ── TOPBAR ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-height); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  box-shadow: var(--shadow-sm);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand-logo { width: 32px; height: 32px; background: var(--primary); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.topbar-brand-name { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.topbar-brand-name span { color: var(--text-secondary); font-weight: 400; }
.topbar-menu-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 20px; padding: 6px; border-radius: var(--radius-sm); display: flex; align-items: center; }
.topbar-menu-btn:hover { background: var(--surface-2); }
.topbar-back-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; color: var(--primary); font-size: 20px; text-decoration: none; flex-shrink: 0; }
.topbar-back-btn:hover { background: var(--surface-2); }
.topbar-page-title { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.topbar-user-info { display: none; text-align: right; }
@media (min-width: 1024px) { .topbar-user-info { display: block; } }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); font-size: 16px; position: relative; }
.topbar-icon-btn .badge { position: absolute; top: -3px; right: -3px; width: 16px; height: 16px; background: var(--danger); color: #fff; font-size: 9px; font-weight: 700; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.topbar-avatar { width: 36px; height: 36px; border-radius: 50%; background: #EFF6FF; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--primary); cursor: pointer; }

/* ── SIDEBAR ── */
.sidebar {
  position: fixed; top: var(--topbar-height); left: 0; bottom: 0; z-index: 90;
  width: var(--sidebar-width); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }

.sidebar-overlay { position: fixed; inset: 0; z-index: 89; background: rgba(0,0,0,.3); display: none; }
.sidebar-overlay.show { display: block; }

.nav-section { padding: 6px 0; }
.nav-section + .nav-section { border-top: 1px solid var(--border); }
.nav-section-label { font-size: 10px; font-weight: 600; color: var(--text-secondary); letter-spacing: .6px; text-transform: uppercase; padding: 10px 16px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 13px; color: var(--text); cursor: pointer; text-decoration: none; transition: background .1s; border-left: 3px solid transparent; }
.nav-link:hover { background: var(--bg); }
.nav-link.active { background: #EFF6FF; color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-link i { font-size: 16px; color: var(--text-secondary); width: 18px; flex-shrink: 0; }
.nav-link.active i { color: var(--primary); }
.nav-badge { margin-left: auto; background: #FFF1F2; color: #9F1239; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px; }
.nav-badge.info { background: #EFF6FF; color: var(--primary); }

/* ── MAIN WRAP ── */
.main-wrap { margin-left: 0; padding-top: var(--topbar-height); min-height: 100vh; transition: margin-left .25s; }
.page-content { padding: 20px 16px; padding-bottom: calc(var(--bottom-nav-height) + 20px); }

/* ── DESKTOP ── */
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0); box-shadow: none; }
  .sidebar-overlay { display: none !important; }
  .main-wrap { margin-left: var(--sidebar-width); }
  .topbar-menu-btn { display: none; }
  .bottom-nav { display: none !important; }
  .page-content { padding: 24px; }
  .fab { display: none; }
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bottom-nav-height); background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
}
.bottom-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; cursor: pointer; text-decoration: none; color: var(--text-secondary); }
.bottom-nav-item i { font-size: 22px; }
.bottom-nav-item span { font-size: 10px; }
.bottom-nav-item.active { color: var(--primary); }

/* ── FAB ── */
.fab { position: fixed; bottom: calc(var(--bottom-nav-height) + 16px); right: 16px; z-index: 80; width: 56px; height: 56px; background: var(--primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: 0 4px 16px rgba(0,122,255,.4); text-decoration: none; cursor: pointer; border: none; }

/* ── PAGE HEADER ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.page-header-left h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.page-header-left p { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: background .15s, transform .1s; min-height: 44px; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 36px; }
.btn-icon { padding: 9px; }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi-card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); cursor: pointer; }
.kpi-card:active { transform: scale(.98); }
.kpi-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.kpi-label i { font-size: 13px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.5px; }
.kpi-trend { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-warn { color: var(--warning); }
.trend-info { color: var(--primary); }

/* ── CARDS ── */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 16px; }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2, .card-header h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 16px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; padding: 10px 16px; text-align: left; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
.table tbody tr:hover td { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.amount { font-weight: 700; }
.table td.muted { color: var(--text-secondary); }

/* ── BADGES / STATUS ── */
.badge { display: inline-flex; align-items: center; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-success { background: #F0FDF4; color: #166534; }
.badge-warning { background: #FFF7ED; color: #92400E; }
.badge-danger { background: #FFF1F2; color: #9F1239; }
.badge-info { background: #EFF6FF; color: #1E40AF; }
.badge-secondary { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-purple { background: #F5F3FF; color: #5B21B6; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font); background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; min-height: 44px; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,122,255,.1); }
.form-control::placeholder { color: var(--text-secondary); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%236E6E73' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.form-control { min-height: 88px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ── TOGGLE ── */
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.toggle-btn { flex: 1; padding: 9px; text-align: center; font-size: 13px; font-weight: 500; cursor: pointer; background: var(--surface); color: var(--text-secondary); border: none; transition: background .15s; }
.toggle-btn.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ── ALERTS / FLASH ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #F0FDF4; color: #166534; border-left: 4px solid var(--success); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.alert-danger { background: #FFF1F2; color: #9F1239; border-left: 4px solid var(--danger); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.alert-warning { background: #FFF7ED; color: #92400E; border-left: 4px solid var(--warning); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.alert-info { background: #EFF6FF; color: #1E40AF; border-left: 4px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── LIST / FEED ROWS ── */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; color: var(--text); transition: background .1s; }
.list-row:hover { background: var(--bg); }
.list-row:last-child { border-bottom: none; }
.list-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.li-blue { background: #EFF6FF; color: var(--primary); }
.li-green { background: #F0FDF4; color: var(--success); }
.li-orange { background: #FFF7ED; color: var(--warning); }
.li-red { background: #FFF1F2; color: var(--danger); }
.li-purple { background: #F5F3FF; color: #7C3AED; }
.list-body { flex: 1; min-width: 0; }
.list-ref { font-size: 13px; font-weight: 600; }
.list-sub { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.list-right { text-align: right; flex-shrink: 0; }
.list-amount { font-size: 14px; font-weight: 700; }
.list-time { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

/* ── SEARCH / FILTER BAR ── */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-box { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 8px 14px; }
.search-box i { font-size: 15px; color: var(--text-secondary); flex-shrink: 0; }
.search-box input { flex: 1; border: none; background: none; font-size: 13px; font-family: var(--font); color: var(--text); outline: none; }
.search-box input::placeholder { color: var(--text-secondary); }

/* ── FILTER TABS ── */
.filter-tabs { display: flex; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab { flex-shrink: 0; padding: 11px 16px; font-size: 13px; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.filter-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── PRODUCT PICKER ── */
.picker-panel { border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface-2); margin-top: 12px; }
.picker-cat-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.picker-cat-bar::-webkit-scrollbar { display: none; }
.picker-cat-pill { flex-shrink: 0; padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); font-size: 12px; font-weight: 500; cursor: pointer; background: var(--surface); color: var(--text-secondary); white-space: nowrap; transition: background .15s; }
.picker-cat-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.picker-search { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; background: var(--surface); }
.picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 600px) { .picker-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .picker-grid { grid-template-columns: repeat(4, 1fr); } }
.picker-product-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: var(--surface); cursor: pointer; transition: border-color .15s; }
.picker-product-card.selected { border-color: var(--primary); transform: scale(1.02); }
.picker-product-img { width: 100%; height: 60px; object-fit: cover; border-radius: 6px; background: var(--surface-2); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--text-secondary); }
.picker-product-img img { width: 100%; height: 60px; object-fit: cover; border-radius: 6px; }
.picker-product-name { font-size: 12px; font-weight: 600; color: var(--text); }
.picker-product-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.picker-variant-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.picker-variant-chip { padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px; font-size: 11px; font-weight: 500; cursor: pointer; background: var(--surface-2); color: var(--text); transition: background .15s; white-space: nowrap; }
.picker-variant-chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip-stock { font-size: 10px; opacity: .7; margin-left: 2px; }
.chip-stock.low { color: var(--danger); opacity: 1; }

/* ── LINE ITEMS TABLE ── */
.line-items-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.line-items-table th { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; text-align: left; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.line-items-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.line-items-table tr.row-enter { animation: slideDown .2s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.qty-stepper { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; align-items: center; width: 90px; }
.qty-btn { width: 28px; height: 36px; background: var(--surface-2); border: none; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); flex-shrink: 0; }
.qty-btn:hover { background: var(--border); }
.qty-input { flex: 1; border: none; text-align: center; font-size: 13px; font-weight: 600; font-family: var(--font); background: var(--surface); color: var(--text); width: 34px; outline: none; }
.rate-input { width: 80px; padding: 7px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; text-align: right; font-family: var(--font); }
.remove-row { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 16px; padding: 4px; border-radius: 50%; }
.remove-row:hover { color: var(--danger); background: #FFF1F2; }

/* ── TOTALS PANEL ── */
.totals-panel { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; border: 1px solid var(--border); }
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; }
.totals-row.grand { font-size: 16px; font-weight: 700; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--border); color: var(--primary); }
.totals-label { color: var(--text-secondary); }

/* ── DASHBOARD LAYOUT ── */
@media (min-width: 768px) {
  .dashboard-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
}

/* ── QUICK ACTIONS ── */
.quick-actions { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.quick-actions::-webkit-scrollbar { display: none; }
.quick-action-btn { flex-shrink: 0; display: flex; align-items: center; gap: 7px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; font-size: 12px; font-weight: 500; color: var(--primary); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s; min-height: 44px; }
.quick-action-btn:hover { background: #EFF6FF; }
.quick-action-btn i { font-size: 15px; }

/* ── ALERT ROWS ── */
.alert-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; color: var(--text); transition: background .1s; }
.alert-row:hover { background: var(--bg); }
.alert-row:last-child { border-bottom: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alert-content { flex: 1; }
.alert-title { font-size: 13px; color: var(--text); }
.alert-desc { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

/* ── CHART ── */
.chart-bar-wrap { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding: 0 4px; }
.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.chart-bar-stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; height: 100px; gap: 1px; }
.bar-pos { background: var(--primary); border-radius: 3px 3px 0 0; opacity: .85; }
.bar-so { background: var(--success); opacity: .75; }
.chart-bar-label { font-size: 10px; color: var(--text-secondary); }

/* ── BACK BUTTON ── */
.back-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); text-decoration: none; padding: 8px 0; margin-bottom: 12px; cursor: pointer; background: none; border: none; font-family: var(--font); }
.back-btn i { font-size: 16px; }

/* ── PAGINATION ── */
.pagination { display: flex; align-items: center; gap: 6px; padding: 12px 16px; }
.page-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; color: var(--text-secondary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.page-btn:hover:not(.active) { background: var(--surface-2); }

/* ── LOADING ── */
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ── PRINT ── */
@media print {
  .topbar, .sidebar, .bottom-nav, .fab, .no-print { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
}
