  /* Dark theme: charcoal surfaces, orange accent with a soft glow.
     Status colours stay distinct from the orange accent: green = OK,
     crimson = problem, blue = international flight. */
  :root {
    --accent: #10b981;
    --accent-2: #0ea5e9;
    --accent-3: #0f766e;
    --accent-rgb: 16, 185, 129;
    --accent-2-rgb: 14, 165, 233;
    --accent-glow: rgba(14, 165, 233, 0.32);
    --bg: #06141a;
    --surface: rgba(12, 34, 44, 0.92);
    --surface-2: rgba(255, 255, 255, 0.07);
    --surface-3: rgba(255, 255, 255, 0.13);
    --ink: #eef7f8;
    --muted: #9fb4bd;
    --navy: #ffffff;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.14);
    --green-ink: #4ade80;
    --red: #ff2e4d;
    --red-bg: rgba(255, 46, 77, 0.16);
    --red-ink: #ff6b81;
    --amber: #fbbf24;
    --purple: #8b5cf6;
    --glass: linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.035));
    --glass-border: rgba(255, 255, 255, 0.16);
    --glass-blur: blur(18px) saturate(160%);
    --shine: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 40%);
    --field: rgba(255, 255, 255, 0.06);
    --option-bg: #0f2a35;
    --line: rgba(255, 255, 255, 0.14);
    --radius: 18px;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
    --intl: rgba(59, 130, 246, 0.2);
    --intl-strong: #3b82f6;
    --intl-ink: #93c5fd;
    --amber-ink: #fbbf24;
    --label: #c9c9d1;
    --placeholder: #6d6d76;
    --overlay: rgba(255, 255, 255, 0.04);
    --inset: rgba(255, 255, 255, 0.05);
    --header-bg: var(--glass);
    --bar-bg: var(--glass);
    --bg-overlay:
      radial-gradient(38% 34% at 12% 8%, rgba(16, 185, 129, 0.42), transparent 70%),
      radial-gradient(42% 38% at 92% 14%, rgba(14, 165, 233, 0.4), transparent 70%),
      radial-gradient(50% 42% at 70% 96%, rgba(20, 184, 166, 0.3), transparent 70%),
      radial-gradient(40% 40% at 4% 82%, rgba(37, 99, 235, 0.3), transparent 70%),
      linear-gradient(160deg, rgba(4, 22, 28, 0.9), rgba(5, 18, 34, 0.95));
    --pop-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    --tip-bg: rgba(12, 34, 44, 0.96);
    --sec-bg: rgba(255, 255, 255, 0.1);
    --cell-line: rgba(255, 255, 255, 0.07);
    --scrim: rgba(0, 0, 0, 0.7);
    --toast-bg: #0f2a35;
    --banner-bg: linear-gradient(135deg, rgba(255, 46, 77, 0.3), rgba(255, 46, 77, 0.12));
    color-scheme: dark;
  }

  /* Light theme: same layout and status colours, light surfaces. */
  :root[data-theme="light"] {
    --accent: #059669;
    --accent-2: #0284c7;
    --accent-3: #0f766e;
    --accent-rgb: 5, 150, 105;
    --accent-2-rgb: 2, 132, 199;
    --accent-glow: rgba(2, 132, 199, 0.25);
    --bg: #c9efdc;
    --surface: rgba(255, 255, 255, 0.95);
    --surface-2: rgba(255, 255, 255, 0.42);
    --surface-3: rgba(15, 60, 70, 0.08);
    --ink: #0f2329;
    --muted: #3f5f63;
    --navy: #06191e;
    --green: #16a34a;
    --green-bg: rgba(22, 163, 74, 0.12);
    --green-ink: #15803d;
    --red: #e11d48;
    --red-bg: rgba(225, 29, 72, 0.09);
    --red-ink: #be123c;
    --amber: #d97706;
    --amber-ink: #b45309;
    --glass: linear-gradient(135deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.22));
    --glass-border: rgba(255, 255, 255, 0.75);
    --field: rgba(255, 255, 255, 0.5);
    --option-bg: #ffffff;
    --line: rgba(10, 70, 60, 0.16);
    --shadow: 0 12px 34px rgba(15, 70, 90, 0.12);
    --intl: rgba(59, 130, 246, 0.13);
    --intl-ink: #1d4ed8;
    --label: #2c4a53;
    --placeholder: #8aa1a9;
    --overlay: rgba(15, 60, 70, 0.05);
    --inset: rgba(255, 255, 255, 0.95);
    --header-bg: var(--glass);
    --bar-bg: var(--glass);
    --bg-overlay:
      radial-gradient(40% 36% at 10% 6%, rgba(16, 185, 129, 0.55), transparent 70%),
      radial-gradient(42% 38% at 94% 12%, rgba(56, 189, 248, 0.42), transparent 70%),
      radial-gradient(52% 44% at 70% 98%, rgba(45, 212, 191, 0.5), transparent 70%),
      radial-gradient(42% 42% at 2% 80%, rgba(74, 222, 128, 0.45), transparent 70%),
      linear-gradient(155deg, rgba(209, 250, 229, 0.96), rgba(167, 243, 208, 0.94) 45%, rgba(186, 230, 253, 0.94));
    --pop-shadow: 0 14px 34px rgba(15, 70, 90, 0.16);
    --tip-bg: rgba(255, 255, 255, 0.97);
    --sec-bg: rgba(15, 60, 70, 0.07);
    --cell-line: rgba(15, 60, 70, 0.1);
    --scrim: rgba(10, 40, 50, 0.4);
    --toast-bg: #0f2a35;
    --banner-bg: linear-gradient(135deg, rgba(225, 29, 72, 0.12), rgba(225, 29, 72, 0.05));
    color-scheme: light;
  }
  * { box-sizing: border-box; }
  /* The app scrolls inside #scroller, not the window, so phones that resize
     the page when the keyboard or a picker opens never jump back to the top. */
  html, body { margin: 0; height: 100%; overflow: hidden; }
  .scroller {
    position: fixed; inset: 0; z-index: 1;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  }
  body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
  }
  /* Background: the site photo from Settings, darkened, with an orange glow at the top. */
  .bg {
    position: fixed; inset: -20px; z-index: 0;
    background: var(--bg);
    background-size: cover; background-position: center;
    /* Only a blur: the colour overlay (::after) tones the photo down, and a
       brightness/greyscale filter here would also wash out that overlay. */
    filter: blur(8px);
  }
  :root[data-theme="light"] .bg {
    transform: scale(1.04);
  }
  .bg::after {
    content: ""; position: absolute; inset: 0;
    background: var(--bg-overlay);
  }
  .shell {
    position: relative; z-index: 1;
    max-width: 1080px; margin: 0 auto; padding: 14px 16px 28px;
    display: flex; flex-direction: column; gap: 14px;
  }
  /* Crystal glass: translucent panels that blur the coloured background behind them. */
  .glass, .tabs, .view-switch, .tile, .intl-toggle, .chip, .lang, .theme-btn, .seg, .multi-panel, .alert-banner {
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
  }
  /* --shine is a soft light reflection across the top of each panel. */
  .glass {
    background: var(--shine), var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow), inset 0 1px 0 var(--inset);
  }
  [hidden] { display: none !important; }
  ::selection { background: var(--accent); color: #fff; }

  /* Header */
  .header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px;
    background: var(--header-bg);
    color: var(--navy);
  }
  .brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
  .logo-wrap {
    background: #fff; border-radius: 12px; padding: 6px 10px;
    display: flex; align-items: center; min-height: 44px;
  }
  .logo-wrap img { display: block; height: 28px; width: auto; max-width: 180px; object-fit: contain; }
  .header h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.2px; }
  .header .sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
  .today { font-size: 13px; color: var(--muted); white-space: nowrap; }
  .header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }

  /* Language switch (top-right) */
  .lang { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
  .lang button {
    font: 700 13px "Inter", sans-serif; color: var(--muted); background: transparent; border: 0;
    border-radius: 7px; padding: 7px 11px; min-width: 40px; cursor: pointer;
  }
  .lang button.on { background: var(--accent); color: #fff; }
  .header-tools { display: flex; gap: 8px; align-items: center; }
  .theme-btn {
    width: 40px; height: 40px; border-radius: 10px; cursor: pointer; display: grid; place-items: center;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  }
  .theme-btn svg { width: 19px; height: 19px; fill: currentColor; }
  .theme-btn .i-sun { display: none; }
  :root[data-theme="light"] .theme-btn .i-sun { display: block; }
  :root[data-theme="light"] .theme-btn .i-moon { display: none; }

  /* International flight toggle */
  .intl-toggle {
    display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
    padding: 14px 18px; border-radius: var(--radius); font-family: "Inter", sans-serif; color: var(--ink);
    background: var(--glass); border: 2px solid var(--glass-border); box-shadow: var(--shadow);
  }
  .intl-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); flex: none; }
  .intl-icon svg { width: 24px; height: 24px; fill: var(--muted); }
  .intl-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
  .intl-text b { font-size: 16px; color: var(--navy); }
  .intl-text small { font-size: 13px; color: var(--muted); }
  .intl-switch { width: 52px; height: 30px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; transition: background 0.15s; }
  .intl-switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4); transition: left 0.15s; }
  .intl-toggle.on { background: var(--intl); border-color: var(--intl-strong); }
  .intl-toggle.on .intl-icon { background: var(--intl-strong); }
  .intl-toggle.on .intl-icon svg { fill: #fff; }
  .intl-toggle.on .intl-text small { color: var(--intl-ink); font-weight: 600; }
  .intl-toggle.on .intl-switch { background: var(--intl-strong); }
  .intl-toggle.on .intl-switch span { left: 25px; }
  #entryForm.intl .card { border-color: var(--intl-strong); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35), var(--shadow); }
  .badge.intl { background: var(--intl); color: var(--intl-ink); margin-left: 6px; }
  .intl-key { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
  .intl-key .swatch { width: 26px; height: 16px; border-radius: 4px; background: var(--intl); border: 1px solid var(--intl-strong); }
  .t-sub { font-size: 12.5px; font-weight: 600; opacity: 0.9; margin-top: 2px; min-height: 16px; }
  .saved-list li.intl { background: var(--intl); }

  /* Tabs */
  .tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px; border-radius: 16px; background: var(--bar-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
  .tab {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font: 600 15px "Inter", sans-serif; padding: 13px 8px;
    border-radius: 11px; cursor: pointer;
    color: var(--muted); background: transparent; border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, transform 0.1s;
  }
  .tab svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
  .tab:hover { color: var(--ink); }
  .tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    box-shadow: 0 8px 22px var(--accent-glow);
  }
  .tab:active { transform: scale(0.98); }

  /* Cards and fields */
  .card { padding: 16px 18px; }
  .view form, .view { display: flex; flex-direction: column; gap: 14px; }
  .card-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 15px; margin-bottom: 12px; color: var(--navy);
  }
  .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.2), 0 0 12px var(--accent); }
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
  .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
  .field > span { font-size: 13px; font-weight: 600; color: var(--label); }
  .field em.unit { font-style: normal; color: var(--muted); font-weight: 500; }
  input, select {
    width: 100%; font: 500 16px "Inter", sans-serif; color: var(--ink);
    padding: 12px 12px; border-radius: 12px;
    border: 1.5px solid var(--line); background: var(--field);
    outline: none; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    min-height: 48px; appearance: none; -webkit-appearance: none;
  }
  input::placeholder { color: var(--placeholder); }
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239b9ba5' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
  }
  select option { background: var(--option-bg); color: var(--ink); }
  input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.2); }
  input[readonly] { background: var(--surface); color: var(--muted); }
  input.ok, select.ok { border-color: var(--green); background: var(--green-bg); }
  input.bad, select.bad { border-color: var(--red); background: var(--red-bg); }
  .field.required > span::after { content: " *"; color: var(--accent); }
  .grow { flex: 1; }

  /* Temperature field with a +/− button (phone number pads often have no minus key) */
  .temp-wrap { display: flex; gap: 8px; }
  .temp-wrap input { flex: 1; min-width: 0; }
  .sign-btn {
    flex: none; min-width: 52px; min-height: 48px; border-radius: 12px; cursor: pointer;
    font: 700 17px "Inter", sans-serif; color: var(--accent-2);
    background: var(--surface-2); border: 1.5px solid var(--line);
  }
  .sign-btn:active { background: var(--surface-3); }
  .temp-wrap.not-needed input { background: var(--surface); border-style: dashed; color: var(--muted); }
  .temp-wrap.not-needed input::placeholder { color: var(--muted); font-weight: 600; font-style: italic; }
  .temp-wrap.not-needed .sign-btn { display: none; }

  /* Multi-select dropdown (Food Item Code) */
  .multi { position: relative; }
  .multi-btn {
    width: 100%; text-align: left; cursor: pointer;
    font: 500 16px "Inter", sans-serif; color: var(--ink);
    padding: 12px 32px 12px 12px; border-radius: 12px; min-height: 48px;
    border: 1.5px solid var(--line); background-color: var(--field);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239b9ba5' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .multi-btn.placeholder { color: var(--placeholder); }
  .multi.open .multi-btn { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.2); }
  .multi.bad .multi-btn { border-color: var(--red); background-color: var(--red-bg); }
  .multi-panel {
    margin-top: 6px; background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 12px;
    padding: 6px; box-shadow: var(--pop-shadow);
  }
  .multi-opt {
    display: flex; align-items: center; gap: 10px; padding: 11px 10px; border-radius: 9px;
    font-size: 15px; cursor: pointer; user-select: none;
  }
  .multi-opt:active { background: var(--surface-3); }
  .multi-opt input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--accent); appearance: auto; -webkit-appearance: checkbox; flex: none; }
  .multi-done {
    width: 100%; margin-top: 4px; font: 600 15px "Inter", sans-serif; color: #fff; cursor: pointer;
    background: var(--accent); border: 0; border-radius: 10px; padding: 11px; min-height: 44px;
  }
  .newname { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; }
  .newname .btn { min-height: 48px; margin-bottom: 4px; }

  /* Status pill */
  .status {
    margin-top: 10px; padding: 10px 12px; border-radius: 12px;
    font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center;
  }
  .status.neutral { background: var(--surface-2); color: var(--muted); }
  .status.ok { background: var(--green-bg); color: var(--green-ink); }
  .status.bad { background: var(--red-bg); color: var(--red-ink); }

  /* Segmented control */
  .seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
  .seg button {
    font: 600 15px "Inter", sans-serif; border: 0; background: transparent; color: var(--muted);
    padding: 10px 26px; border-radius: 9px; cursor: pointer; min-height: 42px;
  }
  .seg button.on { background: var(--surface-3); color: var(--navy); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
  .seg.yn button.on[data-value="Y"] { background: var(--green); color: #fff; }
  .seg.yn button.on[data-value="N"] { background: var(--red); color: #fff; }

  /* Buttons */
  .actions { display: flex; gap: 12px; flex-wrap: wrap; }
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: 600 16px "Inter", sans-serif; border-radius: 14px; padding: 14px 22px;
    border: 1.5px solid transparent; cursor: pointer; min-height: 52px;
    transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
  }
  .btn svg { width: 20px; height: 20px; fill: currentColor; }
  .btn:active { transform: scale(0.98); }
  .btn[disabled] { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
  .btn.primary { flex: 1; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 10px 26px var(--accent-glow); }
  .btn.qa { flex: 1; color: #fff; background: linear-gradient(135deg, #a78bfa, var(--purple)); box-shadow: 0 10px 26px rgba(139, 92, 246, 0.35); }
  .btn.secondary { color: var(--ink); background: var(--surface-2); border-color: var(--line); }
  .btn.ghost { color: var(--ink); background: var(--surface-2); border-color: var(--line); }

  .alert { padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; }
  .alert.bad { background: var(--red-bg); color: var(--red-ink); border: 1px solid rgba(255, 46, 77, 0.45); }
  .alert ul { margin: 8px 0 0; padding-left: 20px; }
  .alert li + li { margin-top: 6px; }
  .muted { color: var(--muted); }
  .small { font-size: 12.5px; }
  .center { text-align: center; }

  /* Saved / finished screens */
  .saved-card { text-align: center; padding: 26px 20px; }
  .saved-card h2 { margin: 12px 0 4px; color: var(--navy); font-size: 22px; }
  .saved-card p { margin: 4px 0; }
  .saved-icon {
    width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
    display: grid; place-items: center; font-size: 32px; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #4ade80, var(--green));
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.4);
  }
  .saved-icon.bad { background: linear-gradient(135deg, #ff6b81, var(--red)); box-shadow: 0 8px 24px rgba(255, 46, 77, 0.4); }
  .saved-list-head { margin: 18px 0 8px; font-weight: 700; font-size: 14px; color: var(--muted); text-align: left; }
  .saved-list { list-style: none; margin: 0; padding: 0; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
  .saved-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 14px; font-size: 15px; font-weight: 600; }
  .saved-list li + li { border-top: 1px solid var(--line); }
  .saved-list li small { color: var(--muted); font-weight: 500; }
  .saved-actions { margin-top: 18px; flex-direction: column; }
  .saved-actions .btn { width: 100%; }

  /* PIN */
  .pin-card { max-width: 380px; width: 100%; margin: 10px auto; text-align: center; padding: 26px 22px; }
  .pin-card h2 { margin: 8px 0 4px; }
  .pin-icon { width: 58px; height: 58px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 10px 26px var(--accent-glow); }
  .pin-icon svg { width: 28px; height: 28px; fill: #fff; }
  #pinForm { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
  #pin { text-align: center; font-size: 24px; letter-spacing: 8px; }

  /* Dashboard */
  #dash { display: flex; flex-direction: column; gap: 14px; }
  .dash-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
  .dash-head h2 { margin: 0; font-size: 22px; color: var(--navy); letter-spacing: -0.3px; }
  .dash-head p { margin: 4px 0 0; font-size: 13px; }
  .dash-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .dash-controls input { width: auto; min-height: 40px; padding: 8px 10px; font-size: 14px; }
  .chip {
    display: inline-flex; align-items: center; gap: 6px;
    font: 600 13px "Inter", sans-serif; padding: 9px 12px; border-radius: 10px; min-height: 40px;
    border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer;
  }
  .chip svg { width: 16px; height: 16px; fill: currentColor; }
  .chip.icon { min-width: 40px; justify-content: center; font-size: 18px; padding: 6px 10px; }
  .chip.accent { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 6px 18px var(--accent-glow); }

  .tiles { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 12px; }
  .tile {
    border-radius: var(--radius); padding: 14px 16px; color: var(--ink);
    background: var(--shine), var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--shadow), inset 0 1px 0 var(--inset);
    position: relative; overflow: hidden;
  }
  .tile::before { content: ""; position: absolute; left: 16px; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--tile-accent, var(--muted)); }
  .t-blue { --tile-accent: #60a5fa; }
  .t-green { --tile-accent: var(--green); }
  .t-orange { --tile-accent: var(--red); }
  .t-purple { --tile-accent: #a78bfa; }
  /* KPI tiles: a donut chart in each tile's own colour, the number in the middle. */
  .kpi { display: flex; flex-direction: column; gap: 8px; }
  .kpi-body { display: flex; align-items: center; gap: 12px; }
  .donut { position: relative; width: 84px; height: 84px; flex: none; }
  .donut svg { width: 100%; height: 100%; display: block; }
  .donut .d-track { fill: none; stroke: var(--surface-3); stroke-width: 9; }
  .donut .d-seg { fill: none; stroke-width: 9; transition: stroke-dasharray 0.5s; }
  .d-center { position: absolute; inset: 0; display: grid; place-items: center; font-size: 21px; font-weight: 700; letter-spacing: -0.4px; color: var(--navy); }
  .d-center.small { font-size: 15px; }
  .kpi-legend { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 12px; color: var(--muted); }
  .kpi-legend span { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kpi-legend b { color: var(--ink); margin-left: auto; padding-left: 6px; }
  .kpi-legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
  .kpi .t-sub { font-size: 12px; color: var(--muted); }
  /* Narrow tiles: legend under the donut so the labels are not cut off. */
  .kpi:not(.t-hero) .kpi-body { flex-direction: column; align-items: stretch; gap: 10px; }
  .kpi:not(.t-hero) .donut { margin: 0 auto; }
  :root { --k-dom: #3b82f6; --k-intl: #93c5fd; --k-chk: #14b8a6; --k-stat: #a78bfa; }
  :root[data-theme="light"] { --k-dom: #1d4ed8; --k-intl: #38bdf8; --k-chk: #0d9488; --k-stat: #7c3aed; }
  .k-ok { stroke: var(--green); background: var(--green); }
  .k-bad { stroke: var(--red); background: var(--red); }
  .k-due { stroke: var(--amber); background: var(--amber); }
  .k-dom { stroke: var(--k-dom); background: var(--k-dom); }
  .k-intl { stroke: var(--k-intl); background: var(--k-intl); }
  .k-chk { stroke: var(--k-chk); background: var(--k-chk); }
  .k-stat { stroke: var(--k-stat); background: var(--k-stat); }
  .k-rest { stroke: var(--surface-3); background: var(--surface-3); }
  .t-hero {
    color: #fff; border-color: rgba(255, 255, 255, 0.35);
    background: radial-gradient(120% 120% at 0% 0%, rgba(255, 255, 255, 0.18), transparent 60%), linear-gradient(140deg, var(--accent-2), var(--accent) 60%, var(--accent-3));
    box-shadow: 0 14px 36px var(--accent-glow);
  }
  .t-hero::before { display: none; }
  /* The planned-flights tile keeps the glass look like the others; only its accent bar is green. */
  .kpi.t-hero { color: var(--ink); background: var(--shine), var(--glass); border-color: var(--glass-border); box-shadow: var(--shadow), inset 0 1px 0 var(--inset); --tile-accent: var(--green); }
  .kpi.t-hero::before { display: block; }
  .kpi.t-hero .t-label { color: var(--muted); }
  .t-label { font-size: 13px; font-weight: 600; color: var(--muted); }
  .t-hero .t-label { color: rgba(255, 255, 255, 0.85); }
  .t-value { font-size: 30px; font-weight: 700; margin-top: 4px; letter-spacing: -0.5px; }
  .t-value.small { font-size: 15px; margin-top: 10px; letter-spacing: 0; }
  .meter { height: 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.28); margin-top: 10px; overflow: hidden; }
  .meter i { display: block; height: 100%; width: 0; border-radius: 999px; background: #fff; transition: width 0.4s; }

  /* Missing flight alert */
  .alert-banner {
    display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
    background: var(--banner-bg);
    border: 1.5px solid var(--red); color: var(--navy);
    box-shadow: 0 0 0 4px rgba(255, 46, 77, 0.12), 0 14px 36px rgba(255, 46, 77, 0.25);
    animation: alertPulse 2s ease-in-out infinite;
  }
  .alert-banner .ab-icon { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--red); font-weight: 800; font-size: 20px; }
  .alert-banner b { font-size: 15px; }
  .alert-banner ul { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
  .alert-banner li span { color: var(--red-ink); font-weight: 700; }
  @keyframes alertPulse { 50% { box-shadow: 0 0 0 8px rgba(255, 46, 77, 0.06), 0 14px 36px rgba(255, 46, 77, 0.35); } }
  @media (prefers-reduced-motion: reduce) { .alert-banner { animation: none; } }

  .dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; }

  /* Flights by departure hour (stacked columns) */
  .chart-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-weight: 600; }
  .chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
  .chart-legend i, .hc-tip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
  .hchart { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 190px; padding: 8px 0 22px; border-bottom: 1px solid var(--line); margin-top: 6px; }
  .hchart .grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--cell-line); }
  .hc-col { position: relative; flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column-reverse; gap: 2px; cursor: pointer; border-radius: 6px; }
  .hc-col:hover, .hc-col.on { background: var(--overlay); }
  .hc-seg { width: 100%; max-width: 26px; margin: 0 auto; flex: none; }
  .hc-col .hc-seg:last-of-type { border-radius: 4px 4px 0 0; }
  .hc-lbl { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
  .hc-tip {
    position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, -100%);
    background: var(--tip-bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
    font-size: 12px; white-space: nowrap; box-shadow: var(--pop-shadow);
  }
  .hc-tip b { display: block; margin-bottom: 4px; }
  .hc-tip div { display: flex; align-items: center; gap: 6px; }
  .c-logged { background: var(--green); }
  .c-due { background: var(--amber); }
  .c-late { background: var(--red); }
  .c-upcoming { background: #74747f; }

  /* Temperatures logged (line chart, selected day + previous day) */
  :root { --s-day: #3b82f6; --s-prev: #0d9488; }
  :root[data-theme="light"] { --s-day: #2563eb; --s-prev: #0d9488; }
  .temp-block { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
  .tchart { position: relative; min-height: 120px; }
  .tchart svg { display: block; width: 100%; height: auto; overflow: visible; }
  .tchart .ax { font: 500 11px "Inter", sans-serif; fill: var(--muted); }
  .tchart .gl { stroke: var(--cell-line); stroke-width: 1; }
  .tchart .lim { stroke: var(--red); stroke-width: 1.5; stroke-dasharray: 6 4; }
  .tchart .lim-t { font: 700 11px "Inter", sans-serif; fill: var(--red-ink); }
  .tchart .above-zone { fill: var(--red); opacity: 0.06; }
  .tchart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .tchart .ln.prev { stroke-dasharray: 5 4; }
  .tchart .ln.hot { stroke: var(--red); }
  .tchart .pt { stroke: var(--surface); stroke-width: 2; }
  .tchart .pt.hot { fill: var(--red); }
  .tchart .hit { fill: transparent; cursor: pointer; outline: none; }
  .tchart .hit:focus-visible + .ring, .tchart .ring.on { opacity: 1; }
  .tchart .ring { fill: none; stroke: var(--ink); stroke-width: 2; opacity: 0; pointer-events: none; }
  .t-tip { position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, calc(-100% - 12px)); width: max-content; max-width: min(300px, 100%);
    background: var(--tip-bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
    font-size: 12px; line-height: 1.5; box-shadow: var(--pop-shadow); }
  .t-tip b { font-size: 13px; }
  .t-tip .hot { color: var(--red-ink); font-weight: 700; }
  .chart-legend .sw-line { width: 18px; height: 0; border-top: 2px solid; border-radius: 0; background: none; }
  .chart-legend .sw-line.prev { border-top-style: dashed; }

  /* Final checkers board */
  .checker-board { display: flex; flex-direction: column; gap: 10px; }
  .cb-row { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; }
  .cb-av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
  .cb-name { font-weight: 600; font-size: 14px; }
  .cb-meta { font-size: 12px; color: var(--muted); }
  .cb-meta .dev { color: var(--red-ink); font-weight: 600; }
  .cb-bar { height: 6px; border-radius: 999px; background: var(--surface-3); margin-top: 5px; overflow: hidden; }
  .cb-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
  .cb-count { font-size: 20px; font-weight: 700; }

  /* Flight progress (planned flights) */
  .plan-table td.pl-etd { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .plan-table tr.st-late td, .plan-table tr.st-missed td { background: rgba(255, 46, 77, 0.1); }
  .pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
  .pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .pill.st-logged { background: var(--green-bg); color: var(--green-ink); }
  .pill.st-due { background: rgba(251, 191, 36, 0.16); color: var(--amber-ink); }
  .pill.st-late, .pill.st-missed { background: var(--red); color: #fff; }
  .pill.st-late::before { animation: blink 1s steps(2) infinite; background: #fff; }
  .pill.st-missed::before { background: #fff; }
  .pill.st-upcoming { background: var(--surface-3); color: var(--muted); }
  @keyframes blink { 50% { opacity: 0; } }
  .unplanned { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.35); font-size: 13px; }
  .unplanned b { color: var(--amber-ink); }

  .steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .step { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
  .step b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--navy); font-size: 12px; }
  .step span { font-weight: 600; }
  .step small { color: var(--muted); }
  .step.done { background: var(--green-bg); border-color: rgba(34, 197, 94, 0.35); }
  .step.done b { background: var(--green); }
  .step.current { border-color: var(--accent); }
  .step.current b { background: var(--accent); }

  /* Log sheets / Flight list switch */
  .view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 14px; background: var(--bar-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow); }
  .view-switch button { font: 600 15px "Inter", sans-serif; color: var(--muted); background: transparent; border: 0; border-radius: 10px; padding: 12px; min-height: 46px; cursor: pointer; }
  .view-switch button.on { background: var(--surface-3); color: var(--navy); }
  .flights-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
  .flights-head .card-title { margin-bottom: 0; }
  #dayEditor .flights-head { flex-wrap: nowrap; align-items: flex-start; }
  #dayEditor .flights-head .card-title { flex: 1; min-width: 0; }
  .filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .filter-chips .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
  #flightsView > p { margin: 10px 0; }
  .flight-table { width: 100%; border-collapse: collapse; background: var(--surface-2); border-radius: 12px; overflow: hidden; font-size: 14px; }
  .flight-table th { background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
  .flight-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .flight-table tr:last-child td { border-bottom: 0; }
  .flight-table tr.frow { cursor: pointer; }
  .flight-table tr.frow:hover td { background: var(--overlay); }
  .flight-table tr.intl td { background: var(--intl); }
  .flight-table td.fl { font-weight: 700; white-space: nowrap; }
  .flight-table td.fl small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
  .flight-table td.who { font-weight: 600; color: var(--accent-2); }
  :root[data-theme="light"] .flight-table td.who { color: #0369a1; }
  .flight-table .issues { color: var(--red-ink); font-size: 12.5px; font-weight: 600; }
  .flight-table .no-issue { color: var(--green-ink); font-weight: 700; }
  .log-card.flash { box-shadow: 0 0 0 3px var(--accent), var(--shadow); transition: box-shadow 0.3s; }
  .log-card h3 { margin: 0 0 10px; font-size: 16px; color: var(--navy); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
  .log-card h3 small { font-weight: 500; color: var(--muted); font-size: 13px; }
  #logs { display: flex; flex-direction: column; gap: 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
  table.log { border-collapse: collapse; width: 100%; min-width: 1100px; font-size: 12.5px; }
  table.log th, table.log td { border: 1px solid var(--cell-line); padding: 6px 6px; text-align: center; vertical-align: middle; }
  table.log th { background: var(--surface-3); color: var(--muted); font-weight: 600; font-size: 11.5px; }
  table.log th.sec { background: var(--sec-bg); color: var(--ink); font-size: 12px; }
  table.log td.bad { background: var(--red-bg); color: var(--red-ink); font-weight: 700; }
  table.log td.na { color: var(--placeholder); }
  table.log td.ca { text-align: left; font-size: 11.5px; max-width: 220px; }
  table.log tr.intl td { background: var(--intl); }
  table.log tr.intl td.bad { background: var(--red-bg); }
  table.log tr.voided td { text-decoration: line-through; color: var(--placeholder); background: var(--surface); }
  table.log tr.voided td.void-note { text-decoration: none; }
  .void-btn { font: 600 11.5px "Inter", sans-serif; color: var(--red-ink); background: transparent; border: 1px solid rgba(255, 46, 77, 0.5); border-radius: 8px; padding: 5px 8px; cursor: pointer; }
  .badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
  .badge.ok { background: var(--green-bg); color: var(--green-ink); }
  .badge.bad { background: var(--red-bg); color: var(--red-ink); }
  .verify-card p { margin: 0 0 12px; }
  .verify-card .small { margin: 12px 0 0; }

  /* Flights tab: calendar */
  .cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
  .cal-head h3 { margin: 0; font-size: 18px; text-transform: capitalize; }
  .cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
  .cal-week { margin-bottom: 6px; }
  .cal-week span { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
  .cal-day {
    position: relative; min-height: 76px; padding: 8px; border-radius: 12px; text-align: left; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-family: "Inter", sans-serif;
    display: flex; flex-direction: column; gap: 4px; transition: border-color 0.15s, background 0.15s;
  }
  .cal-day:hover { border-color: rgba(var(--accent-2-rgb), 0.6); }
  .cal-day b { font-size: 15px; }
  .cal-day .cal-count { font-size: 11.5px; color: var(--muted); font-weight: 600; }
  .cal-day .cal-bar { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: auto; }
  .cal-day .cal-bar i { display: block; height: 100%; background: var(--green); }
  .cal-day.empty { visibility: hidden; }
  .cal-day.past { opacity: 0.85; }
  .cal-day.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 18px var(--accent-glow); }
  .cal-day.sel { background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.32), rgba(var(--accent-2-rgb), 0.14)); border-color: var(--accent); }
  .cal-day .cal-flag { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; }
  .cal-flag.done { background: var(--green); }
  .cal-flag.miss { background: var(--red); box-shadow: 0 0 8px var(--red); }
  .cal-flag.plan { background: var(--accent-2); }
  .cal-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--muted); }
  .cal-legend > span { display: inline-flex; align-items: center; gap: 6px; }
  .lg { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
  .lg-done { background: var(--green); }
  .lg-miss { background: var(--red); }
  .lg-plan { background: var(--accent-2); }

  /* Flights tab: day editor */
  .sched-wrap { margin-bottom: 12px; }
  .sched-table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .sched-table th { background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; padding: 9px 8px; }
  .sched-table td { padding: 6px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
  .sched-table td.n { color: var(--muted); font-size: 12px; width: 28px; text-align: center; }
  .sched-table input { min-height: 42px; padding: 9px 10px; font-size: 15px; text-transform: uppercase; }
  .sched-table td.f { min-width: 110px; }
  .sched-table td.d { width: 96px; }
  .sched-table td.e { width: 92px; }
  .sched-table td.s { white-space: nowrap; }
  .row-del { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; }
  .row-del:hover { color: var(--red-ink); border-color: var(--red); }
  .import-days { max-height: 220px; overflow: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 12px; }
  .import-days table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .import-days td { padding: 7px 10px; border-top: 1px solid var(--line); }
  .import-days tr:first-child td { border-top: 0; }
  .import-warn { color: var(--amber-ink); font-size: 13px; }

  /* Footer */
  .footer {
    display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding: 12px 18px; font-size: 13px; color: var(--muted);
  }

  /* Modal */
  .modal { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: grid; place-items: center; padding: 16px; }
  .modal-box { width: 100%; max-width: 520px; padding: 20px; background: var(--surface); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
  .modal-box h3 { margin: 0 0 12px; color: var(--navy); }
  .sigpad { width: 100%; height: 190px; background: #fff; border: 2px dashed var(--accent); border-radius: 12px; touch-action: none; cursor: crosshair; }
  .modal .actions { margin-top: 12px; }

  /* Toast */
  .toast {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30;
    background: var(--toast-bg); color: #fff; padding: 13px 20px; border-radius: 14px; border: 1px solid var(--line);
    font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center;
  }
  .toast.ok { background: #15803d; }
  .toast.bad { background: var(--red); }

  @media (max-width: 900px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .t-hero { grid-column: 1 / -1; }
    .kpi.t-purple { grid-column: 1 / -1; }
    .dash-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 640px) {
    .shell { padding: 10px 12px 22px; gap: 12px; }
    .header { padding: 12px 14px; }
    .header h1 { font-size: 17px; }
    .header .sub { font-size: 11.5px; }
    .header { align-items: flex-start; }
    .brand { flex-direction: column; align-items: flex-start; gap: 10px; }
    .logo-wrap { min-height: 38px; padding: 5px 10px; }
    .logo-wrap img { height: 24px; }
    .today { display: none; }
    .lang button { padding: 6px 9px; min-width: 36px; }
    .tab { font-size: 13.5px; gap: 6px; padding: 12px 4px; }
    .tab svg { width: 17px; height: 17px; }
    .steps { grid-template-columns: 1fr; }
    .card { padding: 14px; }
    .grid2 { gap: 10px; }
    .seg button { padding: 10px 20px; }
    .cal-week, .cal-grid { gap: 4px; }
    .cal-day { min-height: 58px; padding: 6px 5px; border-radius: 10px; }
    .cal-day b { font-size: 13px; }
    .cal-day .cal-count { font-size: 10.5px; }
    .cal-day .cal-flag { top: 6px; right: 5px; width: 7px; height: 7px; }
    .hchart { gap: 3px; height: 170px; }
    .hc-lbl { font-size: 9.5px; }
    .sched-table td { padding: 6px 3px; }
    .sched-table input { padding: 9px 7px; font-size: 15px; }
    .sched-table td.f { min-width: 0; }
    .sched-table td.d { width: 66px; }
    .sched-table td.e { width: 74px; }
    .sched-table td.n, .sched-table th:first-child { display: none; }
    .sched-table td.s, .sched-table th:nth-child(5) { display: none; }
    .row-del { width: 32px; }
  }
  @media (max-width: 440px) {
    .tab { white-space: nowrap; }
    .tab svg { display: none; }
  }
  @media (max-width: 440px) {
    .donut { width: 70px; height: 70px; }
    .d-center { font-size: 18px; }
    .kpi-body { gap: 8px; }
    .kpi-legend { font-size: 11px; }
  }
  @media (max-width: 380px) {
    .grid2 { grid-template-columns: 1fr; }
  }
