@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.hidden { display: none !important; }

:root {
  --primary: #1565FF;
  --primary-hover: #1254d9;
  --navy: #0F172A;
  --cyan: #00C2FF;
  --white: #FFFFFF;
  --bg: #F8FAFC;
  --border: #E2E8F0;
  --border-light: #CBD5E1;
  --text-muted: #64748B;
  --text-body: #334155;
  --success: #22C55E;
  --warning: #F59E0B;
  --error: #EF4444;
  --info: #3B82F6;
  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-input: 10px;
  --shadow: 0 4px 20px rgba(15,23,42,.08);
  --sidebar-w: 280px;
  --cart-w: 300px;
  --topbar-h: 72px;
  --font: 'Inter', 'Roboto', -apple-system, sans-serif;
  --sidebar-bg: #0F172A;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #1565FF;
  --card-bg: #FFFFFF;
  --input-bg: #FFFFFF;
}

[data-theme="dark"] {
  --bg: #0B1120;
  --card-bg: #111827;
  --input-bg: #1E293B;
  --border: #1E293B;
  --border-light: #334155;
  --text-body: #F8FAFC;
  --text-muted: #94A3B8;
  --navy: #0B1120;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

body.sidebar-open { overflow: hidden; }

body {
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Screens */
.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }

/* ===== AUTH ===== */
.auth-page {
  min-height: 100vh;
  width: 100%;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1e3a5f 50%, #1565FF 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,194,255,.15) 0%, transparent 70%);
  top: -200px; right: -100px;
  pointer-events: none;
}

.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 40px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
  animation: fadeUp .3s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo { text-align: center; margin-bottom: 28px; }

.logo-mark {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.logo-mark svg { width: 28px; height: 28px; }

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.5px;
}

[data-theme="dark"] .auth-logo h1 { color: var(--text-body); }

.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: transform .25s ease;
  z-index: 200;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .logo-mark { width: 40px; height: 40px; border-radius: 10px; margin: 0; }
.sidebar-brand-text { color: #fff; font-weight: 700; font-size: 18px; letter-spacing: -.3px; }
.sidebar-brand-sub { color: var(--sidebar-text); font-size: 11px; display: block; font-weight: 400; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sidebar-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #475569;
  padding: 12px 12px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-btn);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  transition: background .2s, color .2s;
  margin-bottom: 2px;
}

.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }

.nav-link.active {
  background: rgba(21,101,255,.2);
  color: #fff;
}

.nav-link.active .nav-link-icon { color: var(--cyan); }

.nav-link-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: .85;
}

.nav-link-label {
  flex: 1;
  min-width: 0;
}

.nav-cart-badge {
  display: none;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  margin-left: auto;
}

.nav-cart-badge.show {
  display: block;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.cart-panel-client {
  max-width: 420px;
  margin-bottom: 16px;
}

.cart-panel-client label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cart-panel-list {
  max-width: 640px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: 16px;
}

.cart-panel-list-grouped {
  background: transparent;
  border: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cart-distributor-group {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.cart-distributor-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(21, 101, 255, .06);
  border-bottom: 1px solid var(--border);
}

.cart-distributor-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-body);
}

.cart-distributor-id {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.cart-distributor-limits {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px 16px;
  min-width: min(100%, 320px);
}

.cart-limit-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.cart-limit-row strong {
  color: var(--text-body);
  font-size: 12px;
  white-space: nowrap;
}

.cart-distributor-items .cart-item:last-child {
  border-bottom: none;
}

.cart-distributor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  color: var(--text-muted);
}

.cart-distributor-footer-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cart-distributor-footer strong {
  font-size: 16px;
  color: var(--text-body);
}

.btn-cart-group-checkout {
  flex-shrink: 0;
  white-space: nowrap;
}

.finance-debt-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  margin-top: 16px;
}

.finance-debt-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.finance-debt-card.finance-debt-overdue {
  border-color: rgba(239, 68, 68, .35);
}

