/* Pröjsa site. Plommon (#4F2D8C) is the apps' brand colour; neutrals lean towards it. */

:root {
  --brand: #4f2d8c;
  --brand-strong: #3d2170;
  --on-brand: #ffffff;
  --brand-soft: #efe9f8;
  --bg: #f7f5fb;
  --surface: #ffffff;
  --text: #1d1a24;
  --muted: #6b6577;
  --border: #e4dfec;
  --ok: #1f7a4d;
  --ok-soft: #e5f4ec;
  --warn: #a5410e;
  --warn-soft: #fbece3;
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #b79ce8;
    --brand-strong: #cdb8f1;
    --on-brand: #1c1129;
    --brand-soft: #2c2340;
    --bg: #131017;
    --surface: #1e1a24;
    --text: #f1edf6;
    --muted: #a69fb2;
    --border: #2f2938;
    --ok: #6fd4a0;
    --ok-soft: #173326;
    --warn: #f3a37a;
    --warn-soft: #3a2218;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--brand); }
b { font-weight: 650; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 40px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.page.center { min-height: 100vh; justify-content: center; align-items: center; text-align: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Buttons ---------------------------------------------------------------- */

button, .button {
  font: inherit;
  font-weight: 600;
  color: var(--brand);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled { opacity: 0.4; cursor: default; }
button:active:not(:disabled), .button:active { transform: scale(0.98); }
.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.big { min-height: 54px; font-size: 1.05rem; width: 100%; }
.ghost { border-style: dashed; background: transparent; }
.small { min-height: 34px; padding: 4px 10px; font-size: 0.85rem; border-radius: 10px; }
.icon { min-height: 40px; width: 40px; padding: 0; font-size: 1.3rem; color: var(--muted); border: none; background: transparent; }
.link { border: none; background: none; min-height: auto; padding: 4px; text-decoration: underline; font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions > * { flex: 1 1 160px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 550;
  color: var(--text);
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.chip.add { border-style: dashed; color: var(--brand); }

/* Landing ---------------------------------------------------------------- */

.brand-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.05rem; align-self: flex-start; }
.brand-link .logo { width: 26px; height: 30px; }
.brand-link.small .logo { width: 20px; height: 24px; }
.hero { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 12px; }
.hero .logo { width: 52px; height: 60px; }
.hero h1 { font-size: 2.4rem; color: var(--brand); }
.lead { font-size: 1.15rem; color: var(--text); max-width: 32ch; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; }
.steps li::before {
  content: counter(step);
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 0.95rem;
}

.tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; align-self: flex-start; }
.tabs button { border: none; background: transparent; min-height: 36px; padding: 6px 18px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.guide { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 550; }
pre {
  white-space: pre-wrap; word-break: break-word; font-size: 0.8rem; line-height: 1.45;
  background: var(--bg); border-radius: 10px; padding: 12px; margin: 10px 0 0; max-height: 320px; overflow: auto;
}
.recent { list-style: none; margin: 0; padding: 0; }
.recent a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; text-decoration: none; color: var(--text); border-top: 1px solid var(--border); }
.recent li:first-child a { border-top: none; }
.manual { text-align: center; }
.fine { font-size: 0.82rem; color: var(--muted); text-align: center; max-width: 46ch; margin: 0 auto; }

/* Receipt check ---------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 550; font-size: 0.92rem; }
input {
  font: inherit; font-weight: 400; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; resize: vertical;
}
textarea:focus, input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.place input { font-size: 1.1rem; font-weight: 600; }
.hint { font-size: 0.85rem; color: var(--muted); }

.edit-head, .edit-row { display: grid; grid-template-columns: 1fr 52px 92px 36px; gap: 6px; align-items: center; }
.edit-head { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 2px; }
#rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.edit-row input { padding: 8px 9px; }
.edit-row .qty, .edit-row .price { text-align: right; font-variant-numeric: tabular-nums; }
.total-row { display: grid; grid-template-columns: 1fr 120px; gap: 8px; align-items: center; font-weight: 600; border-top: 1px solid var(--border); padding-top: 12px; }
.total-row input { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.check { border-radius: 10px; padding: 10px 12px; background: var(--bg); font-size: 0.92rem; }
.check.ok { background: var(--ok-soft); color: var(--ok); }
.check.warn { background: var(--warn-soft); color: var(--warn); }

/* The live split --------------------------------------------------------- */

.split { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); }
.split-head { display: flex; flex-direction: column; gap: 8px; }
.topline { display: flex; justify-content: space-between; align-items: center; }
.status { font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.status.live { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.status.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.meter { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.meter .bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--brand); border-radius: inherit; transition: width 0.3s ease; }
.meter.done { color: var(--ok); font-weight: 600; }
.meter.done .bar i { background: var(--ok); }

.for-who { display: flex; flex-direction: column; gap: 8px; }
.for-who .tip { align-self: flex-start; }

.items { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color 0.15s; }
.item.mine { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.item.full { opacity: 0.55; }
.item-tap {
  width: 100%; border: none; border-radius: 0; background: transparent; color: var(--text);
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; text-align: left; padding: 14px 16px; font-weight: 500;
}
.item-name { font-weight: 600; }
.qty { color: var(--muted); font-weight: 500; }
.item-price { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.claimers { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.85rem; }
.who { background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 2px 10px; font-weight: 600; }
.who.me { background: var(--brand); color: var(--on-brand); }
.nobody { color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 10px; padding: 0 16px 12px; }
.stepper button { width: 40px; min-height: 40px; padding: 0; font-size: 1.3rem; border-radius: 50%; }
.stepper .count { min-width: 1.5ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.people ul { list-style: none; margin: 0; padding: 0; }
.person {
  display: grid; grid-template-columns: 12px 1fr auto auto; gap: 4px 10px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums;
}
.person:first-child { border-top: none; }
.pname { font-weight: 600; display: flex; flex-direction: column; }
.pname small { font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.pamount { font-weight: 600; }
.pstatus { font-size: 0.85rem; color: var(--muted); min-width: 4.5em; text-align: right; }
.person.paid .pstatus { color: var(--ok); font-weight: 600; }
.pactions { grid-column: 2 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--ok); }

.me-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.08);
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 14px);
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.me-bar > * { max-width: 528px; width: 100%; margin: 0 auto; }
.you { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-variant-numeric: tabular-nums; }
.you b { font-size: 1.35rem; white-space: nowrap; }
.you small { display: block; color: var(--muted); font-size: 0.82rem; }
.you.done { color: var(--ok); }
.swish { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* Dialogs and toasts ----------------------------------------------------- */

dialog {
  border: none; border-radius: 20px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
dialog::backdrop { background: rgb(20 12 30 / 0.45); }
.sheet { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.sheet.center { align-items: stretch; text-align: center; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: min(280px, 100%); margin: 0 auto; }
.qr svg { display: block; width: 100%; height: auto; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 120px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-weight: 550; max-width: calc(100vw - 32px); transition: opacity 0.2s, transform 0.2s; z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
