/* ================================================
   XOS — Trivex Group Operations System
   ================================================ */

:root {
  /* Brand — Soft blue/lavender palette with orange accent */
  --navy: #2c3e6b;
  --navy-light: #3a4f82;
  --navy-lighter: #4a6199;
  --navy-dark: #1e2d52;
  --orange: #f97316;
  --orange-hover: #ea6a0e;
  --orange-light: rgba(249, 115, 22, 0.08);

  /* Layout — Soft glassmorphism */
  --sidebar-bg: linear-gradient(180deg, #c7d2e8 0%, #b8c6e0 50%, #adbdd8 100%);
  --sidebar-hover: rgba(255,255,255,0.35);
  --sidebar-active: rgba(255,255,255,0.5);
  --topbar-bg: rgba(255,255,255,0.7);
  --page-bg: linear-gradient(135deg, #d0daf0 0%, #c4d0e8 30%, #bcc8e2 60%, #c8d4ec 100%);
  --card-bg: rgba(255,255,255,0.72);
  --card-border: rgba(255,255,255,0.5);
  --text: #2c3e6b;
  --text-muted: #6b7a9e;
  --text-light: #8e9bbb;
  --text-sidebar: #4a5a80;
  --text-sidebar-active: #2c3e6b;

  /* Status */
  --green: #34b87a;
  --green-bg: rgba(52, 184, 122, 0.12);
  --yellow: #e6a817;
  --yellow-bg: rgba(230, 168, 23, 0.12);
  --red: #e05252;
  --red-bg: rgba(224, 82, 82, 0.1);
  --blue: #5b8fd9;
  --blue-bg: rgba(91, 143, 217, 0.12);
  --purple: #8b7fd6;
  --cyan: #4db8c9;

  /* Misc */
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(44,62,107,0.06);
  --shadow: 0 2px 8px rgba(44,62,107,0.08);
  --shadow-md: 0 4px 16px rgba(44,62,107,0.1);
  --transition: all 0.25s ease;
}

/* ================================================
   RESET & BASE
   ================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--orange); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
table { width: 100%; border-collapse: collapse; }

/* ================================================
   LOGIN
   ================================================ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #7b98cc 0%, #9ab0d9 30%, #b4c6e6 60%, #c8d8f0 100%);
  z-index: 1000;
}
.login-container {
  display: flex;
  width: 900px; max-width: 95vw;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(44,62,107,0.2);
  border: 1px solid rgba(255,255,255,0.5);
}
.login-left {
  flex: 1;
  background: linear-gradient(135deg, #2c3e6b 0%, #3a5a8c 50%, #4a6fa3 100%);
  color: #fff;
  padding: 48px 40px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-right {
  flex: 1;
  padding: 48px 40px;
  display: flex; align-items: center; justify-content: center;
}
.login-brand { margin-bottom: 40px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.logo-icon {
  width: 44px; height: 44px;
  background: var(--orange);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
}
.logo-text { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.login-subtitle { font-size: 14px; color: #94a3b8; }
.login-features { display: flex; flex-direction: column; gap: 20px; }
.login-feature {
  display: flex; align-items: flex-start; gap: 14px;
  font-size: 13px; color: #cbd5e1;
}
.login-feature i { font-size: 18px; color: var(--orange); margin-top: 2px; width: 24px; text-align: center; }
.login-feature h4 { font-size: 14px; font-weight: 600; color: #fff; margin-bottom: 2px; }
.login-form-container { width: 100%; max-width: 340px; }
.login-form-container h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; color: var(--navy); }
.login-form-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-input {
  padding: 10px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}
.form-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-light); }
.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--orange-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-full { width: 100%; }
/* Portal login */
#portal-login-screen {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}
.portal-login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 25px 50px rgba(0,0,0,0.15);
}
.portal-login-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--card-border);
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 8px;
  border: 1px solid rgba(239,68,68,0.2);
}

/* ================================================
   APP SHELL — Glassmorphism Layout
   ================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--page-bg);
}

/* ---- SIDEBAR — Frosted glass vertical nav ---- */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.3);
  padding: 0;
}
.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon-sm {
  width: 32px; height: 32px;
  background: var(--orange);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
  box-shadow: 0 2px 8px rgba(249,115,22,0.3);
}
.logo-text-sm { font-size: 17px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; }
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-sidebar);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--navy); }
.nav-item.active { background: var(--sidebar-active); color: var(--navy); font-weight: 600; box-shadow: 0 1px 4px rgba(44,62,107,0.08); }
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
}
.nav-section {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-light);
  padding: 14px 12px 4px;
}
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.2);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--orange);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(249,115,22,0.25);
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.btn-icon {
  background: none; border: none; color: var(--text-sidebar); cursor: pointer;
  padding: 6px; border-radius: 6px; font-size: 14px;
  transition: var(--transition);
}
.btn-icon:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  height: 52px;
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.menu-toggle {
  display: none;
  background: none; border: none; font-size: 18px; color: var(--text); cursor: pointer;
  padding: 6px; border-radius: 6px;
}
.menu-toggle:hover { background: var(--page-bg); }
.breadcrumb { font-size: 14px; font-weight: 600; color: var(--text); }
.topbar-icon {
  background: none; border: none; font-size: 16px; color: var(--text-muted);
  cursor: pointer; padding: 8px; border-radius: var(--radius);
  transition: var(--transition); position: relative;
}
.topbar-icon:hover { background: var(--page-bg); color: var(--text); }
.company-logo {
  width: 32px; height: 32px;
  background: var(--navy);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  box-shadow: 0 2px 6px rgba(44,62,107,0.2);
}
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ================================================
   PAGE HEADER
   ================================================ */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--navy); letter-spacing: -0.3px; }
