:root {
  color-scheme: light;
  --bg: #fbf5eb; --surface: #fffdf8; --text: #50392d; --muted: #715c4c;
  --accent: #a66a36; --action: #a66a36; --action-ink: #77471e; --on-action: #090501; --active: #f1d4a5;
  --hover: #f7ecda; --line: #e9dccb; --mat: #f0e5d5;
  --neutral: #eee5db; --neutral-ink: #645348; --green: #a2b38b; --green-ink: #293d23;
  --blue: #dde8ef; --blue-ink: #395772; --peach: #f6e1d4; --peach-ink: #804831;
  --aqua: #d7eae3; --aqua-ink: #305e52; --error: #883b48; --error-bg: #f8e4e6;
  --sent-bg: #e7deee; --sent-ink: #60476d;
  --effect-rgb: 80 57 45;
  --button-hover: rgb(255 253 248 / 12%); --card-shadow: rgb(var(--effect-rgb) / 12%);
  --filter-shadow: rgb(var(--effect-rgb) / 12%); --auth-shadow: rgb(var(--effect-rgb) / 7%);
  --backdrop: rgb(var(--effect-rgb) / 65%); --shadow: 0 2px 9px rgb(var(--effect-rgb) / 4%);
  --radius: 16px; --control: 10px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  --gutter: clamp(16px, 3.5vw, 64px);
  --font: Manrope, system-ui, sans-serif;
  --heading-font: Nunito, system-ui, sans-serif;
  font: 14px/1.5 var(--font); background: var(--bg); color: var(--text);
}
:root[data-theme="light"], :root[data-theme="dark"] {
  --sent-bg: var(--active); --sent-ink: var(--action);
  --action-ink: var(--action); --button-hover: rgb(100 80 125 / 12%); --card-shadow: rgb(73 52 89 / 12%);
  --filter-shadow: rgb(45 32 59 / 12%); --backdrop: rgb(16 13 22 / 65%);
}
:root[data-theme="light"] {
  --bg: #f7f5fa; --surface: #fff; --text: #43394d; --muted: #716877;
  --accent: #81718f; --action: #746380; --on-action: #fff; --active: #ede7f2;
  --hover: #f4f0f7; --line: #e6e1e9; --mat: #efedf2;
  --neutral: #efedf1; --neutral-ink: #5f5966; --green: #e6efe7; --green-ink: #416448;
  --blue: #e7eef6; --blue-ink: #43607e; --peach: #f8ebe2; --peach-ink: #815a40;
  --aqua: #e4efed; --aqua-ink: #3b665f; --error: #8a4454; --error-bg: #f8e9ed;
  --effect-rgb: 52 35 69;
}
:root[data-theme="powder"] {
  --bg: #faf5f3; --surface: #fffcfa; --text: #51423e; --muted: #73615d;
  --accent: #647b59; --action: #647b59; --action-ink: #405436; --on-action: #fff; --active: #f2d9dd;
  --hover: #f5ebe9; --line: #ebddd9; --mat: #eee5e2;
  --neutral: #ede5e3; --neutral-ink: #615452; --green: #dfe9d9; --green-ink: #405635;
  --blue: #e0e8f2; --blue-ink: #405774; --peach: #f5e4d7; --peach-ink: #7b5036;
  --aqua: #d9eae6; --aqua-ink: #355f55; --error: #873e51; --error-bg: #fae4e9;
  --sent-bg: #e9e1ef; --sent-ink: #604d71; --button-hover: rgb(var(--effect-rgb) / 12%);
  --effect-rgb: 81 66 62;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14151a; --surface: #202129; --text: #e4dcff; --muted: #b6afc3;
  --accent: #b4a1ef; --action: #b4a1ef; --on-action: #231d33; --active: #393246;
  --hover: #292832; --line: #37353f; --mat: #2a2932;
  --neutral: #35343d; --neutral-ink: #cdc8d2; --green: #293d33; --green-ink: #9bd3b1;
  --blue: #293745; --blue-ink: #b4cde8; --peach: #44352e; --peach-ink: #e6bca2;
  --aqua: #293d39; --aqua-ink: #a4d5c7; --error: #f0adbc; --error-bg: #422e36;
  --shadow: 0 2px 9px rgb(0 0 0 / 10%); --auth-shadow: rgb(0 0 0 / 18%);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); transition: background-color .18s, color .18s; }
