/* CrossLedger — brand teal #3cd0c0 / green #50d080 on charcoal #1e1f23 (from the logo).
   Themes: light, dark, or follow the device. A saved choice sets data-theme on <html>. */
:root {
  --bg: #f4f6f6; --surface: #ffffff; --surface-2: #eef2f2; --surface-3: #e4eaea; --border: #dde4e4; --text: #14181b; --muted: #5f6b75;
  --brand: #0c8577; --brand-2: #17935c; --brand-ink: #ffffff; --brand-soft: #d6f5ef; --brand-text: #0c8f80;
  --pos: #12804a; --neg: #c2410c; --danger: #b91c1c;
  --ok-bg: #dcfce7; --ok-fg: #166534; --bad-bg: #fee2e2; --bad-fg: #991b1b; --warn-bg: #fef3c7; --warn-fg: #92400e; --info-bg: #ffedd5; --info-fg: #9a3412;
  --bar-income: #a3afba; --bar-profit: #0c8577; --bar-loss: #ea580c;
  --charcoal: #1e1f23; --side-bg: #1e1f23; --side-2: #2a2c32; --side-border: #33363d; --side-text: #e9ecee; --side-muted: #9aa3ad;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .28);
  --tabbar-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #191a1e; --surface: #24262b; --surface-2: #2d3036; --surface-3: #373a41; --border: #383b43; --text: #eceef0; --muted: #a0a8b2;
  --brand: #3cd0c0; --brand-2: #50d080; --brand-ink: #08231f; --brand-soft: #173f3a; --brand-text: #3cd0c0;
  --pos: #5ee08a; --neg: #fb923c; --danger: #f87171;
  --ok-bg: #14532d; --ok-fg: #bbf7d0; --bad-bg: #5b1717; --bad-fg: #fecaca; --warn-bg: #451a03; --warn-fg: #fde68a; --info-bg: #5a2a12; --info-fg: #fed7aa;
  --bar-income: #6b7480; --bar-profit: #3cd0c0; --bar-loss: #fb923c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191a1e; --surface: #24262b; --surface-2: #2d3036; --surface-3: #373a41; --border: #383b43; --text: #eceef0; --muted: #a0a8b2;
    --brand: #3cd0c0; --brand-2: #50d080; --brand-ink: #08231f; --brand-soft: #173f3a; --brand-text: #3cd0c0;
    --pos: #5ee08a; --neg: #fb923c; --danger: #f87171;
    --ok-bg: #14532d; --ok-fg: #bbf7d0; --bad-bg: #5b1717; --bad-fg: #fecaca; --warn-bg: #451a03; --warn-fg: #fde68a; --info-bg: #5a2a12; --info-fg: #fed7aa;
    --bar-income: #6b7480; --bar-profit: #3cd0c0; --bar-loss: #fb923c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25); --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; font-weight: 750; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
h3 { font-size: .98rem; margin: 0 0 .75rem; letter-spacing: -.005em; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.center { text-align: center; }
.strong { font-weight: 650; }
.grow { flex: 1; }
.pad { padding: .75rem; }
.icon { flex: 0 0 auto; display: block; }

/* Inputs */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]):not([type=radio]), select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); min-height: 42px;
  transition: border-color .12s, box-shadow .12s;
}
input[type=file] { width: 100%; font-size: .9rem; }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); }
textarea { resize: vertical; }
.money-input { position: relative; }
.money-input span { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money-input input { padding-left: 1.6rem !important; text-align: right; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field .label, .receipts .label { font-size: .78rem; font-weight: 650; color: var(--muted); }
.hint { color: var(--muted); font-size: .75rem; }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; white-space: nowrap; cursor: pointer; }
.check.span { white-space: normal; }
.inline { display: inline-flex; gap: .5rem; align-items: center; white-space: nowrap; }
.inline input { width: auto; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem .95rem; min-height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 650; white-space: nowrap; text-decoration: none !important; color: var(--text);
  transition: background .12s, transform .05s, box-shadow .12s, filter .12s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible, .chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); border-color: transparent; box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 30%, transparent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.danger-text { color: var(--danger) !important; }
.btn.small { padding: .3rem .65rem; min-height: 32px; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; padding: .4rem; border-radius: 8px; color: var(--muted); line-height: 1; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.tiny { font-size: .75rem; padding: .2rem .35rem; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { /* always charcoal, like the logo */
  --surface: var(--side-bg); --surface-2: var(--side-2); --border: var(--side-border); --text: var(--side-text); --muted: var(--side-muted); --brand-soft: rgba(60, 208, 192, .14); --brand-text: #3cd0c0;
  width: 248px; flex: 0 0 248px; background: var(--side-bg); color: var(--side-text); border-right: 1px solid var(--side-border); padding: 1.1rem .8rem .8rem;
  display: flex; flex-direction: column; gap: .8rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; color-scheme: dark; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 9px; color: var(--side-muted); text-decoration: none; font-weight: 550; position: relative; transition: background .12s, color .12s; }
.sidebar nav a:hover { background: var(--side-2); color: var(--side-text); }
.sidebar nav a.active { background: rgba(60, 208, 192, .14); color: #fff; }
.sidebar nav a.active .icon { color: #3cd0c0; }
.sidebar nav a.active::before { content: ""; position: absolute; left: -0.8rem; top: 20%; bottom: 20%; width: 3px; border-radius: 0 3px 3px 0; background: linear-gradient(#3cd0c0, #50d080); }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #6f7883; padding: .7rem .7rem .2rem; font-weight: 700; }
.ni { width: 1.4em; text-align: center; }
.sidebar .btn.primary { background: linear-gradient(135deg, #2cc0b0, #45c878); color: #08231f; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .6rem; padding: .7rem .2rem 0; border-top: 1px solid var(--side-border); }
.user-row { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #2cc0b0, #45c878); color: #08231f; display: grid; place-items: center; font-weight: 750; font-size: .85rem; flex: 0 0 auto; }
.user-row .who { min-width: 0; flex: 1; line-height: 1.25; }
.user-row .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--side-2); border-radius: 9px; padding: 3px; gap: 2px; }
.theme-seg button { border: 0; background: transparent; color: var(--side-muted); padding: .3rem; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.theme-seg button.on { background: #3a3d45; color: #fff; }
.brand { display: flex; align-items: center; gap: .6rem; font-size: 1.15rem; padding: 0 .3rem; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand.big { font-size: 1.5rem; justify-content: center; margin-bottom: .25rem; }
.brand.big img { width: 54px; height: 54px; border-radius: 13px; }
.wordmark { font-weight: 800; letter-spacing: -.025em; }
.wordmark b { color: var(--brand-text); font-weight: 800; }
.biz-switch { font-weight: 650; }
.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.top-logo { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; }
.content { padding: 1.75rem 2.25rem 3.5rem; max-width: 1240px; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 1.1rem; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head select { width: auto; }
.page-sub { color: var(--muted); font-size: .9rem; margin-top: .1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.tabbar { display: none; }
.scrim { display: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); min-width: 0; }
.card.inset { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.card.notice { background: var(--brand-soft); border-color: transparent; }
.welcome { background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 10%, var(--surface)), var(--surface) 60%); }
.welcome ol { margin: 0; padding-left: 1.2rem; display: grid; gap: .45rem; }
.grid-2 { display: grid; grid-template-columns: 1.45fr 1fr; gap: 1.1rem; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .85rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .95rem 1.1rem; box-shadow: var(--shadow); }
.stat-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 650; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; }
.stat-value { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: .15rem; }
.stat-sub { font-size: .8rem; color: var(--muted); min-height: 1.2em; }
.stat.good .stat-value { color: var(--pos); }
.stat.bad .stat-value { color: var(--neg); }
.delta { font-weight: 700; font-size: .75rem; padding: .05rem .4rem; border-radius: 999px; }
.delta.up { background: var(--ok-bg); color: var(--ok-fg); }
.delta.down { background: var(--info-bg); color: var(--info-fg); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .85rem; }
.kpis > div { display: flex; flex-direction: column; background: var(--surface-2); border-radius: var(--radius-sm); padding: .65rem .8rem; }
.kpis b { font-size: 1.15rem; }

/* Progress + breakdown bars */
.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s ease; }
.goal-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .45rem; }
.goal-row b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: .65rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: .65rem; align-items: center; font-size: .88rem; }
.bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.bar-row .track i.alt { background: var(--bar-income); }
.bar-row .val { font-variant-numeric: tabular-nums; font-weight: 600; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters > input[type=search] { flex: 1 1 220px; width: auto; }
.filters > select { width: auto; max-width: 240px; }
.period { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.period select, .period input { width: auto; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--radius-sm); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: .4rem .8rem; border-radius: 8px; cursor: pointer; font-weight: 650; font-size: .86rem; color: var(--muted); transition: background .12s, color .12s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: .3rem .8rem; cursor: pointer; font-size: .85rem; transition: background .12s, border-color .12s; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pill { display: inline-block; font-size: .7rem; font-weight: 700; padding: .16rem .55rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); text-transform: capitalize; white-space: nowrap; }
.pill.listed, .pill.k-sale { background: var(--brand-soft); color: var(--brand-text); }
.pill.sold, .pill.k-income { background: var(--ok-bg); color: var(--ok-fg); }
.pill.written_off { background: var(--bad-bg); color: var(--bad-fg); }
.pill.k-expense { background: var(--info-bg); color: var(--info-fg); }
.badge { margin-left: auto; background: linear-gradient(135deg, #2cc0b0, #45c878); color: #08231f; border-radius: 999px; font-size: .7rem; font-weight: 750; padding: .05rem .45rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap, .table-wrap.card { border: 0; box-shadow: none; }
.table-wrap.card { padding: .4rem .6rem; border: 1px solid var(--border); box-shadow: var(--shadow); }
.table-wrap.tall { max-height: 50vh; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
.data th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: .7rem .85rem; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface-2); }
.data th:first-child { border-top-left-radius: var(--radius); } .data th:last-child { border-top-right-radius: var(--radius); }
.data td { padding: .7rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data tr:last-child td { border-bottom: 0; }
.data.compact td, .data.compact th { padding: .42rem .55rem; }
.data.compact th { background: transparent; }
.data tfoot td { border-top: 1px solid var(--border); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; transition: background .1s; }
tr.clickable:hover td { background: var(--surface-2); }
tr.selected td { background: var(--brand-soft) !important; }
.sel-cell { width: 36px; padding-right: 0 !important; }
.list td { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.list tr:last-child td { border-bottom: 0; }
.fin td { padding: .45rem .25rem; }
.fin .sec td { font-weight: 700; padding-top: 1rem; }
.fin .indent { padding-left: 1.25rem; }
.fin .subtotal td { font-weight: 650; border-top: 1px solid var(--border); }
.fin .total td { font-weight: 750; border-top: 2px solid var(--text); padding-top: .6rem; }
.fin .total.big td { font-size: 1.1rem; }
.fin .sec-row td { border-bottom: 1px solid var(--border); padding: .6rem .25rem; }
.thumb-cell { width: 52px; padding-right: 0 !important; }
.thumb { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; display: block; background: var(--surface-2); }
.thumb.ph { display: grid; place-items: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .85rem; }
.report-link { text-decoration: none !important; color: var(--text); transition: border-color .12s, transform .12s, box-shadow .12s; }
.report-link:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .1); }
.report-link p { margin: 0; }
.bulk-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; background: var(--charcoal); color: #fff; border-radius: var(--radius); padding: .55rem .8rem; position: sticky; top: .5rem; z-index: 20; box-shadow: var(--shadow-lg); }
.bulk-bar .btn { background: #33363d; border-color: transparent; color: #fff; }
.bulk-bar .btn:hover { background: #40444c; }

/* Chart */
.chart { width: 100%; height: auto; }
.chart .axis, .chart .grid { stroke: var(--border); }
.chart .grid { stroke-dasharray: 3 4; }
.chart .tick { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.chart .ytick { fill: var(--muted); font-size: 10px; text-anchor: end; }
.bar-income { fill: var(--bar-income); } .bar-profit { fill: var(--bar-profit); } .bar-loss { fill: var(--bar-loss); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.sw.income { background: var(--bar-income); } .sw.profit { background: var(--bar-profit); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: .9rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; align-items: start; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.form-grid > .span, .field.span { grid-column: 1 / -1; }
.form-grid > h3 { margin: 0; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; }
.form-actions.wrap { flex-wrap: wrap; justify-content: flex-start; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: .8rem; }
.summary.four { grid-template-columns: repeat(4, 1fr); }
.summary div { display: flex; flex-direction: column; } .summary span { font-size: .76rem; color: var(--muted); } .summary b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.picker { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.picker input { border: 0 !important; border-bottom: 1px solid var(--border) !important; border-radius: 0 !important; box-shadow: none !important; }
.picker-list { max-height: 210px; overflow-y: auto; }
.picker-list button { display: flex; justify-content: space-between; gap: 1rem; width: 100%; border: 0; background: transparent; padding: .6rem .75rem; cursor: pointer; text-align: left; border-bottom: 1px solid var(--border); }
.picker-list button:hover { background: var(--surface-2); }
.picked { display: flex; justify-content: space-between; align-items: center; gap: .75rem; background: var(--surface-2); padding: .65rem .8rem; border-radius: var(--radius-sm); }
.picked.unmatched { background: transparent; border: 1px dashed var(--border); }
.photo-pick { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.photo-pick img, .photo-pick .ph { width: 72px; height: 72px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 1.5rem; }
.receipt-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .3rem; }
.receipt { position: relative; }
.receipt img, .receipt .ph, .receipt.add { width: 72px; height: 72px; border-radius: var(--radius-sm); object-fit: cover; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-size: 1.4rem; }
.receipt.add { cursor: pointer; border-style: dashed; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 1.2rem; color: var(--muted); }
.receipt.add:hover { border-color: var(--brand); color: var(--brand-text); }
.receipt.add span { font-size: .7rem; }
.receipt .icon-btn { position: absolute; top: -6px; right: -6px; background: var(--surface); border: 1px solid var(--border); }
.receipt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .85rem; }
.receipt-card { display: flex; flex-direction: column; gap: .5rem; padding: .6rem; }
.receipt-card img, .receipt-card .ph { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; }
.ph.big { font-size: 2.5rem; }
.row { display: flex; gap: .4rem; flex-wrap: wrap; }
.row.align-end { align-items: flex-end; gap: .75rem; }
.item-detail { display: flex; flex-direction: column; gap: 1rem; }
.item-detail .hero { max-height: 280px; width: 100%; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface-2); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .85rem; } .facts dd { margin: 0; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: .65rem; }
.quick { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 1.05rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 650; font-size: .9rem; transition: border-color .12s, transform .12s, background .12s; }
.quick span { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; font-size: 1.4rem; }
.quick:hover { border-color: var(--brand); transform: translateY(-2px); }
.danger-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 18, .5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 1rem; animation: fadein .15s ease; }
@keyframes fadein { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal.wide { width: min(840px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: .95rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal header h2 { margin: 0; }
.modal-body { padding: 1.2rem; overflow-y: auto; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(ellipse at 30% 20%, rgba(60, 208, 192, .18), transparent 55%), radial-gradient(ellipse at 80% 90%, rgba(80, 208, 128, .14), transparent 50%), var(--charcoal); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1.9rem; width: min(410px, 100%); display: flex; flex-direction: column; gap: .95rem; box-shadow: var(--shadow-lg); }
.auth-card p { margin: 0; text-align: center; }
.auth-card h2 { text-align: center; }

.empty { text-align: center; padding: 2.75rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.card .empty { border: 0; padding: 1.5rem 1rem; }
.empty-icon { font-size: 2.4rem; }
.empty h3 { color: var(--text); margin: .5rem 0 .25rem; }
.loading { display: grid; place-items: center; padding: 3rem; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: var(--bad-bg); color: var(--bad-fg); padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .9rem; }
.warn { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: .4rem .6rem; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1.5rem + var(--safe-b)); background: #111418; color: #fff; padding: .7rem 1.1rem; border-radius: 12px; z-index: 100; box-shadow: var(--shadow-lg); max-width: calc(100vw - 2rem); border: 1px solid #2c2f36; }
.toast.err { background: #b91c1c; border-color: transparent; }
.show-sm, .print-only { display: none; }

/* Sales Inbox */
.tabbar a span { position: relative; }
.dot { position: absolute; top: -5px; right: -12px; background: #dc2626; color: #fff; border-radius: 999px; font-size: .62rem; padding: 0 .35rem; font-weight: 700; line-height: 1.45; }
.section-title { margin: .5rem 0 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.inbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: .85rem; }
.inbox-row { display: flex; flex-direction: column; gap: .6rem; }
.ir-top { display: flex; gap: .75rem; align-items: flex-start; }
.ir-money { display: flex; flex-wrap: wrap; gap: .25rem .9rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ir-match .picked { align-items: center; }
.cost-in { width: 7rem !important; min-height: 34px !important; padding: .3rem .5rem !important; margin-left: .35rem; }
.ebay-card { display: flex; flex-direction: column; gap: .6rem; }
.ebay-head { display: flex; align-items: center; gap: .6rem; cursor: default; flex-wrap: wrap; }
.ebay-head[role=button] { cursor: pointer; }
.ebay-logo { font-weight: 800; font-size: .95rem; letter-spacing: -.02em; background: linear-gradient(90deg, #e53238 0 25%, #0064d2 25% 50%, #f5af02 50% 75%, #86b817 75%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.inbox-banner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; background: var(--brand-soft); border-color: transparent; color: var(--text); text-decoration: none !important; }

/* Profit calculator */
.calc-result { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.calc-result > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .8rem .9rem; display: flex; flex-direction: column; }
.calc-result span { font-size: .78rem; color: var(--muted); font-weight: 650; }
.calc-result b { font-size: 1.5rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.calc-result .hero-num { grid-column: 1 / -1; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 14%, var(--surface-2)), var(--surface-2)); }
.calc-result .hero-num b { font-size: 2.1rem; }
.verdict { font-weight: 700; padding: .5rem .8rem; border-radius: var(--radius-sm); }
.verdict.go { background: var(--ok-bg); color: var(--ok-fg); } .verdict.meh { background: var(--warn-bg); color: var(--warn-fg); } .verdict.no { background: var(--bad-bg); color: var(--bad-fg); }
.fee-table input { min-height: 36px !important; padding: .35rem .5rem !important; }

/* Phone layout */
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .35); width: 270px; }
  .sidebar.open { transform: none; }
  .sidebar .biz-switch, .sidebar .add-btn { display: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 35; }
  .topbar { display: flex; align-items: center; gap: .5rem; position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); padding: .5rem .75rem; padding-top: calc(.5rem + env(safe-area-inset-top, 0px)); }
  .topbar .biz-switch { flex: 1; border: 0; background: var(--surface-2); }
  .content { padding: 1rem 1rem calc(var(--tabbar-h) + var(--safe-b) + 1.75rem); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border); height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .68rem; color: var(--muted); text-decoration: none; font-weight: 650; }
  .tabbar a.active { color: var(--brand-text); }
  .tab-add { width: 54px; height: 54px; margin: -16px 6px 0; border-radius: 50%; border: 0; background: linear-gradient(135deg, #2cc0b0, #45c878); color: #08231f; box-shadow: 0 6px 18px rgba(44, 192, 176, .45); cursor: pointer; align-self: center; display: grid; place-items: center; }
  .toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + .75rem); }
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: .8rem .9rem; }
  .stat-value { font-size: 1.25rem; }
  .stat-icon { width: 28px; height: 28px; }
  .form-grid, .form-grid.cols-5 { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .page-head h1 { font-size: 1.35rem; }
  .page-head .actions .btn.ghost { display: none; }
  .filters > select, .filters .period select { flex: 1 1 140px; max-width: none; }
  .modal-back { padding: 0; align-items: end; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; border-bottom: 0; }
  .modal-body { padding-bottom: calc(1.2rem + var(--safe-b)); }
  .summary b { font-size: 1rem; }
  .summary.four { grid-template-columns: 1fr 1fr; }
  .inbox-list { grid-template-columns: 1fr; }
  .ebay-head .grow { flex-basis: 100%; order: 3; }
  .bulk-bar { top: 3.6rem; }
  input:not([type=checkbox]):not([type=file]):not([type=radio]), select, textarea { font-size: 16px; } /* prevents iOS zoom */
}

@media print {
  .sidebar, .topbar, .tabbar, .no-print, .toast { display: none !important; }
  .print-only { display: block; }
  .content { padding: 0; max-width: none; }
  .card, .table-wrap, .stat { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
