/* ============================================================
   Fit Manage — Complete Application Stylesheet
   Compatible with tokens.css design tokens
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 88%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

[dir="rtl"] { font-family: var(--font-arabic); }

/* ============================================================
   APP SHELL — Sidebar + Main layout
   ============================================================ */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease;
  flex-shrink: 0;
  z-index: 200;
}

.app-sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .nav-item span,
.app-sidebar.collapsed .nav-group-title,
.app-sidebar.collapsed .sidebar-footer .brand-text {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  gap: 0.5rem;
  flex-shrink: 0;
}

.brand-text { white-space: nowrap; overflow: hidden; }

.sidebar-collapse-btn {
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 4px; }

.nav-group { margin-bottom: 0.25rem; }

.nav-group-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text);
  padding: 0.6rem 1rem 0.3rem;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  cursor: pointer;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.nav-item.active {
  background: var(--primary);
  color: #fff;
}
.nav-item.active svg { stroke: #fff; }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* ---------- Main Workspace ---------- */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}

/* ---------- Topbar ---------- */
.app-topbar {
  height: 56px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 100;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.crumb-current { color: var(--text); font-weight: 600; }

.branch-select {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  width: auto;
  margin: 0;
}

/* ---------- Content Area ---------- */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.app-content::-webkit-scrollbar { width: 6px; }
.app-content::-webkit-scrollbar-track { background: transparent; }
.app-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---------- View Sections ---------- */
.view-section { display: none; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#loginScreen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0b0f19 0%, #1a1f35 50%, #0b0f19 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(24px);
  box-shadow: 0 25px 50px rgba(0,0,0,0.6);
}

.login-brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  color: #fff;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
}

.login-input-wrap {
  position: relative;
}

.login-pw-toggle {
  position: absolute;
  inset-inline-end: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}
.login-pw-toggle:hover { color: #94a3b8; }

.login-btn-submit {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--primary), #7c75ff);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: opacity 0.2s, transform 0.1s;
}
.login-btn-submit:hover { opacity: 0.92; }
.login-btn-submit:active { transform: scale(0.98); }

.login-demo-box {
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  color: #94a3b8;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stat-card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.stat-card-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-card-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

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

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.85; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { opacity: 0.85; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.75rem; }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 0.95rem; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin: 0;
}
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.15);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.table th {
  background: var(--bg);
  padding: 0.7rem 1rem;
  text-align: start;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(99, 91, 255, 0.04); }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-danger  { background: var(--danger-subtle);  color: var(--danger); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-info    { background: var(--info-subtle);    color: var(--info); }
.badge-primary { background: var(--primary-subtle); color: var(--primary); }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* --- User Dropdown --- */
.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.topbar-user-btn:hover { background: var(--bg); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { text-align: start; }
.user-name { font-size: 0.82rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

.user-dropdown-wrapper { position: relative; }

.user-dropdown-menu {
  display: none;
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 220px;
  z-index: 500;
  overflow: hidden;
}
.user-dropdown-menu.show { display: block; }

.dropdown-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.dropdown-user-name  { font-weight: 700; font-size: 0.85rem; color: var(--text); }
.dropdown-user-email { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }
.dropdown-user-branch{ font-size: 0.68rem; color: var(--primary); margin-top: 0.15rem; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: start;
  transition: background 0.12s;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--danger); }

/* --- Modal --- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-backdrop.show { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* --- Notification Toast --- */
#notificationArea {
  position: fixed;
  top: 1rem;
  inset-inline-end: 1rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.notification {
  pointer-events: all;
  min-width: 260px;
  max-width: 380px;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border-inline-start: 4px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  animation: notif-in 0.25s ease;
  box-shadow: var(--shadow-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}
@keyframes notif-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.notification.success { border-inline-start-color: var(--success); }
.notification.danger  { border-inline-start-color: var(--danger); }
.notification.warning { border-inline-start-color: var(--warning); }
.notification.info    { border-inline-start-color: var(--info); }

/* --- Toolbar (section header row) --- */
.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-wrap svg {
  position: absolute;
  inset-inline-start: 0.65rem;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  padding-inline-start: 2.2rem;
  min-width: 220px;
}

/* --- POS Specific --- */
.pos-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; height: calc(100vh - 120px); }
.pos-catalog { overflow-y: auto; padding-right: 0.25rem; }

.pos-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pos-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
}

.pos-search-icon {
  position: absolute;
  right: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

[dir="ltr"] .pos-search-icon {
  right: auto;
  left: 0.75rem;
}

.pos-search-input {
  padding-right: 2.2rem;
  padding-left: 1.8rem;
  font-size: 0.84rem;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

[dir="ltr"] .pos-search-input {
  padding-right: 1.8rem;
  padding-left: 2.2rem;
}

.pos-search-clear {
  position: absolute;
  left: 0.6rem;
  background: transparent;
  border: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
}

[dir="ltr"] .pos-search-clear {
  left: auto;
  right: 0.6rem;
}

/* Category Filter Pills */
.pos-categories-container {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.2rem 0.1rem 0.65rem;
  margin-bottom: 0.75rem;
  scrollbar-width: thin;
}

.pos-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.pos-cat-pill:hover {
  border-color: var(--primary);
  color: var(--text);
  background: rgba(99, 91, 255, 0.05);
}

.pos-cat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 91, 255, 0.3);
}

.pos-cat-pill .cat-count {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.pos-cat-pill.active .cat-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Compact Product Cards Grid */
.pos-catalog-grid, .pos-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.pos-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.pos-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(99, 91, 255, 0.16);
  transform: translateY(-2px);
}

.pos-card:active {
  transform: scale(0.97);
}

.pos-card.out-of-stock {
  opacity: 0.55;
  filter: grayscale(0.5);
  cursor: not-allowed !important;
}

.pos-card-bounce {
  animation: posBounceAnim 0.25s ease;
}

@keyframes posBounceAnim {
  0% { transform: scale(1); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.pos-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.pos-card-cat-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(99, 91, 255, 0.1);
  color: var(--primary);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pos-card-stock-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  white-space: nowrap;
}

.pos-card-title {
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.25rem;
}

.pos-card-sku {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-bottom: 0.45rem;
}

.pos-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border);
  margin-top: auto;
}

