:root {
  /* Neutral scale - Slate family, single consistent cool-grey base */
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --border: #e2e2e2;
  --border-light: #eeeeee;
  --text: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;

  /* Accent - Professional blue, B2B management style */
  --accent: #4a90e2;
  --accent-hover: #3a7fd4;
  --accent-soft: #eef4fc;
  --accent-border: #b8d4f0;

  /* Semantic */
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --info: #6366f1;
  --info-soft: #eef2ff;

  /* Shape - small radius per reference */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows - minimal, flat design per reference */
  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 2px 8px rgba(0,0,0,0.08);

  --sidebar-bg: #2c3e50;
  --sidebar-text: #b0bec5;
  --sidebar-active: #4a90e2;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --transition: 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 232px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 0 24px 28px;
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-brand::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; list-style: none; display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }

.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }

.sidebar-nav a.active {
  background: rgba(13,148,136,0.12);
  color: #ccfbf1;
}

.sidebar-nav .icon { font-size: 16px; width: 22px; text-align: center; line-height: 1; }

.sidebar-footer {
  padding: 16px 24px 0;
  margin: 0 12px;
  border-top: 1px solid rgba(148,163,184,0.12);
  font-size: 11.5px;
  color: var(--sidebar-text);
  letter-spacing: 0.3px;
}

/* ===== Main content ===== */
.main {
  margin-left: 232px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-wrapper {
  max-width: 1200px;
  width: 100%;
}

/* ===== Content area ===== */
#content { padding: 28px; flex: 1; }
@media (min-width: 1440px) { #content { padding: 32px 40px; } }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

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

.topbar-actions .user-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 18px; height: 40px;
  border: none; border-radius: 6px;
  font-size: 14px; font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
  letter-spacing: -0.1px;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: #111111; color: #fff; }
.btn-primary:hover { background: #2a2a2a; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-outline {
  background: var(--surface);
  border: 1px solid #E6E6E6;
  color: #1A1A1A;
}
.btn-outline:hover { background: #f5f5f5; border-color: #d0d0d0; }

.btn-sm { padding: 0 14px; height: 32px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-xs { padding: 0 10px; height: 26px; font-size: 12px; border-radius: var(--radius-sm); }

/* ===== Stats cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-sm); }

.stat-card .stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ===== Cards & tables ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

.card-body { padding: 22px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--bg);
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

tr:last-child td { border-bottom: none; }

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

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Status badges ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1px;
  line-height: 1.6;
}

.badge-draft { background: #e5e7eb; color: #4b5563; font-weight: 600; }
.badge-created { background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.badge-approved { background: #d1fae5; color: #047857; font-weight: 600; }
.badge-captured, .badge-paid { background: #d1fae5; color: #065f46; font-weight: 600; }
.badge-refunded { background: #fee2e2; color: #b91c1c; font-weight: 600; }
.badge-cancelled { background: #fef3c7; color: #a16207; font-weight: 600; }
.badge-pending { background: #fed7aa; color: #c2410c; font-weight: 600; }
.badge-shipped { background: #cffafe; color: #0e7490; font-weight: 600; }

/* ===== Filters ===== */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 18px;
}

.filters input, .filters select {
  padding: 0 12px; height: 40px;
  border: 1px solid #E6E6E6;
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  color: #1A1A1A;
  background: var(--surface);
  transition: border-color var(--transition);
}

.filters input:focus, .filters select:focus {
  outline: none;
  border-color: #111111;
  box-shadow: none;
}

.filters input::placeholder { color: var(--text-muted); }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  min-width: 380px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: auto;
  resize: both;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(15,23,42,0.05);
  animation: modalIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #eaeaea;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: var(--surface);
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.modal-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: #8c8c8c;
  padding: 4px; line-height: 1;
  border-radius: 6px;
  transition: all var(--transition);
}

.modal-close:hover { background: #f5f5f5; color: #1f1f1f; }

.modal-body {
  padding: 40px 48px;
  overflow-y: auto;
  flex: 1;
  background: var(--surface);
}

.modal-footer {
  padding: 16px 32px 24px 32px;
  border-top: 1px solid #eaeaea;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 400;
  margin-bottom: 12px;
  color: #8c8c8c;
  letter-spacing: 0.1px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font);
  color: #1f1f1f;
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: #111111;
  box-shadow: none;
}

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

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  animation: toastIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  letter-spacing: -0.1px;
}

.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: #4f46e5; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Login page ===== */
.login-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  display: none;
  background: var(--danger-soft);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-weight: 500;
}

/* ===== Pagination ===== */
.pagination {
  display: flex; gap: 4px; justify-content: center; margin-top: 18px;
}

.pagination button {
  min-width: 36px; height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.pagination button:hover:not(:disabled):not(.active) {
  background: var(--bg);
  border-color: #cbd5e1;
}

.pagination button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

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

.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; font-weight: 500; }

/* ===== Tracking section ===== */
.tracking-section {
  background: #F5F5F5;
  border: none;
  border-radius: 12px;
  padding: 20px;
  margin-top: 32px;
}

/* Override form spacings inside tracking section (tighter) */
.tracking-section .form-group { margin-bottom: 20px; }

/* Notes display in detail modal */
.notes-display {
  margin-top: 4px;
  padding: 12px 16px;
  background: #F5F5F5;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ===== Summary bar ===== */
.summary-bar {
  padding: 14px 18px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.summary-bar strong { color: var(--text); font-weight: 600; }

/* ===== Order cards ===== */
.order-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 12px;
  transition: background var(--transition), box-shadow var(--transition);
  gap: 24px;
}

.order-card:hover { background: var(--surface-hover); box-shadow: var(--shadow-sm); }

.order-card-left { flex: 1; min-width: 0; }

.order-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}

.order-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  font-size: 13px;
  color: var(--text-secondary);
}

.order-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.order-card-meta strong {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11.5px;
}

.order-card-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.order-card-right .btn { white-space: nowrap; }

@media (max-width: 640px) {
  .order-card { flex-direction: column; padding: 18px; }
  .order-card-right { flex-direction: row; align-items: center; }
  .order-card-meta { gap: 6px 18px; }
}

/* ===== Custom scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: #d0d0d0 transparent; }

/* ===== Loading skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--border-light) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { width: 64px; padding: 20px 0; }
  .sidebar-brand { font-size: 0; padding: 0 20px 20px; justify-content: center; }
  .sidebar-nav a { justify-content: center; padding: 10px; font-size: 0; }
  .sidebar-nav .icon { font-size: 20px; margin: 0; }
  .sidebar-footer { display: none; }
  .main { margin-left: 64px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  #content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input { width: 100% !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sidebar { width: 56px; }
  .main { margin-left: 56px; }
  .login-card { padding: 28px 20px; }
}