.finance-debt-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(21, 101, 255, .06);
  border-bottom: 1px solid var(--border);
}

.finance-debt-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #1565ff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.finance-debt-meta {
  flex: 1;
  min-width: 0;
}

.finance-debt-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-body);
}

.finance-debt-id {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.finance-debt-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px;
}

.finance-debt-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.finance-debt-row strong {
  font-size: 14px;
  color: var(--text-body);
}

.finance-debt-note {
  max-width: 640px;
  margin-top: 16px;
}

.finance-debt-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  justify-content: flex-end;
}

.finance-payments-section {
  max-width: 640px;
  margin-top: 24px;
}

.finance-payments-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-body);
}

.finance-payments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finance-payment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.finance-payment-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-body);
}

.finance-payment-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.pay-modal-card {
  max-width: 420px;
  width: 100%;
  padding: 20px;
}

.pay-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pay-modal-header h2 {
  font-size: 18px;
  margin: 0;
}

.pay-modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.pay-modal-debt {
  font-size: 14px;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: rgba(21, 101, 255, .08);
  border-radius: 8px;
}

.pay-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.receive-modal-card {
  max-width: 520px;
  width: 100%;
  padding: 20px;
}

.receive-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.receive-modal-header h2 {
  font-size: 18px;
  margin: 0;
}

.receive-modal-card .section-title {
  margin-bottom: 14px;
}

.return-photo img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 10px;
  margin-top: 8px;
  object-fit: cover;
}
.return-item-row {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.finance-confirm-list {
  max-width: 720px;
  margin-top: 16px;
}

.finance-confirm-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}

.finance-confirm-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.finance-confirm-store {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-body);
}

.finance-confirm-dist {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.finance-confirm-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-body);
  white-space: nowrap;
}

.finance-confirm-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.finance-confirm-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.finance-confirm-actions {
  display: flex;
  gap: 8px;
}

.cart-panel-footer {
  max-width: 420px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.cart-panel-total {
  flex: 1;
  min-width: 180px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-muted);
}

.cart-panel-total strong {
  font-size: 18px;
  color: var(--text-body);
}

.cart-order-result {
  margin-top: 16px;
  max-width: 640px;
}

.cart-item {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  line-height: 1.3;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cart-item-price {
  font-size: 12px;
  color: var(--text-muted);
}

.cart-item-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}

.cart-item-qty button {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-body);
}

.cart-item-qty button:hover {
  background: rgba(0, 0, 0, .05);
}

.cart-item-qty span {
  min-width: 22px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.cart-item-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  line-height: 1;
}

.cart-item-remove:hover {
  color: #ef4444;
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-title h2 { font-size: 22px; font-weight: 600; color: var(--text-body); }
.topbar-title p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--bg);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-body);
  transition: border-color .2s, box-shadow .2s;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,255,.12);
}

.catalog-search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 10px 14px;
  background: rgba(21, 101, 255, .08);
  border: 1px solid rgba(21, 101, 255, .2);
  border-radius: var(--radius-card);
  font-size: 13px;
  color: var(--text-body);
}

.catalog-search-clear {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.catalog-search-clear:hover {
  background: rgba(0, 0, 0, .06);
  color: var(--text-body);
}

.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  max-height: 360px;
  overflow-y: auto;
  z-index: 200;
}

.search-dropdown.show { display: block; }

