/* ============================================================
   MV LAPTOP - PREMIUM UI DESIGN SYSTEM
   Inspired by: Linear, Vercel, Notion
   ============================================================ */

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

:root {
  /* Brand */
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --brand-light: #eef2ff;
  --brand-mid: #6366f1;
  --brand-gradient: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);

  /* Semantic Colors */
  --kv-blue: #4f46e5;
  --kv-blue-dark: #3730a3;
  --kv-blue-light: #eef2ff;
  --kv-green: #16a34a;
  --kv-green-light: #dcfce7;
  --kv-red: #dc2626;
  --kv-red-light: #fee2e2;
  --kv-orange: #ea580c;
  --kv-orange-light: #ffedd5;
  --kv-purple: #7c3aed;
  --kv-purple-light: #f5f3ff;

  /* Neutral Palette */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Semantic Aliases */
  --kv-bg: #f1f5f9;
  --kv-text: var(--gray-800);
  --kv-text-2: var(--gray-500);
  --kv-text-3: var(--gray-400);
  --kv-border: var(--gray-200);
  --kv-border-light: var(--gray-100);

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.07), 0 1px 2px -1px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  /* Sidebar */
  --sidebar-width: 230px;
  --sidebar-bg: #ffffff;
  --topbar-height: 58px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--kv-bg);
  color: var(--kv-text);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { text-decoration: none; color: var(--brand); }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* Utility */
.num { font-family: 'Roboto Mono', 'Roboto', monospace; font-variant-numeric: tabular-nums; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.text-primary { color: var(--brand); }
.text-success { color: var(--kv-green); }
.text-danger { color: var(--kv-red); }
.text-warning { color: var(--kv-orange); }
.text-secondary { color: var(--kv-text-2); }
.text-muted { color: var(--kv-text-3); }

/* Helpers */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

.mobile-only, .mobile-only-flex, .mobile-only-grid, .mobile-bottom-sheet { display: none !important; }
.desktop-only { display: block; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.req { color: var(--kv-red); margin-left: 2px; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--kv-bg);
}

/* ============================================================
   SIDEBAR — Clean, Light, Premium
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-100);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  overflow: hidden;
}

.app-container.sidebar-collapsed .sidebar {
  width: 64px;
}

/* Sidebar Header / Logo */
.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 10px;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
  letter-spacing: -0.5px;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 10.5px;
  color: var(--gray-400);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-400);
  padding: 12px 10px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--gray-400);
  transition: color 0.15s;
}

.nav-item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--gray-50);
  color: var(--gray-800);
}

.nav-item:hover .nav-icon {
  color: var(--gray-500);
}

.nav-item.active {
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--brand);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
  margin-left: -12px;
}

.app-container.sidebar-collapsed .nav-item span { display: none; }
.app-container.sidebar-collapsed .sidebar-brand { display: none; }
.app-container.sidebar-collapsed .sidebar-section-label { display: none; }
.app-container.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.app-container.sidebar-collapsed .nav-item .nav-icon { margin: 0; }
.app-container.sidebar-collapsed .nav-item::before { display: none; }

/* Sidebar footer */
.sidebar-footer {
  border-top: 1px solid var(--gray-100);
  padding: 10px;
}

/* ============================================================
   MAIN WRAPPER & TOPBAR
   ============================================================ */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  z-index: 90;
  flex-shrink: 0;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-btn {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-right .btn-sell-nav {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 34px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
  transition: all 0.15s;
}

.topbar-right .btn-sell-nav:hover {
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--kv-bg);
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

.page { max-width: 1280px; margin: 0 auto; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.3px;
  margin-top: 4px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--gray-400);
  display: flex;
  gap: 6px;
  align-items: center;
}

.breadcrumb .sep { color: var(--gray-300); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border: 1px solid var(--gray-100);
  transition: box-shadow 0.2s;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-800);
}

.card-body { padding: 18px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: #fff;
  border-color: var(--gray-200);
  color: var(--gray-700);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-900);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
}

.btn-success:hover {
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
  transform: translateY(-1px);
}

.btn-warning {
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.25);
}