.pos-card-price {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.pos-card-add-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.pos-card:hover .pos-card-add-btn {
  transform: scale(1.15);
  background: var(--primary-hover, #4f46e5);
}

.pos-card-add-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none !important;
}

.pos-sidebar { display: flex; flex-direction: column; gap: 0.75rem; overflow: hidden; }
.pos-cart-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.pos-cart-items { flex: 1; overflow-y: auto; max-height: calc(100vh - 430px); min-height: 140px; margin-bottom: 0.5rem; }
.pos-cart-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

/* --- Plans Grid --- */
#plansGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

/* --- Permissions Matrix --- */
.perm-matrix { font-size: 0.8rem; }
.perm-matrix th, .perm-matrix td { text-align: center; padding: 0.5rem; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: start; padding-inline-start: 1rem; }
.perm-toggle {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* --- Status Indicator --- */
.status-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.35rem 1.25rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* --- Tabs --- */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-btn {
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab-btn.active { border-bottom-color: var(--primary); color: var(--primary); }
.tab-btn:hover { color: var(--text); }

/* --- Kanban --- */
.kanban-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kanban-col { background: var(--bg); border-radius: var(--radius-sm); padding: 1rem; border: 1px solid var(--border); }
.kanban-col-header { font-weight: 700; margin-bottom: 0.75rem; display: flex; justify-content: space-between; font-size: 0.82rem; }
.kanban-card { background: var(--surface); padding: 0.75rem; border-radius: var(--radius-sm); margin-bottom: 0.5rem; border: 1px solid var(--border); box-shadow: var(--shadow-sm); font-size: 0.82rem; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .app-sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 300; transform: translateX(-100%); }
  [dir="rtl"] .app-sidebar { transform: translateX(100%); }
  .app-sidebar.mobile-open { transform: translateX(0); }
  .pos-layout { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .app-content { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
}

/* ============================================================
   CONTENT CONTAINER (alias for app-content inside app-main)
   ============================================================ */
.content-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.content-container::-webkit-scrollbar { width: 6px; }
.content-container::-webkit-scrollbar-track { background: transparent; }
.content-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============================================================
   USER PROFILE MENU (topbar dropdown)
   ============================================================ */
.user-profile-menu { position: relative; }

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.user-profile-badge:hover { background: var(--bg); }

.user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.user-profile-info {
  display: flex;
  flex-direction: column;
  text-align: start;
}

.user-profile-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}

.user-profile-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* User dropdown items */
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: start;
  transition: background 0.12s;
  font-family: inherit;
}
.user-dropdown-item:hover { background: var(--bg); }
.user-dropdown-item.text-danger,
.text-danger { color: var(--danger) !important; }

/* ============================================================
   STATUS BAR (bottom of page)
   ============================================================ */
.app-status-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.3rem 1.25rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ============================================================
   MOBILE NAVIGATION & PWA STYLES
   ============================================================ */

/* 1. Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
  display: none !important;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: rgba(11, 15, 25, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding: 0.4rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

@media (max-width: 860px) {
  html.is-authenticated .mobile-bottom-nav,
  body.is-authenticated .mobile-bottom-nav {
    display: flex !important;
  }
}

[data-theme="light"] .mobile-bottom-nav {
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item:active {
  transform: scale(0.92);
}

.mobile-nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.mobile-nav-item.active svg {
  stroke: var(--primary);
  filter: drop-shadow(0 2px 6px rgba(99, 91, 255, 0.45));
}

.mobile-nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  width: 16px;
  height: 3px;
  background: var(--primary);
  border-radius: 4px;
}

/* 2. Mobile Drawer Backdrop */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* 3. PWA Install Elements */
.pwa-install-btn {
  background: linear-gradient(135deg, #635bff, #8b5cf6) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 0.35rem 0.85rem !important;
  border-radius: 20px !important;
  font-weight: 700 !important;
  font-size: 0.76rem !important;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 2px 10px rgba(99, 91, 255, 0.35);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  animation: pwaPulse 2.5s infinite;
}

@keyframes pwaPulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 91, 255, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(99, 91, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 91, 255, 0); }
}

.pwa-install-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 91, 255, 0.45);
}

