/* ============================================================
   SimplePOS — Modern Dark Theme
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-base: #0f1117;
  --bg-surface: #1a1d27;
  --bg-elevated: #22263a;
  --bg-hover: #2a2f47;
  --border: #2e3352;
  --border-light: #3a4060;

  --text-primary: #e8eaf6;
  --text-secondary: #8892b0;
  --text-muted: #4a5568;

  --accent: #6c63ff;
  --accent-hover: #7c74ff;
  --accent-glow: rgba(108, 99, 255, 0.25);

  --success: #10d59b;
  --warning: #f5a623;
  --danger: #e74c3c;
  --info: #3498db;

  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

/* ── Auth / Login ──────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 30%, rgba(108, 99, 255, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(16, 213, 155, 0.08) 0%, transparent 60%),
    var(--bg-base);
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo .logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 2.2rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  transition: transform 0.3s ease;
}

.auth-card:hover .logo-icon {
  transform: translateY(-5px);
}

.auth-card {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(26, 29, 39, 0.85);
}

.auth-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.5px;
}


/* ── Layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.open {
  transform: translateX(0) !important;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
}

.sidebar-brand span {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.sidebar-brand small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.75rem 1.25rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 7px;
  margin: 1px 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  margin-left: 0.3rem;
}

.nav-item .nav-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-info .uname {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .urole {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.logout-btn {
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  font-size: 1rem;
  transition: color var(--transition);
}

.logout-btn:hover {
  color: var(--danger);
}

/* Main content area */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  line-height: 1;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.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-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.card-body {
  /* inner */
}

/* 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(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color var(--transition), transform var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: rgba(52, 152, 219, .18);
}

.stat-icon.green {
  background: rgba(16, 213, 155, .18);
}

.stat-icon.orange {
  background: rgba(245, 166, 35, .18);
}

.stat-icon.red {
  background: rgba(231, 76, 60, .18);
}

.stat-icon.purple {
  background: rgba(108, 99, 255, .18);
}

.stat-info .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-info .stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.hide-mobile {
  display: table-cell;
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

thead th {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--bg-hover);
}

td {
  padding: 0.72rem 1rem;
  vertical-align: middle;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 14px var(--accent-glow);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  opacity: 0.88;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.88;
}

.btn-warning {
  background: var(--warning);
  color: #111;
}

.btn-warning:hover {
  opacity: 0.88;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 7px;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.55rem 0.85rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Filter Forms */
.filter-form {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-form .form-group {
  margin: 0;
}

.filter-form .flex-1 {
  flex: 1;
  min-width: 200px;
}

.filter-form .form-actions {
  display: flex;
  gap: 0.5rem;
}

/* Tabs scroll utility */
.tabs-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 5px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.tabs-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}
.tabs-scroll .tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
}

.form-check input[type=checkbox] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ── Badge / Pill ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(16, 213, 155, .18);
  color: var(--success);
}

.badge-danger {
  background: rgba(231, 76, 60, .18);
  color: var(--danger);
}

.badge-warning {
  background: rgba(245, 166, 35, .18);
  color: var(--warning);
}

.badge-info {
  background: rgba(52, 152, 219, .18);
  color: var(--info);
}

.badge-purple {
  background: rgba(108, 99, 255, .18);
  color: var(--accent);
}

.badge-muted {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

/* ── Modal ──────────────────────────────────────────────── */
/* ── Sticky Utilities ────────────────────────────────────── */
.sticky-wrapper {
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
  background: var(--bg-base);
  margin: calc(-1 * var(--radius)) -1.5rem 1.5rem -1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.sticky-wrapper .page-header {
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .sticky-wrapper {
    margin: -1rem -1rem 1rem -1rem;
    padding: 0.75rem 1rem;
    top: calc(var(--topbar-h) - 1px);
    border-radius: 0;
  }
}
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}

.modal-lg {
  max-width: 780px;
}

.modal-xl {
  max-width: 1000px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h4 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  border-radius: 5px;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Toast Notifications ────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  min-width: 260px;
  max-width: 340px;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  font-size: 0.87rem;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px)
  }
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.toast-msg {
  flex: 1;
  color: var(--text-primary);
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.info {
  border-left: 3px solid var(--info);
}

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  padding-bottom: 1px;
}
.tabs::-webkit-scrollbar {
  height: 4px;
}

.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.6rem 1rem;
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ── Search Bar ─────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 0.75rem;
  max-width: 320px;
  flex: 1;
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0;
  width: 100%;
}

.search-bar span {
  color: var(--text-muted);
}