.btn-warning:hover {
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
  transform: translateY(-1px);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

/* ============================================================
   SWITCH TOGGLE
   ============================================================ */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--gray-200);
  transition: .25s; border-radius: 22px;
}
.slider:before {
  position: absolute; content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .25s; border-radius: 50%;
  box-shadow: var(--shadow-xs);
}
input:checked + .slider { background-color: var(--brand); }
input:checked + .slider:before { transform: translateX(16px); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-700);
}
.form-control {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  background: #fff;
  color: var(--kv-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
textarea.form-control {
  height: auto;
  padding: 8px 11px;
  resize: vertical;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.product-form-grid { display: grid; grid-template-columns: 320px 1fr; gap: 24px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

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

.kv-table th, .kv-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.kv-table th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.kv-table tbody tr { transition: background 0.1s; }
.kv-table tr:hover td { background: #fafbff; }
.kv-table tr:last-child td { border-bottom: none; }
.kv-table tr.selected td { background: var(--brand-light) !important; }

.tbl-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--gray-400);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 13px;
}

.tbl-btn:hover { background: var(--gray-100); }
.tbl-btn.edit:hover { color: var(--kv-orange); background: var(--kv-orange-light); }
.tbl-btn.delete:hover { color: var(--kv-red); background: var(--kv-red-light); }
.tbl-btn.view:hover { color: var(--brand); background: var(--brand-light); }
.tr-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.2px;
}

.badge-green { background: var(--kv-green-light); color: var(--kv-green); }
.badge-red { background: var(--kv-red-light); color: var(--kv-red); }
.badge-blue { background: var(--brand-light); color: var(--brand); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); border: 1px solid var(--gray-200); }
.badge-orange { background: var(--kv-orange-light); color: var(--kv-orange); }
.badge-purple { background: var(--kv-purple-light); color: var(--kv-purple); }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-wrap: wrap;
}

.search-input-wrap { position: relative; }
.search-input-wrap i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 13px;
}
.search-input-wrap input {
  padding-left: 32px;
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  height: 34px;
  font-size: 13px;
  background: var(--gray-50);
  transition: all 0.15s;
  color: var(--kv-text);
}
.search-input-wrap input:focus {
  background: #fff;
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ============================================================
   INVOICE / POS LAYOUT
   ============================================================ */
.invoice-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  height: 100%;
}

.invoice-left { display: flex; flex-direction: column; background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--gray-100); overflow: hidden; }
.inv-product-search {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.inv-product-search input {
  height: 40px;
  font-size: 14px;
  border-color: var(--brand);
  background: #fff;
}
.inv-cart { flex: 1; overflow-y: auto; background: #fff; }
.inv-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--gray-300);
  gap: 8px;
}
.inv-cart-empty i { font-size: 40px; }

.invoice-right { display: flex; flex-direction: column; gap: 14px; }
.inv-total-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13.5px;
  color: var(--gray-600);
}
.inv-total-line.grand {
  font-size: 17px;
  font-weight: 700;
  color: var(--brand);
  border-top: 1px dashed var(--gray-200);
  padding-top: 10px;
  margin-top: 4px;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 20, 40, 0.45);
  backdrop-filter: blur(2px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-xl);
  width: 500px;
  max-width: 95vw;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: slideUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-sm { width: 380px; }
.modal-md { width: 620px; }
.modal-lg { width: 860px; }
.modal-xl { width: 1100px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--gray-50);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
}

.modal-close {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--gray-400);
  transition: all 0.15s;
}

.modal-close:hover { background: var(--gray-200); color: var(--gray-600); }

.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ============================================================
   TOAST
   ============================================================ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
}

.toast.success { background: linear-gradient(135deg, #16a34a, #22c55e); }
.toast.error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast.warning { background: linear-gradient(135deg, #ea580c, #f97316); }
.toast.info { background: linear-gradient(135deg, var(--brand), var(--brand-mid)); }
.toast-msg { flex: 1; line-height: 1.5; }

@keyframes toastIn {
  from { transform: translateX(110%) scale(0.95); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

/* ============================================================
   SPINNERS & EMPTY STATES
   ============================================================ */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
}

.empty-state i {
  font-size: 44px;
  margin-bottom: 16px;
  color: var(--gray-200);
  display: block;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
}

/* ============================================================
   TABS
   ============================================================ */
.kv-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  background: #fff;
  padding: 0 20px;
}

.kv-tab {
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.kv-tab:hover { color: var(--gray-700); }
.kv-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ============================================================
   KPI / REPORT BOXES
   ============================================================ */
.report-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

.kpi-box {
  background: #fff;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}

.kpi-box:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-label {
  font-size: 12.5px;
  color: var(--gray-400);
  font-weight: 500;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.5px;
}

/* ============================================================
   PRODUCT THUMBNAIL & DROPDOWN
   ============================================================ */
.prod-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--gray-100);
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-300);
  font-size: 16px;
  overflow: hidden;
}

.dropdown-list {
  position: absolute;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-xl);
  border-radius: var(--radius-lg);
  max-height: 320px;
  overflow-y: auto;
  animation: slideUp 0.15s ease;
}

.dropdown-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-50);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--brand-light); }
.dropdown-item .di-name { font-weight: 600; font-size: 13.5px; color: var(--gray-800); }

