@import url("../assets/tokens.css");

body { background: var(--bg); }
/* Inline icons size to the text they sit in; components with their own
   icon sizes override this below. */
svg { width: 1.1em; height: 1.1em; vertical-align: -0.2em; flex: none; }
.pill svg, .status svg { width: 14px; height: 14px; }
.btn svg { width: 18px; height: 18px; }
.chip svg { width: 16px; height: 16px; }
.store-switch svg { width: 16px; height: 16px; }
.store-switch { white-space: nowrap; }
.store-switch img { width: 22px; height: 22px; border-radius: 6px; vertical-align: -6px; }
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Shell: sidebar on wide screens, tab bar on phones */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.side { border-right: 1px solid var(--line); background: var(--surface); padding: 20px 14px; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 6px; }
.side .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); padding: 6px 10px 18px; }
.side .brand img { width: 30px; height: 30px; border-radius: 9px; }
.side .brand:hover { text-decoration: none; }
.navlink { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--ink); font-weight: 500; font-size: 15.5px; }
.navlink svg { width: 22px; height: 22px; color: var(--muted); }
.navlink:hover { background: var(--bg); text-decoration: none; }
.navlink.is-active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.navlink.is-active svg { color: var(--green); }
.navlink .count { margin-left: auto; background: var(--green); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.side .spacer { flex: 1; }
.side .demo-note { font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-top: 1px solid var(--line); }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.content { width: min(960px, 100%); margin: 0 auto; padding: 24px; display: grid; gap: 18px; }
.tabbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .content { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  .topbar { padding: 12px 16px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--muted); border-radius: 10px; position: relative; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a.is-active { color: var(--green); }
  .tabbar .count { position: absolute; top: 2px; right: 18%; background: var(--green); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
}

/* Cards and lists */
.card + .card { margin-top: 0; }
.card.tight { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.row + .row { border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 15.5px; }
.row .sub { color: var(--muted); font-size: 13.5px; }
.row .amount { font-weight: 600; white-space: nowrap; }
a.row { color: inherit; }
a.row:hover { text-decoration: none; background: var(--bg); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 -6px; }
.section-title h2 { font-size: 17px; margin: 0; }
.section-title a, .section-title button { font-size: 14px; font-weight: 600; background: none; border: 0; color: var(--green); padding: 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.icon-tile { width: 44px; height: 44px; border-radius: 12px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; flex: none; }
.icon-tile svg { width: 22px; height: 22px; }
.icon-tile.amber { background: var(--amber-soft); color: var(--amber); }
.icon-tile.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.icon-tile.muted { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); }
.icon-tile.photo { background: #fff; border: 1px solid var(--line); overflow: hidden; }
.icon-tile.photo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.icon-tile.photo.amber { box-shadow: inset 0 0 0 2px var(--amber); }
.icon-tile.photo.danger { box-shadow: inset 0 0 0 2px var(--danger); }
.initials { width: 44px; height: 44px; border-radius: 12px; background: var(--green); color: #fff; font-weight: 700; display: grid; place-items: center; flex: none; }

.greeting { font-size: clamp(26px, 3vw, 32px); font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.store-switch { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; font-size: 15px; background: none; border: 0; padding: 4px 0; }
.points { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); background: var(--amber-soft); }
.points strong { font-size: 20px; display: block; }
.points .small { color: var(--muted); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin: 10px 0 6px; font-size: 17px; }
.empty svg { width: 36px; height: 36px; color: var(--muted); }

/* Status */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status.amber { background: var(--amber-soft); color: var(--amber); }
.status.green { background: var(--green-soft); color: var(--green); }
.status.muted { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); }
.status.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.timeline { display: grid; grid-template-columns: repeat(4, 1fr); position: relative; padding: 6px 0; }
.timeline::before { content: ""; position: absolute; top: 18px; left: 12.5%; right: 12.5%; height: 3px; background: var(--line); border-radius: 2px; }
.timeline .fill { position: absolute; top: 18px; left: 12.5%; height: 3px; background: var(--green); border-radius: 2px; }
.timeline .step { display: grid; justify-items: center; gap: 6px; font-size: 12px; color: var(--muted); position: relative; }
.timeline .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--line); display: grid; place-items: center; color: var(--muted); }
.timeline .step.done { color: var(--ink); font-weight: 600; }
.timeline .step.done .dot { background: var(--green); color: #fff; }
.timeline .dot svg { width: 13px; height: 13px; }

/* Shop */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: 14.5px; }
.chip.is-active { background: var(--green); color: #fff; border-color: var(--green); }
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search input { flex: 1; border: 0; background: none; min-height: 46px; outline: none; }
.search svg { width: 18px; height: 18px; color: var(--muted); }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.product { display: flex; gap: 12px; align-items: center; padding: 12px; }
.product .name { font-weight: 600; font-size: 15px; line-height: 1.3; }
.product .meta { color: var(--muted); font-size: 13px; }
.product .price { font-weight: 700; margin-top: 2px; }
.product .controls { margin-left: auto; display: grid; gap: 6px; justify-items: end; }
.plus { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; }
.plus[disabled] { background: var(--muted); opacity: .6; }
.plus svg { width: 16px; height: 16px; }
.stepper { display: inline-flex; align-items: center; background: var(--green-soft); border-radius: 999px; color: var(--green); font-weight: 600; }
.stepper button { width: 34px; height: 32px; border: 0; background: none; color: inherit; display: grid; place-items: center; }
.stepper button svg { width: 15px; height: 15px; }
.stepper span { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.linkish { background: none; border: 0; color: var(--green); font-weight: 600; font-size: 13px; padding: 0; }

/* Basket drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--bg); z-index: 31; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer header h2 { margin: 0; font-size: 18px; }
.drawer .body { flex: 1; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.drawer .body > * { flex: none; }
.drawer footer { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.basket-fab { position: fixed; right: 20px; bottom: 24px; z-index: 12; box-shadow: var(--shadow); }
@media (max-width: 860px) { .basket-fab { bottom: calc(84px + env(safe-area-inset-bottom)); right: 16px; } }

/* Forms */
.field { display: grid; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); width: 100%; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; text-align: center; padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: 14.5px; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--green-soft); color: var(--green); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }
.error { color: var(--danger); font-weight: 600; font-size: 14.5px; }
.ok { color: var(--green); font-weight: 600; font-size: 14.5px; }
.summary { display: grid; gap: 8px; }
.summary div { display: flex; justify-content: space-between; }
.actions-col { display: grid; gap: 10px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Auth */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .side-art { background: linear-gradient(160deg, var(--green-deep), var(--green)); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .side-art h2 { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 12px; }
.auth .side-art p { color: rgba(255,255,255,.85); max-width: 32em; }
.auth .form-col { display: grid; place-items: center; padding: 32px 20px; }
.auth form { width: min(420px, 100%); display: grid; gap: 14px; }
.auth h1 { font-size: 28px; margin: 0; letter-spacing: -0.02em; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth .side-art { padding: 28px 20px; } .auth .side-art .spacer-art { display: none; } }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: grid; place-items: end center; }
@media (min-width: 700px) { .modal-backdrop { place-items: center; } }
.modal { width: min(560px, 100%); max-height: 92dvh; overflow: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
@media (min-width: 700px) { .modal { border-radius: 22px; } }
.modal header { display: flex; justify-content: space-between; align-items: center; }
.modal header h2 { margin: 0; font-size: 19px; }
.close { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; }
.close svg { width: 16px; height: 16px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow); max-width: min(520px, 92%); }
@media (max-width: 860px) { .toast { bottom: calc(92px + env(safe-area-inset-bottom)); } }

/* Spend bars */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 10px; font-size: 14px; }
.bar .track { height: 10px; background: var(--green-soft); border-radius: 6px; overflow: hidden; }
.bar .track i { display: block; height: 100%; background: var(--green); border-radius: 6px; }
.bar .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