h1,h2,p { margin: 0; }
h1,h2,h3,h4,h5,h6 { font-family: var(--heading-font); font-weight: 700; }
strong,b { font-weight: 600; }
h1 { font-size: 22px; line-height: 1.3; letter-spacing: -.035em; }
h2 { font-size: 18px; letter-spacing: -.025em; }
a { color: var(--action-ink); text-underline-offset: 3px; text-decoration: none; }
a:hover { text-decoration: underline; }
small,.muted,time,dt,.page-head p,.upload p { color: var(--muted); }
small,time { font-size: 12px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
button,input,textarea,select { font: inherit; color: inherit; }
button,.button,summary { cursor: pointer; }
button,.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 40px; padding: 8px 16px; background: var(--action); color: var(--on-action); border: 0; border-radius: var(--control); font-weight: 500; transition: box-shadow .18s,background-color .18s; }
button:hover,.button:hover { box-shadow: inset 0 0 0 80px var(--button-hover); text-decoration: none; }
button:disabled { opacity: .6; cursor: wait; }
.secondary,.quiet { color: var(--action-ink); background: var(--active); }
.quiet { background: transparent; padding-inline: 0; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute!important; width: 1px!important; height: 1px!important; overflow: hidden; clip-path: inset(50%); white-space: nowrap; padding: 0!important; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { height: 60px; padding-inline: var(--gutter); display: flex; align-items: center; gap: var(--s6); }
.brand,.section-nav,.section-nav a,.section-head a { display: inline-flex; align-items: center; gap: var(--s2); }
.brand { margin-right: auto; font-family: var(--heading-font); font-size: 19px; font-weight: 800; letter-spacing: -.04em; color: var(--text); }
body:not(.signed-out) .mobile-title { font-weight: 700; }
.brand:hover,.section-nav a:hover { text-decoration: none; }
.brand-mark,.metric-icon { display: inline-grid; place-items: center; border-radius: 10px; height: 34px; width: 34px; background: var(--active); color: var(--action-ink); }
.brand-mark { background: var(--action); color: var(--on-action); }
.mobile-title,.mobile-add-label { display: none; }
.section-nav { gap: var(--s1); }
.section-nav a { padding: 8px 12px; color: var(--muted); border-radius: var(--control); font-weight: 500; }
.section-nav a:hover { background: var(--hover); }
.section-nav [aria-current] { color: var(--action-ink); background: var(--active); }
.theme-switch { display: grid; place-items: center; position: relative; width: 42px; height: 40px; background: var(--hover); border-radius: var(--control); }
.theme-switch select { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.topbar-inner > .theme-switch:only-child { margin-inline-start: auto; }
.theme-switch:focus-within { outline: 2px solid var(--action); }
main { padding: var(--s8) var(--gutter); overflow-wrap: anywhere; }
.page-head,.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.page-head p { margin-top: var(--s1); }
.section-head a { font-size: 13px; }
.panel,.metric,.recent-item,.table-wrap,.filter-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.panel,.filter-panel { padding: var(--s6); }
.spaced { margin-top: var(--s6); }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--s3); margin-bottom: var(--s8); }
.metric { display: grid; grid-template-columns: 1fr auto; align-items: start; padding: var(--s4); color: var(--muted); font-size: 13px; }
.metric-icon { grid-area: 1/2/3/3; margin-left: var(--s2); }
.metric:nth-child(2) .metric-icon { background: var(--green); color: var(--green-ink); }
.metric:nth-child(4) .metric-icon { background: var(--peach); color: var(--peach-ink); }
.metric strong { font-size: 25px; letter-spacing: -.04em; color: var(--text); }
.metric:hover { text-decoration: none; }
.recent-grid,.grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(min(100%,198px),1fr)); gap: var(--s4); }
.recent-item { overflow: hidden; color: var(--text); display: flex; flex-direction: column; transition: transform .18s, box-shadow .18s; }
.recent-item:hover { text-decoration: none; }
@media (hover: hover) {
  .recent-item:hover,a.metric:hover { transform: translateY(-2px); box-shadow: 0 4px 16px var(--card-shadow); }
}
.recent-cover { background: var(--mat); padding: var(--s3); height: clamp(180px,16vw,280px); display: grid; place-items: center; }
.recent-cover img,.purchase-photos img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.caption { flex: 1; padding: var(--s3) var(--s4) var(--s4); display: flex; align-items: flex-start; flex-direction: column; gap: var(--s1); }
.caption strong { margin-bottom: var(--s2); }
.caption .badge { margin-top: auto; }
.empty-thumb { display: grid; justify-items: center; align-content: center; gap: var(--s1); color: var(--muted); font-size: 12px; }
.empty-thumb .icon { width: 23px; height: 23px; }
.empty-state { grid-column: 1/-1; text-align: center; color: var(--muted); }
.recent { display: flex; justify-content: space-between; gap: var(--s3); padding-top: var(--s3); }
input:not([type=hidden]),select,textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: var(--control); min-height: 40px; padding: 8px 12px; background: var(--surface); }
select { cursor: pointer; }
option { color: var(--text); background: var(--surface); }
textarea { resize: vertical; }
label { font-weight: 500; }
.purchase-filters { display: flex; gap: var(--s2); align-items: flex-start; margin-bottom: var(--s4); flex-wrap: wrap; }
.filter-row { flex: 1; display: grid; grid-template-columns: minmax(0,2fr) repeat(3,minmax(0,1fr)); gap: var(--s2); }
.archive-filters { grid-template-columns: minmax(0,2fr) repeat(2,minmax(0,1fr)); }
.filter-row label { min-width: 0; }
.filter-summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin: calc(-1 * var(--s2)) 0 var(--s3); font-size: 13px; color: var(--muted); }
.filter-summary a { display: inline-flex; align-items: center; gap: var(--s1); min-height: 32px; color: var(--action-ink); }
.filter-summary .icon { width: 16px; height: 16px; }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; }
.more-filters { position: relative; }
.more-filters summary { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 12px; gap: var(--s2); background: var(--active); color: var(--action-ink); border-radius: var(--control); list-style: none; }
.filter-panel { position: absolute; z-index: 3; right: 0; width: 330px; margin-top: var(--s2); box-shadow: 0 8px 28px var(--filter-shadow); }
details[open]>.filter-panel { animation: appear .18s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(-4px); } }
.extra-fields,.fields,.detail { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s4); }
.extra-fields { gap: var(--s3); margin-bottom: var(--s4); }
.extra-fields label:last-child,.wide { grid-column: 1/-1; }
.actions,.pager { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.pager { justify-content: center; margin-top: var(--s4); }
.table-wrap { overflow: hidden; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; }
th,td { padding: var(--s3); overflow-wrap: anywhere; }
th { background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 500; }
td { border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--hover); }
th:first-child { width: 100px; }
th:nth-child(2) { width: 106px; }
th:nth-child(3) { width: 9%; }
th:nth-child(5) { width: 11%; }
th:nth-child(7) { width: 8%; }
th:nth-child(6) { width: clamp(164px,16vw,240px); }
th:nth-child(5),td:nth-child(5) { text-align: right; font-variant-numeric: tabular-nums; }
.purchase-photos { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--s2); }
.purchase-photos>a,.purchase-photos>.empty-thumb { height: 96px; display: grid; background: var(--mat); border-radius: 8px; overflow: hidden; }
.purchase-photos img { display: block; }
.tile .purchase-photos,.detail .purchase-photos { margin-block: var(--s3); }
.tile .purchase-photos>* { height: 180px; }
.detail .purchase-photos>* { height: min(42vh,340px); }
.tile p { margin-block: var(--s2); }
.status-form,.stack { display: grid; gap: var(--s2); }
.badge { --badge-bg: var(--neutral); --badge-ink: var(--neutral-ink); }
.paid { --badge-bg: var(--green); --badge-ink: var(--green-ink); }
.sent { --badge-bg: var(--sent-bg); --badge-ink: var(--sent-ink); }
.international { --badge-bg: var(--blue); --badge-ink: var(--blue-ink); }
.domestic { --badge-bg: var(--peach); --badge-ink: var(--peach-ink); }
.received { --badge-bg: var(--aqua); --badge-ink: var(--aqua-ink); }
.badge,select.badge { border: 0; border-radius: 8px; padding: 4px 8px; color: var(--badge-ink); background-color: var(--badge-bg); font-size: 12px; font-weight: 500; }
select.badge { white-space: normal; width: fit-content; max-width: 100%; min-height: 32px; }
.status-control { position: relative; max-width: 100%; width: fit-content; }
.status-label { display: none; }
.enhanced .status-label { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.status-label::after { content: ""; flex: none; width: 5px; height: 5px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.enhanced select.badge { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.status-control:focus-within { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 8px; }
.editor-layout { max-width: 850px; margin-inline: auto; }
.fields { margin: var(--s6) 0; }
.fields label,.extra-fields label { font-size: 13px; }
.fields label,.stack label { display: block; margin-bottom: var(--s1); }
.upload { background: var(--hover); border: 1px dashed var(--accent); border-radius: 12px; padding: var(--s4); }
.upload.over { background: var(--active); }
.upload p { margin: var(--s2) 0; }
.upload p:empty,.previews:empty { display: none; }
input[type=file] { overflow: hidden; margin-bottom: var(--s2); }
::file-selector-button { border: 0; border-radius: 6px; padding: 6px 12px; background: var(--active); color: var(--action-ink); font-family: var(--font); }
.previews { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.previews figure { margin: 0; display: grid; gap: var(--s1); }
.previews img { object-fit: contain; width: 100px; height: 140px; }
dl { display: grid; grid-template-columns: minmax(0,max-content) minmax(0,1fr); gap: 8px 16px; }
dd { margin: 0; }
.event { display: grid; gap: var(--s1); padding-block: var(--s3); border-bottom: 1px solid var(--line); }
.notice,.errorlist { border-radius: var(--control); padding: var(--s3); margin: 8px 0; background: var(--green); color: var(--green-ink); }
.errorlist,.notice.error,.danger-button { color: var(--error); background: var(--error-bg); }
.danger summary { color: var(--error); }
.narrow { max-width: 560px; }
.narrow p,.danger form,.detail .status-form { margin-top: var(--s3); }
.narrow .actions,main>.button+.page-head { margin-top: var(--s4); }
.signed-out main { min-height: calc(100vh - 60px); display: grid; place-content: center; }
.auth-card { width: min(400px,calc(100vw - 32px)); padding: 28px; border-radius: 20px; box-shadow: 0 12px 36px var(--auth-shadow); }
.auth-card h1 { margin-top: var(--s4); font-size: 21px; }
.auth-card h1 + .muted { margin-top: var(--s1); }
.signed-out main:has(> .login-card) { min-height: calc(100svh - 61px); padding-block: var(--s6); justify-items: center; }
.panel.login-card {
  --mascot-height: clamp(110px, 30vw, 156px);
  --mascot-overlap: calc(var(--mascot-height) * .23);
  position: relative;
  width: min(440px, calc(100vw - 2 * var(--gutter)));
  margin-top: calc(var(--mascot-height) - var(--mascot-overlap));
  padding: var(--mascot-overlap) clamp(20px, 5vw, 36px) var(--s6);
}
.login-mascot {
  position: absolute;
  bottom: calc(100% - var(--mascot-overlap));
  left: 50%;
  transform: translateX(-50%);
  height: var(--mascot-height);
  width: auto;
  pointer-events: none;
}
.login-card h1 { margin: 0; font-size: clamp(26px, 5vw, 32px); font-weight: 800; text-align: center; }
.login-card h1 + .muted { text-align: center; }
.auth-form,.auth-telegram { margin-top: var(--s6); }
.auth-field { display: grid; gap: 6px; margin-bottom: var(--s3); }
.auth-field .errorlist { margin: 0; font-size: 12px; }
.auth-field .help { line-height: 1.45; }
.auth-field .help ul { margin: 4px 0; padding-left: 18px; }
.auth-divider { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); color: var(--muted); font-size: 12px; }
.auth-divider::before,.auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.auth-divider + .auth-form { margin-top: var(--s4); }
.full-width { width: 100%; }
.auth-secondary { margin-top: var(--s4); text-align: center; font-size: 13px; }
.auth-legal { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s6); color: var(--muted); font-size: 12px; }
.auth-legal a { color: var(--muted); }
.account-settings { width: min(640px,100%); margin-inline: auto; display: grid; gap: var(--s4); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.setting-row p { margin-top: var(--s1); }
.setting-action { margin-top: var(--s4); }
.danger-text { color: var(--error); }
.account-dates { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line); font-size: 13px; }
.legal-document { margin-inline: auto; }
.legal-document h2 { margin-top: var(--s6); margin-bottom: var(--s2); }
.legal-document p { margin-top: var(--s3); }
@media (min-width: 768px) and (max-width: 1023px) {
  .topbar-inner { gap: var(--s2); }
  th,td { padding: 8px; }
  th:first-child { width: 80px; } th:nth-child(2) { width: 90px; }
  .recent-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
}
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  main { padding-block: var(--s6) calc(88px + env(safe-area-inset-bottom)); }
  .brand-name { display: none; }
  .mobile-title { display: inline; }
  .section-nav { position: fixed; z-index: 5; inset: auto 0 0; display: grid; grid-template-columns: repeat(3,1fr); padding: 4px 88px calc(4px + env(safe-area-inset-bottom)) 12px; background: var(--surface); border-top: 1px solid var(--line); }
  .section-nav a { flex-direction: column; gap: 2px; padding: 5px 8px; font-size: 12px; }
  .add-purchase { position: fixed; right: 8px; bottom: calc(4px + env(safe-area-inset-bottom)); z-index: 6; width: 76px; flex-direction: column; padding: 5px 4px; gap: 2px; font-size: 12px; }
  .add-label { display: none; }
  .mobile-add-label { display: inline; }
  .theme-switch,button,.button,input:not([type=hidden]),select,summary,select.badge { min-height: 44px; }
  .theme-switch { width: 44px; }
  .page-head { flex-wrap: wrap; }
  .metrics,.recent-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s2); }
  .metric { padding: var(--s3); }
  .metric-icon { width: 24px; height: 24px; margin-left: 4px; }
  .metric strong { grid-column: 1/-1; }
  .enhanced .status-label { min-height: 44px; }
  .metric-icon .icon { width: 16px; height: 16px; }
  .metric strong { font-size: 22px; }
  .recent-cover { height: clamp(145px,44vw,255px); padding: 8px; }
  .caption { padding: var(--s3); }
  .purchase-filters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s2); }
  .filter-summary a { min-height: 44px; }
  .filter-row { display: contents; }
  .search { grid-column: 1/-1; }
  .search .icon { top: 14px; }
  .archive-filters + .more-filters,.more-filters[open] { grid-column: 1/-1; }
  .more-filters summary { min-height: 44px; }
  .purchase-filters > .search { grid-column: 1/-1; }
  .filter-panel { width: 100%; position: static; }
  .table-wrap { background: transparent; box-shadow: none; border: 0; overflow: visible; }
  table,tbody { display: block; }
  thead { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  tbody tr { display: grid; grid-template-columns: 72px minmax(0,1fr); grid-template-areas: "photo shop" "photo group" "photo date" "photo amount" "photo status" "photo box" "comment comment"; gap: 2px 12px; border-radius: var(--radius); margin-bottom: var(--s2); padding: var(--s3); background: var(--surface); border: 1px solid var(--line); }
  td { padding: 0; min-width: 0; border: 0; }
  td:nth-child(1) { grid-area: photo; } td:nth-child(2) { grid-area: date; color: var(--muted); font-size: 12px; }
  td:nth-child(3) { grid-area: shop; font-weight: 600; } td:nth-child(4) { grid-area: group; }
  td:nth-child(5) { grid-area: amount; text-align: left; } td:nth-child(6) { grid-area: status; margin-top: 6px; }
  td:nth-child(7) { grid-area: box; font-size: 13px; }
  td:nth-child(8) { grid-area: comment; font-size: 13px; margin-top: 6px; }
  .empty-comment { display: none; }
  td:nth-child(7)::before,td:nth-child(8)::before { content: attr(data-label) " · "; color: var(--muted); }
  .detail,.fields { grid-template-columns: 1fr; }
  .panel,.filter-panel { padding: var(--s4); }
  .login-card input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration: 0s!important; transition-duration: 0s!important; }
}