.imei-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-family: 'Roboto Mono', monospace;
  margin-right: 4px;
  margin-bottom: 4px;
}

.imei-tag.available { background: var(--kv-green-light); border-color: #86efac; color: #166534; }
.imei-tag.sold { background: var(--kv-orange-light); border-color: #fdba74; color: #9a3412; text-decoration: line-through; }
.imei-tag .rm { cursor: pointer; color: var(--kv-red); margin-left: 4px; font-weight: bold; }

/* ============================================================
   TWO-PANE LAYOUT
   ============================================================ */
.kv-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 120px);
  overflow: hidden;
  position: relative;
}

.kv-left-filter {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.kv-right-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

.filter-box { border-bottom: 1px solid var(--gray-100); padding: 14px; }
.filter-box-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-400);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.filter-list { display: flex; flex-direction: column; gap: 4px; }
.filter-item {
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.1s;
}
.filter-item:hover, .filter-item.active {
  color: var(--brand);
  background: var(--brand-light);
  font-weight: 500;
}
.filter-item input[type="radio"], .filter-item input[type="checkbox"] { margin: 0; accent-color: var(--brand); }

/* Bottom Panel */
.kv-bottom-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 360px;
  background: #fff;
  border-top: 2px solid var(--brand);
  box-shadow: 0 -8px 24px rgba(79, 70, 229, 0.08);
  display: flex;
  flex-direction: column;
  transform: translateY(105%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kv-bottom-panel.open { transform: translateY(0); }
.kv-bottom-header {
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
  align-items: flex-end;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kv-bottom-tabs { display: flex; }
.kv-bottom-tab {
  padding: 10px 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  color: var(--gray-400);
  margin-bottom: -1px;
  transition: all 0.15s;
}
.kv-bottom-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  background: #fff;
  font-weight: 600;
}
.kv-bottom-body { flex: 1; overflow-y: auto; padding: 16px; background: #fff; }
.kv-bottom-actions { display: flex; gap: 8px; padding-bottom: 8px; }

/* filter-item checked state */
.filter-item input[type="radio"]:checked ~ span,
.filter-item:has(input[type="radio"]:checked),
.filter-item:has(input[type="checkbox"]:checked) {
  color: var(--brand);
  font-weight: 600;
  background: var(--brand-light);
}

/* Misc */
.chart-wrap { position: relative; }

/* ============================================================
   MOBILE RESPONSIVE (PWA) & UX STANDARDS
   ============================================================ */
/* Hide mobile specific elements on Desktop */
.mobile-bottom-nav, .mobile-overlay-menu { display: none; }

@media (max-width: 768px) {
  /* 1. Viewport & Touch Targets */
  .app-container {
    height: 100dvh;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }
  input, select, textarea { font-size: 16px !important; }
  .btn, .form-control, .nav-item { min-height: 44px; }
  
  /* Hide Desktop Nav & Topbar */
  .sidebar { display: none; }
  .topbar { display: none; } /* On mobile, we use specific page headers */
  .main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }
  .main-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    -webkit-overflow-scrolling: touch;
  }

  /* 2. Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--gray-200);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  }
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--gray-500);
    font-size: 11px;
    cursor: pointer;
    height: 100%;
    transition: color 0.2s;
  }
  .bottom-nav-item i { font-size: 20px; margin-bottom: 4px; }
  .bottom-nav-item.active { color: var(--brand); font-weight: 600; }
  
  /* FAB Wrapper */
  .bottom-nav-item.fab-wrapper { flex: 0.8; position: relative; }
  .bottom-nav-fab {
    position: absolute;
    top: -24px;
    width: 56px;
    height: 56px;
    background: var(--brand-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    border: 4px solid #fff;
  }
  .bottom-nav-item.active .bottom-nav-fab { background: #3730a3; }

  /* 3. Mobile Overlay Menu */
  .mobile-overlay-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    background: #fff;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  
  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
  }
  .mobile-menu-header .user-info { display: flex; align-items: center; gap: 12px; }
  .mobile-menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
  }
  .mobile-menu-body .sidebar-section-label { margin-top: 16px; margin-bottom: 8px; color: var(--gray-500); }
  .mobile-menu-body .nav-item {
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-main);
    background: transparent;
    margin-bottom: 4px;
  }
  .mobile-menu-body .nav-item.active { background: var(--brand-light); color: var(--brand); }
  .mobile-menu-body .nav-item .nav-icon { color: var(--gray-500); }
  .mobile-menu-body .nav-item.active .nav-icon { color: var(--brand); }

  /* 4. Modals - Full Screen / Bottom Sheet */
  .modal-box {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: 100dvh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
  }
  .modal-body { flex: 1; overflow-y: auto; padding: 16px; }
  .modal-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--gray-200);
    display: flex;
    flex-direction: row;
  }
  .modal-footer .btn { flex: 1; min-height: 48px; }

  /* 5. Mobile Data Cards (Table to Card) */
  .mobile-card-table {
    display: block;
    width: 100%;
  }
  .mobile-card-table thead { display: none; }
  .mobile-card-table tbody { display: block; width: 100%; }
  .mobile-card-table tr {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
    position: relative;
  }
  .mobile-card-table td {
    display: block;
    width: 100%;
    border: none;
    padding: 4px 0;
    text-align: right;
  }
  .mobile-card-table td::before {
    content: attr(data-label);
    float: left;
    font-weight: 500;
    color: var(--gray-500);
  }
  /* First column often ID/# -> hide or style */
  .mobile-card-table td:nth-child(1) { width: auto; font-weight: bold; padding-bottom: 8px; }
  /* Name/Title column often wide */
  .mobile-card-table td:nth-child(2) { width: 100%; text-align: left; font-weight: 600; font-size: 15px; color: var(--text-main); }
  .mobile-card-table td:nth-child(2)::before { display: none; }
  /* Actions row */
  .mobile-card-table td:last-child {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--gray-200);
  }
  .mobile-card-table td:last-child::before { display: none; }

  /* 6. POS Mobile Layout */
  .invoice-layout {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .invoice-left { margin-bottom: 16px; flex: 1; }
  .inv-cart {
    border: none;
    min-height: 200px;
    padding-bottom: 80px; /* space for sticky bar */
  }
  .invoice-right {
    margin: 0;
    border-radius: 12px;
  }
  .invoice-right .card-body { padding-bottom: 20px; }
  
  .pos-cart-item {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-xs);
  }
  .pos-cart-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  .pos-cart-item-title { font-weight: 600; color: var(--text-main); font-size: 14px; max-width: 80%; }
  .pos-cart-item-price { font-weight: 700; color: var(--brand); font-size: 14px; }
  
  .pos-cart-qty-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    overflow: hidden;
  }
  .qty-btn {
    width: 32px;
    height: 32px;
    background: var(--gray-50);
    border: none;
    font-size: 16px;
    font-weight: bold;
    color: var(--gray-600);
    cursor: pointer;
  }
  .qty-input {
    width: 40px;
    height: 32px;
    border: none;
    border-left: 1px solid var(--gray-200);
    border-right: 1px solid var(--gray-200);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
  }
  .btn-remove-cart {
    color: var(--kv-red);
    background: #fee2e2;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .pos-mobile-sticky-bar {
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 998;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  }
  .pos-sticky-info { display: flex; flex-direction: column; }
  .pos-sticky-info .label { font-size: 12px; color: var(--gray-500); font-weight: 500; }
  .pos-sticky-info .val { font-size: 18px; font-weight: 700; color: var(--text-main); margin-top: 2px; }
  
  .pos-checkout-sheet .mobile-bottom-sheet-content {
    background: #f8fafc;
    padding: 0;
  }
  .pos-checkout-sheet .mobile-sheet-header {
    background: #fff;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--gray-200);
  }
  .pos-checkout-sheet .card {
    border-radius: 0;
    margin-bottom: 8px;
    box-shadow: none;
    border-left: none; border-right: none;
  }

  /* Sticky Payment Footer in POS */
  .pos-mobile-footer {
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom)); /* Above bottom nav */
    left: 0; right: 0;
    background: #fff;
    padding: 12px 16px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    border-top: 1px solid var(--gray-200);
    z-index: 900;
  }
  
  /* Utility layout adjustments */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
  .page-actions { width: 100%; display: flex; }
  .page-actions .btn { flex: 1; }
  .form-row, .form-row-3, .product-form-grid { grid-template-columns: 1fr; gap: 12px; }
  .report-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kv-layout { flex-direction: column; height: auto !important; overflow: visible !important; }
  .kv-right-content { overflow: visible !important; height: auto !important; }
  #prod-body-mobile, #cust-body-mobile, #supp-body-mobile, #purch-body-mobile, #inv-body-mobile { overflow: visible !important; }
  .kv-left-filter { width: 100%; margin-bottom: 12px; }

  .mobile-only { display: block !important; }
  .mobile-only-flex { display: flex !important; }
  .mobile-only-grid { display: grid !important; }
  .desktop-only { display: none !important; }

  /* 7. Enhanced Touch Targets for Mobile (>= 44px) */
  input[type="text"], input[type="number"], input[type="password"], select.form-control, .search-input-wrap input { 
    min-height: 44px !important; 
    padding-top: 10px; 
    padding-bottom: 10px; 
  }
  button, .btn, .tbl-btn, .modal-close {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .badge {
    min-height: 36px; /* Badges inside flex might distort if 44px, but let's make them larger */
    padding: 8px 12px;
    font-size: 14px;
  }
  .invoice-right button.badge {
    min-height: 44px; /* specifically for All TM / All CK */
  }
  input[type="checkbox"]:not(.switch input), input[type="radio"] {
    width: 24px !important;
    height: 24px !important;
  }
  label:has(input[type="checkbox"]:not(.switch input)), label:has(input[type="radio"]) {
    min-height: 44px;
  }
  .switch { min-height: 22px !important; }
  .tr-actions .tbl-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .pos-checkout-sheet .pos-mobile-footer {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    box-shadow: none;
    border-top: none;
    padding: 0;
    background: transparent;
  }

  .pos-checkout-sheet .card-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 5;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  /* Full-screen Modal for Add/Edit Form */
  .mobile-fullscreen-form-modal {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 0 !important;
  }

  .mobile-fullscreen-form-modal .modal-box {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
  }

  .mobile-fullscreen-form-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
  }

  .mobile-fullscreen-form-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 88px;
  }

  .mobile-fullscreen-form-modal .modal-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 5;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  /* Generic Action Footer for Mobile Sheets */
  .mobile-action-footer {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: #fff;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    border-top: 1px solid var(--gray-200);
    z-index: 900;
    display: flex;
    gap: 12px;
  }
  .mobile-action-footer .btn { flex: 1; }


}