.page-header-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ================================================
   BUTTONS
   ================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-accent { background: var(--orange); color: #fff; }
.btn-accent:hover { background: var(--orange-hover); }
.btn-accent:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline { background: rgba(255,255,255,0.6); color: var(--text); border: 1px solid rgba(255,255,255,0.5); backdrop-filter: blur(8px); }
.btn-outline:hover { background: rgba(255,255,255,0.85); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-light); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 24px; font-size: 15px; }

/* ================================================
   STAT CARDS
   ================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.stat-card-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-card-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.stat-card-value { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat-card-change { font-size: 12px; margin-top: 6px; color: var(--text-muted); }
.stat-up { color: var(--green); }
.stat-down { color: var(--red); }

/* ================================================
   DATA TABLES
   ================================================ */
.data-table-container {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
}
.data-table-title { font-size: 15px; font-weight: 600; color: var(--navy); }
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.3);
  background: rgba(200,215,240,0.25);
}
.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(0,0,0,0.015); }

/* ================================================
   STATUS BADGES
   ================================================ */
.status-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.status-planning { background: rgba(156,163,175,0.15); color: #6b7280; }
.status-active { background: var(--green-bg); color: var(--green); }
.status-punch_list, .status-punch-list { background: var(--yellow-bg); color: var(--yellow); }
.status-complete { background: var(--blue-bg); color: var(--blue); }
.status-archived { background: rgba(156,163,175,0.15); color: #6b7280; }
.status-lost { background: var(--red-bg); color: var(--red); }
.status-overdue { background: var(--red-bg); color: var(--red); }
.status-draft { background: rgba(156,163,175,0.15); color: #6b7280; }
.status-sent { background: var(--blue-bg); color: var(--blue); }
.status-accepted { background: var(--green-bg); color: var(--green); }
.status-declined { background: var(--red-bg); color: var(--red); }
.status-paid { background: var(--green-bg); color: var(--green); }
.status-partially_paid, .status-partially-paid { background: var(--yellow-bg); color: var(--yellow); }
.status-pending { background: rgba(156,163,175,0.15); color: #6b7280; }
.status-in_progress, .status-in-progress { background: var(--orange-light); color: var(--orange); }
.status-acknowledged { background: rgba(6,182,212,0.1); color: #0891b2; }
.status-overdue { background: var(--red-bg); color: var(--red); }
.status-submitted { background: var(--blue-bg); color: var(--blue); }
.status-under_review, .status-under-review { background: rgba(139,92,246,0.1); color: var(--purple); }
.status-quoted { background: var(--orange-light); color: var(--orange); }
.status-high { background: var(--red-bg); color: var(--red); }
.status-medium { background: var(--yellow-bg); color: #b45309; }
.status-low { background: var(--green-bg); color: var(--green); }

/* ================================================
   CARDS GRID
   ================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--orange); transform: translateY(-2px); }

/* ================================================
   PROGRESS BAR
   ================================================ */
.progress-bar {
  height: 6px;
  background: rgba(200,215,240,0.4);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ================================================
   TABS
   ================================================ */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid rgba(200,215,240,0.4);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); font-weight: 600; }

/* ================================================
   FORMS
   ================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group-full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; display: block; }
.form-input-styled {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(200,215,240,0.5);
  border-radius: 10px;
  font-size: 14px;
  background: rgba(255,255,255,0.7);
  color: var(--text);
  outline: none;
  transition: var(--transition);
}
.form-input-styled:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-light); background: rgba(255,255,255,0.9); }
select.form-input-styled { cursor: pointer; }
textarea.form-input-styled { resize: vertical; min-height: 80px; }

/* ================================================
   MODAL
   ================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  padding: 32px;
  max-width: 560px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(44,62,107,0.2);
  border: 1px solid rgba(255,255,255,0.5);
}
.modal-card h3 { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ================================================
   ACTIVITY LIST
   ================================================ */
.activity-list { list-style: none; }
.activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.04); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.activity-time { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ================================================
   GRID HELPERS
   ================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.section-title { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 12px; }

/* ================================================
   FIELD DASHBOARD — RECEIPT CAPTURE BUTTON
   ================================================ */
.receipt-capture-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 24px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}
.receipt-capture-btn:hover {
  background: var(--orange-hover);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
  transform: translateY(-1px);
}
.receipt-capture-btn i { font-size: 24px; }

/* ================================================
   RECEIPT CAPTURE FLOW
   ================================================ */
.camera-preview {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius);
  background: #000;
}
.receipt-preview-img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  margin-bottom: 16px;
}

/* ================================================
   PIPELINE KANBAN
   ================================================ */
.pipeline-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.pipeline-column {
  min-width: 220px;
  flex: 1;
}
.pipeline-col-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--page-bg);
}
.pipeline-col-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.pipeline-col-title { font-size: 13px; font-weight: 600; }
.pipeline-col-count { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.pipeline-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}
.pipeline-card:hover { box-shadow: var(--shadow); border-color: var(--orange); }