@media (min-width:851px) {
  .upload label[for="camera"] {display:none}
}

.recent-gallery { position: relative; }
.recent-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.recent-track::-webkit-scrollbar { display: none; }
.recent-track > .recent-cover { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }
.recent-item .caption { color: inherit; text-decoration: none; }
.recent-gallery button { position: absolute; top: 50%; transform: translateY(-50%); border-radius: 50%; width: 36px; height: 36px; min-height: 36px; padding: 0; font-size: 24px; }
.photo-prev { left: 4px; }
.photo-next { right: 4px; }
.recent-gallery button[hidden],
.recent-gallery button:disabled { display: none; }

.photo-viewer {
  margin: auto;
  padding: 8px;
  max-width: calc(100vw - 32px);
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 48px rgb(0 0 0 / 30%);
}
.photo-viewer::backdrop {
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.photo-viewer img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(560px, calc(100vw - 48px));
  max-height: min(620px, 72dvh);
}
.photo-viewer button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
}
html:has(.photo-viewer[open]) { overflow: hidden; }

.account-menu { position: relative; }
.account-menu summary { display: grid; place-items: center; list-style: none; cursor: pointer; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-panel { position: absolute; top: calc(100% + 8px); left: 0; z-index: 8; display: grid; gap: 12px; min-width: 210px; overflow-wrap: anywhere; }
.purchase-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s4); }
.purchase-tabs { display: flex; flex: none; padding: 2px; border-radius: var(--control); background: var(--mat); }
[data-theme="honey"] .purchase-tabs { background: var(--hover); }
.purchase-tabs a { display: flex; align-items: center; gap: var(--s1); padding: 5px 10px; white-space: nowrap; color: var(--text); border-radius: calc(var(--control) - 2px); }
.purchase-tabs [aria-current] { background: var(--surface); font-weight: 600; }
.tab-count { display: inline-grid; place-items: center; width: max-content; min-width: 1.65em; aspect-ratio: 1; padding-inline: .25em; border-radius: 50%; color: var(--action-ink); background: var(--active); font-size: 12px; line-height: 1; font-variant-numeric: tabular-nums; }
.bulk-toggle { margin-inline-start: auto; padding-inline: var(--s3); background: var(--surface); border: 1px solid var(--action); }
.bulk-toggle[aria-expanded=true] { background: var(--active); }
.bulk-status { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3); padding: var(--s2) var(--s3); margin-bottom: var(--s4); background: var(--active); border-radius: var(--control); }
.bulk-selection,.bulk-selection label,.bulk-actions { display: flex; align-items: center; gap: var(--s2); }
.bulk-selection label { cursor: pointer; }
.bulk-selection output { color: var(--action-ink); }
.bulk-actions { margin-inline-start: auto; max-width: 100%; }
.bulk-actions select { width: auto; }
.bulk-actions button { flex-shrink: 0; }
.bulk-selection input[type=checkbox],input[type=checkbox][form=bulk-status] { width: 20px; height: 20px; min-height: 20px; margin: 0; accent-color: var(--action-ink); cursor: pointer; }
.bulk-status[hidden] ~ * input[form=bulk-status] { display: none; }
@media (min-width: 768px) {
  .bulk-status:not([hidden]) ~ .purchase-workspace th:first-child { width: 128px; padding-left: 40px; }
  .bulk-status:not([hidden]) ~ .purchase-workspace td:first-child { position: relative; padding-left: 40px; }
  .purchase-workspace input[form=bulk-status] { position: absolute; left: var(--s3); top: 50%; transform: translateY(-50%); }
}
@media (max-width: 767px) {
  .purchase-toolbar { flex-wrap: nowrap; }
  .purchase-tabs a { min-height: 44px; padding-inline: var(--s2); }
  .purchase-tabs .icon { display: none; }
  .bulk-toggle { padding-inline: var(--s2); gap: var(--s1); }
  .bulk-selection label { min-height: 44px; }
}
@media (max-width: 540px) {
  .bulk-actions { width: 100%; }
  .bulk-actions select { flex: 1; }
  .purchase-toolbar { font-size: 13px; }
  .purchase-tabs a { padding-inline: var(--s1); }
}
@media (max-width: 359px) {
  .purchase-toolbar { font-size: 12px; gap: var(--s1); }
  .bulk-toggle { padding-inline: var(--s1); }
}