.search-dropdown-header {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.search-hit {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  color: var(--text-body);
}

.search-hit:hover, .search-hit.active {
  background: rgba(21, 101, 255, .08);
}

.search-hit-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(21, 101, 255, .1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.search-hit-body { min-width: 0; flex: 1; }
.search-hit-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-hit-sub { font-size: 12px; color: var(--text-muted); }
.search-hit-type { font-size: 10px; text-transform: uppercase; color: var(--primary); font-weight: 700; }

.search-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.topbar-search svg {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.topbar-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all .2s;
  position: relative;
}

.topbar-btn:hover { border-color: var(--primary); color: var(--primary); }

.menu-toggle { display: none; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 190;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.topbar-btn .badge-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid var(--card-bg);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  font-family: var(--font);
  color: inherit;
}

.user-menu:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(21, 101, 255, .12);
}

.user-menu-gear {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  margin-left: 2px;
}

.user-menu:hover .user-menu-gear { color: var(--primary); }

#settings-modal {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#settings-modal::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.modal-card.settings-modal-card {
  max-width: 760px;
  max-height: 92vh;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-card.settings-modal-card::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

#add-product-modal {
  padding: 16px;
  align-items: flex-start;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#add-product-modal::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.modal-card.add-product-modal-card {
  max-width: min(2352px, 69vw);
  width: min(2352px, 69vw);
  max-height: none;
  overflow: hidden;
  padding: 28px 32px 32px;
  margin: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-card.add-product-modal-card::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.add-product-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.add-product-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.add-product-modal-header .modal-close {
  float: none;
  flex-shrink: 0;
}

.modal-card.add-product-modal-card .product-create-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  width: 100%;
  align-items: start;
}

.modal-card.add-product-modal-card .product-create-form,
.modal-card.add-product-modal-card .product-create-preview {
  min-width: 0;
  width: 100%;
}

.modal-card.add-product-modal-card .product-create-preview {
  position: static;
}

.modal-card.add-product-modal-card .product-create-form .form-group {
  margin-bottom: 12px;
}

.add-product-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.add-product-modal-actions .btn-primary {
  flex: 1;
  min-width: 140px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-info { line-height: 1.3; }
.user-info .name { font-size: 13px; font-weight: 600; color: var(--text-body); }
.user-info .role { font-size: 11px; color: var(--text-muted); }

.lang-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--card-bg);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-body);
  cursor: pointer;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 32px;
  background: var(--bg);
}

.tab-panel { display: none; animation: fadeUp .25s ease; }
.tab-panel.active { display: block; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.password-field {
  position: relative;
  width: 100%;
}

.password-field .form-input {
  padding-right: 44px;
  width: 100%;
}

.password-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  line-height: 0;
}

.password-toggle-btn:hover { color: var(--primary); }

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-input, .form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 15px;
  font-family: var(--font);
  background: var(--input-bg);
  color: var(--text-body);
  transition: border-color .2s, box-shadow .2s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,255,.12);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all .2s;
}

.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text-body); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--error); color: #fff; }
.btn-block { width: 100%; }

.warehouse-field-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.warehouse-field-row .form-select { flex: 1; min-width: 0; }
.warehouse-add-form {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.warehouse-add-form.hidden { display: none; }

/* ===== KPI CARDS ===== */
.dash-section { margin-bottom: 8px; }
.dash-period-block {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.dash-period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.dash-period-tab {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-body);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.dash-period-tab:hover { border-color: var(--primary); color: var(--primary); }
.dash-period-tab.active {
  background: rgba(21,101,255,.1);
  border-color: var(--primary);
  color: var(--primary);
}
.dash-period-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-top: 4px;
}
.dash-period-custom.hidden { display: none; }
.dash-period-field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.dash-period-field input[type="date"] {
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-body);
  font-size: 14px;
}
.dash-period-range {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 10px;
}
.dash-summary-grid {
  margin-bottom: 8px;
}
.dash-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform .2s, box-shadow .2s;
  animation: fadeUp .3s ease backwards;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(15,23,42,.12); }

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.kpi-icon.blue { background: rgba(21,101,255,.12); color: var(--primary); }
.kpi-icon.cyan { background: rgba(0,194,255,.12); color: var(--cyan); }
.kpi-icon.green { background: rgba(34,197,94,.12); color: var(--success); }
.kpi-icon.orange { background: rgba(245,158,11,.12); color: var(--warning); }
.kpi-icon.red { background: rgba(239,68,68,.12); color: var(--error); }

.kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-body);
  line-height: 1.2;
  letter-spacing: -0.25px;
  word-break: break-word;
}

.kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.kpi-trend {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.kpi-trend.up { background: rgba(34,197,94,.12); color: var(--success); }
.kpi-trend.down { background: rgba(239,68,68,.12); color: var(--error); }

/* ===== DATA TABLE ===== */
.table-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.table-header h3 { font-size: 16px; font-weight: 600; }

.table-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-search {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 13px;
  font-family: var(--font);
  background: var(--input-bg);
  color: var(--text-body);
  width: 200px;
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 12px 22px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.data-table th:hover { color: var(--primary); }

.data-table td {
  padding: 14px 22px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
}

.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: rgba(21,101,255,.04); }
.data-table tbody tr:nth-child(even) { background: rgba(248,250,252,.5); }
[data-theme="dark"] .data-table tbody tr:nth-child(even) { background: rgba(30,41,59,.3); }

/* ===== STATUS BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: rgba(34,197,94,.12); color: var(--success); }
.badge-warning { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-error { background: rgba(239,68,68,.12); color: var(--error); }
.badge-info { background: rgba(59,130,246,.12); color: var(--info); }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ===== PRODUCT CARDS ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
}

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 240px;
  width: 100%;
  justify-self: center;
  transition: transform .2s, box-shadow .2s;
  animation: fadeUp .25s ease backwards;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 45, 92, .12);
  border-color: rgba(21, 101, 255, .25);
}

.product-card-media {
  position: relative;
  aspect-ratio: 1;
  background: #f4f6f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.product-card-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.product-card-placeholder {
  font-size: 52px;
  opacity: .45;
}

.product-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px;
  pointer-events: none;
}

.product-card-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  pointer-events: auto;
  z-index: 2;
}

.product-card-tag {
  max-width: 58%;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

.product-card-promo {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(245, 158, 11, .92);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.product-card-action {
  pointer-events: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .95);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card-action:hover {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

.product-card-fav {
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
}

.product-card-fav.active {
  color: #ef4444;
  border-color: rgba(239, 68, 68, .35);
  background: rgba(254, 226, 226, .95);
}

.catalog-filters {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}

.catalog-filter {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text-body);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}

.catalog-filter.active {
  background: #0f2d5c;
  border-color: #0f2d5c;
  color: #fff;
}

.catalog-filter-count {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
  font-size: 11px;
}

.catalog-filter.active .catalog-filter-count {
  background: rgba(255, 255, 255, .25);
}

.modal-fav-btn {
  position: absolute;
  top: 14px;
  right: 48px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-fav-btn.active {
  color: #ef4444;
  border-color: rgba(239, 68, 68, .35);
  background: rgba(254, 226, 226, .95);
}

.product-card-body {
  padding: 12px 12px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.product-card-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: #0f2d5c;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
  cursor: pointer;
}

.product-card-min {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.product-card-price {
  font-size: 20px;
  font-weight: 800;
  color: #0f2d5c;
  margin-top: 4px;
  letter-spacing: -.02em;
}

.product-card-old-price {
  font-size: 12px;
  color: #94a3b8;
  text-decoration: line-through;
}

.product-card-brand {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}

.product-modal-img {
  text-align: center;
  margin: 12px 0;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: linear-gradient(135deg, rgba(21,101,255,.06), rgba(0,194,255,.06));
}

.product-modal-img img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.image-preview {
  margin-top: 8px;
  text-align: center;
}

.image-preview img {
  max-width: 120px;
  max-height: 120px;
  object-fit: cover;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
}

.file-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.file-upload-btn {
  flex-shrink: 0;
}

.file-upload-name {
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-all;
}
.product-card-stock {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.product-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 12px;
  margin-top: auto;
}

.btn-add-cart {
  flex: 1;
  min-width: 72px;
  height: 34px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: #0f2d5c;
  color: #fff;
  font-family: var(--font);
  cursor: pointer;
  transition: background .2s, color .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-add-cart:hover { background: #1565ff; }

.btn-add-cart.in-cart {
  background: var(--success);
  color: #fff;
}

.btn-add-cart.in-cart:hover {
  background: #16a34a;
}

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card-bg);
}

.qty-step {
  width: 30px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text-body);
  font-size: 16px;
  cursor: pointer;
  font-family: var(--font);
}

.qty-step:hover { background: var(--bg); }

.qty-step-value {
  min-width: 22px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #0f2d5c;
}

[data-theme="dark"] .product-card-media { background: #1a2332; }
[data-theme="dark"] .product-card-name,
[data-theme="dark"] .product-card-price,
[data-theme="dark"] .qty-step-value { color: #e8eef7; }
[data-theme="dark"] .product-card-tag { background: rgba(30, 41, 59, .92); color: #cbd5e1; }
[data-theme="dark"] .btn-add-cart { background: #1565ff; }
[data-theme="dark"] .btn-add-cart.in-cart { background: var(--success); }
[data-theme="dark"] .btn-add-cart.in-cart:hover { background: #16a34a; }

.add-product-form {
  padding: 0 16px 16px;
}

.add-product-form[hidden] {
  display: none !important;
}

.product-create-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

.product-create-preview {
  position: sticky;
  top: 16px;
}

.product-create-form #p-image-preview {
  display: none;
}

.product-preview-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -4px 0 14px;
}

.product-card-preview {
  pointer-events: none;
  margin: 0 auto;
}

.product-card-preview .btn-add-cart,
.product-card-preview .qty-step {
  opacity: .75;
  cursor: default;
}

.product-card-tag-empty {
  opacity: .45;
}

@media (max-width: 900px) {
  .product-create-layout {
    grid-template-columns: 1fr;
  }

  .product-create-preview {
    position: static;
  }

  .modal-card.add-product-modal-card .product-create-layout {
    grid-template-columns: 1fr;
  }
}

.qty-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  font-size: 15px;
  text-align: center;
  font-family: var(--font);
  background: var(--input-bg);
  color: var(--text-body);
}

.qty-input:focus { outline: none; border-color: var(--primary); }

/* ===== CHARTS ===== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-body);
}

/* ===== ORDER CARD ===== */
.order-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.order-timeline {
  display: flex;
  gap: 0;
  margin-top: 20px;
  overflow-x: auto;
}

.timeline-step {
  flex: 1;
  min-width: 80px;
  text-align: center;
  position: relative;
}

.timeline-step::after {
  content: '';
  position: absolute;
  top: 14px; left: 50%;
  width: 100%; height: 2px;
  background: var(--border);
  z-index: 0;
}

.timeline-step:last-child::after { display: none; }

.timeline-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--border);
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  position: relative;
  z-index: 1;
  color: var(--text-muted);
}

