/* ============================================================
   SmartPOS — Design System
   Theme: Light Gray primary / #1b405f secondary
   Tone: Refined utilitarian — clean, fast, professional
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:        #1b405f;
  --brand-dark:   #122d44;
  --brand-light:  #234f75;
  --brand-faint:  #eaf1f7;
  --brand-border: #b8d0e3;

  /* Grays */
  --gray-50:  #f7f8f9;
  --gray-100: #f0f1f3;
  --gray-150: #e8eaec;
  --gray-200: #dde0e4;
  --gray-300: #c4c9cf;
  --gray-400: #9aa0a9;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Semantic */
  --success:       #1a7a4a;
  --success-bg:    #edf7f2;
  --success-border:#b0ddc8;
  --warning:       #92550a;
  --warning-bg:    #fef6ec;
  --warning-border:#f5cfa0;
  --danger:        #b91c1c;
  --danger-bg:     #fef2f2;
  --danger-border: #fecaca;
  --info:          #1b405f;
  --info-bg:       #eaf1f7;
  --info-border:   #b8d0e3;

  /* Surfaces */
  --bg-page:    #f4f5f7;
  --bg-surface: #ffffff;
  --bg-raised:  #ffffff;
  --bg-sunken:  #f0f1f3;

  /* Text */
  --text-primary:   #1a2332;
  --text-secondary: #4b5563;
  --text-muted:     #6b7280;
  --text-disabled:  #9aa0a9;
  --text-inverse:   #ffffff;
  --text-brand:     #1b405f;

  /* Borders */
  --border-light:  #e8eaec;
  --border-base:   #dde0e4;
  --border-strong: #c4c9cf;
  --border-brand:  #1b405f;

  /* Sidebar */
  --sidebar-bg:        #1b405f;
  --sidebar-text:      rgba(255,255,255,0.82);
  --sidebar-text-muted:rgba(255,255,255,0.45);
  --sidebar-active-bg: rgba(255,255,255,0.12);
  --sidebar-active-text:#ffffff;
  --sidebar-hover-bg:  rgba(255,255,255,0.07);
  --sidebar-border:    rgba(255,255,255,0.10);
  --sidebar-width:     230px;
  --sidebar-icon:      rgba(255,255,255,0.55);

  /* Topbar */
  --topbar-height: 58px;
  --topbar-bg:     #ffffff;
  --topbar-border: #e8eaec;

  /* Layout */
  --content-max:   1200px;
  --radius-sm:     4px;
  --radius-md:     7px;
  --radius-lg:     10px;
  --radius-xl:     14px;
  --radius-full:   9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07), 0 0 1px rgba(0,0,0,0.04);
  --shadow-md: 0 3px 10px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10), 0 0 1px rgba(0,0,0,0.05);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.12), 0 0 2px rgba(0,0,0,0.06);

  /* Focus */
  --focus-ring: 0 0 0 3px rgba(27, 64, 95, 0.20);

  /* Transitions */
  --t-fast:   100ms ease;
  --t-base:   170ms ease;
  --t-slow:   280ms ease;

  /* Z-index */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-sidebar:  300;
  --z-topbar:   400;
  --z-modal:    500;
  --z-toast:    600;
  --z-tooltip:  700;

  /* Typography */
  --font-sans: 'DM Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-num:  'DM Sans', sans-serif;    /* tabular figures */
}