/* DESKTOP OVERRIDES FOR MOBILE-ONLY SHEET */
@media (min-width: 769px) {
  .invoice-layout {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    gap: 16px;
  }
  .invoice-left {
    flex: 2 !important;
    margin-bottom: 0 !important;
  }
  
  .pos-checkout-sheet.mobile-bottom-sheet {
    flex: 1 !important;
    position: static;
    background: transparent;
    opacity: 1; pointer-events: auto;
    z-index: auto;
    display: block !important;
  }
  .pos-checkout-sheet.mobile-bottom-sheet .mobile-bottom-sheet-content {
    background: transparent;
    padding: 0;
    max-height: none;
    transform: none;
    overflow-y: visible;
  }
  .pos-checkout-sheet.mobile-bottom-sheet .mobile-sheet-header {
    display: none !important;
  }
}

/* ============================================================
   DASHBOARD CUSTOM CLASSES
   ============================================================ */
.dashboard-page { max-width: 100%; padding: 20px; }
.db-grid { display: grid; grid-template-columns: 3fr 1fr; gap: 20px; }
.db-col-left { display: flex; flex-direction: column; gap: 20px; }
.db-col-right { display: flex; flex-direction: column; gap: 16px; }
.db-activity-feed { max-height: 400px; overflow-y: auto; padding-right: 4px; }
.db-activity-feed::-webkit-scrollbar { width: 4px; }
.db-activity-feed::-webkit-scrollbar-track { background: transparent; }
.db-activity-feed::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }

