/* Signed-in app shell + screens. Uses only tokens from site.css. */

.app-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: var(--space-8); padding-block: var(--space-6) var(--space-16); align-items: start; }
.app-side { position: sticky; top: calc(var(--header-h) + var(--space-4)); display: grid; gap: 2px; font-size: var(--text-sm); }
.app-side a { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius); color: var(--muted); text-decoration: none; font-weight: 600; min-height: 40px; white-space: nowrap; }
.app-side a:hover { background: var(--paper-2); color: var(--fg); }
.app-side a[aria-current="page"] { background: var(--card); color: var(--fg); box-shadow: var(--shadow-1); border: var(--rule); }
.app-side a .count-badge { margin-left: auto; }
.app-side__h { font-size: var(--text-xs); color: var(--subtle); font-weight: 700; padding: var(--space-4) var(--space-3) var(--space-1); }
.app-main { min-width: 0; }
@media (max-width: 899px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); padding-top: var(--space-4); }
  .app-side { display: none; }
}

.app-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.app-head h1 { font-size: var(--text-2xl); }
.app-head .sub { color: var(--muted); margin-top: var(--space-1); }
.app-back { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--muted); text-decoration: none; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-3); }
.app-back:hover { color: var(--fg); }
.app-section + .app-section { margin-top: var(--space-8); }
.app-section > h2 { font-size: var(--text-lg); margin-bottom: var(--space-4); }
.app-grid-2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
@media (max-width: 1023px) { .app-grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* tabs */
.tabs { display: flex; gap: var(--space-1); border-bottom: var(--rule); margin-bottom: var(--space-5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-3); color: var(--muted); font-weight: 600; text-decoration: none; background: none; border: 0; white-space: nowrap; font-size: var(--text-sm); }
.tabs a:hover, .tabs button:hover { color: var(--fg); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--fg); }
.tabs [aria-selected="true"]::after, .tabs [aria-current="page"]::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: -1px; height: 2px; background: var(--fg); border-radius: 2px; }
.tabs .count { font-size: var(--text-xs); background: var(--sunken); border-radius: var(--radius-pill); padding: 0 6px; font-variant-numeric: tabular-nums; }

