
  :root{
    --bg:#F2F4F5;
    --surface:#FFFFFF;
    --surface-alt:#E7EAEC;
    --border:#D6DBDE;
    --text:#181C1F;
    --text-muted:#5C6670;
    --text-faint:#8B939B;
    --accent:#1F6E77;
    --accent-2:#0F8B8D;
    --accent-strong:#0E3D42;
    --accent-soft:#DCE9EA;
    --good:#2E7D4F;
    --good-soft:#DDF0E3;
    --warn:#B4700F;
    --warn-soft:#F6E6CC;
    --crit:#B23A32;
    --crit-soft:#F7DEDB;
    --shadow: 0 1px 2px rgba(20,25,28,0.06), 0 8px 24px -12px rgba(20,25,28,0.18);
    --shadow-lift: 0 2px 4px rgba(20,25,28,0.08), 0 16px 32px -14px rgba(20,25,28,0.28);
  }
  @media (prefers-color-scheme: dark){
    :root:not([data-theme="light"]){
      --bg:#12161A;
      --surface:#1B2124;
      --surface-alt:#232A2E;
      --border:#333B40;
      --text:#EAEDEE;
      --text-muted:#A2ABB1;
      --text-faint:#75808A;
      --accent:#57BAC2;
      --accent-2:#3FD6C9;
      --accent-strong:#93DCE0;
      --accent-soft:#1B3438;
      --good:#5FBE85;
      --good-soft:#1E3327;
      --warn:#E3A552;
      --warn-soft:#3A2C16;
      --crit:#E2766C;
      --crit-soft:#3B2220;
      --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -12px rgba(0,0,0,0.6);
      --shadow-lift: 0 4px 10px rgba(0,0,0,0.5), 0 20px 40px -16px rgba(0,0,0,0.7);
    }
  }
  :root[data-theme="dark"]{
    --bg:#12161A;
    --surface:#1B2124;
    --surface-alt:#232A2E;
    --border:#333B40;
    --text:#EAEDEE;
    --text-muted:#A2ABB1;
    --text-faint:#75808A;
    --accent:#57BAC2;
    --accent-2:#3FD6C9;
    --accent-strong:#93DCE0;
    --accent-soft:#1B3438;
    --good:#5FBE85;
    --good-soft:#1E3327;
    --warn:#E3A552;
    --warn-soft:#3A2C16;
    --crit:#E2766C;
    --crit-soft:#3B2220;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px -12px rgba(0,0,0,0.6);
    --shadow-lift: 0 4px 10px rgba(0,0,0,0.5), 0 20px 40px -16px rgba(0,0,0,0.7);
  }

  *{box-sizing:border-box;}
  html,body{margin:0;}
  body{
    background:
      radial-gradient(1100px 520px at 12% -12%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
      var(--bg);
    color:var(--text);
    font-family:'Work Sans', system-ui, sans-serif;
    padding-inline:16px;
    -webkit-font-smoothing:antialiased;
    position:relative;
  }
  body::before{
    content:""; position:fixed; top:0; left:0; right:0; height:3px; z-index:100;
    background:linear-gradient(90deg, var(--accent-2), var(--accent-strong) 45%, var(--accent-2));
  }
  h1,h2,h3,.display{
    font-family:'Big Shoulders Text', 'Avenir Next Condensed', 'Arial Narrow', system-ui, sans-serif;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:0.02em;
    text-wrap:balance;
    margin:0;
  }
  .mono, .num{ font-family:'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
  a{ color: var(--accent-strong); }
  button{ font-family:inherit; }
  ::selection{ background:var(--accent-soft); }

  .wrap{ max-width:1180px; margin:0 auto; padding-block: 18px 64px; }

  /* ---- Topbar ---- */
  .topbar{
    display:flex; align-items:baseline; justify-content:space-between; gap:16px;
    flex-wrap:wrap; padding-bottom:14px; border-bottom:1px solid var(--border);
  }
  .brand{ display:flex; align-items:baseline; gap:12px; }
  .brand .mark{
    display:inline-flex; align-items:center; justify-content:center;
    width:38px; height:44px; padding-bottom:5px;
    background:linear-gradient(155deg, var(--accent-2), var(--accent-strong) 85%);
    clip-path: polygon(50% 0%, 100% 16%, 100% 60%, 50% 100%, 0% 60%, 0% 16%);
    color:#fff; font-family:'Big Shoulders Text',sans-serif; font-weight:800; font-size:14.5px; letter-spacing:0.01em;
    flex:none; box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--accent-strong) 65%, transparent);
  }
  .brand h1{ font-size:27px; color:var(--text); letter-spacing:0.015em; }
  .brand .tag{ font-size:12.5px; color:var(--text-faint); font-weight:500; text-transform:none; letter-spacing:0; }
  .preview-banner{
    background:var(--warn-soft); color:var(--warn); border:1px solid color-mix(in srgb, var(--warn) 40%, transparent);
    border-radius:8px; padding:8px 12px; font-size:13px; font-weight:500; margin-top:12px;
    display:flex; gap:8px; align-items:baseline; flex-wrap:wrap;
  }

  /* ---- Nav tabs ---- */
  .tabs{
    display:flex; gap:2px; margin-top:14px; overflow-x:auto; padding-bottom:2px;
    scrollbar-width:thin;
  }
  .tab{
    appearance:none; border:none; background:transparent; color:var(--text-muted);
    font-weight:600; font-size:13.5px; padding:9px 14px; border-radius:8px 8px 0 0;
    cursor:pointer; white-space:nowrap; border-bottom:2px solid transparent;
    display:flex; align-items:center; gap:7px;
    transition: color .15s, background-color .15s, border-color .15s;
  }
  .tab svg{ width:15px; height:15px; flex:none; opacity:.85; }
  .tab:hover{ color:var(--text); background:var(--surface-alt); }
  .tab.active{ color:var(--accent-strong); border-bottom-color:var(--accent-2); background:var(--surface); }
  .tab .pip{
    min-width:18px; height:18px; padding:0 5px; border-radius:9px; background:var(--crit-soft); color:var(--crit);
    font-size:11px; font-weight:700; display:inline-flex; align-items:center; justify-content:center;
    font-family:'IBM Plex Mono',monospace;
  }

  main{ margin-top:18px; display:flex; flex-direction:column; gap:22px; }

  /* ---- Generic components ---- */
  .section-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:12px; flex-wrap:wrap; }
  .section-head h2{ font-size:20px; }
  .section-head .sub{ color:var(--text-muted); font-size:13px; margin-top:2px; text-transform:none; letter-spacing:0; font-weight:500;}

  .btn{
    appearance:none; border:1px solid var(--border); background:var(--surface); color:var(--text);
    font-weight:600; font-size:13.5px; padding:8px 14px; border-radius:7px; cursor:pointer;
    display:inline-flex; align-items:center; gap:6px;
    transition:border-color .15s, background-color .15s, transform .12s, box-shadow .15s;
  }
  .btn:hover{ border-color:var(--text-faint); transform:translateY(-1px); }
  .btn:active{ transform:translateY(0); }
  .btn:focus-visible, a:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible{
    outline:2px solid var(--accent); outline-offset:1px;
  }
  .btn-primary{ background:linear-gradient(155deg, var(--accent-2), var(--accent-strong) 120%); border-color:var(--accent-strong); color:#fff; }
  .btn-primary:hover{ border-color:var(--accent-strong); box-shadow:0 8px 20px -8px color-mix(in srgb, var(--accent-2) 65%, transparent); }
  .btn-danger{ color:var(--crit); border-color:color-mix(in srgb, var(--crit) 45%, var(--border)); }
  .btn-danger:hover{ background:var(--crit-soft); }
  .btn-sm{ padding:5px 10px; font-size:12.5px; }
  .btn-ghost{ border-color:transparent; background:transparent; }
  .btn-ghost:hover{ background:var(--surface-alt); }
  .btn[disabled]{ opacity:.55; cursor:default; transform:none !important; }

  .grid-cards{ display:grid; gap:12px; grid-template-columns:repeat(auto-fit, minmax(220px,1fr)); }
  .card{
    background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:16px;
    box-shadow: var(--shadow);
  }
  .stat{ display:flex; flex-direction:column; gap:4px; position:relative;
    transition: transform .18s ease, box-shadow .18s ease; }
  .stat:hover{ transform:translateY(-3px); box-shadow:var(--shadow-lift); }
  .stat::before{ content:""; position:absolute; top:0; left:16px; right:16px; height:3px; border-radius:0 0 3px 3px;
    background:var(--tone-color, var(--border)); opacity:.9; }
  .stat .label{ font-size:12px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-faint); font-weight:600; }
  .stat .value{ font-family:'Big Shoulders Text',sans-serif; font-size:34px; font-weight:700; line-height:1; }
  .stat .value.good{ color:var(--good); } .stat .value.warn{ color:var(--warn); } .stat .value.crit{ color:var(--crit); }
  .stat .note{ font-size:12.5px; color:var(--text-muted); }

  .panel{ background:var(--surface); border:1px solid var(--border); border-radius:12px; overflow:hidden; box-shadow:var(--shadow); }
  .panel .panel-head{ padding:14px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
  .panel .panel-head h3{ font-size:15px; }
  .panel-body{ padding:4px 16px 16px; }
  .panel-body.pad0{ padding:0; }

  table{ width:100%; border-collapse:collapse; font-size:13.5px; }
  th{ text-align:left; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--text-faint); font-weight:700; padding:10px 12px; border-bottom:1px solid var(--border); }
  td{ padding:10px 12px; border-bottom:1px solid var(--border); vertical-align:middle; }
  tr:last-child td{ border-bottom:none; }
  tbody tr{ transition: background-color .1s; }
  tbody tr:hover td{ background:var(--surface-alt); }
  .table-wrap{ overflow-x:auto; }
  .row-muted td{ color:var(--text-muted); }

  .badge{ display:inline-flex; align-items:center; gap:5px; font-size:11.5px; font-weight:700; padding:3px 9px; border-radius:999px; white-space:nowrap;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 16%, transparent); }
  .badge-good{ background:var(--good-soft); color:var(--good); }
  .badge-warn{ background:var(--warn-soft); color:var(--warn); }
  .badge-crit{ background:var(--crit-soft); color:var(--crit); }
  .badge-neutral{ background:var(--surface-alt); color:var(--text-muted); }
  .badge-accent{ background:var(--accent-soft); color:var(--accent-strong); }

  .empty{ padding:28px 16px; text-align:center; color:var(--text-muted); font-size:13.5px; }
  .empty .btn{ margin-top:10px; }

  input, select, textarea{
    font-family:inherit; font-size:13.5px; padding:8px 10px; border-radius:7px;
    border:1px solid var(--border); background:var(--surface); color:var(--text); width:100%;
  }
  label{ font-size:12px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.03em; display:block; margin-bottom:5px; }
  .field{ display:flex; flex-direction:column; gap:0; }
  .field-row{ display:grid; gap:12px; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); }

  /* ---- Modal ---- */
  .modal-backdrop{
    position:fixed; inset:0; background:rgba(10,12,13,0.55); backdrop-filter:blur(6px) saturate(1.1); -webkit-backdrop-filter:blur(6px) saturate(1.1);
    display:flex; align-items:center; justify-content:center;
    padding:20px; z-index:50; overflow-y:auto; animation:backdropIn .15s ease-out;
  }
  @keyframes backdropIn{ from{ opacity:0; } to{ opacity:1; } }
  .modal{
    background:var(--surface); border-radius:14px; max-width:640px; width:100%; box-shadow:var(--shadow-lift);
    border:1px solid var(--border); max-height:calc(100vh - 40px); display:flex; flex-direction:column; margin:auto;
    animation:modalIn .18s cubic-bezier(.2,.8,.3,1);
  }
  @keyframes modalIn{ from{ opacity:0; transform:translateY(10px) scale(.98); } to{ opacity:1; transform:none; } }
  .modal.wide{ max-width:820px; }
  .modal-head{ padding:16px 18px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; gap:10px; }
  .modal-head h3{ font-size:17px; }
  .modal-body{ padding:16px 18px; overflow-y:auto; display:flex; flex-direction:column; gap:14px; }
  .modal-foot{ padding:14px 18px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
  .modal-x{ border:none; background:transparent; color:var(--text-faint); font-size:20px; cursor:pointer; line-height:1; padding:2px 6px; border-radius:6px; }
  .modal-x:hover{ background:var(--surface-alt); color:var(--text); }

  .toast-wrap{ position:fixed; bottom:18px; left:50%; transform:translateX(-50%); z-index:60; display:flex; flex-direction:column; gap:8px; align-items:center; }
  .toast{
    background:var(--accent-strong); color:#fff; padding:10px 16px; border-radius:8px; font-size:13.5px; font-weight:600;
    box-shadow:var(--shadow); animation:toastin .15s ease-out;
  }
  @keyframes toastin{ from{ opacity:0; transform:translateY(6px);} to{ opacity:1; transform:none; } }

  .recipe-item-row{ display:grid; grid-template-columns: 1fr 90px 30px; gap:8px; align-items:center; }
  .ing-price-trend{ font-size:11px; color:var(--text-faint); }
  .drift{ color:var(--crit); font-weight:700; }
  .muted-link{ background:none; border:none; color:var(--accent-strong); font-weight:600; font-size:12.5px; cursor:pointer; padding:0; }
  .divider{ height:1px; background:var(--border); border:none; margin:2px 0; }
  .subtabs{ display:flex; gap:6px; flex-wrap:wrap; }
  .subtab{ appearance:none; border:1px solid var(--border); background:var(--surface); color:var(--text-muted); font-weight:600; font-size:12.5px; padding:6px 12px; border-radius:999px; cursor:pointer; transition: background-color .15s, color .15s, border-color .15s; }
  .subtab:hover{ border-color:var(--text-faint); }
  .subtab.active{ background:var(--accent-soft); color:var(--accent-strong); border-color:transparent; }
  .file-drop{ border:1.5px dashed var(--border); border-radius:10px; padding:22px; text-align:center; color:var(--text-muted); font-size:13px; cursor:pointer; transition:border-color .15s, color .15s; }
  .file-drop:hover{ border-color:var(--accent-2); color:var(--text); }
  .spinner{ width:16px; height:16px; border-radius:50%; border:2px solid var(--border); border-top-color:var(--accent); animation:spin .7s linear infinite; display:inline-block; }
  @keyframes spin{ to{ transform:rotate(360deg); } }
  .items-table input{ padding:6px 8px; font-size:13px; }
  .kv{ display:flex; justify-content:space-between; gap:10px; font-size:13px; padding:4px 0; }
  .kv .k{ color:var(--text-muted); }

  @media (prefers-reduced-motion: reduce){ *{ animation-duration:0.001ms !important; transition-duration:0.001ms !important; } }
  @media (max-width:520px){
    .stat .value{ font-size:28px; }
    .brand h1{ font-size:21px; }
  }

  /* ===== Additions for the standalone app ===== */
  .auth-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px 0; }
  .auth-card{ width:100%; max-width:420px; display:flex; flex-direction:column; gap:14px; }
  .auth-card .brand{ justify-content:center; margin-bottom:6px; }
  .auth-links{ display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; font-size:13px; }
  .err{ color:var(--crit); font-size:13px; font-weight:500; }
  .ok-msg{ color:var(--good); font-size:13px; font-weight:500; }
  .choice-grid{ display:grid; gap:14px; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); }
  .steps{ display:flex; gap:6px; }
  .steps span{ flex:1; height:4px; border-radius:2px; background:var(--border); }
  .steps span.on{ background:var(--accent-2); }
  .topbar-right{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
  .who{ font-size:12.5px; color:var(--text-muted); }
  .kitchen-name{ font-size:13px; font-weight:600; color:var(--accent-strong); text-transform:none; letter-spacing:0; }
  .quick-actions{ display:grid; gap:10px; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); }
  .quick-actions .btn{ justify-content:center; padding:14px; font-size:14.5px; }
  .fab{ position:fixed; right:18px; bottom:18px; z-index:40; box-shadow:var(--shadow-lift); }
  .tiny{ font-size:11.5px; color:var(--text-faint); }
  .strike td{ text-decoration:line-through; color:var(--text-faint); }
  .strike td:last-child, .strike td:nth-last-child(2){ text-decoration:none; }
  .check-row{ display:flex; align-items:center; gap:10px; padding:6px 0; }
  .check-row input{ width:22px; height:22px; flex:none; }
  .check-row .meta{ margin-left:auto; }
  .readonly-note{ font-size:12px; color:var(--text-muted); display:flex; gap:6px; align-items:center; }
  .loading{ padding:60px 0; text-align:center; color:var(--text-muted); display:flex; gap:10px; justify-content:center; align-items:center; }
  .code-chip{ font-family:'IBM Plex Mono',monospace; font-size:18px; letter-spacing:.15em; font-weight:600; background:var(--accent-soft); color:var(--accent-strong); padding:6px 12px; border-radius:8px; }
  @media (max-width:640px){
    .btn{ min-height:40px; }
    input, select, textarea{ font-size:16px; } /* stop iOS zooming */
    .modal-backdrop{ padding:0; align-items:flex-end; }
    .modal{ border-radius:14px 14px 0 0; max-height:92vh; margin:auto 0 0; }
    th, td{ padding:9px 8px; }
    .grid-cards{ grid-template-columns:1fr 1fr; gap:10px; }
    .stat .value{ font-size:26px; }
    .stat .label{ font-size:10.5px; }
  }

  /* ===== Shared kitchen tablet ===== */
  .name-grid{ display:grid; gap:12px; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); }
  .name-tile{ display:flex; flex-direction:column; align-items:center; gap:8px; padding:18px 10px; border-radius:14px; border:1px solid var(--border); background:var(--surface); box-shadow:var(--shadow); cursor:pointer; font:inherit; color:var(--text); }
  .name-tile:hover:not(:disabled){ border-color:var(--accent-2); }
  .name-tile:disabled{ opacity:.5; cursor:not-allowed; }
  .name-tile .avatar{ width:56px; height:56px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:20px; background:var(--accent-soft); color:var(--accent-strong); }
  .name-tile .nm{ font-weight:600; font-size:15px; text-align:center; }
  .pin-dots{ display:flex; justify-content:center; gap:12px; margin:6px 0 10px; }
  .pin-dots span{ width:16px; height:16px; border-radius:50%; border:2px solid var(--accent-2); }
  .pin-dots span.on{ background:var(--accent-2); }
  .pin-pad{ display:grid; grid-template-columns:repeat(3,76px); gap:10px; justify-content:center; margin-top:6px; }
  .pin-key{ height:64px; border-radius:14px; border:1px solid var(--border); background:var(--surface); font:inherit; font-size:24px; font-weight:600; color:var(--text); cursor:pointer; }
  .pin-key:active{ background:var(--accent-soft); }
  .pin-key.ok{ background:var(--accent-2); color:#fff; border-color:transparent; font-size:18px; }

/* Clocking in */
.clock-card{ border-left:4px solid var(--accent); }
.clock-row{ display:flex; gap:12px; align-items:center; flex-wrap:wrap; justify-content:space-between; }
.big-btn{ justify-content:center; padding:16px; font-size:17px; width:100%; }

/* Rota */
.rota-grid td{ vertical-align:top; min-width:96px; }
.rota-grid th.today, .rota-grid td.today{ background:var(--accent-soft); }
.rota-grid tr.me td:first-child{ border-left:3px solid var(--accent); }
.rota-grid tr.totals td{ font-weight:600; }
.rota-shift{ display:flex; flex-direction:column; align-items:flex-start; gap:1px; width:100%; margin:0 0 4px; padding:5px 7px; border-radius:8px; border:1px solid var(--accent); background:var(--accent-soft); color:inherit; font:inherit; font-size:13px; text-align:left; cursor:pointer; }
.rota-shift:disabled{ cursor:default; }
.rota-shift.draft{ border-style:dashed; background:transparent; }
.rota-shift.mine{ box-shadow:inset 3px 0 0 var(--accent); }
.rota-add{ width:100%; padding:2px; border:1px dashed var(--line, #ccc); border-radius:8px; background:transparent; color:var(--muted, #888); cursor:pointer; opacity:.55; }
.rota-add:hover{ opacity:1; }

.app-foot{ text-align:center; margin:28px 0 70px; }
.app-foot a{ color:inherit; }

/* Terms shown inside the app, with the agreement at the end */
.terms-scroll{ max-height:min(55vh,520px); overflow:auto; border:1px solid var(--line, #dde5e6); border-radius:10px; padding:4px 16px 14px; background:var(--surface, #fff); }
.legal-text{ font-size:14px; line-height:1.55; }
.legal-text h2{ font-size:17px; margin:22px 0 6px; } .legal-text h3{ font-size:15px; margin:16px 0 4px; }
.legal-text ol, .legal-text ul{ padding-left:20px; } .legal-text li{ margin:4px 0; }
.legal-text .box{ background:var(--accent-soft); border-left:4px solid var(--accent); padding:10px 14px; border-radius:6px; margin:12px 0; }
.legal-text .meta{ color:var(--muted, #667); font-size:13px; } .legal-text .missing{ color:var(--crit, #b23a2e); font-weight:600; }
.terms-agree{ display:flex; gap:10px; align-items:flex-start; margin:16px 0 4px; padding:12px; border-radius:10px; background:var(--accent-soft); font-size:15px; font-weight:600; text-transform:none; color:var(--text); cursor:pointer; }
.terms-agree input{ width:20px; height:20px; margin-top:2px; flex:none; }
.terms-status{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

/* Food safety plan */
.plan-point{ padding:10px 0; border-bottom:1px solid var(--border); line-height:1.45; }
.plan-point:last-of-type{ border-bottom:0; }
.plan-choice{ display:flex; gap:16px; flex-wrap:wrap; margin-top:6px; font-size:13.5px; }
.plan-choice label{ display:flex; align-items:center; gap:6px; text-transform:none; font-weight:500; color:var(--text); margin:0; }
.plan-choice input{ width:auto; }
.plan-point textarea{ margin-top:6px; }

/* Plans */
.plan-cards{ display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px; }
.plan-card{ display:flex; flex-direction:column; gap:4px; border:1.5px solid var(--border); border-radius:12px; padding:14px; cursor:pointer; text-transform:none; font-weight:400; color:var(--text); margin:0; }
.plan-card:has(input:checked){ border-color:var(--accent); background:var(--accent-soft); }
.plan-card input{ width:auto; align-self:flex-start; }
.plan-name{ font-weight:700; font-size:16px; }
.plan-price{ font-size:24px; font-weight:700; } .plan-price small{ font-size:13px; font-weight:500; color:var(--text-muted); }