.purchase-composition { margin: var(--s6) 0; border: 1px solid var(--line); border-radius: 12px; background: var(--hover); }
.purchase-composition > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); list-style: none; }
.purchase-composition > summary::-webkit-details-marker { display: none; }
.purchase-composition > summary::after { content: ""; flex: none; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.purchase-composition[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.purchase-composition > summary > span { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s2); font-weight: 600; }
.purchase-composition > summary output { margin-left: auto; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.composition-body { padding: var(--s4); border-top: 1px solid var(--line); }
.composition-body > p { margin-bottom: var(--s4); }
.purchase-item-list { display: grid; gap: var(--s2); }
.purchase-item-list:empty { display: none; }
.purchase-item-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) 110px auto; align-items: end; gap: var(--s3); padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--control); }
.purchase-item-row > div > label { display: block; margin-bottom: var(--s1); color: var(--muted); font-size: 12px; }
.purchase-item-row .errorlist { grid-column: 1/-1; margin: 0; }
.item-remove { align-self: end; }
.item-remove button { min-height: 40px; padding-inline: var(--s2); }
.item-delete-fallback { display: flex; align-items: center; gap: var(--s2); min-height: 40px; color: var(--muted); }
.item-delete-fallback input { width: 20px; height: 20px; min-height: 20px; margin: 0; accent-color: var(--action); }
.add-item { margin-top: var(--s3); }
.detail-composition { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line); }
.detail-composition .section-head { margin-bottom: var(--s3); }
.purchase-item-chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.item-chip { --chip-bg: var(--neutral); --chip-ink: var(--neutral-ink); display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 8px; background: var(--chip-bg); color: var(--chip-ink); font-size: 12px; font-weight: 500; }
.item-chip .icon { width: 16px; height: 16px; }
.item-chip.card { --chip-bg: var(--blue); --chip-ink: var(--blue-ink); }
.item-chip.plush { --chip-bg: var(--peach); --chip-ink: var(--peach-ink); }
.item-chip.album { --chip-bg: var(--aqua); --chip-ink: var(--aqua-ink); }
.item-chip.merch { --chip-bg: var(--sent-bg); --chip-ink: var(--sent-ink); }

