/* Lupii portal. Every colour and gap below is a token copied from ios/Lupii/Brand.swift
   (see DESIGN.md): never type a raw padding or colour into a rule, use the variable. */
:root {
  --paper: #fff; --surface: #f6f6f9; --ink: #0c0a1d; --muted: #6d6c77; --hairline: #ebeaf1; --tint: #efeaff;
  --blue: #4140fa; --purple-text: #6040e6; --night: #0c0a1d; --danger: #c2261d;
  --purple: #8062ff; --yellow: #e0ff00; --green: #acff7f; --pink: #e59ef5;
  --screen: 16px; --block: 14px; --section: 6px; --row: 10px; --field: 11px; --card: 16px; --card-gap: 5px;
  --inline: 10px; --text-gap: 3px; --chip-h: 10px; --chip-v: 5px; --control: 40px; --avatar: 48px;
  --radius-small: 8px; --radius: 12px; --report-radius: 24px; --report-pad: 22px; --report-gap: 24px; --chart: 156px;
  --side: 232px; --list: 340px; --sheet: 480px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0c0a1d; --surface: #1a182e; --ink: #f6f6f9; --muted: #a09fac; --hairline: #2c2a42; --tint: #2c2454;
  --blue: #8c96ff; --purple-text: #a894ff; --danger: #ff8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 36px; font-weight: 700; letter-spacing: -1.5px; line-height: 1.05; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: var(--section); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { opacity: 0.45; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.quiet { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.block { display: block; }
.pad { padding: var(--row) 0; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wordmark { font-size: 26px; font-weight: 800; letter-spacing: -1.2px; }

/* layout */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100%; }
.side { display: flex; flex-direction: column; gap: var(--block); padding: var(--screen); border-right: 1px solid var(--hairline); min-height: 0; }
.shop { display: flex; align-items: center; gap: var(--inline); min-width: 0; }
.shop div { display: flex; flex-direction: column; gap: var(--text-gap); min-width: 0; }
.shop strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; flex-direction: column; gap: var(--card-gap); }
.tab { display: flex; justify-content: space-between; align-items: center; padding: var(--row) var(--card); border-radius: var(--radius); font-weight: 600; color: var(--muted); }
.tab:hover { background: var(--surface); }
.tab.on { background: var(--ink); color: var(--paper); }
.count { background: var(--yellow); color: var(--night); border-radius: 999px; padding: 0 var(--section); font-size: 12px; font-weight: 700; min-width: 20px; text-align: center; }
.main { min-width: 0; min-height: 0; overflow-y: auto; }
.page { display: flex; flex-direction: column; gap: var(--block); padding: var(--screen); min-height: 100%; }
.page.narrow { max-width: 760px; margin: 0 auto; }
.title { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--inline); flex-wrap: wrap; }
.title > div:first-child { display: flex; flex-direction: column; gap: var(--text-gap); }
.title-actions { display: flex; gap: var(--card-gap); flex-wrap: wrap; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control); padding: 0 var(--card); border-radius: 999px; background: var(--surface); font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--hairline); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover:not(:disabled) { background: var(--ink); opacity: 0.86; }
.btn.danger { color: var(--danger); }
.btn.full { width: 100%; }
.link { color: var(--purple-text); font-weight: 600; }
.icon { width: var(--control); height: var(--control); border-radius: 50%; background: var(--surface); display: inline-grid; place-items: center; font-size: 20px; flex: none; }
input, select, textarea { width: 100%; background: var(--surface); border: 0; border-radius: var(--radius); padding: var(--field) var(--card); }
textarea { resize: vertical; }
input.pill { border-radius: 999px; }
select.plain { width: auto; padding: var(--chip-v) var(--chip-h); border-radius: var(--radius-small); }
input[type="checkbox"] { width: auto; }
.field { display: flex; flex-direction: column; gap: var(--section); }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--inline); }
.check { display: flex; align-items: center; gap: var(--inline); }
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.track { width: 46px; height: 28px; border-radius: 999px; background: var(--hairline); transition: background 0.15s; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--paper); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--purple); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }
.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: var(--text-gap); }
.seg button { padding: var(--chip-v) var(--chip-h); border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--paper); }
.chip { display: inline-block; padding: var(--chip-v) var(--chip-h); border-radius: var(--radius-small); background: var(--surface); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.tint { background: var(--tint); }
.chip.green { background: var(--green); color: var(--night); }
.chip.pink { background: var(--pink); color: var(--night); }
.dot { width: var(--inline); height: var(--inline); border-radius: 50%; background: var(--purple); display: inline-block; }

/* cards and rows */
.card { background: var(--surface); border-radius: var(--radius); padding: var(--card); }
.card.rows { padding: 0 var(--card); }
.rows > * + * { border-top: 1px solid var(--hairline); }
.row { display: flex; align-items: center; gap: var(--inline); width: 100%; padding: var(--row) 0; min-width: 0; }
button.row:hover, a.row:hover { opacity: 0.72; }
.row.danger strong { color: var(--danger); }
.row-text { display: flex; flex-direction: column; gap: var(--text-gap); flex: 1; min-width: 0; }
.row-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: var(--text-gap); flex: none; }
.row-end.inline { flex-direction: row; align-items: center; gap: var(--section); }
.chevron { color: var(--muted); font-size: 20px; line-height: 1; }
.avatar { width: var(--avatar); height: var(--avatar); border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 17px; flex: none; color: var(--night); }
.avatar.small { width: var(--control); height: var(--control); font-size: 14px; }
.tone-purple { background: var(--purple); } .tone-green { background: var(--green); } .tone-yellow { background: var(--yellow); } .tone-pink { background: var(--pink); }
.tone-tint { background: var(--tint); color: var(--ink); }
.thumb { width: var(--avatar); height: var(--avatar); border-radius: var(--radius-small); object-fit: cover; flex: none; background: var(--hairline); }
.line { display: flex; justify-content: space-between; align-items: center; gap: var(--inline); padding: var(--section) 0; }
.line.total { border-top: 1px solid var(--hairline); margin-top: var(--section); padding-top: var(--row); }
.person { display: flex; align-items: center; gap: var(--inline); min-width: 0; flex: 1; }
.person > span:last-child { display: flex; flex-direction: column; gap: var(--text-gap); min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: var(--card-gap); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--card-gap); }
.auto { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--inline); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--card-gap); }
.stat { background: var(--surface); border-radius: var(--radius); padding: var(--card); display: flex; flex-direction: column; gap: var(--text-gap); min-width: 0; }
.stat strong { font-size: 24px; letter-spacing: -0.8px; height: 36px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.empty { color: var(--muted); padding: var(--report-gap) 0; display: flex; flex-direction: column; gap: var(--block); align-items: flex-start; max-width: 460px; }
div.empty { padding: var(--report-gap) var(--screen); }
.empty h1 { color: var(--ink); }
.loading { display: flex; align-items: center; gap: var(--inline); color: var(--muted); padding: var(--screen); }
.flower { width: 14px; height: 14px; border-radius: 4px; background: var(--purple); animation: turn 1.4s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .flower { animation: none; } .track, .track::after { transition: none; } }
.note { background: var(--tint); border-radius: var(--radius); padding: var(--row) var(--card); }
.note.bad { color: var(--danger); }

/* chats */
.split { display: grid; grid-template-columns: var(--list) minmax(0, 1fr); height: 100%; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane.list { gap: var(--block); padding: var(--screen); border-right: 1px solid var(--hairline); }
.scroll { flex: 1; overflow-y: auto; min-height: 0; }
.group { display: flex; flex-direction: column; margin-bottom: var(--block); }
.group .row + .row { border-top: 1px solid var(--hairline); }
.row.on { background: var(--surface); border-radius: var(--radius); padding-left: var(--row); padding-right: var(--row); }
.thread.blank { align-items: center; justify-content: center; }
.thread-head { display: flex; align-items: center; gap: var(--inline); padding: var(--row) var(--screen); border-bottom: 1px solid var(--hairline); }
.back { display: none; }
.bubbles { display: flex; flex-direction: column; gap: var(--card-gap); padding: var(--screen); }
.bubble { max-width: min(72%, 560px); padding: var(--row) var(--card); border-radius: var(--radius); display: flex; flex-direction: column; gap: var(--text-gap); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.in { background: var(--surface); align-self: flex-start; }
.bubble.out { background: var(--tint); align-self: flex-end; }
.meta { font-size: 11px; color: var(--muted); align-self: flex-end; }
.day { align-self: center; font-size: 12px; color: var(--muted); padding: var(--section) 0; }
.composer { display: flex; align-items: flex-end; gap: var(--inline); padding: var(--row) var(--screen) var(--screen); }
.composer textarea { resize: none; max-height: 140px; }
.composer.closed { flex-direction: column; align-items: flex-start; }

/* orders */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--inline); align-items: start; }
.column { display: flex; flex-direction: column; gap: var(--section); min-width: 0; }
.column-list { display: flex; flex-direction: column; gap: var(--card-gap); }
.order { display: flex; flex-direction: column; gap: var(--section); width: 100%; }
.order:hover { opacity: 0.8; }
.order-top { display: flex; justify-content: space-between; align-items: center; gap: var(--inline); min-width: 0; }
.order-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { max-height: 260px; overflow-y: auto; }
.stepper { display: inline-flex; align-items: center; gap: var(--section); flex: none; }
.qty { min-width: 20px; text-align: center; font-weight: 600; }

.bring { display: flex; align-items: center; justify-content: space-between; gap: var(--inline); flex-wrap: wrap; background: var(--tint); }
.bring > div:first-child { flex: 1; min-width: 200px; }
.meter { flex-basis: 100%; height: var(--section); border-radius: 999px; background: var(--hairline); overflow: hidden; }
.meter-fill { height: 100%; background: var(--purple); border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--card-gap); }
/* analytics */
.report { background: var(--surface); border-radius: var(--report-radius); padding: var(--report-pad); display: flex; flex-direction: column; gap: var(--block); }
.headline { display: flex; align-items: center; gap: var(--inline); flex-wrap: wrap; }
.headline strong { font-size: 36px; letter-spacing: -1.5px; line-height: 1; }
.chart { height: var(--chart); display: flex; align-items: flex-end; gap: 2px; }
.bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.bar { width: 100%; background: var(--purple); border-radius: var(--text-gap) var(--text-gap) 0 0; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.about summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.about p { padding-top: var(--section); }

/* sheets and toasts */
.overlay { position: fixed; inset: 0; background: rgba(12, 10, 29, 0.42); display: flex; justify-content: flex-end; z-index: 10; }
.sheet { width: min(var(--sheet), 100%); height: 100%; background: var(--paper); display: flex; flex-direction: column; }
.sheet.wide { width: min(620px, 100%); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: var(--screen); }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 var(--screen) var(--avatar); display: flex; flex-direction: column; gap: var(--block); }
.sheet-body form { display: flex; flex-direction: column; gap: var(--block); }
.choice { display: flex; flex-direction: column; gap: var(--text-gap); width: 100%; padding: var(--card); border-radius: var(--radius); background: var(--surface); }
.choice.on { background: var(--tint); }
.toast { position: fixed; left: 50%; bottom: var(--report-gap); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: var(--row) var(--card); border-radius: 999px; font-weight: 600; z-index: 20; max-width: calc(100% - 2 * var(--screen)); }
.toast.bad { background: var(--danger); color: #fff; }

/* sign in: always light, like the phone app */
.entry { min-height: 100%; display: grid; place-items: center; padding: var(--screen); background: #fff; color: #0c0a1d; }
.entry-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--block); }
.entry-links { display: flex; justify-content: space-between; gap: var(--inline); flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .side { order: 2; flex-direction: row; padding: var(--section) var(--section) calc(var(--section) + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--hairline); }
  .side .wordmark, .side .shop { display: none; }
  .tabs { flex-direction: row; flex: 1; justify-content: space-between; overflow-x: auto; }
  .tab { padding: var(--row) var(--inline); font-size: 13px; gap: var(--text-gap); }
  .split { grid-template-columns: 1fr; }
  .pane.list.has-open { display: none; }
  .pane.list { border-right: 0; }
  .thread.blank { display: none; }
  .back { display: inline-grid; }
  .board { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  h1 { font-size: 30px; }
}

/* The install offer shows on the sign-in screens only, where the corner is empty: inside the app
   that corner holds the message box. A notice that appears meanwhile sits above it. See install.js. */
#install { display: none; position: fixed; right: var(--screen); bottom: calc(var(--report-gap) + env(safe-area-inset-bottom)); z-index: 9; box-shadow: 0 6px 20px rgba(12, 10, 29, 0.22); }
body:has(main.entry) #install { display: inline-flex; }
body:has(main.entry) #install ~ .toast { bottom: calc(var(--report-gap) + var(--control) + var(--row) + env(safe-area-inset-bottom)); }
