/* ═══════════════════════════════════════════════════════════
   FieldOrder Pro — Main Stylesheet
   Modern, Responsive, Mobile-First Design
═══════════════════════════════════════════════════════════ */

/* ─── CSS VARIABLES ─────────────────────────────────────── */
:root {
  /* Brand Colors */
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-mid: #3B82F6;

  /* Status Colors */
  --success: #10B981;
  --success-light: #ECFDF5;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --info: #06B6D4;
  --info-light: #ECFEFF;

  /* Neutral */
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Sidebar */
  --sidebar-bg: #0F172A;
  --sidebar-border: #1E293B;
  --sidebar-text: #94A3B8;
  --sidebar-hover: #1E293B;
  --sidebar-active-bg: #1D4ED8;
  --sidebar-active-text: #FFFFFF;
  --sidebar-width: 260px;

  /* Surface */
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --text: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  /* Layout */
  --topbar-height: 60px;
  --bottom-nav-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── DARK MODE VARIABLES ───────────────────────────────── */
html.dark {
  /* Neutral overrides */
  --gray-50:  #1E293B;
  --gray-100: #273549;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748B;
  --gray-500: #94A3B8;
  --gray-600: #CBD5E1;
  --gray-700: #E2E8F0;
  --gray-800: #F1F5F9;
  --gray-900: #F8FAFC;

  /* Surface */
  --bg:      #0F172A;
  --surface: #1E293B;
  --border:  #334155;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.3), 0 2px 4px -1px rgba(0,0,0,.2);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.4);

  /* Typography */
  --text:       #F1F5F9;
  --text-muted: #94A3B8;
  --text-light: #64748B;

  /* Brand — slightly brighter in dark */
  --primary:       #3B82F6;
  --primary-dark:  #2563EB;
  --primary-light: #1E3A5F;
  --primary-mid:   #60A5FA;

  /* Status lights */
  --success-light: #064E3B;
  --warning-light: #451A03;
  --danger-light:  #450A0A;
  --info-light:    #082F49;

  /* Sidebar stays very dark but slightly different */
  --sidebar-bg:     #070E1A;
  --sidebar-border: #1A2744;
  --sidebar-hover:  #1E2D4A;
}

/* status badge dark adjustments */
html.dark .badge-draft        { background: #1E293B; color: #94A3B8; }
html.dark .badge-pending      { background: #451A03; color: #FCD34D; }
html.dark .badge-approved     { background: #064E3B; color: #6EE7B7; }
html.dark .badge-rejected     { background: #450A0A; color: #FCA5A5; }
html.dark .badge-synced       { background: #082F49; color: #67E8F9; }
html.dark .badge-scheduled    { background: #1E3A5F; color: #93C5FD; }
html.dark .badge-in_progress  { background: #451A03; color: #FDE68A; }
html.dark .badge-completed    { background: #064E3B; color: #6EE7B7; }

/* item-type badges */
html.dark .type-product  { background: #1E3A5F; color: #93C5FD; }
html.dark .type-service  { background: #2D1B69; color: #C4B5FD; }
html.dark .type-material { background: #451A03; color: #FDE68A; }
html.dark .type-labour   { background: #064E3B; color: #6EE7B7; }

/* forms in dark mode */
html.dark .form-control {
  background: #273549;
  border-color: #334155;
  color: var(--text);
}
html.dark .form-control:focus {
  border-color: var(--primary);
  background: #1E2D4A;
}
html.dark select.form-control option { background: #1E293B; }

/* ─── LOGIN SCREEN — LIGHT MODE OVERRIDES ───────────────── */
html:not(.dark) .login-screen {
  background: linear-gradient(145deg, #EFF6FF 0%, #F8FAFF 40%, #F0F4FF 100%);
}
html:not(.dark) .shape-1 { background: #3B82F6; opacity: 0.08; }
html:not(.dark) .shape-2 { background: #8B5CF6; opacity: 0.07; }
html:not(.dark) .shape-3 { background: #06B6D4; opacity: 0.06; }

html:not(.dark) .login-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(37,99,235,0.1);
  box-shadow: 0 20px 60px rgba(37,99,235,0.12), 0 4px 16px rgba(0,0,0,0.06);
}
html:not(.dark) .brand-text h1        { color: #1E293B; }
html:not(.dark) .brand-text h1 span   { color: #2563EB; }
html:not(.dark) .brand-text p         { color: #64748B; }

html:not(.dark) .login-form .form-group label { color: #374151; }

html:not(.dark) .input-wrapper .input-icon { color: #94A3B8; }
html:not(.dark) .input-wrapper input {
  background: #F8FAFF;
  border-color: #CBD5E1;
  color: #1E293B;
}
html:not(.dark) .input-wrapper input::placeholder { color: #CBD5E1; }
html:not(.dark) .input-wrapper input:focus {
  background: #EFF6FF;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
html:not(.dark) .toggle-password        { color: #94A3B8; }
html:not(.dark) .toggle-password:hover  { color: #475569; }

html:not(.dark) .login-error {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.25);
  color: #B91C1C;
}
html:not(.dark) .login-footer { color: #94A3B8; }

html:not(.dark) .info-badge {
  background: rgba(37,99,235,0.06);
  border-color: rgba(37,99,235,0.15);
  color: #64748B;
}

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

html { font-size: 16px; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }

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

a { cursor: pointer; text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ─── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ═══════════════════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-900);
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}
.shape-1 { width: 500px; height: 500px; background: #2563EB; top: -100px; right: -100px; animation: pulse-shape 8s ease-in-out infinite; }
.shape-2 { width: 400px; height: 400px; background: #7C3AED; bottom: -80px; left: -80px; animation: pulse-shape 10s ease-in-out infinite reverse; }
.shape-3 { width: 300px; height: 300px; background: #0EA5E9; top: 50%; left: 50%; transform: translate(-50%,-50%); animation: pulse-shape 6s ease-in-out infinite; }

@keyframes pulse-shape {
  0%, 100% { transform: scale(1) translate(0,0); }
  50% { transform: scale(1.1) translate(10px, -10px); }
}

.shape-3 { animation: pulse-shape3 6s ease-in-out infinite; }
@keyframes pulse-shape3 {
  0%, 100% { transform: translate(-50%,-50%) scale(1); }
  50% { transform: translate(-50%,-50%) scale(1.1); }
}

.login-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: 0 25px 50px rgba(0,0,0,.5);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}

.brand-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #2563EB, #7C3AED);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-icon .material-icons-round { color: white; font-size: 28px; }

.brand-text h1 { font-size: 22px; font-weight: 700; color: white; line-height: 1.2; }
.brand-text h1 span { color: #60A5FA; }
.brand-text p { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 2px; }

.login-form { display: flex; flex-direction: column; gap: 20px; }

.form-group label { display: block; font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.7); margin-bottom: 8px; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .input-icon {
  position: absolute;
  left: 14px;
  color: rgba(255,255,255,0.4);
  font-size: 20px;
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 48px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: white;
  font-size: 15px;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.input-wrapper input::placeholder { color: rgba(255,255,255,0.3); }
.input-wrapper input:focus { outline: none; border-color: #3B82F6; background: rgba(59,130,246,0.1); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

.toggle-password {
  position: absolute;
  right: 12px;
  color: rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.toggle-password:hover { color: rgba(255,255,255,0.8); }

.login-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #FCA5A5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-login {
  height: 50px;
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: white;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
  box-shadow: 0 4px 15px rgba(37,99,235,0.4);
  margin-top: 4px;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.5); }
.btn-login:active { transform: translateY(0); }
.btn-login.loading { opacity: 0.7; pointer-events: none; }

.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: rgba(255,255,255,0.3); }

.login-info {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.info-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}
.info-badge .material-icons-round { font-size: 14px; }

/* ═══════════════════════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100dvh;
  position: relative;
}

/* ─── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100dvh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-slow);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-icon .material-icons-round { color: white; font-size: 20px; }

.sidebar-app-name { display: block; font-size: 16px; font-weight: 700; color: white; line-height: 1.2; }
.sidebar-app-name b { color: #60A5FA; }
.sidebar-store { display: block; font-size: 11px; color: var(--sidebar-text); }

.sidebar-close { color: var(--sidebar-text); display: none; padding: 4px; border-radius: 6px; transition: all var(--transition); }
.sidebar-close:hover { color: white; background: var(--sidebar-hover); }

.sidebar-user {
  margin: 8px 12px 16px;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563EB, #7C3AED);
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--sidebar-text); text-transform: capitalize; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148,163,184,0.5);
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}
.nav-item .material-icons-round { font-size: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--primary); color: white !important; }
.nav-item.logout { color: #F87171; }
.nav-item.logout:hover { background: rgba(239,68,68,0.1); color: #EF4444; }

.nav-badge {
  margin-left: auto;
  background: var(--warning);
  color: var(--gray-900);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 299;
  backdrop-filter: blur(2px);
}

/* ─── SIDEBAR COLLAPSE BUTTON ───────────────────────────── */
.sidebar-collapse-btn {
  position: absolute;
  right: -14px;
  top: 68px;
  width: 28px;
  height: 28px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 301;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  color: var(--text-muted);
}
.sidebar-collapse-btn:hover { background: var(--primary); color: white; border-color: var(--primary); transform: scale(1.1); }
.sidebar-collapse-btn .material-icons-round { font-size: 16px; transition: transform var(--transition-slow); }

/* ─── COLLAPSED SIDEBAR STATE ───────────────────────────── */
/* Applied to .sidebar element, not to body */
.sidebar.collapsed {
  width: 68px;
}
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-item > span:last-child {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
}
.sidebar.collapsed .sidebar-logo { justify-content: center; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-bottom .nav-item { justify-content: center; padding: 10px 0; }
/* Tooltip on hover when collapsed */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--gray-900);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 400;
  box-shadow: var(--shadow-md);
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* Main wrapper adjusts when sidebar is collapsed.
   Class .sidebar-collapsed applied on #app by JS. */
#app.sidebar-collapsed .main-wrapper {
  margin-left: 68px;
}
#app.sidebar-collapsed .topbar {
  left: 68px;
}
#app.sidebar-collapsed .view-order-bar {
  left: 68px;
}
#app.sidebar-collapsed .sidebar-collapse-btn #collapse-icon {
  transform: rotate(180deg);
}

/* Transition for sidebar width change */
.sidebar { transition: width var(--transition-slow), transform var(--transition-slow); }

/* ─── THEME TOGGLE BUTTON ───────────────────────────────── */
.theme-toggle-btn { position: relative; }
.theme-toggle-btn .material-icons-round { transition: transform 0.4s ease, opacity 0.2s; }
html.dark .theme-toggle-btn .material-icons-round { transform: rotate(20deg); }

/* ─── MAIN WRAPPER ──────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-top: var(--topbar-height); /* space reserved for the fixed topbar */
  transition: margin-left var(--transition-slow);
}

/* ─── TOPBAR ────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: fixed;          /* fixed: stays at top regardless of parent overflow settings */
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  transition: left var(--transition-slow);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.menu-toggle { color: var(--gray-600); display: none; padding: 6px; border-radius: 8px; transition: all var(--transition); }
.menu-toggle:hover { background: var(--gray-100); }
.menu-toggle .material-icons-round { font-size: 22px; }

.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.topbar-btn:hover { background: var(--gray-100); color: var(--primary); }
.topbar-btn .material-icons-round { font-size: 22px; }

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── PAGE CONTENT ──────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
  overflow-x: hidden;
}

/* ─── BOTTOM NAV (Mobile) ───────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.bottom-nav { display: none; }

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition);
  cursor: pointer;
  padding: 8px 4px 4px;
  position: relative;
  flex: 1;
}
.bottom-nav-item .material-icons-round { font-size: 22px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.fab-item { color: var(--gray-400); }
.bottom-nav-item.fab-item span:not(.material-icons-round) { font-size: 10px; }

.fab-btn {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(37,99,235,0.4);
  margin-top: -20px;
}
.fab-btn .material-icons-round { color: white; font-size: 24px; }

/* ═══════════════════════════════════════════════════════════
   COMMON COMPONENTS
═══════════════════════════════════════════════════════════ */

/* ─── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }
.card-body-sm { padding: 16px; }

/* ─── STAT CARDS ────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon .material-icons-round { font-size: 24px; }

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: #F3F4FF; color: #7C3AED; }
.stat-icon.cyan { background: var(--info-light); color: var(--info); }

.stat-content { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.2; margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  font-family: var(--font);
}
.btn .material-icons-round { font-size: 18px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,0.4); transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; transform: translateY(-1px); }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* ─── FORM ELEMENTS ─────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-hint { font-size: 11px; color: var(--text-muted); }

.form-control {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.form-control::placeholder { color: var(--text-light); }
.form-control.error { border-color: var(--danger); }
textarea.form-control { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }

.input-group { position: relative; display: flex; }
.input-group .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 18px; pointer-events: none; }
.input-group .form-control { padding-left: 40px; }
.input-group .input-suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }

/* ─── BADGE / PILLS ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-pending { background: var(--warning-light); color: #B45309; }
.badge-approved { background: var(--success-light); color: #065F46; }
.badge-rejected { background: var(--danger-light); color: #991B1B; }
.badge-synced { background: var(--info-light); color: #0E7490; }
.badge-cancelled { background: var(--gray-100); color: var(--gray-500); }
.badge-scheduled { background: var(--primary-light); color: var(--primary-dark); }
.badge-in_progress { background: var(--warning-light); color: #92400E; }
.badge-completed { background: var(--success-light); color: #065F46; }

/* ─── TABLE ─────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ─── SEARCH BAR ────────────────────────────────────────── */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.search-bar .material-icons-round {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 20px;
  pointer-events: none;
}
.search-bar input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 48px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  transition: all var(--transition);
}
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.search-bar .clear-btn {
  position: absolute;
  right: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition);
}
.search-bar .clear-btn:hover { color: var(--danger); background: var(--danger-light); }

/* ─── LIST ITEMS ────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--gray-50); }
.list-item:active { background: var(--gray-100); }
.list-item .item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.list-item .item-icon .material-icons-round { font-size: 20px; }
.list-item .item-content { flex: 1; min-width: 0; overflow: hidden; }
.list-item .item-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .item-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .item-meta { font-size: 12px; color: var(--text-muted); }
.list-item .item-right { text-align: right; flex-shrink: 0; min-width: 90px; max-width: 130px; overflow: hidden; }

/* ─── EMPTY STATE ───────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .material-icons-round { font-size: 56px; color: var(--gray-300); margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ─── GRID ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ─── TOAST ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--gray-900);
  color: white;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  min-width: 280px;
  max-width: 360px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast .material-icons-round { font-size: 18px; flex-shrink: 0; }
.toast.success .material-icons-round { color: var(--success); }
.toast.error .material-icons-round { color: var(--danger); }
.toast.warning .material-icons-round { color: var(--warning); }
.toast.info .material-icons-round { color: #60A5FA; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(20px); } }
.toast.fade-out { animation: fadeOut 0.3s ease forwards; }

/* ─── LOADING ───────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-spinner { text-align: center; }
.spinner-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── MODAL ─────────────────────────────────────────────── */
.modal-container {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 600px) {
  .modal-container { align-items: center; padding: 20px; }
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
}
.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (min-width: 600px) {
  .modal-box { border-radius: var(--radius-lg); animation: scaleIn 0.25s ease; }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { color: var(--text-muted); padding: 4px; border-radius: 6px; display: flex; align-items: center; transition: all var(--transition); }
.modal-close:hover { background: var(--gray-100); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0; }

/* ─── DIVIDER ───────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; font-weight: 500; margin: 16px 0; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── ORDER RECEIPT CARD ────────────────────────────────── */
.receipt-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.receipt-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
}
.receipt-items { padding: 8px 0; }
.receipt-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.receipt-item:last-child { border-bottom: none; }
.receipt-item-info { flex: 1; }
.receipt-item-name { font-size: 13px; font-weight: 600; }
.receipt-item-detail { font-size: 12px; color: var(--text-muted); }
.receipt-item-price { text-align: right; font-size: 13px; font-weight: 700; white-space: nowrap; }
.receipt-total {
  padding: 16px 20px;
  border-top: 2px solid var(--border);
  background: var(--gray-50);
}
.receipt-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.receipt-row.total { font-size: 16px; font-weight: 800; color: var(--primary); margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }

/* ─── STOCK INDICATOR ───────────────────────────────────── */
.stock-indicator { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.stock-dot { width: 8px; height: 8px; border-radius: 50%; }
.stock-ok { color: var(--success); }
.stock-ok .stock-dot { background: var(--success); }
.stock-low { color: var(--warning); }
.stock-low .stock-dot { background: var(--warning); }
.stock-out { color: var(--danger); }
.stock-out .stock-dot { background: var(--danger); }

/* ─── ITEM CATALOG CARD ─────────────────────────────────── */
.item-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.type-product { background: #EFF6FF; color: #1D4ED8; }
.type-service { background: #F3F4FF; color: #6D28D9; }
.type-material { background: #FFFBEB; color: #92400E; }
.type-labour { background: #ECFDF5; color: #065F46; }

/* ─── FILTER TABS ───────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.filter-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ─── PROGRESS STEPS ────────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}
.step {
  display: flex;
  align-items: center;
  flex: 1;
}
.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  flex-shrink: 0;
  transition: all var(--transition);
}
.step.active .step-circle { border-color: var(--primary); background: var(--primary); color: white; }
.step.done .step-circle { border-color: var(--success); background: var(--success); color: white; }
.step-line { flex: 1; height: 2px; background: var(--border); transition: background var(--transition); }
.step.done + .step .step-line, .step.done .step-line { background: var(--success); }

/* ─── ACTION SHEET ──────────────────────────────────────── */
.action-sheet {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition);
}
.action-sheet-item:hover { background: var(--gray-50); }
.action-sheet-item .item-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.action-sheet-item .item-icon .material-icons-round { font-size: 22px; }
.action-sheet-item .item-title { font-size: 15px; font-weight: 600; }
.action-sheet-item .item-sub { font-size: 12px; color: var(--text-muted); }

/* ─── PRINT STYLES ──────────────────────────────────────── */
.print-only { display: none; }

/* ─── PAGINATION — dots + swipe hint ───────────────────── */
.page-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--gray-200);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.page-dot.active {
  background: var(--primary);
  color: #fff;
  width: 32px;
  height: 32px;
  font-size: 12px;
}
.page-dot:hover:not(.active) { background: var(--gray-300); }

.page-ellipsis {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 2px;
}

.swipe-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-light);
  padding-top: 4px;
}
.swipe-hint .material-icons-round { font-size: 14px; }

/* ═══════════════════════════════════════════════════════════
   PWA / FULL-SCREEN — Smartphone & Tablet
═══════════════════════════════════════════════════════════ */

/* Safe area insets — handles notch, punch-hole, home indicator
   on all modern smartphones (iPhone 14/15 Pro Max, Samsung S24, etc.) */
html, body { height: 100%; height: 100dvh; }

/* Use equal top/bottom padding (the larger of both insets) so that
   flex centering stays symmetric even when safe-area-inset-top ≠ bottom */
.login-screen {
  --_safe-v: max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px));
  padding-top:    max(16px, var(--_safe-v));
  padding-bottom: max(16px, var(--_safe-v));
  padding-left:   max(16px, env(safe-area-inset-left, 0px));
  padding-right:  max(16px, env(safe-area-inset-right, 0px));
}

.topbar {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--topbar-height) + env(safe-area-inset-top));
}
.main-wrapper {
  padding-top: calc(var(--topbar-height) + env(safe-area-inset-top));
}

.sidebar {
  padding-top:    env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav {
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
}

/* When running as installed PWA (standalone / fullscreen mode) */
@media (display-mode: standalone), (display-mode: fullscreen) {
  /* Status bar space on iOS/Android */
  .topbar {
    padding-top: max(env(safe-area-inset-top, 0px), 12px);
    height: calc(var(--topbar-height) + max(env(safe-area-inset-top, 0px), 12px));
  }
  .main-wrapper {
    padding-top: calc(var(--topbar-height) + max(env(safe-area-inset-top, 0px), 12px));
  }
  .view-order-bar {
    top: calc(var(--topbar-height) + max(env(safe-area-inset-top, 0px), 12px));
  }
  .sidebar {
    padding-top: max(env(safe-area-inset-top, 0px), 12px);
  }
  /* login screen: keep equal vertical padding for correct centering */
  .login-screen {
    --_safe-v: max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px), 12px);
    padding-top:    var(--_safe-v);
    padding-bottom: var(--_safe-v);
  }
  /* Hide browser-chrome-equivalent hints since we're already full-screen */
  .login-info { display: none; }
}

/* ─── TABLET LANDSCAPE (768px – 1024px, e.g. iPad, Tab S) ── */
@media (min-width: 768px) and (max-width: 1024px) {
  :root { --sidebar-width: 220px; }

  .page-content { padding: 20px; }

  /* Better grid for tablet */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }

  /* Order builder: side-by-side on tablet */
  .order-builder {
    grid-template-columns: 1fr 320px;
  }
  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* ─── LARGE TABLET / IPAD PRO (1024px+) ────────────────── */
@media (min-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ─── TALL SMARTPHONE LANDSCAPE (6.67" in landscape) ───── */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --topbar-height: 48px; --bottom-nav-height: 52px; }

  .login-card { padding: 24px 28px; }
  .login-brand { margin-bottom: 20px; }
  .login-form { gap: 14px; }
  .login-container { flex-direction: row; align-items: flex-start; gap: 20px; max-width: 700px; }
  .login-card { flex: 1; }
  .login-info { flex-direction: column; justify-content: center; align-self: center; }

  .page-content { padding: 12px 16px; }
  .greeting-banner { padding: 16px 20px; }
  .greeting-banner h3 { font-size: 17px; }
}

@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  .print-receipt {
    font-family: 'Courier New', monospace;
    max-width: 80mm;
    margin: 0 auto;
    font-size: 12px;
  }
  .print-receipt h1 { font-size: 16px; text-align: center; }
  .print-receipt hr { border: none; border-top: 1px dashed #000; margin: 8px 0; }
  .print-receipt .line { display: flex; justify-content: space-between; margin: 3px 0; }
  .print-receipt .total-line { font-weight: bold; font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Sidebar becomes a narrower overlay on mobile portrait */
  .sidebar,
  .sidebar.collapsed {
    transform: translateX(-100%);
    border-right: none;
    box-shadow: var(--shadow-lg);
    /* Narrower than desktop: 72% of viewport width, capped at 240px */
    width: min(240px, 72vw) !important;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.active { display: block; }
  /* Hide desktop collapse button on mobile */
  .sidebar-collapse-btn { display: none; }

  /* Reset collapsed-sidebar text hiding so nav labels are always visible */
  .sidebar.collapsed .sidebar-logo-text,
  .sidebar.collapsed .user-info,
  .sidebar.collapsed .nav-section-label,
  .sidebar.collapsed .nav-badge,
  .sidebar.collapsed .nav-item > span:last-child {
    opacity: 1;
    width: auto;
    overflow: visible;
    pointer-events: auto;
  }
  .sidebar.collapsed .sidebar-logo { justify-content: flex-start; }
  .sidebar.collapsed .sidebar-user { justify-content: flex-start; padding: 12px; }
  .sidebar.collapsed .nav-item,
  .sidebar.collapsed .sidebar-bottom .nav-item { justify-content: flex-start; padding: 10px 16px; }
  /* Hide collapsed tooltips on mobile */
  .sidebar.collapsed .nav-item::after { display: none; }

  /* Main takes full width — override sidebar-collapsed margin regardless of JS state */
  .main-wrapper,
  #app.sidebar-collapsed .main-wrapper { margin-left: 0; padding-bottom: var(--bottom-nav-height); }

  /* Fixed topbar/view-order-bar: start at left edge on mobile (no sidebar) */
  .topbar,
  #app.sidebar-collapsed .topbar { left: 0; }
  .view-order-bar,
  #app.sidebar-collapsed .view-order-bar { left: 0; }

  /* Show mobile nav */
  .bottom-nav { display: flex; }

  /* Hide desktop topbar items on mobile */
  .menu-toggle { display: flex; }

  .page-content { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  #toast-container { left: 16px; right: 16px; top: auto; bottom: calc(var(--bottom-nav-height) + 16px); }
  .toast { min-width: auto; max-width: none; }
}

@media (max-width: 480px) {
  .modal-box { border-radius: 20px 20px 0 0; max-height: 95dvh; }
  .stat-value { font-size: 20px; }
}

/* ─── PAGE-SPECIFIC: DASHBOARD ──────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 800; color: var(--text); }
.page-header p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.greeting-banner {
  background: linear-gradient(135deg, #1E3A5F 0%, #2563EB 50%, #7C3AED 100%);
  border-radius: var(--radius);
  padding: 24px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.greeting-banner::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}
.greeting-banner::before {
  content: '';
  position: absolute;
  right: 40px;
  bottom: -40px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}
.greeting-banner h3 { font-size: 20px; font-weight: 700; position: relative; z-index: 1; }
.greeting-banner p { font-size: 13px; opacity: 0.8; margin-top: 4px; position: relative; z-index: 1; }
.greeting-banner .banner-actions { display: flex; gap: 10px; margin-top: 20px; position: relative; z-index: 1; flex-wrap: wrap; }
.banner-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.banner-btn-primary { background: white; color: var(--primary); }
.banner-btn-primary:hover { background: rgba(255,255,255,0.9); }
.banner-btn-ghost { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3); }
.banner-btn-ghost:hover { background: rgba(255,255,255,0.25); }

/* ─── PAGE-SPECIFIC: SEARCH ─────────────────────────────── */
.search-results-meta { font-size: 12px; color: var(--text-muted); padding: 8px 16px; background: var(--gray-50); border-bottom: 1px solid var(--border); }

.transaction-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.transaction-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--primary); }
.transaction-card-header { padding: 14px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.transaction-card-body { padding: 0 16px 14px; border-top: 1px solid var(--border); }
.tx-number { font-size: 15px; font-weight: 700; color: var(--text); }
.tx-customer { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ─── PAGE-SPECIFIC: CHANGE ORDER ───────────────────────── */

/* ── Tab switcher: always visible on mobile (mobile-first) ── */
.order-builder-tabs {
  display: flex; /* hidden on wide screens via min-width query */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.ob-tab {
  flex: 1;
  padding: 9px 12px;
  border-radius: calc(var(--radius) - 4px);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
  text-align: center;
  cursor: pointer;
  position: relative;
}
.ob-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.ob-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--warning);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 5px;
  vertical-align: middle;
}
.ob-tab.active .ob-tab-badge { background: rgba(255,255,255,.3); }

/* Layout: mobile-first — single panel, tabs shown */
.order-builder {
  display: block;
  width: 100%;
  overflow-x: hidden;
}
.ob-panel {
  display: none;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
.ob-panel.active { display: block; }

/* Catalog grid: single column on mobile (mobile-first) */
.catalog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
  width: 100%;
  box-sizing: border-box;
}

/* Wide screens ≥ 769px: two panels side by side, tabs hidden */
@media (min-width: 769px) {
  .order-builder-tabs { display: none; }
  .order-builder {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: flex-start;
  }
  .ob-panel, .ob-panel.active { display: block; }
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}

/* Tablet / medium — narrower second column */
@media (min-width: 769px) and (max-width: 1024px) {
  .order-builder { grid-template-columns: 1fr 280px; gap: 12px; }
}

/* ─── VIEW ORDER BAR — fixed, sits right below the fixed topbar ────────── */
.view-order-bar {
  position: fixed;
  top: var(--topbar-height);
  left: var(--sidebar-width);
  right: 0;
  z-index: 190;
  background: var(--primary);
  border-bottom: 2px solid var(--primary-dark);
  box-shadow: 0 3px 10px rgba(37,99,235,.35);
  transition: left var(--transition-slow);
}
/* Placeholder div that takes up the same space in the flow when bar is visible */
.view-order-placeholder {
  height: 46px;
  flex-shrink: 0;
}
.view-order-bar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  background: none;
  cursor: pointer;
  text-align: left;
}
.view-order-bar-btn .material-icons-round { font-size: 20px; }

/* Embedded FAB inside page-content — now superseded by the sticky bar above */
.ob-view-order-fab { display: none !important; }

.catalog-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.catalog-item:hover { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); transform: translateY(-1px); }
.catalog-item.in-cart { border-color: var(--success); background: var(--success-light); }
.catalog-item-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.catalog-item-code { font-size: 10px; color: var(--text-muted); font-family: monospace; }
.catalog-item-price { font-size: 13px; font-weight: 700; color: var(--primary); }
.catalog-item-footer { display: flex; align-items: center; justify-content: space-between; }

/* Mobile 1-column: horizontal row layout */
@media (max-width: 768px), (max-width: 900px) and (orientation: portrait) {
  .catalog-item {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
  }
  .catalog-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }
  .catalog-item-footer {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
  }
}

.order-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: calc(var(--topbar-height) + 16px);
  box-shadow: var(--shadow-sm);
}
.order-summary-header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.order-summary-items { padding: 8px 0; max-height: 300px; overflow-y: auto; }
.order-line-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.order-line-item:last-child { border-bottom: none; }
.order-line-remove { color: var(--danger); opacity: 0.6; transition: opacity var(--transition); }
.order-line-remove:hover { opacity: 1; }
.qty-control { display: flex; align-items: center; gap: 4px; }
.qty-btn { width: 26px; height: 26px; border-radius: 6px; background: var(--gray-100); color: var(--text); font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.qty-btn:hover { background: var(--primary); color: white; }
.qty-display { min-width: 30px; text-align: center; font-size: 14px; font-weight: 700; }

/* ─── MISC ──────────────────────────────────────────────── */
.text-money { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-warning { color: var(--warning); }