.timeline-step.done .timeline-dot { background: var(--success); color: #fff; }
.timeline-step.done span { color: var(--success); font-weight: 600; }
.timeline-step.active .timeline-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(21,101,255,.2); }
.timeline-step span { font-size: 11px; color: var(--text-muted); display: block; }

/* ===== SETTINGS ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-card-wide { grid-column: 1 / -1; }

.staff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.staff-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--surface);
}

.staff-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.staff-row-login {
  font-size: 12px;
  color: var(--text-muted);
}

.staff-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
}

.staff-create-form {
  margin-top: 16px;
}

.staff-create-form.hidden {
  display: none;
}

.staff-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.staff-form-actions .btn {
  flex: 1;
}

.settings-distributor-id-compact {
  margin-bottom: 0;
}

.settings-distributor-id-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-distributor-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-body);
  padding: 2px 0;
}

.settings-distributor-id-badge {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--primary);
  padding: 10px 12px;
  background: rgba(21, 101, 255, 0.06);
  border: 1px solid rgba(21, 101, 255, 0.2);
  border-radius: var(--radius-input);
  user-select: all;
}

.settings-distributor-hint-compact {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}

.modal-overlay.show { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(15,23,42,.2);
  animation: fadeUp .25s ease;
}

.modal-close {
  float: right;
  background: var(--bg);
  border: 1px solid var(--border);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
}

/* ===== DISTRIBUTORS ===== */
.distributors-search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