/* ── POS / Cart ─────────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  min-height: calc(100vh - 120px);
}

.pos-products {
  overflow-y: auto;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.product-card .p-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
}

.product-card .p-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

.product-card .p-stock {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.product-card .p-icon {
  font-size: 2rem;
}

.cart-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
  position: sticky;
  top: 70px;
}

.cart-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 7px;
  margin-bottom: 0.4rem;
  background: var(--bg-elevated);
}

.cart-item-name {
  flex: 1;
  font-size: 0.83rem;
  font-weight: 500;
}

.cart-item-price {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.qty-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-primary);
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:hover {
  background: var(--accent);
}

.cart-qty {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}

.remove-item-btn {
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

.cart-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  font-size: 0.87rem;
}

.cart-total-row.grand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.5rem;
}

/* ── Misc ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-muted {
  color: var(--text-secondary);
}

.text-accent {
  color: var(--accent);
}

.f-right {
  float: right;
}

.flex {
  display: flex;
  align-items: center;
}

.flex-gap {
  gap: 0.5rem;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.w-full {
  width: 100%;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

.modal-roles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

/* M-Pesa status */
.mpesa-waiting {
  text-align: center;
  padding: 1.5rem;
}

.mpesa-waiting .mpesa-phone {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--success);
  margin: 1rem 0 0.5rem;
}

.mpesa-status-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 1rem 0;
  overflow: hidden;
}

.mpesa-status-bar-inner {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  animation: pulse-bar 1.5s ease-in-out infinite;
}

@keyframes pulse-bar {

  0%,
  100% {
    width: 0%
  }

  50% {
    width: 100%
  }
}

/* Low stock row */
tr.low-stock td {
  background: rgba(231, 76, 60, 0.06);
}

/* Log table */
.log-action {
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

/* Product card adding animation */
.product-card.adding {
  animation: cardAdded 0.3s ease;
}

@keyframes cardAdded {
  0% {
    transform: scale(1)
  }

  50% {
    transform: scale(0.92);
    border-color: var(--success);
    box-shadow: 0 0 14px rgba(16, 213, 155, .3)
  }

  100% {
    transform: scale(1)
  }
}

/* Mobile menu toggle */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.4rem;
  padding: 4px;
}

.mobile-only {
  display: none;
}

/* Mobile cart FAB (floating action button) */
.cart-fab {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--accent-glow);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.cart-fab .cart-fab-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Receipt print styles */
.receipt-line-items {
  text-align: left;
  width: 100%;
  margin: 1rem 0;
}

.receipt-line-items th {
  font-size: .75rem;
  color: var(--text-secondary);
  border-bottom: 1px dashed var(--border);
  padding: .4rem .6rem;
}

.receipt-line-items td {
  font-size: .82rem;
  padding: .35rem .6rem;
  border-bottom: 1px dashed var(--border);
}

/* ── Responsive ────────────────────────────────────────── */
@media(max-width:768px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: none;
    box-shadow: 6px 0 30px rgba(0, 0, 0, .6);
  }

  .main-content {
    margin-left: 0;
  }

  .page-content {
    padding: 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header h2 {
    font-size: 1.1rem;
  }

  .dashboard-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  /* POS Layout — stacked */
  .pos-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    min-height: auto;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .search-bar {
    max-width: none !important;
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .mobile-only {
    display: inline-flex !important;
  }

  .pos-category-filters {
    display: none;
    width: 100%;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: var(--bg-surface);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
  }

  .pos-category-filters.mobile-show {
    display: flex;
  }

  .filter-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .filter-form .form-group {
    width: 100%;
  }

  .filter-form .flex-1 {
    min-width: 100%;
  }

  .filter-form input,
  .filter-form select {
    font-size: 0.95rem;
    padding: 0.65rem;
  }

  .filter-form .form-actions {
    margin-top: 0.5rem;
  }

  .filter-form .form-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .settings-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }

  .rpt-grid-4, .rpt-grid-2 {
    grid-template-columns: 1fr !important;
  }
  .pos-products div[style*="display:flex"] {
    flex-direction: column;
    align-items: stretch !important;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
  }

  .product-card {
    padding: 0.65rem;
  }

  .product-card .p-icon {
    font-size: 1.4rem;
  }

  .product-card .p-name {
    font-size: 0.78rem;
    margin: 0.3rem 0 0.15rem;
  }

  .product-card .p-price {
    font-size: 0.88rem;
  }

  /* Cart: hide by default, show as modal-like panel */
  .cart-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 80vh;
    z-index: 180;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
  }

  .cart-panel.mobile-open {
    transform: translateY(0);
  }

  .cart-fab {
    display: flex;
  }

  /* Grids */
  .form-row {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Tables — allow horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 500px;
  }

  /* Modals — full width on mobile */
  .modal {
    max-width: 95vw !important;
    margin: 0.5rem;
  }

  .modal-xl {
    max-width: 95vw !important;
  }

  /* Stat cards */
  .stat-card {
    padding: 0.85rem;
  }

  .stat-info .stat-value {
    font-size: 1.2rem;
  }

  /* Tabs — scrollable */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Search bar full width */
  .search-bar {
    max-width: 100%;
  }

  /* Toast — bottom center */
  #toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 5rem;
  }

  .toast {
    max-width: 100%;
    min-width: auto;
  }
}

