:root {
  --bg: #f6f5f1; --panel: #ffffff; --line: #e4e1da; --text: #1e1d1a; --muted: #6d6a63;
  --accent: #d8572a; --accent-text: #ffffff; --accent-soft: #fbe8df;
  --green: #1f7a42; --green-soft: #e2f3e8; --blue: #2457a6; --blue-soft: #e5edfa;
  --amber: #8a5a00; --amber-soft: #fdf1d6; --red: #b3261e; --red-soft: #fbe4e2; --grey-soft: #efede8;
  --chat-bg: #efe7dd; --bubble-in: #ffffff; --bubble-out: #d9fdd3;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --panel: #1f1e1b; --line: #34322d; --text: #ece9e2; --muted: #a29e94;
    --accent: #ef7a4c; --accent-text: #1a0f0a; --accent-soft: #3a2419;
    --green: #6fcf94; --green-soft: #1d3326; --blue: #8fb3f0; --blue-soft: #1c2a40;
    --amber: #f0c060; --amber-soft: #3a2f16; --red: #f08a82; --red-soft: #3d1f1c; --grey-soft: #2a2925;
    --chat-bg: #0f1a17; --bubble-in: #24302c; --bubble-out: #1f4a3a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
code { background: var(--grey-soft); padding: 1px 6px; border-radius: 6px; font-size: 13px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; font-size: 17px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-size: 15px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { text-decoration: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav a:hover { background: var(--grey-soft); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--accent); }
.count { background: var(--accent); color: var(--accent-text); border-radius: 99px; font-size: 11px; padding: 1px 7px; margin-left: 4px; font-weight: 700; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 80px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

button, .btn { font: inherit; font-weight: 600; font-size: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { background: var(--grey-soft); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.05); }
button.success { background: var(--green); border-color: var(--green); color: var(--panel); }
button.danger { color: var(--red); }
button.big { padding: 12px 22px; font-size: 16px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: none; background: none; padding: 0 4px; color: var(--muted); font-weight: 500; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=number], input[type=tel], input[type=password], input:not([type]), select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.was { font-size: 12px; color: var(--muted); margin-top: 3px; }
.was b { color: var(--text); font-weight: 500; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .6; margin-left: 4px; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.b-new { background: var(--accent-soft); color: var(--accent); }
.b-approved { background: var(--blue-soft); color: var(--blue); }
.b-in_pack { background: var(--amber-soft); color: var(--amber); }
.b-done { background: var(--green-soft); color: var(--green); }
.b-rejected { background: var(--grey-soft); color: var(--muted); }
.t-new_item { background: var(--green-soft); color: var(--green); }
.t-update_item { background: var(--blue-soft); color: var(--blue); }
.t-other { background: var(--grey-soft); color: var(--muted); }
.t-menu_file { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.t-menu_file { background: var(--green-soft, var(--blue-soft)); color: var(--green, var(--blue)); }

.list { display: flex; flex-direction: column; gap: 8px; }
.task-row { display: grid; grid-template-columns: 56px minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.task-row:hover { border-color: var(--accent); }
.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--grey-soft); display: grid; place-items: center; color: var(--muted); font-size: 20px; }
.task-row .title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.task-row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .meta { text-align: right; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.photo-box { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--grey-soft); }
.photo-box img { width: 100%; display: block; max-height: 320px; object-fit: contain; background: #000; }
.photo-box .cap { padding: 8px 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--panel); }
.photo-none { padding: 32px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.note-box { background: var(--amber-soft); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; }

table.data { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
table.data tr:last-child td { border-bottom: none; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--bg); }
table.data img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; display: block; }
.table-wrap { overflow-x: auto; }

.pack-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pack-card.done { opacity: .7; }
.pack-card .head { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pack-card .head h2 { margin: 0; flex: 1; }
.pack-card .body { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 16px; padding: 14px; }
.pack-card .body img { width: 180px; height: 135px; object-fit: cover; border-radius: 8px; display: block; }
.kv { display: grid; grid-template-columns: 150px minmax(0,1fr) auto; gap: 4px 10px; align-items: start; font-size: 14px; }
.kv .k { color: var(--muted); }
.kv .v { white-space: pre-wrap; }
.ticks { display: flex; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--bg); flex-wrap: wrap; }
.tick { display: flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 14px; }
.tick.on { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.go-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.go-box .big-n { font-size: 34px; font-weight: 700; line-height: 1; }

/* WhatsApp simulator */
.sim { display: grid; grid-template-columns: 380px minmax(0,1fr); gap: 20px; align-items: start; }
.phone { border: 1px solid var(--line); border-radius: 22px; overflow: hidden; background: var(--chat-bg); display: flex; flex-direction: column; height: 640px; box-shadow: var(--shadow); }
.phone-top { background: #1f6f5c; color: #fff; padding: 12px 14px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.phone-top small { display: block; font-weight: 400; opacity: .8; font-size: 12px; }
.chat { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 85%; padding: 7px 10px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.bubble.bot { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 2px; }
.bubble.owner { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 2px; }
.bubble img { max-width: 100%; border-radius: 6px; display: block; margin-bottom: 4px; }
.bubble .actions { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.bubble .actions button { justify-content: center; border: none; color: #1f8a70; background: transparent; padding: 4px; }
.bubble .actions button:hover { background: var(--grey-soft); }
.bubble .time { font-size: 10px; color: var(--muted); text-align: right; margin-top: 2px; }
.composer { display: flex; gap: 6px; padding: 8px; background: var(--panel); border-top: 1px solid var(--line); align-items: center; }
.composer input[type=text] { border-radius: 99px; }
.composer label.attach { cursor: pointer; padding: 6px 8px; font-size: 18px; }
.list-pick { display: flex; flex-direction: column; gap: 2px; }
.list-pick button { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; gap: 0; border: none; border-bottom: 1px solid var(--line); border-radius: 0; }
.list-pick button small { color: var(--muted); font-weight: 400; }

dialog { border: none; border-radius: 16px; padding: 0; width: min(520px, 94vw); background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.45); }
#modal-body { padding: 20px; max-height: 85vh; overflow-y: auto; }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opts label { display: flex; gap: 8px; align-items: center; font-size: 14px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 500; transition: transform .2s; z-index: 50; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); color: #fff; }

.status-list { list-style: none; padding: 0; margin: 0; }
.status-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.status-list li:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 99px; margin-top: 7px; flex: none; }
.dot.ok { background: var(--green); } .dot.no { background: var(--amber); }
ol.steps { padding-left: 20px; } ol.steps li { margin-bottom: 6px; }

@media (max-width: 860px) {
  .grid2, .sim { grid-template-columns: 1fr; }
  .pack-card .body { grid-template-columns: 1fr; }
  .pack-card .body img { width: 100%; height: 200px; }
  .kv { grid-template-columns: 1fr auto; } .kv .k { grid-column: 1 / -1; margin-top: 4px; }
  main { padding: 16px 16px 80px; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .task-row { grid-template-columns: 48px minmax(0,1fr); }
  .task-row .meta { grid-column: 2; align-items: flex-start; flex-direction: row; }
}

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px; }
.login-error { background: var(--red-soft); color: var(--red); padding: 8px 12px; border-radius: 8px; margin: 0 0 14px; font-size: 14px; }
.logout { margin-left: auto; color: var(--muted); font-size: 14px; text-decoration: none; }
.logout:hover { color: var(--text); }

#token-banner { background: var(--amber-soft); color: var(--amber); padding: 10px 24px; font-weight: 500; font-size: 14px; border-bottom: 1px solid var(--line); }
#token-banner a { color: inherit; font-weight: 700; }
details summary { cursor: pointer; }

.t-delete_item { background: var(--red-soft); color: var(--red); }
.warn-box { background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 10px 12px; }
button.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.confirm-body { color: var(--muted); }
.confirm-body .note-box { color: var(--text); margin-top: 6px; }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; color: var(--text); }

dialog.wide { width: min(900px, 96vw); }
.err-text { color: var(--red); }

.composer textarea { border-radius: 18px; min-height: 38px; max-height: 140px; resize: none; padding: 8px 12px; }
.bubble.owner { white-space: pre-wrap; }

.req { color: var(--red); font-weight: 700; }

.account { margin-left: auto; position: relative; }
.account-btn { border: none; background: none; color: var(--muted); font-weight: 500; padding: 6px 12px; }
.account-btn:hover, .account-btn.active, .account-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.account-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; z-index: 20; }
.account-menu[hidden] { display: none; }
.account-who { padding: 8px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.account-menu a, .account-menu .menu-logout { display: block; width: 100%; text-align: left; text-decoration: none; padding: 8px 10px; border-radius: 6px; color: var(--text); font-weight: 500; font-size: 14px; border: none; background: none; }
.account-menu a:hover, .account-menu a.active { background: var(--accent-soft); color: var(--accent); }
.account-menu .menu-logout { color: var(--red); }
.account-menu .menu-logout:hover { background: var(--red-soft); }
.logout-form { margin: 0; }
.login-note { background: var(--green-soft); color: var(--green); padding: 8px 12px; border-radius: 8px; margin: 0 0 14px; font-size: 14px; }

/* Upload packs: pending packs as drop-downs, completed ones folded away */
details.pack-row, details.completed-packs { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--panel); }
details.pack-row > summary, details.completed-packs > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; font-weight: 500; }
details > summary::-webkit-details-marker { display: none; }
.chev { display: inline-block; transition: transform .15s; color: var(--muted); }
details[open] > summary .chev { transform: rotate(90deg); }
.pack-row-body { padding: 4px 14px 12px; border-top: 1px solid var(--line); }
.mini-task { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mini-task:last-child { border-bottom: none; }
.mini-task a { text-decoration: none; }
.mini-task .tick { padding: 4px 10px; font-size: 13px; }
details.completed-packs > .table-wrap, details.completed-packs > .stack { padding: 0 14px 14px; }
details.rejected-pack { opacity: .85; }
a.mini-task { color: inherit; text-decoration: none; }
a.mini-task:hover b { text-decoration: underline; }

/* WhatsApp log (Restaurants → 💬 WhatsApp log): the owner on the left, our replies on the right */
.wl-chat { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; padding: 10px; background: var(--chat-bg); border-radius: 10px; }
.wl-chat .empty { background: transparent; }
.wl-day { align-self: center; font-size: 12px; color: var(--muted); background: var(--bubble-in); padding: 2px 10px; border-radius: 10px; margin: 6px 0 2px; }
.bubble.wl-in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 2px; }
.bubble.wl-out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 2px; }
.wl-read { color: #1f8a70; }
.wl-failed { color: var(--red); }
button.mini { padding: 4px 8px; font-size: 13px; }

/* An owner's set of dish photos (Tasks → Dish photos) */
.t-dish_photos { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.dp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.dp-cell { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: inherit; text-decoration: none; word-break: break-word; }
.dp-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

/* "Photos of food, not a menu?" on a Full menu task */
.hint-box { background: var(--blue-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* Menus page: tick dishes to change or delete several at once */
th.pick, td.pick { width: 28px; text-align: center; }
td.pick input, th.pick input { width: 18px; height: 18px; cursor: pointer; }
.sel-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; background: var(--blue-soft); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.sel-bar[hidden] { display: none; }

/* Full menu task: what to do next after loading */
.next-steps { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.next-steps li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line, #e6e1d8); border-radius: 10px; }
.next-steps .step-no { flex: none; width: 24px; height: 24px; border-radius: 50%; background: #1f6f5c; color: #fff; font-size: 13px; font-weight: 600; display: grid; place-items: center; }
.next-steps .btn, .next-steps button { flex: none; }

/* "Next step" box: what to do now at each stage */
.next-box { border: 1px solid #b9dccf; background: #f0f8f4; border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; }
.next-box.done { border-color: #e6e1d8; background: #faf8f4; }
.next-box .next-title { font-weight: 700; font-size: 14px; color: #1f6f5c; margin-bottom: 4px; }
.next-box.done .next-title { color: #6b6457; }
.next-box .next-steps { margin-top: 4px; gap: 6px; }
.next-box .next-steps li { border: 0; padding: 4px 0; }
.next-panel { border: 1px solid #b9dccf; }

.next-steps li { flex-wrap: wrap; }
.next-steps li > .spacer { flex: 1 1 260px; min-width: 0; }
.next-steps .step-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