.distributors-search-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.distributors-search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.distributors-search {
  flex: 1;
  min-width: 220px;
  max-width: 340px;
}

.distributors-id-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.distributors-search-result {
  margin-bottom: 24px;
}

.distributors-grid-single {
  max-width: 420px;
}

.distributors-my-section {
  margin-top: 8px;
}

.distributors-my-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

.distributors-empty {
  padding: 32px 16px;
}

.distributors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.distributor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .2s, border-color .2s;
}

.distributor-card:hover {
  border-color: rgba(21, 101, 255, .35);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}

.distributor-card-clickable {
  cursor: pointer;
}

.distributor-card-clickable .distributor-card-actions {
  cursor: default;
}

.catalog-distributor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(21, 101, 255, .08);
  border: 1px solid rgba(21, 101, 255, .2);
  font-size: 13px;
}

.distributor-card.connected {
  border-color: rgba(34, 197, 94, .35);
  background: linear-gradient(180deg, rgba(34, 197, 94, .04), var(--surface));
}

.distributor-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.distributor-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.distributor-card-meta { flex: 1; min-width: 0; }

.distributor-card-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.distributor-card-region {
  font-size: 13px;
  color: var(--text-muted);
}

.distributor-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.distributor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.distributor-tag {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(21, 101, 255, .08);
  color: var(--primary);
}

.distributor-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.distributor-card-actions { margin-top: auto; }