@media(max-width:480px) {
  html {
    font-size: 13px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.4rem;
  }

  .product-card .p-icon {
    font-size: 1.2rem;
  }

  .product-card .p-name {
    font-size: 0.72rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Tooltip / Info Tip ───────────────────────────────── */
.info-tip {
  position: relative;
  cursor: help;
  font-size: .8rem;
  opacity: .7;
  transition: opacity var(--transition);
}

.info-tip:hover {
  opacity: 1;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: .6rem .85rem;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s, visibility .15s;
  z-index: 500;
}

.info-tip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ── Performance Scorecard ────────────────────────────── */
.scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .85rem;
}

.scorecard-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
  transition: border-color var(--transition), transform var(--transition);
}

.scorecard-item:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.scorecard-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: .6rem;
}

.scorecard-icon.blue {
  background: rgba(52, 152, 219, .18);
}

.scorecard-icon.green {
  background: rgba(16, 213, 155, .18);
}

.scorecard-icon.purple {
  background: rgba(108, 99, 255, .18);
}

.scorecard-icon.orange {
  background: rgba(245, 166, 35, .18);
}

.scorecard-icon.red {
  background: rgba(231, 76, 60, .18);
}

.scorecard-value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: .2rem;
}

.scorecard-label {
  font-size: .78rem;
  color: var(--text-secondary);
}

/* ── Trend Badges ─────────────────────────────────────── */
.trend-badge {
  display: inline-flex;
  align-items: center;
  font-size: .7rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: .35rem;
}

.trend-up {
  color: var(--success);
  background: rgba(16, 213, 155, .12);
}

.trend-down {
  color: var(--danger);
  background: rgba(231, 76, 60, .12);
}

/* ── Report Assist Banner ─────────────────────────────── */
.report-assist {
  background: rgba(108, 99, 255, .06);
  border: 1px solid rgba(108, 99, 255, .2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.report-assist strong {
  color: var(--text-primary);
}

/* ── Security Dashboard ───────────────────────────────── */
.alert-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: border-color var(--transition);
}

.alert-card:hover {
  border-color: var(--border-light);
}

.alert-card.alert-critical {
  border-left: 3px solid var(--danger);
}

.alert-card.alert-warning {
  border-left: 3px solid var(--warning);
}

.alert-card.alert-info {
  border-left: 3px solid var(--info);
}

.alert-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-content {
  flex: 1;
}

.alert-content strong {
  display: block;
  margin-bottom: .25rem;
}

.alert-content p {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.alert-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .4rem;
}

.profile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color var(--transition);
}

.profile-card:hover {
  border-color: var(--border-light);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}

.profile-avatar {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}

.profile-meta {
  flex: 1;
}

.profile-meta strong {
  display: block;
  font-size: .95rem;
}

