*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: #f0f2f5;
  color: #1e293b;
  min-height: 100vh;
}

/* Dashboard: fill viewport; only tables scroll (login page is unaffected). */
body.dashboard-body {
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; min-height: 100vh; }
body.dashboard-body .app {
  height: 100%;
  min-height: 0;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 200px;
  background: #ffffff;
  border-right: 1px solid #e8eaed;
  display: flex;
  flex-direction: column;
  padding: 24px 12px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 28px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 16px;
}

.logo-circle {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}

.logo-text { font-weight: 700; font-size: 13.5px; color: #1e293b; line-height: 1.2; }

.sidebar-nav { flex: 1; }
.sidebar-nav ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: #f1f5f9; color: #1e293b; }
.nav-item.active { background: #eff6ff; color: #2563eb; }

.nav-icon {
  width: 17px; height: 17px;
  min-width: 17px; min-height: 17px;
  max-width: 17px; max-height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  display: block;
}

.sidebar-footer { padding-top: 16px; border-top: 1px solid #f1f5f9; }
.nav-item.logout { color: #ef4444; }
.nav-item.logout:hover { background: #fef2f2; color: #dc2626; }

/* ── MAIN ── */
.main {
  margin-left: 200px;
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.dashboard-body .main {
  height: 100%;
  min-height: 0;
}

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
  flex-shrink: 0;
}

.page-title { font-size: 22px; font-weight: 700; color: #0f172a; }

.topbar-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.filter-dropdown { position: relative; display: flex; align-items: center; }

.filter-dropdown select {
  appearance: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 32px 8px 12px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  color: #374151;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.filter-dropdown select:focus { border-color: #3b82f6; }

.dropdown-arrow {
  position: absolute;
  right: 10px;
  width: 14px; height: 14px;
  min-width: 14px; max-width: 14px;
  pointer-events: none;
  color: #64748b;
  display: block;
}

.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0 12px;
  gap: 7px;
  transition: border-color 0.15s;
}
.search-box:focus-within { border-color: #3b82f6; }

.search-icon { width: 15px; height: 15px; min-width: 15px; max-width: 15px; color: #94a3b8; flex-shrink: 0; display: block; }

.search-box input {
  border: none; outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  padding: 8px 0;
  width: 180px;
  color: #374151;
  background: transparent;
}
.search-box input::placeholder { color: #b0bad0; }

.btn-add {
  display: flex; align-items: center; gap: 7px;
  background: #2563eb; color: white;
  border: none; border-radius: 8px;
  padding: 9px 16px;
  font-size: 13.5px; font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}
.btn-add svg { width: 16px; height: 16px; min-width: 16px; max-width: 16px; display: block; }
.btn-add:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37,99,235,0.35); }
.hidden { display: none !important; }

/* ── TABLE ── */
.table-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e8eaed;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.dashboard-body .table-card {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; }
thead tr { background: #f8fafc; }

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  box-shadow: 0 1px 0 #f1f5f9;
}

td {
  padding: 14px 16px;
  font-size: 13.5px;
  color: #374151;
  border-bottom: 1px solid #f8fafc;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

td.id-cell   { color: #94a3b8; font-size: 13px; }
td.name-cell { font-weight: 600; color: #0f172a; }
td.stock-low { color: #ef4444; font-weight: 600; }
td.stock-ok  { color: #22c55e; font-weight: 600; }
.critical-tag {
  color: #ef4444;
  font-weight: 700;
  margin-left: 4px;
}
.order-products-cell {
  max-width: 260px;
  white-space: normal;
  line-height: 1.5;
}
tr.order-line-subrow td {
  background: #fafbfc;
  border-top: none;
}
td.order-actions-cell {
  vertical-align: middle;
}
td.order-qty-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}
.status-pending {
  background: #ffedd5;
  color: #c2410c;
}
.status-successful {
  background: #dcfce7;
  color: #15803d;
}
.status-cancelled {
  background: #fee2e2;
  color: #b91c1c;
}
.action-btn.complete {
  background: #ecfdf5;
  color: #16a34a;
}
.action-btn.complete:hover {
  background: #dcfce7;
}
.action-btn.cancel {
  background: #fff7ed;
  color: #ea580c;
}
.action-btn.cancel:hover {
  background: #ffedd5;
}

.empty-row td { text-align: center; color: #94a3b8; padding: 48px; font-size: 14px; }

.action-btn {
  width: 32px; height: 32px;
  border: none; border-radius: 7px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s;
  margin-right: 4px;
}
.action-btn:active { transform: scale(0.94); }
.action-btn.edit   { background: #eff6ff; color: #3b82f6; }
.action-btn.delete { background: #fef2f2; color: #ef4444; }
.action-btn.edit:hover   { background: #dbeafe; }
.action-btn.delete:hover { background: #fee2e2; }
.action-btn svg {
  width: 15px; height: 15px; min-width: 15px; max-width: 15px;
  stroke: currentColor; display: block;
  pointer-events: none;
}

/* ── MODAL BASE ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  animation: modalIn 0.2s ease;
}

.modal-sm { width: 380px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h2 { font-size: 17px; font-weight: 700; color: #0f172a; }

.modal-close {
  background: none; border: none;
  font-size: 22px; color: #94a3b8;
  cursor: pointer; line-height: 1;
  padding: 2px 6px; border-radius: 4px;
}
.modal-close:hover { background: #f1f5f9; color: #374151; }

/* ── CHOICE MODAL ── */
.modal-choice { width: 440px; }
.modal-order { width: 620px; }

.choice-buttons { display: flex; flex-direction: column; gap: 12px; }

.choice-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  font-family: 'Inter', sans-serif;
}
.choice-btn:hover { border-color: #3b82f6; background: #eff6ff; box-shadow: 0 2px 8px rgba(59,130,246,0.1); }
.choice-btn svg { flex-shrink: 0; color: #3b82f6; }
.choice-btn span { font-size: 14px; font-weight: 600; color: #0f172a; display: block; }
.choice-btn small { font-size: 12px; color: #64748b; display: block; margin-top: 2px; }

/* ── FORM ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
  font-size: 12px; font-weight: 600;
  color: #64748b; letter-spacing: 0.03em;
}

.form-group input,
.form-group select {
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}
.form-group input:focus,
.form-group select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* New category row */
.new-category-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.new-category-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 7px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  color: #374151;
}
.new-category-row input:focus { border-color: #3b82f6; border-style: solid; }

.btn-add-cat {
  padding: 7px 13px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #2563eb;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-add-cat:hover { background: #dbeafe; }
.order-products-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 10px;
}
.order-products-header label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.03em;
}
.order-line {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 10px;
  margin-bottom: 10px;
}
.btn-line-remove {
  border: 1px solid #fee2e2;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
}
.btn-line-remove:hover {
  background: #fee2e2;
}

/* Delete message */
.delete-msg {
  font-size: 14px;
  color: #374151;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ── MODAL ACTIONS ── */
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.btn-cancel {
  padding: 9px 18px;
  border: 1px solid #e2e8f0;
  background: #fff; border-radius: 8px;
  font-size: 13.5px; font-family: 'Inter', sans-serif;
  font-weight: 500; color: #64748b; cursor: pointer;
}
.btn-cancel:hover { background: #f8fafc; }

.btn-submit {
  padding: 9px 20px;
  background: #2563eb; color: white;
  border: none; border-radius: 8px;
  font-size: 13.5px; font-family: 'Inter', sans-serif;
  font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.btn-submit:hover { background: #1d4ed8; }

.btn-danger {
  padding: 9px 20px;
  background: #ef4444; color: white;
  border: none; border-radius: 8px;
  font-size: 13.5px; font-family: 'Inter', sans-serif;
  font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #dc2626; }