/* ========================================
   Hielos Iceman - Dark Theme, Mobile-First
   ======================================== */

/* --- CSS Variables --- */
:root {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-tertiary: #334155;
  --color-surface: #1e293b;
  --color-surface-hover: #263548;
  --color-border: #334155;
  --color-border-light: #475569;

  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: rgba(37, 99, 235, 0.15);

  --color-success: #10b981;
  --color-success-hover: #059669;
  --color-success-light: rgba(16, 185, 129, 0.15);

  --color-warning: #f59e0b;
  --color-warning-hover: #d97706;
  --color-warning-light: rgba(245, 158, 11, 0.15);

  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-danger-light: rgba(239, 68, 68, 0.15);

  --color-orange: #f97316;
  --color-orange-light: rgba(249, 115, 22, 0.15);

  --color-emerald: #34d399;
  --color-emerald-light: rgba(52, 211, 153, 0.15);

  /* Status colors */
  --status-pending: #f59e0b;
  --status-pending-bg: rgba(245, 158, 11, 0.15);
  --status-assigned: #2563eb;
  --status-assigned-bg: rgba(37, 99, 235, 0.15);
  --status-in_delivery: #f97316;
  --status-in_delivery-bg: rgba(249, 115, 22, 0.15);
  --status-delivered: #10b981;
  --status-delivered-bg: rgba(16, 185, 129, 0.15);
  --status-confirmed: #34d399;
  --status-confirmed-bg: rgba(52, 211, 153, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  --sidebar-width: 260px;
  --topbar-height: 56px;
  --bottom-nav-height: 64px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

ul, ol {
  list-style: none;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* --- Typography --- */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-primary { color: var(--color-primary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-small { font-size: 0.85rem; }
.text-large { font-size: 1.2rem; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }

/* --- Layout Utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.p-sm { padding: 8px; }
.p-md { padding: 16px; }
.p-lg { padding: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--color-border-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-body {
  color: var(--color-text-secondary);
}

.card-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

/* Stat cards */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.stat-card.stat-pending { border-left: 3px solid var(--status-pending); }
.stat-card.stat-assigned { border-left: 3px solid var(--status-assigned); }
.stat-card.stat-in_delivery { border-left: 3px solid var(--status-in_delivery); }
.stat-card.stat-delivered { border-left: 3px solid var(--status-delivered); }
.stat-card.stat-confirmed { border-left: 3px solid var(--status-confirmed); }
.stat-card.stat-revenue { border-left: 3px solid var(--color-emerald); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-pending {
  background: var(--status-pending-bg);
  color: var(--status-pending);
}

.badge-assigned {
  background: var(--status-assigned-bg);
  color: var(--status-assigned);
}

.badge-in_delivery {
  background: var(--status-in_delivery-bg);
  color: var(--status-in_delivery);
}

.badge-delivered {
  background: var(--status-delivered-bg);
  color: var(--status-delivered);
}

.badge-confirmed {
  background: var(--status-confirmed-bg);
  color: var(--status-confirmed);
}

.badge-active {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-inactive {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-success {
  background: var(--color-success);
  color: white;
}
.btn-success:hover:not(:disabled) {
  background: var(--color-success-hover);
}

.btn-warning {
  background: var(--color-warning);
  color: #1a1a1a;
}
.btn-warning:hover:not(:disabled) {
  background: var(--color-warning-hover);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border-light);
  color: var(--color-text);
}
.btn-outline:hover:not(:disabled) {
  background: var(--color-bg-tertiary);
  border-color: var(--color-text-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-xl {
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
  width: 100%;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  line-height: 1;
  min-width: 36px;
  min-height: 36px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.8rem;
  color: var(--color-danger);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* --- Tables --- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th {
  background: var(--color-bg-tertiary);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-top: 1px solid var(--color-border);
  vertical-align: middle;
}

.table tr:hover td {
  background: var(--color-surface-hover);
}

.table-clickable tr {
  cursor: pointer;
}

/* Mobile: card-style table */
.table-responsive-cards {
  display: none;
}

/* --- Sidebar (Admin) --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
  font-size: 1.5rem;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.sidebar-link:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.sidebar-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.sidebar-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--color-border);
}

.sidebar-user {
  padding: 8px 14px;
  margin-bottom: 4px;
}

.sidebar-user-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.logout-link {
  color: var(--color-danger) !important;
}

/* --- Top bar --- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
}

.topbar-menu {
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
}

.topbar-logo {
  font-size: 1.3rem;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- Bottom Nav (Driver) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  padding: 8px 16px;
  text-decoration: none;
  transition: color var(--transition);
}

.bottom-nav-item.active {
  color: var(--color-primary);
}

.bottom-nav-icon {
  font-size: 1.3rem;
}

.bottom-nav-label {
  font-weight: 600;
}

/* --- Main content areas --- */
.main-content {
  min-height: 100vh;
}

.admin-content {
  padding: calc(var(--topbar-height) + 16px) 16px 16px;
}

.driver-content {
  padding: calc(var(--topbar-height) + 16px) 16px calc(var(--bottom-nav-height) + 16px);
}

.auth-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Login page --- */
.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  font-size: 3rem;
  margin-bottom: 8px;
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* --- Order cards (driver view) --- */
.order-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.order-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.order-card:active {
  transform: scale(0.99);
}

.order-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.order-card-venue {
  font-weight: 600;
  font-size: 1rem;
}

.order-card-id {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.order-card-items {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.order-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.order-card-time {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--color-border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-border);
  border: 2px solid var(--color-bg);
}

.timeline-dot.active {
  background: var(--color-primary);
}

.timeline-dot.completed {
  background: var(--color-success);
}

.timeline-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* --- Filters bar --- */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-chip:hover {
  border-color: var(--color-text-muted);
}

.filter-chip.active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* --- Signature pad --- */
.signature-pad-container {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: var(--color-bg);
  touch-action: none;
}

.signature-pad-container canvas {
  display: block;
  width: 100%;
  height: 200px;
}

.signature-pad-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
  gap: 8px;
}

/* --- Photo upload --- */
.photo-upload {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition);
}

.photo-upload:hover {
  border-color: var(--color-primary);
}

.photo-upload-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.photo-upload-text {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.photo-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-top: 12px;
}

/* --- Toast notifications --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100% - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease forwards;
  font-size: 0.9rem;
  min-width: 250px;
}

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

.toast-success { border-left: 3px solid var(--color-success); }
.toast-error { border-left: 3px solid var(--color-danger); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info { border-left: 3px solid var(--color-primary); }

.toast-icon { font-size: 1.2rem; }
.toast-message { flex: 1; }
.toast-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 1rem;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* --- Section title --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 1rem;
  margin-bottom: 16px;
}

/* --- Quick actions grid --- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.quick-action-btn:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
}

.quick-action-icon {
  font-size: 1.5rem;
}

/* --- Detail list --- */
.detail-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.detail-value {
  font-weight: 600;
  text-align: right;
}

/* --- Product line (order items) --- */
.product-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.product-qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
}

.qty-btn:hover {
  border-color: var(--color-primary);
}

.qty-input {
  width: 50px;
  text-align: center;
  padding: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.95rem;
}

/* --- Report summary --- */
.report-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* --- Loading spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--color-text-muted);
}

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}

/* ========================================
   Responsive: Tablet (768px+)
   ======================================== */
@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .form-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal {
    max-width: 560px;
    border-radius: var(--radius-lg);
    margin: auto;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal {
    transform: translateY(20px);
  }

  .modal-overlay.open .modal {
    transform: translateY(0);
  }

  .report-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   Responsive: Desktop (1024px+)
   ======================================== */
@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0);
    border-right: 1px solid var(--color-border);
  }

  .sidebar-close {
    display: none;
  }

  .sidebar-overlay {
    display: none;
  }

  .topbar {
    left: var(--sidebar-width);
  }

  .topbar-menu {
    display: none;
  }

  .admin-content {
    margin-left: var(--sidebar-width);
  }

  .stats-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .modal {
    max-width: 640px;
  }

  .table-responsive-cards {
    display: none !important;
  }

  .report-summary {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ========================================
   Print styles
   ======================================== */
@media print {
  .sidebar, .topbar, .bottom-nav, .btn, .toast-container, .modal-overlay {
    display: none !important;
  }
  .main-content {
    padding: 0 !important;
    margin: 0 !important;
  }
  body {
    background: white;
    color: black;
  }
  .card {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}

/* Emoji fallback */
.sidebar-icon, .bottom-nav-icon, .empty-icon, .empty-state-icon {
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Segoe UI Symbol', sans-serif;
}

/* Sidebar scrollable + footer always visible */
.sidebar {
  display: flex;
  flex-direction: column;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
}
.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding: 12px 16px;
  flex-shrink: 0;
}

/* Compact sidebar for mobile */
@media (max-width: 768px) {
  .sidebar { height: 100vh; height: 100dvh; }
  .sidebar-header { padding: 12px 16px; }
  .sidebar-nav { padding: 4px 0; }
  .sidebar-link { padding: 10px 16px; font-size: 0.9rem; }
  .sidebar-footer { padding: 8px 16px; }
  .sidebar-user { margin-bottom: 4px; }
  .sidebar-user-name, .sidebar-user-role { font-size: 0.8rem; }
}