/* KPI Card */
.db-kpi-card { border-top: 3px solid var(--kv-blue); border-radius: 4px 4px 0 0; }
.db-kpi-header { border-bottom: none; padding-bottom: 0; }
.db-kpi-body { display: flex; gap: 40px; }
.kpi-item { display: flex; align-items: center; gap: 12px; }
.kpi-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.kpi-label { font-size: 13px; color: var(--kv-text-2); }
.kpi-val { font-size: 24px; font-weight: 700; }
.kpi-sep { width: 1px; background: var(--kv-border-light); height: 50px; margin-top: 5px; }

/* Chart */
.db-chart-header { display: flex; justify-content: space-between; align-items: center; border-bottom: none; }
.db-chart-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--kv-border-light); margin-bottom: 20px; }
.db-chart-tab { font-weight: 600; color: var(--kv-text-2); cursor: pointer; padding-bottom: 11px; margin-bottom: -1px; }
.db-chart-tab.active { color: var(--kv-blue); border-bottom: 2px solid var(--kv-blue); }

/* Reports Grid */
.reports-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; flex: 1; min-height: 0; padding-bottom: 14px; }

/* Top Lists */
.db-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.db-list { display: flex; flex-direction: column; gap: 12px; }
.db-list-item { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--kv-border-light); }
.db-list-item:last-child { border-bottom: none; padding-bottom: 0; }
.db-list-rank { width: 24px; font-weight: 700; font-size: 13px; }
.db-list-content { flex: 1; min-width: 0; }
.db-list-title { font-weight: 600; color: var(--kv-blue); font-size: 13px; cursor: pointer; }
.db-list-subtitle { font-size: 11px; color: var(--kv-text-3); margin-top: 2px; }
.db-list-val { text-align: right; font-weight: 600; font-size: 13px; }
.db-list-unit { color: var(--kv-text-3); font-weight: 400; font-size: 12px; }