.pwa-mobile-banner {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

/* PWA Banners */
.pwa-login-banner {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(99, 91, 255, 0.15);
  border: 1px solid rgba(99, 91, 255, 0.35);
  margin-bottom: 1.25rem;
  transition: transform 0.15s, background 0.15s;
}
.pwa-login-banner:hover {
  background: rgba(99, 91, 255, 0.22);
  transform: translateY(-1px);
}
.btn-pwa-badge {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-global-banner {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* 4. Responsive Breakpoints for Mobile View */
@media (max-width: 860px) {
  body {
    overflow-y: auto !important;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 285px;
    max-width: 85vw;
    z-index: 1000 !important;
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  [dir="rtl"] .app-sidebar {
    right: 0;
    left: auto;
    transform: translateX(100%) !important;
  }

  [dir="ltr"] .app-sidebar {
    left: 0;
    right: auto;
    transform: translateX(-100%) !important;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
  }

  .content-container {
    padding: 0.85rem 0.85rem calc(80px + env(safe-area-inset-bottom, 0px)) 0.85rem !important;
  }

  .app-topbar {
    padding: 0.4rem 0.75rem !important;
    min-height: 52px;
  }

  .topbar-left .breadcrumbs {
    display: none !important;
  }

  .user-profile-info {
    display: none !important;
  }

  .branch-select {
    max-width: 135px;
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }

  .pos-layout {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .metrics-grid,
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .metric-card {
    padding: 0.85rem 1rem !important;
  }

  .metric-value {
    font-size: 1.45rem !important;
  }

  .pos-categories-nav {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap !important;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .pos-cat-pill {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Modals on mobile: Bottom sheet style */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-box,
  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    animation: slideUpModal 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

@media (max-width: 480px) {
  .pos-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
  }

  .pos-card-compact {
    padding: 0.6rem !important;
  }

  .pos-card-compact .product-name {
    font-size: 0.78rem !important;
  }

  .pos-card-compact .price-tag {
    font-size: 0.85rem !important;
  }

  .metric-card {
    padding: 0.75rem !important;
  }

  .metric-value {
    font-size: 1.25rem !important;
  }
}