/* list rows */
.rows { background: var(--card); border: var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.rows > * + * { border-top: var(--rule); }
.rowi { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-4); align-items: center; padding: var(--space-4); color: var(--fg); text-decoration: none; position: relative; }
a.rowi:hover, .rowi.is-link:hover { background: var(--paper-2); text-decoration: none; }
.rowi.is-unread { background: color-mix(in oklch, var(--saffron) 12%, var(--card)); }
.rowi__thumb { width: 56px; height: 56px; border-radius: var(--radius); object-fit: cover; background: var(--paper-3); display: grid; place-items: center; color: var(--subtle); overflow: hidden; flex: none; }
.rowi__thumb img { width: 100%; height: 100%; object-fit: cover; }
.rowi__main { min-width: 0; display: grid; gap: 2px; }
.rowi__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowi__sub { color: var(--muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowi__end { display: grid; justify-items: end; gap: var(--space-1); text-align: right; }
@media (max-width: 560px) { .rowi { grid-template-columns: auto minmax(0, 1fr); } .rowi__end { grid-column: 2; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; gap: var(--space-2); } }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: var(--space-3); }
.tile-stat { background: var(--card); border: var(--rule); border-radius: var(--radius-lg); padding: var(--space-5); display: grid; gap: var(--space-1); color: var(--fg); text-decoration: none; }
a.tile-stat:hover { border-color: var(--fg); text-decoration: none; }
.tile-stat .label { color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
.tile-stat .value { font-family: var(--font-display); font-weight: 700; font-size: var(--text-2xl); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile-stat .foot { color: var(--subtle); font-size: var(--text-xs); }
.tile-stat.is-accent { background: var(--navy); border-color: var(--navy); color: oklch(97% 0.01 85); }
.tile-stat.is-accent .label, .tile-stat.is-accent .foot { color: oklch(82% 0.02 258); }

/* status pill colours for transaction states */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); white-space: nowrap; background: var(--sunken); color: var(--muted); }
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-action { background: var(--saffron-soft); color: var(--saffron-ink); }
.st-live { background: var(--navy-soft); color: var(--link); }
.st-done { background: var(--ok-soft); color: var(--ok); }
.st-off { background: var(--sunken); color: var(--subtle); }
.st-bad { background: var(--danger-soft); color: var(--danger); }

/* timeline (transaction progress) */
.timeline { list-style: none; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); position: relative; padding-bottom: var(--space-5); }
.timeline li::before { content: ""; width: 14px; height: 14px; margin: 3px 7px 0; border-radius: 50%; border: 2px solid var(--line-2); background: var(--card); z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: 13px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.is-done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.is-now::before { background: var(--saffron); border-color: var(--saffron-2); box-shadow: 0 0 0 4px var(--saffron-soft); }
.timeline li.is-bad::before { background: var(--danger); border-color: var(--danger); }
.timeline b { display: block; font-size: var(--text-sm); }
.timeline span { color: var(--muted); font-size: var(--text-xs); }

/* chat */
.chat { display: grid; grid-template-columns: 320px minmax(0, 1fr); border: var(--rule); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); height: calc(100dvh - var(--header-h) - 10rem); min-height: 480px; }
.chat__list { border-right: var(--rule); overflow: auto; }
.chat__list a { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: var(--space-3); padding: var(--space-3) var(--space-4); text-decoration: none; color: var(--fg); align-items: center; border-bottom: var(--rule); }
.chat__list a:hover { background: var(--paper-2); }
.chat__list a[aria-current="true"] { background: var(--navy-soft); }
.chat__list img, .chat__list .ph { width: 48px; height: 48px; border-radius: var(--radius); object-fit: cover; background: var(--paper-3); }
.chat__pane { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.chat { grid-template-rows: minmax(0, 1fr); }
.chat__list, .chat__msgs { min-height: 0; }
.chat__head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: var(--rule); min-width: 0; }
.chat__msgs { overflow: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); background: var(--paper); }
.bubble { max-width: min(78%, 520px); padding: var(--space-2) var(--space-3); border-radius: 16px 16px 16px 4px; background: var(--card); border: var(--rule); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); border-radius: 16px 16px 4px 16px; }
.bubble time { display: block; font-size: 10px; opacity: 0.7; margin-top: 2px; text-align: right; }
.bubble img { border-radius: var(--radius-sm); margin-top: var(--space-1); max-height: 240px; width: auto; }
.bubble.is-pending { opacity: 0.6; }
.chat__day { align-self: center; font-size: var(--text-xs); color: var(--subtle); padding: var(--space-2); }
.chat__typing { font-size: var(--text-xs); color: var(--subtle); padding: 0 var(--space-4) var(--space-1); min-height: 1.2em; }
.chat__compose { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: var(--rule); align-items: flex-end; }
.chat__compose textarea { flex: 1; min-height: 44px; max-height: 160px; resize: none; }
@media (max-width: 899px) {
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--header-h) - 64px - 5rem); }
  .chat.has-open .chat__list { display: none; }
  .chat:not(.has-open) .chat__pane { display: none; }
}

/* uploader */
.dropzone { border: 2px dashed var(--line-2); border-radius: var(--radius-lg); padding: var(--space-6); text-align: center; display: grid; gap: var(--space-2); justify-items: center; color: var(--muted); cursor: pointer; transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out); }
.dropzone:hover, .dropzone.is-over { border-color: var(--focus); background: var(--navy-soft); }
.dropzone .i { width: 32px; height: 32px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--space-3); }
.thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--paper-3); border: var(--rule); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: color-mix(in oklch, var(--ink) 70%, transparent); color: var(--paper); display: grid; place-items: center; }
.thumb .x .i { width: 16px; height: 16px; }
.thumb .cover { position: absolute; left: 4px; bottom: 4px; }
.thumb.is-uploading::after { content: ""; position: absolute; inset: 0; background: color-mix(in oklch, var(--surface) 55%, transparent); }
.thumb.is-uploading .spinner { position: absolute; inset: 0; margin: auto; z-index: 1; }
.thumb[draggable="true"] { cursor: grab; }