/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 0.933rem;  /* ~14px */
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--t-base);
}
a:hover { color: var(--brand-dark); text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

ul, ol { list-style: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button { cursor: pointer; }

p { max-width: 68ch; }

hr {
  border: none;
  border-top: 1px solid var(--border-light);
}

/* ── Typography ───────────────────────────────────────────── */
h1, .h1 { font-size: 1.6rem;  font-weight: 600; line-height: 1.25; letter-spacing: -0.02em; color: var(--text-primary); }
h2, .h2 { font-size: 1.27rem; font-weight: 600; line-height: 1.30; letter-spacing: -0.01em; color: var(--text-primary); }
h3, .h3 { font-size: 1.07rem; font-weight: 600; line-height: 1.35; color: var(--text-primary); }
h4, .h4 { font-size: 0.933rem;font-weight: 600; line-height: 1.40; color: var(--text-primary); }
h5, .h5 { font-size: 0.867rem;font-weight: 600; line-height: 1.45; color: var(--text-secondary); }

.text-sm    { font-size: 0.8rem; }
.text-xs    { font-size: 0.733rem; }
.text-lg    { font-size: 1.067rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-brand { color: var(--brand); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-mono    { font-family: var(--font-mono); letter-spacing: 0; }

/* ── Layout Shell ─────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: var(--z-sidebar);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--t-slow);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none !important;
}

.sidebar-logo-mark {
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-mark svg { color: #fff; }

.sidebar-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.sidebar-logo-sub {
  font-size: 0.72rem;
  color: var(--sidebar-text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  padding: 14px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 18px;
  color: var(--sidebar-text);
  font-size: 0.867rem;
  font-weight: 500;
  border-radius: 0;
  border-left: 3px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  text-decoration: none !important;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: rgba(255,255,255,0.75);
}

.nav-item .nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--sidebar-icon);
  transition: color var(--t-fast);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  color: rgba(255,255,255,0.9);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid var(--sidebar-border);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: var(--z-topbar);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: background var(--t-fast), color var(--t-fast);
}

.topbar-btn:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--t-fast);
  background: transparent;
}

.topbar-user:hover { background: var(--gray-50); }

.topbar-avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--brand);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.topbar-user-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  flex: 1;
}

.page-body {
  padding: 28px 28px 60px;
  max-width: var(--content-max);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-left { flex: 1; }

.page-title {
  font-size: 1.33rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.page-subtitle {
  font-size: 0.833rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: 20px; }
.card-body-flush { padding: 0; }

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Stat cards */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--brand-faint); color: var(--brand); }
.stat-icon.green  { background: var(--success-bg);  color: var(--success); }
.stat-icon.amber  { background: var(--warning-bg);  color: var(--warning); }
.stat-icon.red    { background: var(--danger-bg);   color: var(--danger); }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 0.833rem;
  font-weight: 600;
  line-height: 1;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  user-select: none;
}

.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary:active { background: var(--brand-dark); }

/* Secondary */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-base);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--border-strong); }

/* Danger */
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover { background: #fde8e8; border-color: #fca5a5; }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--text-primary); }

/* Icon-only */
.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 5px 11px;
}

.btn-lg {
  font-size: 0.95rem;
  padding: 11px 22px;
  border-radius: var(--radius-lg);
}

.btn-full { width: 100%; }

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  color: #fff;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.867rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  line-height: 1.5;
  appearance: none;
}

.form-control::placeholder { color: var(--text-disabled); }

.form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.form-control:disabled {
  background: var(--bg-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-control.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(185,28,28,0.12);
}

.form-control.is-valid {
  border-color: var(--success);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Input groups */
.input-group {
  display: flex;
}

.input-group .form-control {
  border-radius: 0;
  flex: 1;
}

.input-group .form-control:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-control:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border-base);
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.input-group-addon:first-child {
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group-addon:last-child {
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Search input */
.search-wrap {
  position: relative;
}

.search-wrap .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 15px; height: 15px;
  pointer-events: none;
}

.search-wrap .form-control {
  padding-left: 34px;
}

.search-wrap .search-clear {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-200);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  padding: 0;
  font-size: 10px;
  display: none;
}

.search-wrap .form-control:not(:placeholder-shown) ~ .search-clear { display: flex; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.833rem;
}

.table thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  user-select: none;
}

.table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--t-fast);
}

.table tbody tr:last-child { border-bottom: none; }

.table tbody tr:hover { background: var(--gray-50); }

.table td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.table td.muted { color: var(--text-muted); }

.table-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