.profile-meta span {
  font-size: .78rem;
  color: var(--text-secondary);
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.profile-stat {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: .6rem .75rem;
}

.profile-stat .ps-val {
  font-size: 1.1rem;
  font-weight: 700;
}

.profile-stat .ps-lbl {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.correlation-matrix {
  overflow-x: auto;
}

.correlation-matrix table {
  font-size: .8rem;
}

.correlation-matrix td,
.correlation-matrix th {
  text-align: center;
  padding: .5rem .6rem;
}

/* ── Print Improvements ───────────────────────────────── */
@media print {

  .sidebar,
  .topbar,
  .mobile-menu-btn,
  .tabs,
  .btn,
  .info-tip::after,
  .report-assist {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-content {
    padding: .5rem !important;
  }

  .card {
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }

  .stat-card,
  .scorecard-item {
    break-inside: avoid;
  }

  body {
    background: #fff !important;
    color: #111 !important;
  }

  .info-tip {
    display: none !important;
  }
}

@media(max-width:768px) {
  /* Sidebar — hide by default */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 20px 0 50px rgba(0,0,0,0.5);
  }

  .main-content {
    margin-left: 0 !important;
  }

  /* Topbar — compact */
  .topbar { padding: 0 1rem; }
  .topbar .topbar-actions span { display: none; }
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Info tips — touch-friendly positioning */
  .info-tip::after {
    left: 0;
    transform: none;
    max-width: 240px;
    font-size: .72rem;
  }

  /* Scorecard — 2 columns */
  .scorecard {
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
  }
  .scorecard-item { padding: .8rem .6rem; }
  .scorecard-value { font-size: 1.1rem; }

  /* Report assist — smaller text */
  .report-assist {
    padding: .75rem .85rem;
    font-size: .82rem;
    line-height: 1.45;
  }

  /* Trend badges — smaller */
  .trend-badge { font-size: .65rem; padding: 1px 4px; }

  /* Security profile cards — single column */
  .profile-card { padding: .85rem; }
  .profile-header { flex-wrap: wrap; gap: .5rem; }
  .profile-stats { grid-template-columns: 1fr 1fr; gap: .4rem; }
  .empty-state { padding: 2rem 1rem; }
  .empty-state .empty-icon { font-size: 2rem; }

  .modal-roles-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Alert cards — stack content */
  .alert-card { padding: .75rem .85rem; gap: .65rem; flex-wrap: wrap; }
  .alert-icon { font-size: 1.2rem; }
  .alert-content p { font-size: .78rem; }
  .alert-meta { font-size: .7rem; }

  /* Buttons — larger tap targets */
  .btn { min-height: 40px; padding: .55rem 1rem; }
  .btn-sm { min-height: 36px; padding: .4rem .75rem; }

  /* Forms — stack on mobile */
  .form-group { margin-bottom: .6rem; }
  form[style*="display:flex"] { flex-direction: column !important; }
  form .form-group { width: 100% !important; max-width: none !important; }
  .form-control { font-size: 16px; } /* Prevents iOS zoom on focus */

  .filter-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .filter-form .form-actions {
    margin-top: 0.5rem;
  }

  .filter-form .flex-1 {
    min-width: auto;
  }

  /* Cards — reduce padding */
  .card { margin-bottom: .65rem; }
  .card-body { padding: .75rem; }
  .card-header { padding: .6rem .75rem; }
  .card-header h3 { font-size: .92rem; }

  /* Page header — compact */
  .page-header { gap: .5rem; margin-bottom: .75rem; }
  .page-header h2 { font-size: 1.05rem; }

  /* Stat cards — compact */
  .stat-card { gap: .6rem; }
  .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }
  .stat-info .stat-label { font-size: .72rem; }

  /* Modal — full width with safe area */
  .modal { margin: .4rem; max-width: calc(100vw - .8rem) !important; }
  .modal-body { padding: .85rem; }
  .modal-footer { padding: .6rem .85rem; gap: .4rem; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 100px; }
}

/* ══════════════════════════════════════════════════════════
   SMALL PHONES — 480px and below
   ══════════════════════════════════════════════════════════ */
@media(max-width:480px) {
  html { font-size: 13px; }
  .page-content { padding: .6rem; }

  /* POS — tighter grid */
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: .4rem;
  }
  .product-card .p-icon { font-size: 1.2rem; }
  .product-card .p-name { font-size: .72rem; }

  /* Stats — single column */
  .stats-grid { grid-template-columns: 1fr; }

  /* Scorecard — single column */
  .scorecard { grid-template-columns: 1fr; gap: .5rem; }
  .scorecard-item { padding: .65rem .5rem; }

  /* Tabs — even more compact */
  .tab-btn { padding: .4rem .6rem; font-size: .72rem; }

  /* Security profiles — single column, tighter */
  .profile-stats { grid-template-columns: 1fr; }

  /* Buttons — full width */
  .btn-block, .page-header .btn { width: 100%; text-align: center; }

  /* Cart FAB — larger on small phones */
  .cart-fab { width: 60px; height: 60px; font-size: 1.6rem; bottom: 1rem; right: 1rem; }
  .cart-fab .cart-fab-count { min-width: 20px; height: 20px; font-size: .7rem; }

  /* Report P&L rows — stack labels and values */
  .report-assist { font-size: .78rem; padding: .6rem .7rem; }

  /* Hide secondary info on very small screens */
  .info-tip { display: none; }
}