/* wizard */
.wizard { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-8); align-items: start; }
.wizard__steps { list-style: none; display: grid; gap: 2px; position: sticky; top: calc(var(--header-h) + var(--space-4)); counter-reset: ws; }
.wizard__steps button { width: 100%; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: none; border: 0; text-align: left; color: var(--muted); font-weight: 600; font-size: var(--text-sm); counter-increment: ws; }
.wizard__steps button::before { content: counter(ws); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); font-size: var(--text-xs); flex: none; }
.wizard__steps button[aria-current="step"] { color: var(--fg); background: var(--card); box-shadow: var(--shadow-1); }
.wizard__steps button[aria-current="step"]::before { background: var(--primary-bg); color: var(--primary-fg); }
.wizard__steps button.is-done::before { content: "✓"; background: var(--ok-soft); color: var(--ok); }
.wizard__steps button.is-error::before { content: "!"; background: var(--danger-soft); color: var(--danger); }
.wizard__foot { display: flex; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-8); padding-top: var(--space-5); border-top: var(--rule); flex-wrap: wrap; }
.save-state { font-size: var(--text-xs); color: var(--subtle); display: inline-flex; align-items: center; gap: var(--space-1); }
@media (max-width: 899px) {
  .wizard { grid-template-columns: minmax(0, 1fr); }
  .wizard__steps { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; scrollbar-width: none; }
  .wizard__steps button span { display: none; }
  .wizard__steps button[aria-current="step"] span { display: inline; }
}

/* seller-state gate */
.gate { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); padding: var(--space-5); border-radius: var(--radius-lg); background: var(--saffron-soft); align-items: start; }
.gate > .i { width: 32px; height: 32px; color: var(--saffron-ink); }
.gate h2, .gate h3 { font-size: var(--text-md); margin-bottom: var(--space-1); }

/* money table */
.table { width: 100%; font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 700; color: var(--muted); font-size: var(--text-xs); padding: var(--space-2) var(--space-3); border-bottom: var(--rule); white-space: nowrap; }
.table td { padding: var(--space-3); border-bottom: var(--rule); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-in { color: var(--ok); }
.amount-out { color: var(--fg); }
.table-wrap { overflow-x: auto; background: var(--card); border: var(--rule); border-radius: var(--radius-lg); }
@media (max-width: 640px) {
  .table.stack-sm thead { display: none; }
  .table.stack-sm tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: var(--space-3); border-bottom: var(--rule); gap: 2px var(--space-3); }
  .table.stack-sm td { padding: 0; border: 0; }
}

/* card on file */
.card-visual { display: flex; align-items: center; gap: var(--space-4); }
.card-visual .brand-box { width: 52px; height: 36px; border-radius: 6px; background: var(--navy); color: var(--saffron); display: grid; place-items: center; font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

/* code block (referral code, recovery codes) */
.code-box { font-family: var(--font-mono); font-size: var(--text-lg); letter-spacing: 0.08em; padding: var(--space-3) var(--space-4); background: var(--sunken); border-radius: var(--radius); display: inline-flex; align-items: center; gap: var(--space-3); user-select: all; }
.code-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); font-family: var(--font-mono); }
.code-grid span { padding: var(--space-2); background: var(--sunken); border-radius: var(--radius-sm); text-align: center; }

.dialog-body .suggest { position: static !important; box-shadow: none; }

/* stripe mount */
.stripe-mount { min-height: 120px; padding: var(--space-2) 0; }
.stub-note { font-size: var(--text-sm); }

/* handover photo capture */
.capture { display: grid; gap: var(--space-4); }