/* Sortable header */
.th-sort {
  cursor: pointer;
}
.th-sort:hover { color: var(--text-primary); }
.th-sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-style: normal;
}
.th-sort.asc  .th-sort-icon::before { content: '↑'; opacity: 1; }
.th-sort.desc .th-sort-icon::before { content: '↓'; opacity: 1; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-blue    { background: var(--brand-faint);    color: var(--brand);   border: 1px solid var(--brand-border); }
.badge-green   { background: var(--success-bg);     color: var(--success); border: 1px solid var(--success-border); }
.badge-amber   { background: var(--warning-bg);     color: var(--warning); border: 1px solid var(--warning-border); }
.badge-red     { background: var(--danger-bg);      color: var(--danger);  border: 1px solid var(--danger-border); }
.badge-gray    { background: var(--gray-100);       color: var(--gray-600);border: 1px solid var(--gray-200); }

/* Low stock dot */
.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.833rem;
  border: 1px solid;
}

.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 20, 35, 0.45);
  backdrop-filter: blur(2px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px) scale(0.98);
  transition: transform var(--t-base);
}

.modal-backdrop.active .modal {
  transform: translateY(0) scale(1);
}

.modal-lg { max-width: 700px; }
.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.modal-close:hover { background: var(--gray-100); color: var(--text-primary); }

.modal-body { padding: 22px; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--border-light);
}

/* ── Toasts ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--gray-800);
  color: #fff;
  border-radius: var(--radius-lg);
  font-size: 0.833rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  min-width: 260px;
  max-width: 360px;
  animation: toast-in 0.22s ease forwards;
}

.toast.removing { animation: toast-out 0.18s ease forwards; }

.toast-success { border-left: 3px solid #22c55e; }
.toast-error   { border-left: 3px solid #ef4444; }
.toast-warning { border-left: 3px solid #f59e0b; }
.toast-info    { border-left: 3px solid var(--brand); }

.toast-icon { font-size: 0.9rem; }
.toast-msg  { flex: 1; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(8px); } }

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: var(--z-dropdown);
  padding: 4px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  font-size: 0.833rem;
  color: var(--text-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--gray-50); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-divider { margin: 4px 0; border-top: 1px solid var(--border-light); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
  justify-content: flex-end;
}

.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.page-btn:hover { background: var(--gray-50); border-color: var(--border-strong); }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px;
}

.tab {
  padding: 8px 16px 10px;
  font-size: 0.833rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ── Misc Utilities ───────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end   { justify-content: flex-end; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 12px; }
.gap-4         { gap: 16px; }
.gap-6         { gap: 24px; }
.flex-1        { flex: 1; }
.flex-wrap     { flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-2  { margin-bottom: 8px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }

.w-full { width: 100%; }

.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 20px 0;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 48px; height: 48px;
  background: var(--gray-100);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  color: var(--gray-400);
}

.empty-state-title {
  font-size: 0.933rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 280px;
  margin: 0 auto 18px;
}

/* ── Loading Spinner ──────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-base);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
}

.spinner-sm { width: 14px; height: 14px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton Loaders ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--gray-150) 25%, var(--gray-100) 50%, var(--gray-150) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer { to { background-position: -200% center; } }

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  padding: 24px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.auth-card-header {
  background: var(--brand);
  padding: 28px 32px 24px;
  text-align: center;
}

.auth-logo-wrap {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}

.auth-app-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.auth-tagline {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.65);
  margin-top: 3px;
}

.auth-card-body {
  padding: 28px 32px;
}

/* ── POS-specific styles ──────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}

.pos-products-panel {
  overflow-y: auto;
  padding: 20px;
  border-right: 1px solid var(--border-light);
  background: var(--bg-page);
}

.pos-cart-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

.pos-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.pos-cart-footer {
  border-top: 1px solid var(--border-light);
  padding: 16px;
  background: var(--bg-surface);
}

.pos-product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  position: relative;
  overflow: hidden;
}

.pos-product-card:hover {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.pos-product-card.out-of-stock {
  opacity: 0.55;
  cursor: not-allowed;
}

.pos-cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.pos-cart-item:last-child { border-bottom: none; }

.qty-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 2px;
}

.qty-btn {
  width: 24px; height: 24px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
}

.qty-btn:hover { background: var(--bg-surface); color: var(--brand); }

.qty-value {
  min-width: 28px;
  text-align: center;
  font-size: 0.833rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar {
    left: 0;
  }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-body { padding: 20px 16px 40px; }
  .pos-layout { grid-template-columns: 1fr; }
}