/* Summary & Activity */
.db-summary-card { border-radius: 4px; overflow: hidden; margin-bottom: 0; }
.db-summary-header { padding: 12px 16px; border-bottom: 1px solid var(--kv-border-light); background: #f8fafc; font-size: 13px; font-weight: 600; color: var(--kv-text-2); text-transform: uppercase; letter-spacing: 0.5px; }
.db-timeline { position: relative; padding-left: 14px; }
.db-timeline::before { content: ''; position: absolute; top: 0; bottom: 0; left: 15px; width: 2px; background: var(--kv-border-light); z-index: 0; }
.db-timeline-item { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; position: relative; z-index: 1; }
.db-timeline-item:last-child { margin-bottom: 0; }
.db-timeline-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; margin-left: -13px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--kv-border-light); }
.db-timeline-content { flex: 1; background: #fcfdfe; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--gray-200); }
.db-timeline-text { font-size: 13px; line-height: 1.4; color: var(--text-main); }
.db-timeline-date { color: var(--kv-text-3); font-size: 11px; margin-top: 4px; font-weight: 500; }

/* ============================================================
   MOBILE NATIVE COMPONENTS (PHASE 1 & 2)
   ============================================================ */
/* Mobile Menu Grid (Nhiều hơn) */
.mobile-menu-grid { display: flex; flex-direction: column; gap: 24px; }
.menu-group-title { font-size: 12px; font-weight: 700; color: var(--kv-text-3); text-transform: uppercase; margin-bottom: 12px; letter-spacing: 0.5px; }
.menu-items { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px 8px; }
.menu-item { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; cursor: pointer; }
.menu-item i { font-size: 24px; width: 44px; height: 44px; background: #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.menu-item span { font-size: 11px; font-weight: 500; color: var(--text-main); }

/* Horizontal Scroll Row (e.g. for Stats Cards on Mobile) */
.mobile-scroll-row { display: flex; overflow-x: auto; gap: 12px; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.mobile-scroll-row::-webkit-scrollbar { display: none; }
.mobile-scroll-row > * { flex: 0 0 85%; scroll-snap-align: start; }

/* Cashflow Mobile Specifics */
.cf-list-item {
  display: flex; flex-direction: column; gap: 8px;
  background: #fff; padding: 12px 16px; border-bottom: 1px solid var(--gray-200);
}
.cf-list-item:active { background: var(--gray-50); }
.cf-list-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cf-list-title { font-weight: 600; font-size: 14px; color: var(--kv-blue); margin-bottom: 4px; }
.cf-list-desc { font-size: 13px; color: var(--text-main); }
.cf-list-amount { font-weight: 700; font-size: 15px; text-align: right; flex-shrink: 0; margin-left: 8px; }
.cf-list-amount.thu { color: var(--kv-green); }
.cf-list-amount.chi { color: var(--kv-red); }
.cf-list-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--kv-text-3); }
.cf-badge-thu { background: var(--kv-green-light); color: var(--kv-green); padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.cf-badge-chi { background: var(--kv-red-light); color: var(--kv-red); padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.cf-list-meta-line { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--kv-text-3); min-width: 0; }
.cf-list-meta-line > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-list-ref { font-size: 12px; color: var(--kv-blue); background: #f1f7ff; border-radius: 6px; padding: 6px 8px; line-height: 1.35; margin-top: 4px; }
.cf-detail-row { display: flex; justify-content: space-between; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--gray-200); }
.cf-detail-label { color: var(--kv-text-3); }
.cf-detail-value { font-weight: 500; color: var(--text-main); text-align: right; max-width: 70%; word-break: break-word; }
.cf-detail-row-note { border-bottom: none; margin-bottom: 0; padding-bottom: 0; flex-direction: column; gap: 6px; align-items: flex-start; }
.cf-detail-row-note .cf-detail-value { max-width: 100%; text-align: left; }

/* Generic Mobile Rich Card (Base for Products/Purchases) */
.mobile-rich-card {
  display: flex; flex-direction: column; gap: 8px;
  background: #fff; padding: 12px 16px; border-bottom: 1px solid var(--gray-200);
}
.mobile-rich-card:active { background: var(--gray-50); }
.mrc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.mrc-title { font-weight: 600; font-size: 14px; color: var(--brand); margin-bottom: 4px; }
.mrc-subtitle { font-size: 13px; color: var(--text-main); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.mrc-amount { font-weight: 700; font-size: 15px; text-align: right; flex-shrink: 0; margin-left: 8px; }
.mrc-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--kv-text-3); }
.mrc-meta-line { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--kv-text-3); min-width: 0; flex-wrap: wrap; }