/* ===== MISC ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 { font-size: 18px; font-weight: 600; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }

.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  background: rgba(239,68,68,.1);
  color: var(--error);
  padding: 12px 14px;
  border-radius: var(--radius-input);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
  border: 1px solid rgba(239,68,68,.2);
}

.error-msg.show { display: block; }

.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }

.auth-card-wide { max-width: 520px; }

.register-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.register-type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.register-type-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(37, 99, 235, .12);
  transform: translateY(-2px);
}

.register-type-icon { font-size: 28px; line-height: 1; }

.register-type-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.register-type-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 520px) {
  .register-type-grid { grid-template-columns: 1fr; }
}

.alert-success {
  background: rgba(34,197,94,.1);
  color: var(--success);
  padding: 12px 16px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(34,197,94,.2);
  font-size: 14px;
}

.alert-error {
  background: rgba(239,68,68,.1);
  color: var(--error);
  padding: 12px 16px;
  border-radius: var(--radius-input);
  border: 1px solid rgba(239,68,68,.2);
  font-size: 14px;
}

.toast-container {
  position: fixed;
  top: 88px; right: 28px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: fadeUp .25s ease;
  min-width: 260px;
  border-left: 4px solid var(--primary);
}

.page-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

@media (max-width: 1024px) {
  .menu-toggle { display: flex; }

  .sidebar-backdrop { display: block; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, .25);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sidebar.open { transform: translateX(0); }

  .main-wrapper { width: 100%; }

  .page-grid-2 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }

  .modal-card.add-product-modal-card {
    max-width: calc(100vw - 32px);
    width: 100%;
    padding: 20px 18px 24px;
  }

  .modal-card.settings-modal-card {
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 768px) {
  :root {
    --topbar-h: 64px;
    --sidebar-w: min(280px, 88vw);
  }

  .topbar {
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    gap: 8px;
    min-height: var(--topbar-h);
    height: auto;
  }

  .topbar-title {
    flex: 1;
    min-width: 0;
    order: 2;
  }

  .topbar-title h2 {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-title p { display: none; }

  .menu-toggle { order: 1; flex-shrink: 0; }

  .topbar-search {
    order: 4;
    flex: 1 1 100%;
    max-width: none;
    display: block;
  }

  .topbar-actions {
    order: 3;
    margin-left: auto;
    gap: 6px;
  }

  .user-info { display: none; }

  .user-menu { padding: 4px 8px 4px 4px; }

  .page-content {
    padding: 14px 12px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 4px;
  }

  .product-card {
    max-width: none;
    justify-self: stretch;
    border-radius: 12px;
  }

  .product-card-body {
    padding: 8px 8px 6px;
  }

  .product-card-name {
    font-size: 12px;
    min-height: 2.5em;
    -webkit-line-clamp: 2;
  }

  .product-card-min,
  .product-card-stock,
  .product-card-brand {
    font-size: 10px;
  }

  .product-card-price {
    font-size: 15px;
    margin-top: 2px;
  }

  .product-card-old-price { font-size: 10px; }

  .product-card-tag {
    max-width: 70%;
    font-size: 9px;
    padding: 3px 7px;
  }

  .product-card-action {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .product-card-overlay { padding: 6px; }

  .product-card-footer {
    padding: 0 8px 8px;
    gap: 6px;
  }

  .btn-add-cart {
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
  }

  .qty-stepper { height: 32px; border-radius: 8px; }

  .qty-step {
    width: 26px;
    height: 32px;
    font-size: 14px;
  }

  .qty-step-value {
    min-width: 18px;
    font-size: 12px;
  }

  .toolbar { margin-bottom: 12px; }

  .toolbar .btn { flex: 1; }

  .finance-debt-rows {
    grid-template-columns: 1fr;
  }

  .cart-distributor-limits {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .cart-distributor-head,
  .cart-distributor-footer,
  .finance-confirm-head,
  .distributors-search-row,
  .catalog-distributor-bar,
  .section-header,
  .table-header {
    flex-direction: column;
    align-items: stretch;
  }

  .cart-panel-footer,
  .pay-modal-actions,
  .finance-confirm-actions,
  .staff-form-actions {
    flex-direction: column;
  }

  .cart-panel-footer .btn,
  .pay-modal-actions .btn,
  .finance-confirm-actions .btn {
    width: 100%;
  }

  .data-table { min-width: 520px; }

  .data-table th,
  .data-table td {
    padding: 10px 14px;
    font-size: 13px;
  }

  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-card {
    max-width: 100%;
    max-height: 92dvh;
    padding: 20px 16px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-overlay.show .modal-card {
    animation: slideUp .25s ease;
  }

  @keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .toast-container {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .toast { min-width: 0; width: 100%; }

  .screen.auth-page.active {
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-page {
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    align-items: flex-start;
    min-height: min-content;
  }

  .auth-card {
    padding: 28px 20px;
    border-radius: 14px;
    width: 100%;
    max-width: 100%;
  }

  .auth-card-wide { max-width: 100%; }

  .auth-logo h1 { font-size: 22px; }

  .order-timeline { padding-bottom: 4px; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }

  .distributors-grid {
    grid-template-columns: 1fr;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 6px 2px;
  }

  .table-search { width: 100%; }

  .table-toolbar {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 400px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 4px 2px;
  }

  .product-card-body { padding: 6px 6px 4px; }

  .product-card-name {
    font-size: 11px;
    min-height: 2.3em;
  }

  .product-card-price { font-size: 14px; }

  .product-card-min,
  .product-card-stock { display: none; }

  .product-card-footer { padding: 0 6px 6px; }

  .btn-add-cart { height: 30px; }

  .qty-stepper { height: 30px; }

  .qty-step { width: 24px; height: 30px; }
}

@media (max-width: 380px) {
  .topbar-btn:not(.menu-toggle) { display: none; }

  .btn { padding: 10px 16px; font-size: 13px; }
}