.statistics-filters { display: grid; grid-template-columns: auto minmax(260px,1fr) auto; align-items: end; gap: var(--s4); margin-bottom: var(--s3); }
.statistics-mode { min-width: 0; margin: 0; padding: 0; border: 0; }
.statistics-mode legend,.statistics-period label { display: block; margin-bottom: var(--s1); font-size: 13px; font-weight: 500; }
.segmented-control { display: flex; padding: 2px; border-radius: var(--control); background: var(--mat); }
.segmented-control label { position: relative; flex: 1; margin: 0; cursor: pointer; }
.segmented-control input { position: absolute; width: 1px; height: 1px; min-height: 1px; opacity: 0; }
.segmented-control span { display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 10px; border-radius: calc(var(--control) - 2px); white-space: nowrap; text-align: center; }
.segmented-control input:checked + span { background: var(--surface); color: var(--action-ink); font-weight: 600; }
.segmented-control input:focus-visible + span { outline: 2px solid var(--action); outline-offset: 2px; }
.statistics-period { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s2); }
.statistics-note { margin-bottom: var(--s4); }
.item-type-metrics { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: var(--s3); }
.item-type-stat { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: var(--s1); padding: var(--s3); border-radius: var(--control); background: var(--hover); color: var(--muted); }
.item-type-stat .metric-icon { grid-area: 1/2/3/3; }
.item-type-stat strong { color: var(--text); font-size: 24px; font-variant-numeric: tabular-nums; }
.item-type-stat.card .metric-icon { background: var(--blue); color: var(--blue-ink); }
.item-type-stat.plush .metric-icon { background: var(--peach); color: var(--peach-ink); }
.item-type-stat.album .metric-icon { background: var(--aqua); color: var(--aqua-ink); }
.item-type-stat.merch .metric-icon { background: var(--sent-bg); color: var(--sent-ink); }
.item-type-stat.other .metric-icon { background: var(--neutral); color: var(--neutral-ink); }
.statistics-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(320px,1fr); gap: var(--s4); }
.chart-subtitle { margin-top: var(--s1); }
.member-chart { display: grid; gap: var(--s3); margin-top: var(--s6); }
.member-bar-row { display: grid; grid-template-columns: 90px minmax(0,1fr) 34px; align-items: center; gap: var(--s3); }
.member-bar-row > strong { text-align: right; font-variant-numeric: tabular-nums; }
.member-bar-track { height: 12px; overflow: hidden; border-radius: 6px; background: var(--mat); }
.member-bar-track > span { display: block; height: 100%; min-width: 0; border-radius: inherit; background: var(--action); }
.donut-layout { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--s6); margin-top: var(--s6); }
.donut-chart { display: grid; place-items: center; flex: none; width: 180px; aspect-ratio: 1; border-radius: 50%; background: var(--donut-gradient); }
.donut-chart > div { display: grid; place-items: center; align-content: center; width: 62%; aspect-ratio: 1; border-radius: 50%; background: var(--surface); }
.donut-chart strong { font-family: var(--heading-font); font-size: 28px; line-height: 1.1; }
.donut-chart span { color: var(--muted); font-size: 12px; }
.donut-legend { display: grid; gap: var(--s2); min-width: 150px; margin: 0; padding: 0; list-style: none; }
.donut-legend li { display: grid; grid-template-columns: 12px minmax(0,1fr) auto; align-items: center; gap: var(--s2); }
.donut-legend strong { font-variant-numeric: tabular-nums; }
.legend-color { width: 12px; height: 12px; border-radius: 4px; }
@media (max-width: 1100px) {
  .statistics-filters { grid-template-columns: 1fr 1fr; }
  .statistics-filters > .actions { grid-column: 1/-1; }
  .item-type-metrics { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 767px) {
  .purchase-item-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: var(--s3) var(--s2); }
  .item-remove button,.item-delete-fallback { min-height: 44px; }
  .purchase-composition > summary { min-height: 44px; padding-inline: var(--s3); }
  .composition-body { padding: var(--s3); }
  .statistics-filters { grid-template-columns: 1fr; }
  .statistics-filters > .actions { grid-column: auto; }
  .segmented-control span { min-height: 42px; white-space: normal; font-size: 13px; }
  .item-type-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--s2); }
  .statistics-grid { grid-template-columns: 1fr; }
  .member-bar-row { grid-template-columns: 76px minmax(0,1fr) 28px; gap: var(--s2); }
  .donut-chart { width: 160px; }
}
