

  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=DM+Mono:wght@400;500&display=swap');

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

  :root {
    --bg:           #f0f4ff;
    --surface:      #ffffff;
    --primary:      #8bb8f8;
    --primary-dark: #5a91e8;
    --secondary:    #b8e0d2;
    --accent:       #ffd6e0;
    --text:         #2d3436;
    --muted:        #7f8c8d;
    --border:       #e0e6f0;
    --success-bg:   #c8f7c5;
    --success-text: #1a4a18;
    --danger-bg:    #ffb3ba;
    --danger-text:  #4a1018;
    --warn-bg:      #fff0d9;
    --warn-text:    #7a4a00;
    --info-bg:      #eaf2ff;
    --info-text:    #174a9c;
    --positive:     #0052cc;
    --negative:     #e63939;
    --radius:       14px;
    --shadow:       0 2px 16px rgba(120,160,220,0.12);
    --shadow-sm:    0 1px 8px rgba(120,160,220,0.08);
    --font:         'DM Sans', sans-serif;
    --mono:         'DM Mono', monospace;
    --fast:         150ms;
    --base:         250ms;
  }

  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
  }

  input, select, textarea, button { font-family: var(--font); font-size: 14px; }

  /* ── CARD ── */
  .card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    border: 1px solid var(--border);
  }
  .card-sm { padding: 14px 16px; border-radius: 12px; }

  /* ── FORM ELEMENTS ── */
  label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 5px;
  }

  input[type=text], input[type=password], input[type=number],
  input[type=email], input[type=datetime-local], select, textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--fast), background var(--fast), box-shadow var(--fast);
    appearance: none;
    -webkit-appearance: none;
  }
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237F8C8D' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
  }
  input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(139,184,248,.18);
  }
  input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
  textarea { resize: vertical; min-height: 80px; }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  @media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
  .field { margin-bottom: 14px; }

  /* ── BUTTONS ── */
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px; padding: 10px 20px; border: none; border-radius: 10px;
    font-weight: 600; font-size: 14px; cursor: pointer;
    transition: background var(--fast), transform var(--fast), color var(--fast);
    letter-spacing: .01em; white-space: nowrap; text-decoration: none;
  }
  .btn:active { transform: scale(.97); }
  .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
  .btn-primary   { background: var(--primary); color: #1a2a4a; }
  .btn-primary:hover { background: var(--primary-dark); color: #fff; }
  .btn-secondary { background: var(--surface); border: 1.5px solid var(--border); color: var(--text); }
  .btn-secondary:hover { border-color: var(--primary); }
  .btn-ghost     { background: transparent; color: var(--muted); padding: 8px 12px; }
  .btn-ghost:hover { background: var(--bg); color: var(--text); }
  .btn-danger    { background: var(--danger-text, #c0392b); color: #fff; border-color: transparent; }
  .btn-danger:hover { background: #a93226; }
  .btn-sm  { padding: 6px 14px; font-size: 12px; }
  .btn-full { width: 100%; }
  .btn-icon { padding: 8px; border-radius: 10px; }

  /* ── BADGE ── */
  .badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
  }
  .badge-success { background: var(--success-bg); color: var(--success-text); }
  .badge-error   { background: var(--danger-bg);  color: var(--danger-text); }
  .badge-warning { background: var(--warn-bg);    color: var(--warn-text); }
  .badge-info    { background: var(--info-bg);    color: var(--info-text); }
  .badge-neutral { background: var(--bg); border: 1px solid var(--border); color: var(--muted); }

  /* ── SPINNER ── */
  .spinner {
    display: inline-block; width: 15px; height: 15px;
    border: 2px solid var(--border); border-top-color: var(--primary-dark);
    border-radius: 50%; animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ── TOAST ── */
  .toast {
    position: fixed; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(12px);
    padding: 11px 22px; border-radius: 10px; font-weight: 500; font-size: 14px;
    opacity: 0; transition: opacity var(--base), transform var(--base);
    z-index: 9999; max-width: 90vw; text-align: center; pointer-events: none;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  .toast.success { background: var(--success-bg); color: var(--success-text); }
  .toast.error   { background: var(--danger-bg);  color: var(--danger-text); }
  .toast.info    { background: var(--info-bg);     color: var(--info-text); }
  @media (min-width: 769px) { .toast { bottom: 24px; } }

  /* ── MODAL ── */
  .modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,40,.5); backdrop-filter: blur(4px);
    z-index: 1000; align-items: flex-end; justify-content: center;
  }
  .modal-overlay.open { display: flex; animation: fadeIn var(--fast) ease; }
  @media (min-width: 600px) { .modal-overlay { align-items: center; padding: 20px; } }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px 20px 0 0; box-shadow: 0 4px 32px rgba(120,160,220,0.18);
    width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
    padding: 24px 20px; animation: slideUp var(--base) ease;
  }
  @media (min-width: 600px) { .modal { border-radius: 20px; } }
  @keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  .modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
  .modal-title  { font-size: 18px; font-weight: 700; }
  .modal-close  {
    background: var(--bg); border: none; border-radius: 999px;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; color: var(--muted);
    transition: background var(--fast);
  }
  .modal-close:hover { background: var(--border); color: var(--text); }
  .modal-footer {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
  }

  /* ── ITEM ROW ── */
  .item-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px;
  }
  .item-row:last-child { border-bottom: none; }
  .cat-item-row:hover { background: var(--bg); }
  .item-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .item-sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .item-left { flex: 1; min-width: 0; }
  .item-right { text-align: right; flex-shrink: 0; }
  .price { font-family: var(--mono); font-size: 14px; font-weight: 600; }
  .mono { font-family: var(--mono); }

  /* ── METRICS GRID ── */
  .metrics-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .metric-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
  .metric-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
  .metric-value { font-family: var(--mono); font-size: 20px; font-weight: 700; line-height: 1.2; }
  .metric-value.positive { color: var(--positive); }
  .metric-value.negative { color: var(--negative); }

  /* ── ORDER ITEM ROWS ── */
  .order-items-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
  .order-item-entry {
    position: relative;
    display: flex; flex-direction: column; gap: 8px;
    background: var(--bg); padding: 10px; padding-right: 44px;
    border-radius: 10px; border: 1px solid var(--border);
  }
  .remove-item-btn {
    position: absolute; top: 8px; right: 8px;
    background: var(--danger-bg); color: var(--danger-text); border: none;
    border-radius: 8px; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px;
  }
  .add-item-btn {
    width: 100%; margin-top: 8px; padding: 8px;
    border: 1.5px dashed var(--primary); border-radius: 10px;
    background: rgba(139,184,248,.08); color: var(--primary-dark);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background var(--fast); font-family: var(--font);
  }
  .add-item-btn:hover { background: rgba(139,184,248,.16); }

  /* ── EMPTY STATE ── */
  .empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
  .empty-icon  { font-size: 40px; margin-bottom: 12px; }
  .empty-text  { font-size: 15px; font-weight: 500; }
  .empty-sub   { font-size: 13px; margin-top: 4px; }

  /* ── PROGRESS BAR ── */
  .progress-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 6px; }
  .progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width var(--base); }
  .progress-fill.full { background: var(--success-text); }

  /* ── PILL TABS ── */
  .pill-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
  .pill-tab {
    padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
    cursor: pointer; border: 1.5px solid var(--border); background: transparent;
    color: var(--muted); transition: all var(--fast); font-family: var(--font);
  }
  .pill-tab.active { background: var(--primary); border-color: var(--primary); color: #1a2a4a; }

  /* ── GLOBAL TOOLTIPS ── */
  .tooltip-icon {
    width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border, #d9e1ea); border-radius: 999px;
    background: #f8fbff; color: var(--text-muted, #6b7280);
    font-size: 11px; font-weight: 600; line-height: 1; cursor: help; user-select: none;
    transition: border-color var(--fast), background var(--fast), color var(--fast), transform var(--fast);
  }
  .tooltip-icon:hover { border-color: var(--primary, #2563eb); background: #eef5ff; color: var(--primary-dark, #1e40af); }
  .tooltip-icon:active { transform: scale(.96); }
  .tooltip-icon:focus-visible { outline: 2px solid var(--primary, #2563eb); outline-offset: 1px; }

  #globalTooltip {
    position: fixed; z-index: 99999; width: 220px; padding: 8px 12px; border-radius: 10px;
    background: var(--surface, #ffffff); border: 1px solid var(--border, #d9e1ea);
    box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.12)); color: var(--text, #111827);
    font-size: 12px; line-height: 1.5; pointer-events: none; opacity: 0; transition: opacity var(--fast);
  }
  #globalTooltip::after {
    content: ''; position: absolute; width: 10px; height: 10px;
    background: var(--surface, #ffffff); border-right: 1px solid var(--border, #d9e1ea);
    border-bottom: 1px solid var(--border, #d9e1ea); transform: translateX(-50%) rotate(45deg);
    left: var(--arrow-left, 50%); bottom: -6px;
  }
  #globalTooltip.arrow-below::after { top: -6px; bottom: auto; transform: translateX(-50%) rotate(225deg); }
  #globalTooltip.visible { opacity: 1; }

  /* ── DELIVERY CHECKLIST ── */
  .delivery-checklist { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 240px; overflow-y: auto; }
  .delivery-check-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    background: var(--bg); border-radius: 10px; border: 1.5px solid var(--border);
    cursor: pointer; transition: border-color var(--fast);
  }
  .delivery-check-row:has(input:checked) { border-color: var(--primary); background: rgba(139,184,248,.08); }
  .delivery-check-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary-dark); cursor: pointer; flex-shrink: 0; }

  /* ── LOADING ── */
  .loading-row { display: flex; align-items: center; justify-content: center; padding: 32px; gap: 10px; color: var(--muted); font-size: 13px; }

  /* ── SECTION HEADER ── */
  .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
  .section-title  { font-size: 18px; font-weight: 700; }

  /* ── SCROLLBAR ── */
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  /* ── SVG ICONS ── */
  .svg-icon { width: 1.1em; height: 1.1em; display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
