* { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, Geneva, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    min-height: 100vh;
  }

  /* ===== Theme palette (maroon #591616) ===== */
  :root {
    --brand: #591616;          /* primary  rgb(89,22,22) */
    --brand-dark: #420f0f;     /* hover / darker */
    --brand-light: #7c2222;    /* gradient end / lighter */
    --brand-50: #fbeaea;       /* very light tint */
    --brand-100: #f5d6d6;      /* light tint */
    --brand-200: #ecbcbc;      /* focus ring */
    --brand-400: #b35a5a;      /* soft border */
    --brand-ring: rgba(89,22,22,0.15); /* focus ring */
  }

  /* Custom scrollbar */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
  ::-webkit-scrollbar-thumb { background: var(--brand-400); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--brand); }

  /* Header gradient */
  .app-header {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  }

  /* Nav tab */
  .nav-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    border-radius: 8px;
    transition: all 0.3s;
    white-space: nowrap;
  }
  .nav-tab:hover { background: var(--brand-50); color: var(--brand); }
  .nav-tab.active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
    color: white;
  }

  /* Order card */
  .order-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-left: 4px solid var(--brand);
    transition: all 0.3s;
  }
  .order-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

  /* Status badges */
  .status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
  }
  /* Status colors are applied inline from Settings (see statusBadge() in script) */

  /* Filter tag */
  .filter-tag {
    padding: 6px 14px;
    border-radius: 20px;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    color: #6b7280;
  }
  .filter-tag:hover { background: #e5e7eb; }
  .filter-tag.active { background: var(--brand); color: white; }

  /* Modal */
  .modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
  }
  .modal-overlay.show { display: flex; }
  .modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  }

  /* Item entry grid */
  .item-entry {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr 0.7fr 0.9fr 1.2fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px;
    background: #f8f9ff;
    border-radius: 8px;
  }

  /* Price input row */
  .price-input-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
  }

  /* File upload area */
  .file-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
  }
  .file-upload-area:hover { border-color: var(--brand); background: var(--brand-50); }

  /* Stock image */
  .stock-image-preview {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
  }

  /* Toast */
  .toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
  }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast.success { background: #10b981; }
  .toast.error { background: #ef4444; }
  .toast.info { background: #3b82f6; }

  /* Table styles */
  .table-container { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; }
  th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
  }
  th {
    background: #f8f9ff;
    font-weight: 600;
    color: #6b7280;
    position: sticky;
    top: 0;
  }
  tr:hover { background: var(--brand-50); }
  .report-table th { background: var(--brand); color: white; }

  /* Form elements */
  .form-group { margin-bottom: 16px; }
  .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: border 0.3s;
    font-family: inherit;
    background: white;
  }
  .form-group input:focus,
  .form-group select:focus,
  .form-group textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring, rgba(89,22,22,0.15));
  }

  /* Stats */
  .stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  .stat-value { font-size: 28px; font-weight: 700; color: var(--brand); }
  .stat-label { font-size: 13px; color: #9ca3af; margin-top: 4px; }

  /* File preview */
  .file-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
  .file-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; }

  /* ===== Override Tailwind indigo/purple utilities → brand maroon ===== */
  .text-indigo-500 { color: var(--brand) !important; }
  .border-indigo-100 { border-color: var(--brand-100) !important; }
  .border-indigo-400 { border-color: var(--brand-400) !important; }
  .bg-indigo-500 { background-color: var(--brand) !important; }
  .hover\:bg-indigo-600:hover { background-color: var(--brand-dark) !important; }
  .hover\:bg-indigo-50:hover { background-color: var(--brand-50) !important; }
  .focus\:border-indigo-400:focus { border-color: var(--brand) !important; }
  .focus\:ring-indigo-200:focus { --tw-ring-color: var(--brand-200) !important; }

  /* Gradient buttons: from-indigo-500 to-purple-600 */
  .from-indigo-500 {
    --tw-gradient-from: var(--brand) !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(89,22,22,0)) !important;
  }
  .to-purple-600 { --tw-gradient-to: var(--brand-light) !important; }

  /* ===== Fallback: Tailwind build นี้ไม่มีสี amber/emerald → นิยามเอง ===== */
  .bg-amber-500 { background-color: #f59e0b; }
  .hover\:bg-amber-600:hover { background-color: #d97706; }
  .text-amber-600 { color: #d97706; }
  .bg-emerald-500 { background-color: #10b981; }
  .hover\:bg-emerald-600:hover { background-color: #059669; }
  .text-emerald-600 { color: #059669; }

  /* Responsive */
  @media (max-width: 768px) {
    .item-entry { grid-template-columns: 1fr; }
    .price-input-row { grid-template-columns: 1fr; }
    .modal { width: 95%; padding: 16px; }
  }
