:root {
  --ink: #15211f; --muted: #5d6b68; --line: #dbe3e1; --bg: #f4f6f5; --card: #fff;
  --brand: #0f3d3e; --brand-2: #1b5e5f; --gold: #f2c14e; --gold-dark: #b8860b;
  --ok: #1e8e5a; --ok-bg: #e3f5ec; --warn: #a86400; --warn-bg: #fff3dc; --bad: #c0392b; --bad-bg: #fde8e6;
  --radius: 14px; --shadow: 0 6px 20px rgba(15, 61, 62, .08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
.boot { display: grid; place-items: center; min-height: 100vh; font-weight: 800; color: var(--brand); font-size: 22px; }

/* layout */
.top { position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 18px; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .back, .top .icon-btn { background: transparent; border: 0; color: #fff; font-size: 22px; padding: 4px 8px; cursor: pointer; }
.top .net { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.15); }
.top .net.off { background: var(--gold); color: var(--brand); font-weight: 700; }
main { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(110px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h2 { font-size: 17px; margin: 0 0 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.mt { margin-top: 12px; }
.hidden { display: none !important; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; color: var(--brand); }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--brand); background: var(--card); color: var(--brand); border-radius: 12px; padding: 11px 16px; font-weight: 700; cursor: pointer; min-height: 46px; text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--brand); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20; width: min(92vw, 520px); font-size: 18px; min-height: 58px; box-shadow: 0 10px 30px rgba(15, 61, 62, .35); }

/* forms */
label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; min-height: 46px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(27, 94, 95, .15); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.check-row input { width: 22px; min-height: 22px; height: 22px; }
.check-row label { margin: 0; color: var(--ink); font-size: 15px; }
.qty { display: flex; gap: 8px; align-items: stretch; }
.qty input { text-align: center; font-size: 22px; font-weight: 800; }
.qty button { width: 56px; font-size: 24px; }
.ai-high { border-color: var(--ok); background: var(--ok-bg); }
.ai-check { border-color: var(--gold-dark); background: var(--warn-bg); }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hint.warn { color: var(--warn); font-weight: 700; }

/* photos */
.photos { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.photo { position: relative; flex: 0 0 auto; width: 96px; height: 96px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #e9eeed; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }
.photo .badge { position: absolute; left: 4px; bottom: 4px; }
.add-photo { flex: 0 0 auto; width: 96px; height: 96px; border-radius: 12px; border: 2px dashed var(--brand-2); background: #fff; color: var(--brand-2); font-weight: 700; font-size: 13px; cursor: pointer; }
.ai-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #eef5f4; font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 3px solid rgba(15,61,62,.2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* lists */
.list { display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; text-align: left; width: 100%; color: inherit; text-decoration: none; }
.item .name { font-weight: 700; }
.item .thumb { width: 48px; height: 48px; flex: none; border-radius: 10px; object-fit: cover; background: #e9eeed; }
.item .qty-pill { font-weight: 800; font-size: 18px; color: var(--brand); min-width: 48px; text-align: right; }
.badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #e9eeed; color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.pills { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0 12px; }
.pills button { flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.pills button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
table.map { width: 100%; border-collapse: collapse; font-size: 14px; }
table.map td, table.map th { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: middle; }
table.map select, table.map input { min-height: 38px; padding: 6px 8px; }
.complete-bar { margin: -4px 0 10px; }
.mult-line { margin-top: 6px; gap: 8px; }
.tab-box { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #eef5f4; }
.unit-prices th:not(:first-child), .unit-prices td:not(:first-child) { text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 30, 30, .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: min(100%, 560px); max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.modal h3 { margin: 0 0 8px; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
#toasts { position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 92vw; box-shadow: var(--shadow); font-size: 14px; }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }
.auth { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.auth .logo { width: 72px; height: 72px; display: block; margin: 0 auto 10px; }
.auth h1 { text-align: center; color: var(--brand); margin: 0 0 4px; }
.install { max-width: 520px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 16px 40px; text-align: left; }
.install .logo { display: block; margin: 0 auto 8px; border-radius: 20px; }
.install h1 { text-align: center; color: var(--brand); margin: 0 0 6px; }
.install > p.muted { text-align: center; }
.install ol { margin: 8px 0 0; padding-left: 22px; line-height: 1.7; }
.install .qr { display: block; margin: 6px auto; width: 220px; height: 220px; }
.center { text-align: center; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; background: var(--warn-bg); color: var(--warn); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
/* team activity */
.act meter, .hour meter { width: 100%; height: 10px; }
.act { margin-bottom: 0; }
.act .name { font-weight: 700; }
.hours { display: grid; gap: 6px; }
.hour { display: grid; grid-template-columns: 48px 1fr 36px; gap: 8px; align-items: center; }
.hour .strong { text-align: right; }
/* bulk add */
.bulk-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.bulk-row.off { opacity: .5; }
.bulk-row .tick { width: 22px; height: 22px; min-height: 22px; flex: none; }
.bulk-row .thumb { width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: cover; }
.bulk-row input:not(.tick) { min-height: 38px; padding: 6px 8px; }
.bulk-row label { margin: 0; font-size: 12px; }
.bulk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 8px; margin-top: 8px; }
@media (min-width: 640px) { .bulk-grid { grid-template-columns: repeat(6, 1fr); } }
.drug { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 120px)); gap: 8px; margin-top: 8px; }
.slot { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #e9eeed; padding: 0; cursor: pointer; }
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(15, 61, 62, .75); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 4px; text-align: center; }
.slot.empty { border: 2px dashed var(--brand-2); background: #fff; color: var(--brand-2); font-weight: 700; font-size: 13px; }
.slot-preview { width: 100%; max-height: 50vh; object-fit: contain; border-radius: 10px; background: #e9eeed; }
.icon-x { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 6px; }
/* teams, sign-up and payment */
.team-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--warn-bg); color: var(--warn); font-size: 14px; font-weight: 700; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plan { display: grid; gap: 2px; text-align: left; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; color: inherit; }
.plan span { font-size: 13px; color: var(--muted); }
.plan.on { border-color: var(--brand); background: #eef5f4; }
.pay { text-align: center; }
.pay-amount { font-size: 40px; font-weight: 900; color: var(--brand); }
.pay-to { margin-top: 10px; font-size: 28px; font-weight: 900; letter-spacing: .04em; }
.team-card { margin-bottom: 0; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