/* ================================================
   EMPTY STATE
   ================================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}
.empty-state i { font-size: 48px; color: var(--text-light); margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--text-muted); max-width: 360px; margin: 0 auto 20px; }

/* ================================================
   LOADING
   ================================================ */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ================================================
   MOBILE RESPONSIVE
   ================================================ */
/* ================================================
   BOTTOM NAV (mobile)
   ================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,0.4);
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 10px; font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  min-width: 56px;
  min-height: 44px;
  transition: var(--transition);
  border-radius: 8px;
}
.bottom-nav-item i { font-size: 18px; }
.bottom-nav-item.active { color: var(--orange); }
.bottom-nav-item:active { background: var(--page-bg); }

/* More menu (bottom sheet) */
.more-menu {
  position: fixed; inset: 0;
  z-index: 300;
}
.more-menu-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
}
.more-menu-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}
.more-menu-handle {
  width: 36px; height: 4px;
  background: var(--card-border);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.more-menu-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  background: none; border: none;
  padding: 14px 12px;
  font-size: 14px; font-weight: 500;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  min-height: 48px;
}
.more-menu-item:active { background: var(--page-bg); }
.more-menu-item i { width: 20px; text-align: center; color: var(--text-muted); font-size: 16px; }

/* ================================================
   INSTALL BANNER
   ================================================ */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 400;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  background: #fff;
  border-top: 1px solid var(--card-border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}
.install-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

/* ================================================
   TABLE SCROLL WRAPPER (mobile)
   ================================================ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ================================================
   MOBILE RESPONSIVE
   ================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: -240px; top: 0; bottom: 0;
    z-index: 200; width: 240px;
    box-shadow: 4px 0 24px rgba(44,62,107,0.2);
  }
  .sidebar.open { left: 0; }
  .menu-toggle { display: block; }
  .bottom-nav { display: flex; }

  /* Page content needs bottom padding for bottom nav */
  .page-content { padding: 16px 16px 80px; }
  .page-header { flex-direction: column; }
  .page-header h1 { font-size: 18px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }

  .login-container { flex-direction: column; }
  .login-left { padding: 32px 24px; }
  .login-right { padding: 32px 24px; }
  .login-features { display: none; }

  /* Tables scroll horizontally */
  .data-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 12px; min-width: 500px; }
  .data-table th, .data-table td { padding: 8px 10px; white-space: nowrap; }

  .tabs { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: 8px 12px; font-size: 12px; flex-shrink: 0; }

  .pipeline-board { flex-direction: column; }
  .pipeline-column { min-width: unset; }

  /* Ensure all tap targets are 44px+ */
  .btn, .btn-sm { min-height: 44px; }
  .nav-item { min-height: 44px; }
  .tab { min-height: 44px; display: flex; align-items: center; }
  .form-input, .form-input-styled { min-height: 44px; }
  select.form-input-styled { min-height: 44px; }

  /* Receipt capture button full-width */
  .receipt-capture-btn { padding: 20px; font-size: 16px; }

  /* Install banner above bottom nav */
  .install-banner { bottom: 64px; }

  /* Modal adjustments */
  .modal-card { max-height: 85vh; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-card-value { font-size: 20px; }
  .page-content { padding: 12px 12px 80px; }
  .topbar { padding: 0 12px; }
}

/* Standalone mode (installed PWA) — hide install banner */
@media (display-mode: standalone) {
  .install-banner { display: none !important; }
}

/* ================================================
   SIDEBAR BACKDROP (mobile)
   ================================================ */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
}
.sidebar-backdrop.show { display: block; }

/* ================================================
   CHART PLACEHOLDER
   ================================================ */
.chart-container {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 20px;
}
.chart-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

/* ================================================
   MISC
   ================================================ */
.divider {
  height: 1px;
  background: var(--card-border);
  margin: 16px 0;
}
.tag {
  display: inline-flex;
  padding: 2px 8px;
  background: rgba(200,215,240,0.35);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ================================================
   SAFE AREAS (notch devices)
   ================================================ */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
  .more-menu-sheet { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
