/* Shared look for every screen. Phone first; tablet from 768px, desktop from 1100px.
   Colours follow Apple's system greys: grey page, white rounded groups without borders,
   thin separators, one tint colour for actions. */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #e9e9ee;
  --surface-3: #dcdce1;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: #e3e3e8;
  --line-strong: #d1d1d6;
  --fill: rgba(118, 118, 128, 0.12);
  --accent: #146c55;
  --accent-hover: #0f5a47;
  --accent-text: #ffffff;
  --accent-soft: #e1f0ea;
  --warn: #9a5800;
  --warn-soft: #fcefdc;
  --danger: #b3261e;
  --danger-soft: #fbe5e3;
  --ok: #2e7d32;
  --can: #1d5fa8;
  --can-soft: #e2ecf8;
  --bottle: #7a4a12;
  --bottle-soft: #f4e8d6;
  --photo-bg: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: none;
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --text: #ffffff;
    --muted: #98989f;
    --line: #2c2c2e;
    --line-strong: #3a3a3c;
    --fill: rgba(118, 118, 128, 0.24);
    --accent: #4cc3a1;
    --accent-hover: #6dd3b4;
    --accent-text: #08201a;
    --accent-soft: #17352d;
    --warn: #f0a548;
    --warn-soft: #3a2a14;
    --danger: #f28b82;
    --danger-soft: #3d1f1d;
    --ok: #81c784;
    --can: #8ab8ee;
    --can-soft: #1b2a3c;
    --bottle: #e0b27a;
    --bottle-soft: #382a17;
    --photo-bg: #ffffff;
    --shadow: none;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 750; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---- buttons & fields ---- */
/* Buttons as on iOS: grey fill without a border (secondary), solid tint (primary), plain (ghost). */
button, .btn {
  font: inherit; font-weight: 600;
  border: 1px solid transparent;
  background: var(--fill);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 16px;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
button:hover:not(:disabled), .btn:hover { background: color-mix(in srgb, var(--fill) 100%, var(--text) 6%); }
button:active:not(:disabled), .btn:active { opacity: 0.7; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 650; }
button.primary:hover:not(:disabled), .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger, .btn.danger { color: var(--danger); background: var(--danger-soft); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; }
button.ghost:hover, .btn.ghost:hover { background: var(--fill); }
button.block, .btn.block { width: 100%; }
button.big, .btn.big { min-height: 50px; font-size: 17px; padding: 12px 20px; border-radius: 14px; }
button.sm, .btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 44px; width: 100%;
}
/* Search fields look like the iOS search bar: grey fill, no border. */
input[type="search"] { border-color: transparent; padding-left: 38px; background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field + .field { margin-top: 14px; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 0; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
/* Grouped containers have no outline, like inset grouped lists on iOS (screens add .list/.pcard/... to this). */
.list, .pcard, .prod, .stat, .tile { border-color: transparent !important; }
.pcard .pic, .prod .pic { border-bottom: 0 !important; }
.badge { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge.open, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.done, .badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.cancelled, .badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.pkg-can { background: var(--can-soft); color: var(--can); }
.badge.pkg-bottle { background: var(--bottle-soft); color: var(--bottle); }

.thumb {
  width: 56px; height: 56px; border-radius: var(--radius-sm); flex: none;
  background: var(--photo-bg); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-weight: 700; font-size: 20px; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }

/* Product picture box: white, picture fitted (supplier photos are cut-outs). */
.pic { aspect-ratio: 1 / 1; background: var(--photo-bg); display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; color: #b8b2a7; font-size: 44px; font-weight: 800; }
.pic img { width: 100%; height: 100%; object-fit: contain; padding: 8%; }
.pic .badge { position: absolute; top: 10px; left: 10px; }
.pic .corner { position: absolute; top: 10px; right: 10px; }
.pic .size-badge { position: absolute; top: auto; bottom: 10px; left: 10px; font-size: 15px; padding: 4px 10px; background: var(--accent, #2a7); color: #fff; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { min-height: 36px; padding: 4px 14px; border-radius: 99px; white-space: nowrap; font-size: 15px; font-weight: 550; background: var(--fill); border-color: transparent; }
.chips button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Segmented control (iOS): grey track, the chosen part is a raised pill. */
.seg { display: flex; gap: 2px; background: var(--fill); padding: 2px; border-radius: 10px; }
.seg button { flex: 1; border: 0; background: transparent; min-height: 34px; padding: 4px 10px; border-radius: 8px; font-size: 15px; font-weight: 550; }
.seg button:hover:not(:disabled) { background: transparent; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14), 0 0 0 0.5px rgba(0, 0, 0, 0.04); font-weight: 650; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: #636366; } }

.stepper { display: inline-flex; align-items: center; border: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--fill); }
.stepper button { border: 0; border-radius: 0; min-width: 44px; min-height: 40px; font-size: 20px; padding: 0; background: transparent; }
.stepper input { background: transparent; }
.stepper input { border: 0; border-radius: 0; width: 56px; min-height: 40px; text-align: center; padding: 0; font-weight: 650; -moz-appearance: textfield; }
.stepper input:focus { outline: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 12px; z-index: 100; font-weight: 550;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
.toast.error { background: var(--danger); color: #fff; }
@media (min-width: 768px) { .toast { bottom: 28px; } }

.modal-back { position: fixed; inset: 0; background: rgba(15, 14, 12, 0.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--bg); width: 100%; max-width: 600px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg);
}
@media (min-width: 768px) { .modal-back { align-items: center; padding: 24px; } .modal { border-radius: 18px; padding: 22px; } }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
select.lang { width: auto; min-height: 36px; padding: 4px 8px; font-size: 14px; }