@media (max-width: 768px) {
  /* Bottom Sheet Filter / Action Sheet */
  .mobile-bottom-sheet {
    position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    background: rgba(0,0,0,0.5) !important; z-index: 10000 !important;
    display: flex !important; flex-direction: column !important; justify-content: flex-end !important;
    opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
    width: 100% !important; margin: 0 !important; padding: 0 !important;
  }
  .mobile-bottom-sheet.show { opacity: 1; pointer-events: auto; visibility: visible; }
  .mobile-bottom-sheet-content {
    background: #fff; border-radius: 16px 16px 0 0; 
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom)) 20px;
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
    max-height: 90vh; overflow-y: auto; width: 100%; box-sizing: border-box;
  }
  .mobile-bottom-sheet.show .mobile-bottom-sheet-content { transform: translateY(0); }
  .mobile-sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
  .mobile-sheet-title { font-size: 16px; font-weight: 600; margin: 0; }
  .mobile-sheet-close { background: none; border: none; font-size: 24px; color: var(--gray-500); cursor: pointer; padding: 4px; }
  /* 8. Dashboard Mobile Layout Overrides */
  .dashboard-page { padding: 12px !important; }
  .db-quick-actions { display: grid !important; }
  .db-grid { grid-template-columns: 1fr; gap: 16px; }
  .db-kpi-body { 
    display: grid !important; 
    grid-template-columns: 1fr; 
    gap: 12px !important; 
  }
  .kpi-sep { display: none; } /* Hide vertical separators on mobile */
  .db-top-grid { grid-template-columns: 1fr; gap: 16px; }
  .reports-grid { grid-template-columns: 1fr; }
  .db-chart-tabs { justify-content: space-between; }
  .page-title-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }
  .db-chart-tab { 
    min-height: 44px !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    flex: 1 !important;
    text-align: center;
  }
}
. s e t t i n g s - g r i d   {   d i s p l a y :   g r i d ;   g r i d - t e m p l a t e - c o l u m n s :   1 f r   1 f r ;   g a p :   1 6 p x ;   } 
 @ m e d i a   ( m a x - w i d t h :   7 6 8 p x )   {   . s e t t i n g s - g r i d   {   g r i d - t e m p l a t e - c o l u m n s :   1 f r ;   }   }  
 