
:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0e13;
  color: #f7f9fc;
  font-synthesis: none;
  font-variant-numeric: tabular-nums;
  --canvas: #0b0e13;
  --surface: #111720;
  --raised: #171e29;
  --border: #283241;
  --text: #f7f9fc;
  --muted: #96a2b3;
  --primary: #1e5eff;
  --primary-pressed: #164ed8;
  --success: #2dcc73;
  --warning: #f2b84b;
  --danger: #ef4444;
  --focus: #7aa2ff;
  --radius: 14px;
  --large-radius: 16px;
  --ink: var(--text);
  --line: var(--border);
  --line-strong: #3b485c;
  --accent: var(--primary);
  --accent-deep: #9db7ff;
  --accent-soft: rgba(30, 94, 255, .14);
  --surface-muted: #0f151e;
  --success-soft: rgba(45, 204, 115, .12);
  --danger-soft: rgba(239, 68, 68, .12);
  --warning-soft: rgba(242, 184, 75, .12);
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow-card: 0 12px 28px rgba(0, 0, 0, .16);
  --font-display: Inter, ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% -20%, rgba(30,94,255,.08), transparent 42%), var(--canvas);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .45; }
img, video, svg { display: block; max-width: 100%; }
svg { width: 21px; height: 21px; stroke-width: 1.9; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(1.65rem, 6.5vw, 2rem); line-height: 1.15; letter-spacing: -.035em; }
h2 { margin-bottom: 14px; font-size: 1.18rem; line-height: 1.3; letter-spacing: -.02em; }
p { color: var(--muted); line-height: 1.5; }
a { color: inherit; text-decoration: none; }

.app-shell, .app-main { min-height: 100vh; }
.app-main { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.page { width: 100%; max-width: 640px; min-height: 100vh; margin: 0 auto; padding: 20px 16px 32px; }
.dashboard-page, .detail-page { max-width: 1180px; }
.page-header, .detail-header, .workflow-header, .active-header {
  display: flex; min-height: 56px; margin-bottom: 18px; align-items: flex-start;
  justify-content: space-between; gap: 12px;
}
.page-header { padding-right: 112px; }
.page-header p, .detail-header p, .active-header p { margin: 4px 0 0; font-size: .86rem; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.admin-owner-control { display: grid; min-width: 132px; gap: 3px; color: var(--muted); font-size: .62rem; font-weight: 760; text-transform: uppercase; }
.admin-owner-control select { min-height: 38px; padding: 6px 28px 6px 9px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface); text-transform: none; }
.library-owner { color: #9db7ff; font-size: .65rem; font-weight: 700; }
.header-spacer { width: 48px; flex: 0 0 48px; }

.icon-button {
  position: relative; display: inline-grid; width: 48px; height: 48px; padding: 0;
  place-items: center; flex: 0 0 48px; color: var(--muted); border: 1px solid transparent;
  border-radius: 13px; background: transparent; cursor: pointer;
}
.icon-button:hover { color: var(--text); border-color: var(--border); background: var(--surface); }
.icon-button b {
  position: absolute; top: -2px; right: -2px; display: grid; min-width: 20px; height: 20px;
  padding: 0 5px; place-items: center; border-radius: 999px; background: var(--primary);
  color: white; font-size: .68rem;
}
.danger-icon { color: var(--danger); }

.button {
  display: inline-flex; min-height: 52px; padding: 0 18px; align-items: center;
  justify-content: center; gap: 10px; border: 1px solid transparent; border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 1rem; font-weight: 680;
  line-height: 1.2; cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.button:active { transform: translateY(1px); }
.button-large { width: 100%; min-height: 60px; }
.button-primary { border-color: var(--primary); background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-pressed); }
.button-secondary { border-color: rgba(30,94,255,.8); background: transparent; color: #77a0ff; }
.button-quiet { border-color: var(--border); background: var(--surface); color: var(--muted); }
.button-danger { border-color: #cf3030; background: #c6292f; color: white; }
.button-warning { border-color: #8a6a26; background: #5f481b; color: #ffd985; }

.section-label {
  margin: 0 0 10px; color: var(--muted); font-size: .76rem; font-weight: 720;
  letter-spacing: .1em; text-transform: uppercase;
}
.status {
  display: inline-flex; min-height: 30px; align-items: center; gap: 7px; color: var(--muted);
  font-size: .78rem; font-weight: 690; line-height: 1; white-space: nowrap;
}
.status svg { width: 17px; height: 17px; }
.status-success { color: var(--success); }
.status-warning { color: var(--warning); }
.status-danger { color: #ff6b6b; }
.status-info { color: #79a1ff; }
.status-compact { font-size: .72rem; }
.spin { animation: spin 1.1s linear infinite; }
.money-positive { color: var(--success) !important; }
.money-negative { color: #ff6262 !important; }
.success-icon { color: var(--success); }
.warning-icon { color: var(--warning); }

.inline-warning, .inline-success {
  display: flex; min-height: 48px; margin: 12px 0; padding: 12px 14px; align-items: center;
  gap: 9px; border: 1px solid rgba(242,184,75,.35); border-radius: 12px;
  background: rgba(242,184,75,.08); color: #f7d386; font-size: .86rem; line-height: 1.4;
}
.inline-success { border-color: rgba(45,204,115,.35); background: rgba(45,204,115,.08); color: #83e6ac; }
.app-loading { display: grid; min-height: 100vh; padding: 24px; place-items: center; color: var(--muted); }

.field { display: grid; gap: 7px; }
.field > span { color: var(--muted); font-size: .78rem; font-weight: 660; }
.field input, .field select, .field textarea, .search-field input, .setting-row input, .setting-row select {
  width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); color: var(--text);
}
.field textarea { min-height: 104px; padding-top: 13px; resize: vertical; }
.field select, .setting-row select {
  appearance: none;
  background-image: linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);
  background-position: calc(100% - 18px) 21px,calc(100% - 13px) 21px;
  background-repeat: no-repeat; background-size: 5px 5px,5px 5px; padding-right: 36px;
}
.form-grid { display: grid; gap: 13px; }
.form-error { margin: 0; color: #ff7777; font-size: .86rem; }
.check-row { display: flex; min-height: 48px; align-items: center; gap: 10px; color: var(--muted); font-size: .87rem; }
.check-row input, .toggle-row input { width: 22px; height: 22px; accent-color: var(--primary); }

.login-page {
  display: grid; min-height: 100vh; padding: max(28px,env(safe-area-inset-top)) 20px max(28px,env(safe-area-inset-bottom));
  place-items: center;
}
.login-panel { width: min(100%,390px); }
.login-brand {
  display: grid; width: 54px; height: 54px; margin: 0 auto 28px; place-items: center;
  border: 1px solid rgba(30,94,255,.65); border-radius: 16px; color: white;
  font-family: Georgia,serif; font-size: 1.65rem;
  background: linear-gradient(145deg,rgba(30,94,255,.28),rgba(30,94,255,.02));
}
.login-panel h1 { margin-bottom: 6px; text-align: center; font-size: 2rem; }
.login-subtitle { margin-bottom: 34px; text-align: center; }
.login-panel form { display: grid; gap: 16px; }
.input-with-icon { position: relative; display: flex; align-items: center; }
.input-with-icon > svg { position: absolute; left: 14px; z-index: 1; color: var(--muted); }
.input-with-icon input { padding-left: 46px; padding-right: 50px; }
.input-action {
  position: absolute; right: 2px; display: grid; width: 48px; height: 48px; padding: 0;
  place-items: center; border: 0; background: transparent; color: var(--muted);
}
.privacy-note, .capture-footnote, .storage-disclaimer, .panel-note {
  max-width: 340px; margin: 24px auto 0; text-align: center; font-size: .78rem;
}

.side-nav { display: none; }
.bottom-tabs {
  position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; display: grid;
  height: calc(74px + env(safe-area-inset-bottom)); padding: 8px 6px env(safe-area-inset-bottom);
  grid-template-columns: repeat(5,1fr); border-top: 1px solid var(--border);
  background: #0d121a; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.bottom-tabs a {
  display: flex; min-width: 0; min-height: 56px; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px; border-radius: 11px; color: var(--muted);
  font-size: .62rem; font-weight: 650;
}
.bottom-tabs a.active { background: var(--primary); color: white; }
.bottom-tabs a svg { width: 23px; height: 23px; }
.floating-sync {
  position: fixed; top: max(10px,env(safe-area-inset-top)); right: 10px; z-index: 35;
  display: flex; min-height: 38px; padding: 0 10px; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px; background: rgba(17,23,32,.94); cursor: pointer;
}
.floating-sync b { display: grid; min-width: 19px; height: 19px; padding: 0 4px; place-items: center; border-radius: 999px; background: var(--primary); font-size: .65rem; }
.global-sync-button { display: none; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end;
  justify-content: center; background: rgba(0,0,0,.7);
}
.sheet {
  width: min(100%,620px); max-height: 88vh; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto; border: 1px solid var(--border); border-bottom: 0;
  border-radius: 22px 22px 0 0; background: var(--raised); box-shadow: 0 -16px 40px rgba(0,0,0,.45);
}
.sheet-handle { width: 44px; height: 4px; margin: 0 auto 8px; border-radius: 99px; background: #536075; }
.sheet-header { display: flex; min-height: 54px; align-items: center; justify-content: space-between; }
.sheet-header h2 { margin: 0; }
.sheet > .button, .sync-summary > .button { width: 100%; margin-top: 12px; }
.modal-actions { display: grid; margin-top: 18px; grid-template-columns: 1fr 1fr; gap: 10px; }
.sync-summary > .status { margin-bottom: 10px; }
.definition-list { margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); }
.definition-list div {
  display: flex; min-height: 46px; padding: 0 13px; align-items: center;
  justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border);
}
.definition-list div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); font-size: .78rem; }
.definition-list dd { margin: 0; font-size: .86rem; font-weight: 680; text-align: right; }

.sr-only {
  position: absolute !important; overflow: hidden; width: 1px !important; height: 1px !important;
  padding: 0 !important; clip: rect(0,0,0,0); white-space: nowrap; border: 0 !important;
}
@keyframes spin { to { transform: rotate(360deg); } }


.new-play-button {
  width: 100%;
  min-height: 110px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(124, 92, 255, .34);
  border-radius: var(--radius-xl);
  background: linear-gradient(140deg, #7657f6 0%, #9b63f4 60%, #b36ae9 100%);
  color: #fff;
  font: 800 clamp(1.35rem, 5vw, 1.8rem)/1.1 var(--font-display);
  letter-spacing: -.03em;
  box-shadow: 0 20px 42px rgba(118, 87, 246, .28);
}
.new-play-button svg { width: 30px; height: 30px; margin-bottom: 8px; }
.new-play-button:active { transform: translateY(1px) scale(.995); }
.today-summary { margin-top: 20px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.section-label { margin: 0 0 10px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.summary-primary { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.summary-primary strong { font: 800 1.85rem/1 var(--font-display); letter-spacing: -.04em; }
.summary-primary span { color: var(--muted); font-weight: 650; }
.metric-pair { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0 0; }
.metric-pair div { padding-top: 14px; border-top: 1px solid var(--line); }
.metric-pair dt { color: var(--muted); font-size: .78rem; }
.metric-pair dd { margin: 4px 0 0; font-weight: 800; }
.open-rows { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.open-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 12px; align-items: center; padding: 15px 16px; }
.open-row + .open-row { border-top: 1px solid var(--line); }
.open-row strong { display: block; font-size: .9rem; }
.open-row small { color: var(--muted); }
.warning-icon { color: var(--warning); }
.success-icon { color: var(--success); }
.workflow-page, .validation-page, .capture-screen, .classification-page, .completion-page { min-height: calc(100dvh - 86px); }
.workflow-header, .active-header, .detail-header { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; margin-bottom: 18px; }
.workflow-header h1, .active-header h1, .detail-header h1 { margin: 0; text-align: center; font: 800 1.15rem/1.15 var(--font-display); letter-spacing: -.02em; }
.header-spacer { display: block; }
.casino-section { margin-top: 20px; }
.selection-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.selection-list button { width: 100%; min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; font-weight: 720; }
.selection-list button:last-child { border-bottom: 0; }
.selection-list button::after { content: ""; width: 18px; height: 18px; border: 2px solid var(--line-strong); border-radius: 50%; }
.selection-list button.selected { background: var(--accent-soft); color: var(--accent-deep); }
.selection-list button.selected::after { border: 5px solid var(--accent); }
.sticky-action { position: sticky; bottom: 76px; padding: 18px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--canvas) 28%); }
.setup-game-field { display: grid; gap: 6px; margin-bottom: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.setup-game-field > span { color: var(--ink); font-size: .82rem; font-weight: 800; }
.setup-game-field > small { color: var(--muted); font-size: .7rem; line-height: 1.35; }
.setup-game-field select, .game-select-field select, .game-select-field input, .quick-field select, .quick-field input {
  width: 100%; min-width: 0; min-height: 48px; padding: 0 36px 0 12px; border: 1px solid var(--line-strong);
  border-radius: 12px; background-color: var(--surface-muted); color: var(--ink); font-weight: 720;
}
.setup-game-field select, .game-select-field select, .quick-field select {
  appearance: none;
  background-image: linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);
  background-position: calc(100% - 17px) 20px,calc(100% - 12px) 20px;
  background-repeat: no-repeat; background-size: 5px 5px,5px 5px;
}
.start-confirmation { min-height: calc(100dvh - 74px); padding-top: 12px; padding-bottom: 18px; }
.compact-workflow-header { margin-bottom: 10px; }
.compact-workflow-header > div { min-width: 0; text-align: center; }
.compact-workflow-header p { margin: 3px 0 0; font-size: .7rem; line-height: 1.3; }
.photo-confirmation-status {
  display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; min-height: 68px;
  margin-bottom: 10px; padding: 8px; align-items: center; border: 1px solid rgba(45,204,115,.32);
  border-radius: 15px; background: var(--success-soft);
}
.confirmation-thumb { width: 58px; height: 52px; display: grid; overflow: hidden; place-items: center; border-radius: 10px; background: #080b10; color: var(--muted); }
.confirmation-thumb img { width: 100%; height: 100%; object-fit: cover; }
.confirmation-thumb svg { width: 24px; height: 24px; }
.photo-confirmation-status strong { display: flex; align-items: center; gap: 7px; color: var(--success); font-size: .88rem; }
.photo-confirmation-status strong svg { width: 17px; height: 17px; }
.photo-confirmation-status.manual { border-color: rgba(242,184,75,.35); background: var(--warning-soft); }
.photo-confirmation-status.manual strong { color: var(--warning); }
.photo-confirmation-status span { display: block; margin-top: 3px; color: var(--muted); font-size: .68rem; line-height: 1.3; }
.start-details-form { min-width: 0; display: grid; gap: 10px; }
.game-select-field, .quick-field { display: grid; gap: 5px; min-width: 0; }
.game-select-field > span, .quick-field > span { color: var(--muted); font-size: .7rem; font-weight: 750; }
.start-value-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.free-play-entry { min-width: 0; min-height: 42px; display: grid; grid-template-columns: minmax(70px, 1fr) 38px minmax(72px, 110px) 38px; gap: 5px; align-items: center; }
.free-play-entry > span { color: var(--muted); font-size: .7rem; font-weight: 750; }
.free-play-entry button { min-width: 38px; min-height: 38px; padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--accent-deep); font-size: 1.15rem; font-weight: 850; }
.free-play-entry input { width: 100%; min-width: 0; min-height: 38px; padding: 7px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); text-align: center; font-size: .82rem; font-weight: 780; }
.currency-input { position: relative; min-width: 0; }
.currency-prefix { position: absolute; z-index: 1; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 780; pointer-events: none; }
.currency-input input { width: 100%; padding-left: 27px !important; }
.free-play-entry .currency-input input { text-align: center; padding-left: 20px !important; }
.quick-field select, .quick-field input { min-height: 50px; font-size: .9rem; }
.quick-field input { padding-right: 12px; }
.ball-level-editor { min-width: 0; margin: 0; padding: 9px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ball-level-editor legend { padding: 0 6px; color: var(--ink); font-size: .76rem; font-weight: 800; }
.ball-level-editor > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.ball-level-editor .quick-field select, .ball-level-editor .quick-field input { min-height: 48px; padding-left: 9px; font-size: .84rem; }
.bubble-grid-fieldset { min-width: 0; margin: 0; padding: 9px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.bubble-grid-fieldset legend { padding: 0 6px; color: var(--ink); font-size: .76rem; font-weight: 800; }
.bubble-grid-help, .bubble-grid-empty { margin: 0 0 7px; color: var(--muted); font-size: .68rem; line-height: 1.35; }
.bubble-grid-editor, .bubble-grid-readonly { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(34px, .65fr) repeat(5, minmax(0, 1fr)); gap: 5px; align-items: center; }
.bubble-grid-column-label, .bubble-grid-row-label { min-width: 0; color: var(--muted); font-size: .62rem; font-weight: 800; text-align: center; }
.bubble-grid-row-label { text-align: left; }
.bubble-grid-toggle, .bubble-grid-cell { min-width: 0; min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--primary); display: grid; place-items: center; }
.bubble-grid-toggle { padding: 0; cursor: pointer; font-size: 1.1rem; }
.bubble-grid-toggle.active, .bubble-grid-cell.active { border-color: var(--primary); background: rgba(38,101,255,.25); box-shadow: inset 0 0 0 1px var(--primary); }
.bubble-grid-cell.active::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }
.bubble-grid-confirm { margin-top: 9px; display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: .72rem; font-weight: 750; }
.bubble-grid-confirm input { width: 18px; height: 18px; accent-color: var(--primary); }
.bubble-state-summary { width: 100%; min-width: 0; display: grid; gap: 7px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); text-align: left; }
.bubble-state-summary > span { font-weight: 800; }
.bubble-state-summary > small { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.bubble-state-summary > .icon { position: absolute; right: 14px; }
.bubble-audit-grid { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bubble-audit-grid > div { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.bubble-audit-grid h3, .bubble-audit-grid p { margin: 0 0 8px; }
.bubble-audit-grid p { margin-top: 8px; color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.start-play-button { width: 100%; min-height: 58px; font-size: 1rem; }
.retake-link {
  width: 100%; min-height: 44px; margin-top: 4px; display: flex; align-items: center; justify-content: center;
  gap: 8px; border: 0; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 720;
}
.retake-link svg { width: 18px; height: 18px; }
.camera-frame { position: relative; width: 100%; aspect-ratio: 4 / 5; max-height: 62dvh; overflow: hidden; border-radius: 24px; background: #161a22; box-shadow: 0 18px 60px rgba(20, 24, 36, .22); }
.camera-frame video, .camera-frame img { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { height: 100%; display: grid; place-items: center; color: rgba(255,255,255,.7); text-align: center; padding: 30px; }
.camera-placeholder svg { width: 46px; height: 46px; margin: 0 auto 12px; }
.frame-corner { position: absolute; width: 42px; height: 42px; border-color: #fff; border-style: solid; filter: drop-shadow(0 1px 3px rgba(0,0,0,.35)); }
.frame-a { top: 22px; left: 22px; border-width: 3px 0 0 3px; border-radius: 12px 0 0; }
.frame-b { top: 22px; right: 22px; border-width: 3px 3px 0 0; border-radius: 0 12px 0 0; }
.frame-c { bottom: 22px; left: 22px; border-width: 0 0 3px 3px; border-radius: 0 0 0 12px; }
.frame-d { bottom: 22px; right: 22px; border-width: 0 3px 3px 0; border-radius: 0 0 12px; }
.capture-actions { display: grid; gap: 10px; margin-top: 16px; }
.file-button { cursor: pointer; }
.file-button input { position: absolute; opacity: 0; pointer-events: none; }
.capture-footnote { color: var(--muted); text-align: center; font-size: .78rem; line-height: 1.5; }
.mock-fixtures { margin-top: 10px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); color: var(--muted); }
.mock-fixtures summary { cursor: pointer; font-weight: 750; }
.mock-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.validation-photo, .end-photo-preview { overflow: hidden; aspect-ratio: 16 / 10; border-radius: var(--radius-lg); background: #171b25; }
.validation-photo img, .end-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: rgba(255,255,255,.55); background: #1a1d26; }
.progress-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0; margin: 20px 0; list-style: none; }
.progress-track li { position: relative; padding-top: 17px; color: var(--muted); font-size: .66rem; text-align: center; }
.progress-track li::before { content: ""; position: absolute; top: 3px; left: 50%; width: 9px; height: 9px; border: 2px solid var(--line-strong); border-radius: 50%; transform: translateX(-50%); background: var(--canvas); }
.progress-track li::after { content: ""; position: absolute; top: 7px; left: calc(50% + 7px); width: calc(100% - 8px); height: 2px; background: var(--line); }
.progress-track li:last-child::after { display: none; }
.progress-track li.done { color: var(--ink); font-weight: 700; }
.progress-track li.done::before { border-color: var(--success); background: var(--success); }
.progress-track li.done::after { background: var(--success); }
.progress-track li.failed::before { border-color: var(--danger); background: var(--danger); }
.validation-result { padding: 22px 18px; border-radius: var(--radius-lg); text-align: center; }
.validation-result h2 { margin: 8px 0 6px; font: 800 1.25rem var(--font-display); }
.validation-result p { margin: 0 0 16px; }
.result-valid { background: var(--success-soft); border: 1px solid rgba(19, 133, 99, .25); }
.result-rejected { background: var(--danger-soft); border: 1px solid rgba(199, 61, 75, .25); }
.result-processing { background: var(--surface); border: 1px solid var(--line); }
.result-offline { background: rgba(242,184,75,.10); border: 1px solid rgba(242,184,75,.42); }
.result-offline .result-icon { color: #17130a; background: var(--warning); }
.result-icon { width: 54px; height: 54px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--success); }
.result-rejected .result-icon { background: var(--danger); }
.processing-ring { border: 5px solid var(--accent-soft); border-top-color: var(--accent); background: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.detected-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.detected-values div { padding: 10px 6px; border: 1px solid rgba(45,204,115,.2); border-radius: 12px; background: rgba(5,30,23,.62); }
.detected-values dt { color: #b7c5d1; font-size: .68rem; }
.detected-values dd { margin: 4px 0 0; color: var(--ink); font-weight: 800; }
.active-play { padding-top: 10px; }
.active-play > .status { margin-bottom: 7px; }
.edit-details-button { display: inline-flex; min-height: 38px; padding: 0 9px; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--accent-deep); font-size: .7rem; font-weight: 780; white-space: nowrap; }
.edit-details-button svg { width: 15px; height: 15px; }
.buyin-photo { display: grid; grid-template-columns: minmax(0, 1fr) 58px; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.start-thumb { aspect-ratio: 1; overflow: hidden; border-radius: 14px; background: #171b25; }
.start-thumb img { width: 100%; height: 100%; object-fit: cover; }
.buyin-photo strong { display: block; font-size: 1.2rem; }
.buyin-photo span { color: var(--muted); font-size: .8rem; }
.buyin-photo .buyin-breakdown { display: block; margin: 1px 0 2px; color: var(--danger); font-size: .72rem; font-weight: 720; }
.ball-levels-summary {
  width: 100%; min-height: 68px; margin-top: 10px; padding: 9px 12px; display: grid;
  grid-template-columns: minmax(64px, 1fr) repeat(3, minmax(48px, .7fr)) 22px; gap: 6px;
  align-items: center; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink); text-align: left;
}
.ball-levels-summary > span { color: var(--muted); font-size: .72rem; font-weight: 760; }
.ball-levels-summary strong { display: grid; gap: 2px; font-size: 1rem; text-align: center; }
.ball-levels-summary i { color: var(--muted); font-size: .58rem; font-style: normal; font-weight: 650; }
.ball-levels-summary svg { width: 18px; height: 18px; color: var(--accent-deep); }
.active-controls { display: grid; gap: 7px; margin-top: 8px; }
.active-primary-actions, .active-secondary-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.active-primary-actions .button { min-width: 0; min-height: 48px; padding: 0 8px; font-size: .82rem; }
.add-default { min-height: 48px; font-size: .82rem; }
.end-play-button { min-height: 48px; margin: 0; border-color: #2dcc73; background: #168a4f; color: #fff; font-weight: 820; }
.end-play-button:hover { background: #117743; }
.active-secondary-controls .button { min-width: 0; min-height: 42px; padding: 0 8px; gap: 6px; font-size: .72rem; }
.active-secondary-controls .button svg { width: 17px; height: 17px; }
.active-guide-action { grid-column: 1 / -1; }
.active-controls > .cancel-play-button { min-height: 42px; margin-top: 2px; font-size: .76rem; }
.control-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.undo-toast { position: fixed; z-index: 20; bottom: 92px; left: 50%; width: min(calc(100% - 28px), 390px); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-radius: 14px; background: #242633; color: #fff; box-shadow: 0 16px 34px rgba(0,0,0,.28); transform: translateX(-50%); }
.undo-toast button { color: #c8bfff; font-weight: 800; }
.quick-money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.end-play-entry { max-width: 520px; padding-top: 10px; }
.end-play-entry .workflow-header { margin-bottom: 10px; }
.end-out-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.end-out-card h2 { margin: 0; }
.end-out-card .field > span { font-size: .9rem; }
.end-out-card .field input { min-height: 58px; font-size: 1.45rem; font-weight: 800; }
.end-out-card .currency-prefix { left: 18px; font-size: 1.45rem; }
.end-out-card .currency-input input { padding-left: 48px !important; }
.end-out-card .form-error:empty { display: none; }
.confirm-out-button { min-height: 54px; border-color: #2dcc73; background: #168a4f; color: #fff; }
.confirm-out-button:hover { background: #117743; }
.classification-actions { display: grid; gap: 12px; margin-top: 18px; }
.classification-button { min-height: 74px; font-size: 1rem; }
.confetti-layer { position: fixed; z-index: 70; inset: 0; overflow: hidden; pointer-events: none; contain: strict; }
.confetti-piece { position: absolute; top: 55%; width: var(--confetti-width); height: var(--confetti-height); border-radius: 2px; opacity: 0; background: var(--confetti-color); box-shadow: 0 0 4px rgba(255,255,255,.28); animation: confetti-blast var(--confetti-duration) cubic-bezier(.18,.8,.26,1) var(--confetti-delay) forwards; will-change: transform, opacity; }
.confetti-piece.from-left { left: 3%; }
.confetti-piece.from-right { right: 3%; }
@keyframes confetti-blast {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg) scale(.7); }
  38% { opacity: 1; transform: translate3d(var(--confetti-blast-x), var(--confetti-blast-y), 0) rotate(var(--confetti-spin)) scale(1); }
  100% { opacity: 0; transform: translate3d(var(--confetti-fall-x), var(--confetti-fall-y), 0) rotate(var(--confetti-spin)) scale(.85); }
}
@media (prefers-reduced-motion: reduce) { .confetti-layer { display: none !important; } }
.completion-page { display: grid; align-content: center; text-align: center; gap: 14px; }
.completion-check { width: 74px; height: 74px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.completion-check svg { width: 36px; height: 36px; }
.completion-page h1 { margin: 0; font: 800 2rem var(--font-display); }
.completion-page > strong { font: 800 2.8rem var(--font-display); }
.completion-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; overflow: hidden; margin: 4px 0 8px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--line); }
.completion-summary div { padding: 14px; background: var(--surface); }
.completion-summary dt { color: var(--muted); font-size: .75rem; }
.completion-summary dd { margin: 4px 0 0; font-weight: 800; }



.completed-search { margin: 8px 0 10px; }
.completed-list, .expense-list { display: grid; gap: 7px; }
.completed-card {
  display: block;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: inherit;
  box-shadow: none;
}
.completed-card:hover { border-color: var(--accent); }
.completed-card > header { display: grid; grid-template-columns: minmax(0, 1fr) 16px; gap: 1px 7px; align-items: center; margin-bottom: 7px; }
.completed-card > header > .completed-title-line { grid-column: 1; grid-row: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 1px 5px; align-items: baseline; line-height: 1.15; }
.completed-card > header strong { font-size: .92rem; }
.completed-card > header > .completed-title-line span { color: var(--muted); font-size: .74rem; }
.completed-card .completed-meta-line { grid-column: 1; grid-row: 2; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.completed-card .completed-meta-line time { color: var(--muted); font-size: .64rem; }
.completed-card .completed-meta-line .completion-tag { padding: 1px 5px; font-size: .52rem; }
.completed-card .completed-card-review { gap: 2px; font-size: .58rem; }
.completed-card .completed-card-review svg { width: 12px; height: 12px; }
.completed-card > header svg { grid-column: 2; grid-row: 1 / span 2; width: 16px; color: var(--muted); }
.completed-card > footer { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 6px; }
.completed-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  margin: 0;
}
.completed-grid div { min-width: 0; }
.completed-grid dt { color: var(--muted); font-size: .56rem; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
.completed-grid dd { margin: 2px 0 0; overflow: hidden; font-size: .76rem; font-weight: 780; text-overflow: ellipsis; white-space: nowrap; }
.completion-tag {
  display: inline-flex;
  margin-top: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: .56rem;
  font-weight: 800;
  letter-spacing: .07em;
}
.missing-value { display: inline-flex; align-items: center; gap: 5px; color: var(--warning); font-size: .78rem; }
.missing-value svg { width: 14px; }

.expense-total, .bankroll-band {
  padding: 20px;
  border-radius: var(--radius-xl);
  color: #fff;
  background: linear-gradient(135deg, #272334, #594794);
  box-shadow: 0 20px 50px rgba(52, 38, 91, .22);
}
.expense-total span, .bankroll-band > span { display: block; color: rgba(255,255,255,.72); font-size: .78rem; }
.expense-total strong, .bankroll-band > strong { display: block; margin-top: 5px; font: 800 2.15rem var(--font-display); letter-spacing: -.04em; }
.add-expense { width: 100%; margin: 14px 0; }
.expense-row {
  display: grid;
  grid-template-columns: 44px 1fr auto 40px 40px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.expense-row > span:first-child {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent);
}
.expense-row h2 { margin: 0; font-size: .92rem; }
.expense-row p { margin: 3px 0 0; color: var(--muted); font-size: .74rem; }
.expense-row strong { font-size: .95rem; }

.bankroll-band { margin-bottom: 14px; }
.bankroll-band > div { display: grid; gap: 6px; margin-top: 16px; }
.bankroll-band div span {
  display: flex; justify-content: space-between; gap: 16px;
  color: rgba(255,255,255,.72); font-size: .75rem;
}
.bankroll-band .money-positive, .bankroll-band .money-negative { color: #fff; }
.summary-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.metric dt { color: var(--muted); font-size: .72rem; line-height: 1.25; }
.metric dd { margin: 6px 0 0; font: 780 1rem var(--font-display); overflow-wrap: anywhere; }
.metric-featured {
  border-color: rgba(124, 92, 255, .28);
  background: var(--accent-soft);
}
.chart-section, .all-metrics, .breakdown-section, .financial-panel, .extracted-panel, .timeline, .edit-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.chart-section h2, .all-metrics h2, .breakdown-section h2, .financial-panel h2, .extracted-panel h2, .timeline h2, .edit-panel h2 {
  margin: 0 0 14px;
  font: 800 1rem var(--font-display);
}
.chart-wrap { width: 100%; height: 230px; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0;
}
.breakdown-list { display: grid; gap: 8px; }
.breakdown-row { border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.breakdown-row summary {
  min-height: 52px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 750;
}
.breakdown-row summary::marker { color: var(--accent); }
.breakdown-row summary > span { min-width: 0; display: flex; flex-wrap: wrap; gap: 3px 7px; align-items: baseline; }
.breakdown-row summary small { color: var(--muted); font-weight: 600; }
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0;
  border-top: 1px solid var(--line);
  background: var(--line);
}
.breakdown-grid div { padding: 10px; background: var(--surface-muted); }
.breakdown-grid dt { color: var(--muted); font-size: .65rem; }
.breakdown-grid dd { margin: 3px 0 0; font-weight: 750; font-size: .78rem; }

.dashboard-charts { display: grid; gap: 14px; }
.breakdown-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.breakdown-heading h2 { margin-bottom: 14px; }
.breakdown-heading span { color: var(--muted); font-size: .7rem; font-weight: 750; }
.dashboard-table-wrap { display: none; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
.dashboard-table { width: 100%; min-width: 930px; border-collapse: collapse; font-size: .72rem; }
.dashboard-table th, .dashboard-table td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.dashboard-table thead th { position: sticky; top: 0; color: var(--muted); background: var(--surface-muted); font-size: .62rem; letter-spacing: .045em; text-transform: uppercase; }
.dashboard-table th:first-child, .dashboard-table td:first-child { text-align: left; }
.dashboard-table tbody th { max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-weight: 760; }
.dashboard-table tbody tr:last-child th, .dashboard-table tbody tr:last-child td { border-bottom: 0; }
.dashboard-table tbody tr:hover { background: var(--surface-muted); }
.detail-result { text-align: center; margin-bottom: 16px; }
.detail-result > span { color: var(--muted); font-weight: 700; }
.detail-result > strong { display: block; margin-top: 4px; font: 800 2.5rem var(--font-display); letter-spacing: -.05em; }
.detail-photo {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.detail-photo img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: #171b25; }
.detail-photo figcaption { padding: 10px 12px; color: var(--muted); font-size: .75rem; }
.photo-pair { display: grid; gap: 10px; }
.photo-pair > section > h2 { font: 800 1rem var(--font-display); }
.definition-list { display: grid; gap: 0; margin: 0; }
.definition-list div {
  min-height: 42px; padding: 10px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  border-bottom: 1px solid var(--line);
}
.definition-list div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); font-size: .78rem; }
.definition-list dd { margin: 0; text-align: right; font-weight: 740; overflow-wrap: anywhere; }
.panel-note { color: var(--muted); font-size: .75rem; line-height: 1.5; }
.timeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 94px minmax(0,1fr) auto;
  gap: 10px;
  min-height: 42px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  font-size: .78rem;
}
.timeline-row:last-child { border-bottom: 0; }
.timeline-row time { color: var(--muted); }
.timeline-row span { text-transform: capitalize; }
.timeline-row .timeline-action { min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 7px; align-items: baseline; }
.timeline-row .timeline-action .timeline-account { display: block; flex-basis: 100%; color: #aebbd0; font-size: .7rem; font-weight: 700; line-height: 1.25; white-space: normal; text-transform: none; }
.edit-panel { background: #fbfaff; }
.edit-panel > .button { width: 100%; margin-top: 12px; }

.settings-group { margin-top: 18px; }
.settings-group > h2 { margin: 0 0 8px; color: var(--muted); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.settings-rows {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.setting-row {
  min-height: 68px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row > span { min-width: 0; }
.setting-row b { display: block; font-size: .86rem; }
.setting-row small { display: block; margin-top: 3px; color: var(--muted); font-size: .69rem; }
.setting-row input:not([type="checkbox"]), .setting-row select { width: min(144px, 42%); }
.setting-row > .currency-input { width: min(144px, 42%); flex: 0 0 min(144px, 42%); }
.setting-row > .currency-input input:not([type="checkbox"]) { width: 100%; }
.toggle-row input {
  width: 44px; height: 26px; flex: 0 0 44px;
  appearance: none; border-radius: 999px;
  background: var(--line-strong); cursor: pointer;
}
.toggle-row input::after {
  content: ""; display: block; width: 20px; height: 20px; margin: 3px;
  border-radius: 50%; background: #fff; transition: transform .18s ease;
}
.toggle-row input:checked { background: var(--accent); }
.toggle-row input:checked::after { transform: translateX(18px); }
.storage-group { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.storage-status { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.inline-success { color: var(--success); font-weight: 750; }
.storage-disclaimer { color: var(--muted); text-align: center; font-size: .72rem; line-height: 1.5; }

@media (max-width: 767px) {

  .detail-page { width: 100%; max-width: 100%; overflow-x: hidden; }
  .detail-page *,
  .detail-page > * { min-width: 0; max-width: 100%; }
  .detail-header {
    grid-template-columns: 44px minmax(0, 1fr);
    padding-right: 0;
    align-items: start;
  }
  .detail-header > div:nth-child(2) { min-width: 0; align-self: center; }
  .detail-header h1,
  .detail-header p { text-align: left; overflow-wrap: anywhere; }
  .detail-header .header-actions {
    grid-column: 1 / -1;
    display: grid;
    width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .detail-header .header-actions .button {
    width: 100%; min-width: 0; min-height: 42px; padding: 0 8px;
    font-size: .8rem; white-space: nowrap;
  }
  .detail-page .photo-pair,
  .detail-page .financial-panel,
  .detail-page .extracted-panel,
  .detail-page .timeline,
  .detail-page .definition-list { width: 100%; max-width: 100%; }
  .detail-page .definition-list dt,
  .detail-page .definition-list dd { min-width: 0; overflow-wrap: anywhere; }
  .detail-page .timeline-row { grid-template-columns: minmax(70px, 84px) minmax(0, 1fr) auto; }
  .completed-delete-button { width: 100%; margin-top: 14px; }
  .floating-sync { width: 44px; padding: 0; justify-content: center; }
  .floating-sync .status { gap: 0; font-size: 0; }
  .floating-sync .status svg { width: 21px; height: 21px; }
  .floating-sync b { position: absolute; top: -4px; right: -4px; }
}

@media (min-width: 430px) {
  .page, .capture-screen { padding-left: 22px; padding-right: 22px; }
  .new-play-button { min-height: 122px; }
  .photo-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
  :root { --page-max: 1040px; }
  body { background: #efedf3; }
  .app-shell { min-height: 100dvh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
  .side-nav {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: 224px;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    border-right: 1px solid var(--line);
    background: rgba(249,248,251,.96);
    backdrop-filter: blur(18px);
  }
  .brand-lockup {
    display: flex; align-items: center; gap: 10px;
    padding: 0 8px 24px;
    font: 800 .92rem var(--font-display);
  }
  .brand-mark {
    width: 38px; height: 38px; display: grid; place-items: center;
    border-radius: 13px; color: #fff;
    background: linear-gradient(140deg, var(--accent), #aa64eb);
    box-shadow: 0 8px 20px rgba(124,92,255,.25);
  }
  .side-nav nav { display: grid; gap: 5px; }
  .side-nav a {
    min-height: 46px;
    display: flex; align-items: center; gap: 12px;
    padding: 0 12px;
    border-radius: 13px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 760;
  }
  .side-nav a:hover { color: var(--ink); background: var(--surface); }
  .side-nav a.active { color: var(--accent-deep); background: var(--accent-soft); }
  .side-nav a svg { width: 19px; }
  .global-sync-button {
    margin-top: auto;
    min-height: 44px;
    display: flex; align-items: center; gap: 10px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--muted);
    background: var(--surface);
    font-size: .76rem;
    font-weight: 750;
  }
  .app-main { grid-column: 2; min-width: 0; }
  .bottom-tabs, .floating-sync { display: none; }
  .page, .capture-screen {
    width: min(100%, var(--page-max));
    min-height: 100dvh;
    padding: 38px 42px 54px;
  }
  .page-header h1 { font-size: 1.85rem; }
  .play-home { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); gap: 18px; align-content: start; }
  .play-home .page-header { grid-column: 1 / -1; }
  .play-home .new-play-button { min-height: 155px; }
  .play-home .today-summary { margin-top: 0; }
  .play-home .open-rows { grid-column: 1 / -1; margin-top: 0; }
  .workflow-page, .validation-page, .classification-page, .completion-page, .capture-screen, .active-play {
    max-width: 650px;
  }
  .sticky-action { bottom: 0; }
  .undo-toast { bottom: 30px; margin-left: 112px; }
  .completed-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-metrics { grid-template-columns: repeat(6, 1fr); }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .dashboard-page { max-width: 1320px; }
  .dashboard-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-charts .chart-section { margin-top: 0; }
  .dashboard-table-wrap { display: block; }
  .breakdown-list { display: none; }
  .expense-row { grid-template-columns: 44px minmax(0,1fr) 140px 40px 40px; }
  .expenses-page, .settings-page, .detail-page { max-width: 850px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet { left: calc(50% + 112px); bottom: 20px; width: min(520px, calc(100% - 270px)); border-radius: 24px; }
  .sheet-wide { max-width: 720px; }
}

@media (min-width: 1024px) {
  .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .side-nav { width: 250px; padding: 30px 20px; }
  .app-main { grid-column: 2; }
  .completed-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .undo-toast { margin-left: 125px; }
  .sheet { left: calc(50% + 125px); }
}

@media (max-width: 520px) {
  .completed-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .completed-search input { min-height: 42px; padding-block: 7px; }
  .expense-row { grid-template-columns: 40px minmax(0,1fr) auto 38px; }
  .expense-row > .danger-icon { display: none; }
}

@media (max-width: 370px) {
  html { font-size: 15px; }
  .page, .capture-screen { padding-left: 14px; padding-right: 14px; }
  .bottom-tabs a { font-size: .58rem; }
  .bottom-tabs a svg { width: 19px; }
  .quick-money { grid-template-columns: 1fr; }
  .detected-values { grid-template-columns: 1fr; }
  .progress-track li { font-size: .58rem; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* Native application utilities */
.side-nav { display: none; }
.modal-backdrop { position: fixed; z-index: 80; inset: 0; display: grid; align-items: end; justify-items: center; padding: 12px; background: rgba(0,0,0,.68); backdrop-filter: blur(5px); }
.sheet { width: min(100%, 560px); max-height: min(88vh, 800px); overflow: auto; padding: 18px; border: 1px solid var(--border); border-radius: 22px 22px 14px 14px; background: var(--surface); box-shadow: 0 24px 80px rgba(0,0,0,.4); }
.sheet-header { position: sticky; z-index: 2; top: -18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -18px -18px 14px; padding: 16px 18px 10px; background: var(--surface); }
.sheet-header h2 { margin: 0; }
.sheet-content { display: grid; gap: 12px; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.stack-actions { display: grid; gap: 10px; }
.toast { position: fixed; z-index: 100; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); max-width: min(420px, calc(100% - 32px)); padding: 13px 16px; border: 1px solid var(--border); border-radius: 13px; color: var(--text); background: var(--raised); box-shadow: var(--shadow-card); }
.toast-success { border-color: var(--success); }
.toast-danger { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(100%, 420px); display: grid; gap: 14px; padding: 24px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-card); }
.login-card h1 { margin: 4px 0 0; }
.login-card p { margin-bottom: 0; }
.login-brand { padding: 0; }
.remember-row { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.remember-row input { width: 20px; height: 20px; }
.form-error { min-height: 1.4em; margin: 0; color: var(--danger); }
.camera-file-input { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; pointer-events: auto; }
.capture-button { position: relative; overflow: hidden; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.camera-picker-actions { display: grid; gap: 10px; }
.camera-picker-actions .button-secondary { min-height: 52px; }
.camera-stage { min-height: min(56vh, 560px); display: grid; place-items: center; align-content: center; gap: 12px; margin: 12px 0 18px; padding: 28px; border: 1px dashed var(--line-strong); border-radius: 22px; color: var(--muted); background: var(--surface); text-align: center; }
.camera-stage svg { width: 58px; height: 58px; color: var(--accent-deep); }
.camera-stage strong { color: var(--text); font-size: 1.15rem; }
.camera-stage p, .camera-help { margin: 0; text-align: center; }
.capture-processing-overlay { position: fixed; z-index: 1400; inset: 0; display: grid; place-items: center; padding: 24px; color: var(--text); background: rgba(7,11,18,.96); text-align: center; }
.capture-processing-overlay[hidden] { display: none; }
.capture-processing-card { width: min(100%, 360px); display: grid; justify-items: center; gap: 12px; padding: 28px 24px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-card); }
.capture-processing-card .processing-ring, .camera-stage .processing-ring { width: 56px; height: 56px; display: block; border-radius: 50%; }
.capture-processing-card strong { font-size: 1.35rem; }
.capture-processing-card p { margin: 0; color: var(--muted); }
.capture-screen.has-manual-entry .camera-stage { min-height: min(38vh, 380px); }
.manual-start-button { min-height: 50px; border-color: rgba(157,183,255,.52); color: var(--accent-deep); background: var(--accent-soft); }
.manual-start-page { display: grid; align-content: start; gap: 8px; }
.manual-start-notice { display: grid; grid-template-columns: 30px minmax(0,1fr); align-items: center; gap: 9px; padding: 9px 11px; border: 1px solid rgba(157,183,255,.38); border-radius: 12px; background: var(--accent-soft); }
.manual-start-notice svg { width: 22px; height: 22px; color: var(--accent-deep); }
.manual-start-notice div { display: grid; gap: 1px; }
.manual-start-notice strong { font-size: .78rem; }
.manual-start-notice span { color: var(--muted); font-size: .66rem; line-height: 1.3; }
.details-form { display: grid; gap: 16px; margin-top: 16px; text-align: left; }
.field { display: grid; gap: 7px; color: var(--text); font-size: .78rem; font-weight: 700; }
.field small { color: var(--muted); font-size: .68rem; font-weight: 500; }
.field input, .field select, .field textarea, .completed-search input { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface-muted); }
.field textarea { min-height: 110px; resize: vertical; }
.field input[readonly] { color: var(--accent-deep); background: var(--raised); }
.picker-list, .open-rows { display: grid; gap: 10px; }
.picker-row { width: 100%; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 15px; color: var(--text); background: var(--surface); text-align: left; }
.picker-row span { display: grid; gap: 4px; }
.picker-row small { color: var(--muted); }
.draft-row { min-width: 0; display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); }
.draft-summary { width: 100%; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px; border: 0; color: var(--text); background: transparent; text-align: left; }
.draft-summary > span { min-width: 0; display: grid; gap: 3px; }
.draft-summary small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.draft-summary .draft-waiting { color: var(--warning); font-weight: 700; }
.draft-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) 46px; gap: 7px; }
.draft-actions .button { min-height: 42px; padding: 7px 9px; font-size: .74rem; }
.draft-remove-button { width: 46px; min-height: 42px; align-self: center; border-color: rgba(255, 78, 91, .45); color: var(--danger); background: rgba(255, 78, 91, .08); }
.draft-remove-button:hover { background: rgba(255, 78, 91, .16); }.new-play-button { width: 100%; min-height: 116px; display: grid; place-items: center; align-content: center; gap: 7px; border: 1px solid var(--primary); border-radius: 20px; color: var(--text); background: linear-gradient(145deg, rgba(30,94,255,.25), rgba(30,94,255,.07)); }
.new-play-icon { color: var(--accent-deep); }
.new-play-button small { color: var(--muted); }
.today-summary, .open-rows { margin-top: 18px; }
.status { display: inline-flex; width: fit-content; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.status svg { width: 15px; height: 15px; }
.status-success { color: var(--success); border-color: rgba(45,204,115,.35); }
.status-danger { color: var(--danger); border-color: rgba(239,68,68,.35); }
.status-warning { color: var(--warning); border-color: rgba(242,184,75,.35); }
.sync-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.sync-row div { display: grid; gap: 3px; }
.sync-row small, .sync-row time { color: var(--muted); font-size: .7rem; }
.empty-state { display: grid; place-items: center; gap: 8px; padding: 30px 18px; color: var(--muted); text-align: center; }
.money-positive { color: var(--success); }
.money-negative { color: var(--danger); }
.chart-wrap svg { overflow: visible; }
.global-sync-button b { margin-left: auto; }
.capture-screen { width: 100%; max-width: 640px; min-height: 100vh; margin: 0 auto; padding: 20px 16px 32px; }
@media (min-width: 768px) {
  .side-nav { display: flex; }
  .modal-backdrop { align-items: center; padding-left: 250px; }
  .sheet { border-radius: 22px; }
  .toast { bottom: 24px; }
}
@media (max-width: 767px) {

  .active-play { padding: 8px 12px 18px; }
  .active-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    min-height: 46px;
    margin-bottom: 7px;
    padding-right: 48px;
  }
  .active-header h1 { text-align: left; font-size: 1.12rem; line-height: 1.08; }
  .active-header p { margin-top: 2px; font-size: .68rem; line-height: 1.2; }
  .active-header .edit-details-button { width: auto; justify-content: center; }
  .active-play .status { min-height: 25px; padding: 4px 7px; font-size: .65rem; }
  .active-play .buyin-photo strong { font-size: 1.05rem; }
  .active-play .buyin-photo span { font-size: .68rem; }
  .active-play .start-thumb { border-radius: 10px; }
  .active-play .ball-levels-summary { min-height: 52px; margin-top: 6px; padding: 6px 9px; border-radius: 14px; }
  .active-play .ball-levels-summary > span { font-size: .66rem; }
  .active-play .ball-levels-summary strong { font-size: .88rem; }
  .active-play .ball-levels-summary i { font-size: .52rem; }
  .bottom-tabs { max-width: 100vw; overflow: hidden; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .bottom-tabs a { padding-inline: 2px; font-size: .56rem; }
  .bottom-tabs a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (min-width: 768px) {
  body { background: var(--canvas); }
  .side-nav { border-right-color: var(--border); background: rgba(17, 23, 32, .98); }
  .side-nav a:hover { color: var(--text); background: var(--raised); }
  .side-nav a.active { color: #fff; background: var(--primary); }
}

/* Compact recency-first selection and confirmation */
.compact-picker-page { min-height: auto; padding-top: 12px; }
.compact-picker-page .page-header { min-height: 48px; margin-bottom: 10px; }
.compact-picker-page .page-header h1 { font-size: 1.48rem; }
.compact-picker-page .page-header p { margin-top: 2px; font-size: .74rem; }
.compact-picker-panel { display: grid; gap: 10px; }
.picker-recent {
  width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border: 1px solid rgba(30,94,255,.55); border-radius: 13px;
  color: var(--text); background: var(--accent-soft); text-align: left;
}
.picker-recent span { display: grid; gap: 1px; min-width: 0; }
.picker-recent small { color: var(--accent-deep); font-size: .64rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.picker-recent strong { overflow: hidden; font-size: .94rem; text-overflow: ellipsis; white-space: nowrap; }
.picker-recent svg { width: 18px; height: 18px; color: var(--accent-deep); }
.compact-picker-field { display: grid; gap: 5px; }
.compact-picker-field > span { color: var(--muted); font-size: .7rem; font-weight: 750; }
.compact-picker-field select, .custom-entry input {
  width: 100%; min-height: 48px; padding: 0 38px 0 12px; border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); background-color: var(--surface-muted);
}
.compact-picker-field select {
  appearance: none; background-image: linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%);
  background-position: calc(100% - 18px) 20px,calc(100% - 13px) 20px; background-repeat: no-repeat; background-size: 5px 5px,5px 5px;
}
.game-picker-browser { display: grid; gap: 10px; }
.game-picker-tools { display: grid; grid-template-columns: minmax(0,1fr) minmax(126px,auto); gap: 8px; }
.game-picker-tools input, .game-picker-tools select {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); background: var(--surface-muted); font-size: .8rem;
}
.game-picker-tools select { padding-right: 30px; }
.game-picker-results { display: grid; gap: 12px; }
.game-picker-section { display: grid; gap: 5px; }
.game-picker-section h2 { margin: 0; color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.game-picker-list { display: grid; gap: 4px; }
.game-picker-row {
  width: 100%; min-height: 44px; display: grid; grid-template-columns: minmax(0,1fr) auto 18px; align-items: center; gap: 8px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 11px; color: var(--text); background: var(--surface-muted); text-align: left;
}
.game-picker-row > span { overflow: hidden; font-size: .84rem; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.game-picker-row small { color: var(--muted); font-size: .64rem; white-space: nowrap; }
.game-picker-row svg { width: 16px; height: 16px; color: var(--muted); }
.game-picker-empty { margin: 0; padding: 18px 12px; border: 1px dashed var(--border); border-radius: 11px; color: var(--muted); text-align: center; }.custom-entry { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.custom-entry input { padding-right: 12px; }
.custom-entry .custom-entry-button { min-height: 48px; padding-inline: 13px; font-size: .8rem; white-space: nowrap; }
.confirmation-thumb { margin: 0; }
.photo-confirmation-status strong > span { display: inline; margin: 0; color: inherit; font-size: inherit; line-height: inherit; }
.start-details-form .form-error { min-height: 16px; font-size: .72rem; line-height: 1.2; }

@media (max-width: 767px) {

  .compact-picker-page { padding: 10px 12px calc(90px + env(safe-area-inset-bottom)); }
  .compact-picker-page .page-header { padding-right: 54px; }
  .start-confirmation { min-height: auto; padding: 8px 12px calc(88px + env(safe-area-inset-bottom)); }
  .compact-workflow-header { min-height: 44px; margin-bottom: 6px; align-items: center; }
  .compact-workflow-header .icon-button, .compact-workflow-header .header-spacer { width: 42px; height: 42px; flex-basis: 42px; }
  .compact-workflow-header h1 { margin: 0; font-size: 1.3rem; }
  .compact-workflow-header p { display: none; }
  .photo-confirmation-status { grid-template-columns: 50px minmax(0,1fr); min-height: 58px; gap: 9px; margin-bottom: 7px; padding: 5px; border-radius: 12px; }
  .confirmation-thumb { width: 50px; height: 46px; border-radius: 8px; }
  .photo-confirmation-status strong { font-size: .78rem; }
  .photo-confirmation-status > div > span { margin-top: 1px; font-size: .61rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .start-details-form { gap: 7px; }
  .game-select-field, .quick-field { gap: 3px; }
  .game-select-field > span, .quick-field > span { font-size: .63rem; }
  .game-select-field select, .quick-field select, .quick-field input { min-height: 42px; border-radius: 10px; font-size: .82rem; }
  .start-value-grid { gap: 6px 7px; }
  .ball-level-editor { padding: 6px; border-radius: 11px; }
  .ball-level-editor legend { font-size: .68rem; }
  .ball-level-editor > div { gap: 5px; }
  .ball-level-editor .quick-field input { min-height: 40px; font-size: .8rem; }
  .start-play-button { min-height: 48px; font-size: .9rem; }
}
/* Deliberate play cancellation */
.cancel-play-button { width: 100%; min-height: 48px; margin-top: 6px; }
.cancel-confirmation { gap: 10px; }
.cancel-confirmation p { margin: 0; }
.cancel-warning { color: #ff8585; font-weight: 750; }
.cancel-delay-status { min-height: 24px; padding: 8px 10px; border: 1px solid rgba(239,68,68,.35); border-radius: 10px; color: var(--muted); background: var(--danger-soft); font-size: .78rem; }
.cancel-play-final:disabled { border-color: var(--border); background: var(--surface-muted); color: var(--muted); opacity: .72; }
/* Stable interactive dashboard charts */
html { scrollbar-gutter: stable; }
.dashboard-page { overflow-anchor: none; }
.dashboard-chart-panel { min-height: 470px; padding: 14px; contain: layout paint; }
.chart-panel-heading { display: flex; min-height: 46px; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chart-panel-heading h2 { margin: 0 0 3px; }
.chart-panel-heading p { margin: 0; font-size: .72rem; }
.chart-export {
  flex: 0 0 auto; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-muted); color: var(--accent-deep); font-size: .72rem; font-weight: 760; cursor: pointer;
}
.chart-toolbar { display: grid; gap: 10px; margin: 12px 0; }
.chart-control { display: grid; gap: 5px; min-width: 0; }
.chart-control > span { color: var(--muted); font-size: .62rem; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }
.chart-segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-muted); }
.chart-segments button {
  min-width: 0; min-height: 34px; padding: 0 7px; overflow: hidden; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-size: .7rem; font-weight: 760; line-height: 1; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.chart-segments button.active { background: var(--raised); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.22); }
.chart-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.chart-summary div { min-width: 0; padding: 9px 10px; background: var(--surface-muted); }
.chart-summary dt { color: var(--muted); font-size: .62rem; }
.chart-summary dd { margin: 3px 0 0; overflow: hidden; font: 780 .84rem var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.performance-chart { position: relative; width: 100%; height: 280px; min-height: 280px; border-radius: 12px; outline: none; }
.performance-chart:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.performance-chart > svg { width: 100%; height: 100%; overflow: hidden; }
.chart-grid-line { stroke: rgba(150,162,179,.16); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-zero-line { stroke: rgba(150,162,179,.48); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis-label { fill: var(--muted); font: 600 11px Inter,system-ui,sans-serif; stroke: none; }
.chart-date-label { font-size: 10px; }
.chart-area { fill: rgba(30,94,255,.18); stroke: none; }
.chart-line { fill: none; stroke: #78a0ff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-bar-positive { fill: var(--success); }
.chart-bar-negative { fill: var(--danger); }
.chart-guide { stroke: rgba(255,255,255,.5); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.chart-marker { fill: var(--surface); stroke: #9db7ff; stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart-hit-area { cursor: crosshair; touch-action: pan-y; }
.chart-tooltip {
  position: absolute; z-index: 3; display: grid; gap: 2px; min-width: 104px; padding: 8px 10px; pointer-events: none;
  border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(15,21,30,.96); box-shadow: 0 8px 24px rgba(0,0,0,.32);
  transform: translate(-50%, calc(-100% - 10px)); text-align: center;
}
.chart-tooltip[hidden] { display: none; }
.chart-tooltip time { color: var(--muted); font-size: .62rem; }
.chart-tooltip strong { font-size: .82rem; }
.chart-empty { display: grid; height: 100%; padding: 24px; place-content: center; gap: 5px; color: var(--muted); text-align: center; }
.chart-empty strong { color: var(--text); font-size: .9rem; }
.chart-empty span { font-size: .72rem; }

@media (min-width: 620px) {
  .dashboard-chart-panel { min-height: 430px; padding: 18px; }
  .chart-toolbar { grid-template-columns: 1.1fr 1fr .85fr; align-items: end; }
  .chart-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .performance-chart { height: 300px; min-height: 300px; }
}

@media (max-width: 380px) {
  .dashboard-chart-panel { padding: 12px 10px; }
  .chart-segments button { padding-inline: 4px; font-size: .64rem; }
  .performance-chart { height: 250px; min-height: 250px; }
  .chart-export { padding-inline: 9px; }
}
/* Dashboard mobile width guard */
.dashboard-chart-panel,
.chart-panel-heading,
.chart-panel-heading > div,
.chart-toolbar,
.chart-control,
.chart-segments,
.chart-summary,
.performance-chart { min-width: 0; max-width: 100%; }
.dashboard-chart-panel { width: 100%; overflow: hidden; }
.chart-segments { width: 100%; }
.chart-segments button { width: 100%; }
@media (max-width: 520px) {
  .chart-panel-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .chart-export { max-width: 94px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* Fast persistent navigation */
.bottom-tabs {
  contain: layout paint;
  transform: translateZ(0);
  isolation: isolate;
}
.bottom-tabs a,
.side-nav a {
  touch-action: manipulation;
  user-select: none;
}
.bottom-tabs a.active { transition: none; }
/* Desktop admin workspaces. Mobile and tablet layouts remain unchanged. */
@media (min-width: 1100px) {
  .app-main { padding-bottom: 0; }
  .completed-page,
  .dashboard-page,
  .expenses-page,
  .settings-page {
    width: min(100%, 1480px);
    max-width: 1480px;
    padding: 42px 48px 64px;
  }
  .completed-page .page-header,
  .dashboard-page .page-header,
  .expenses-page .page-header,
  .settings-page .page-header {
    min-height: 64px;
    margin-bottom: 22px;
    padding-right: 0;
    align-items: center;
  }
  .completed-page .page-header h1,
  .dashboard-page .page-header h1,
  .expenses-page .page-header h1,
  .settings-page .page-header h1 { font-size: 2rem; }

  .completed-search { margin: 0 0 18px; }
  .completed-search input { min-height: 46px; }
  .completed-list { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .completed-card {
    display: grid;
    grid-template-columns: minmax(220px, 1.15fr) minmax(360px, 2fr) minmax(118px, .55fr);
    gap: 22px;
    min-height: 94px;
    padding: 15px 18px;
    align-items: center;
    border-radius: 14px;
    box-shadow: none;
  }
  .completed-card > header { margin: 0; }
  .completed-card > header > div { display: grid; gap: 2px; }
  .completed-card > header > div span { font-size: .78rem; }
  .completed-card > header time { font-size: .7rem; }
  .completed-card > header svg { display: none; }
  .completed-grid { grid-template-columns: repeat(4, minmax(68px, 1fr)); gap: 18px; }
  .completed-grid dt { font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; }
  .completed-grid dd { font-size: .88rem; }
  .completed-card > footer { justify-content: flex-end; }
  .completed-card .completion-tag { margin-top: 0; }

  .expenses-page {
    display: grid;
    grid-template-columns: minmax(230px, .34fr) minmax(480px, 1fr);
    grid-template-rows: auto auto auto 1fr;
    gap: 14px 24px;
    align-content: start;
  }
  .expenses-page > .page-header { grid-column: 1 / -1; }
  .expenses-page > .expense-total { grid-column: 1; grid-row: 2; min-height: 154px; }
  .expenses-page > .add-expense { grid-column: 1; grid-row: 3; margin: 0; }
  .expenses-page > .expense-list { grid-column: 2; grid-row: 2 / span 3; gap: 8px; }
  .expense-row {
    grid-template-columns: 44px minmax(0, 1fr) 150px 40px 40px;
    min-height: 70px;
    padding: 11px 14px;
    border-radius: 14px;
  }
  .expense-row h2 { font-size: .9rem; }
  .expense-row p { max-width: 720px; }

  .settings-page {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 24px;
    align-content: start;
  }
  .settings-page > .page-header { grid-column: 1 / -1; margin-bottom: 2px; }
  .settings-page > .settings-group { margin-top: 0; }
  .settings-page > .storage-group { min-height: 100%; }
  .settings-page > .button { width: fit-content; min-width: 210px; justify-self: start; }
  .settings-page .setting-row { min-height: 72px; }

  .dashboard-page {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
    align-content: start;
  }
  .dashboard-page > .page-header,
  .dashboard-page > .bankroll-band,
  .dashboard-page > .summary-metrics,
  .dashboard-page > .dashboard-chart-panel,
  .dashboard-page > .all-metrics,
  .dashboard-page > .breakdown-section { grid-column: 1 / -1; margin-top: 0; }
  .dashboard-page > .summary-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-page > .dashboard-chart-panel { min-height: 500px; padding: 22px; }
  .dashboard-page .performance-chart { height: 330px; min-height: 330px; }
  .dashboard-page .metric-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dashboard-page .metric { min-height: 76px; }
  .dashboard-page .dashboard-table { font-size: .76rem; }
  .dashboard-page .dashboard-table th,
  .dashboard-page .dashboard-table td { padding: 12px 14px; }
}

@media (min-width: 1440px) {
  .dashboard-page > .bankroll-band { grid-column: span 4; }
  .dashboard-page > .summary-metrics { grid-column: span 8; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Completed desktop spreadsheet. The mobile card surface is unchanged. */
@media (min-width: 1100px) {
  .completed-page-desktop .page-header { margin-bottom: 14px; }
  .completed-workbench { display: grid; gap: 10px; min-width: 0; }
  .completed-commandbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
  }
  .completed-search-wide { grid-column: span 2; margin: 0; }
  .completed-search-wide input,
  .completed-filter select {
    width: 100%;
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    background: var(--surface-muted);
    font-size: .74rem;
  }
  .completed-filter { display: grid; gap: 4px; min-width: 0; }
  .completed-filter > span { color: var(--muted); font-size: .58rem; font-weight: 760; letter-spacing: .06em; text-transform: uppercase; }
  .completed-filter select { appearance: auto; overflow: hidden; text-overflow: ellipsis; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .completed-table-toolbar { display: flex; min-height: 38px; align-items: center; justify-content: space-between; gap: 12px; }
  .completed-table-toolbar > div { display: flex; gap: 7px; }
  .completed-table-meta { color: var(--muted); font-size: .68rem; }
  .completed-tool-button,
  .completed-page-button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    background: var(--surface);
    font-size: .68rem;
    font-weight: 720;
    cursor: pointer;
  }
  .completed-tool-button:hover,
  .completed-page-button:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); background: var(--raised); }
  .completed-tool-button svg,
  .completed-page-button svg { width: 15px; height: 15px; }
  .completed-sheet-wrap {
    min-width: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    scrollbar-gutter: stable;
  }
  .completed-sheet { width: 100%; min-width: 1050px; border-collapse: collapse; table-layout: fixed; font-size: .7rem; }
  .completed-sheet th,
  .completed-sheet td { height: 42px; padding: 7px 9px; overflow: hidden; border-bottom: 1px solid var(--border); text-align: left; text-overflow: ellipsis; white-space: nowrap; }
  .completed-sheet thead th { position: sticky; z-index: 2; top: 0; height: 36px; padding: 0; background: var(--surface-muted); }
  .completed-sheet thead button { width: 100%; min-height: 36px; display: flex; align-items: center; gap: 5px; padding: 0 9px; border: 0; color: var(--muted); background: transparent; font-size: .59rem; font-weight: 780; letter-spacing: .055em; text-align: left; text-transform: uppercase; cursor: pointer; }
  .completed-sheet thead button:hover { color: var(--text); background: var(--raised); }
  .completed-sheet tbody tr:last-child th,
  .completed-sheet tbody tr:last-child td { border-bottom: 0; }
  .completed-sheet tbody tr:hover { background: rgba(30, 94, 255, .07); }
  .completed-sheet tbody th { font-weight: 760; }
  .completed-sheet tbody th a { display: block; overflow: hidden; color: var(--text); text-overflow: ellipsis; }
  .completed-sheet tbody th a:hover { color: #8fb0ff; text-decoration: underline; }
  .completed-sheet th:nth-child(1) { width: 132px; }
  .completed-sheet th:nth-child(2) { width: 240px; }
  .completed-sheet th:nth-child(3) { width: 92px; }
  .completed-sheet th:nth-child(4) { width: 145px; }
  .completed-sheet th:nth-child(5),
  .completed-sheet th:nth-child(6) { width: 92px; }
  .completed-sheet th:nth-child(7) { width: 72px; }
  .completed-sheet th:nth-child(8) { width: 78px; }
  .completed-sheet th:nth-child(3),
  .completed-sheet td:nth-child(3),
  .completed-sheet th:nth-child(5),
  .completed-sheet td:nth-child(5),
  .completed-sheet th:nth-child(6),
  .completed-sheet td:nth-child(6),
  .completed-sheet th:nth-child(7),
  .completed-sheet td:nth-child(7) { text-align: right; }
  .completed-sheet th:nth-child(3) button,
  .completed-sheet th:nth-child(5) button,
  .completed-sheet th:nth-child(6) button,
  .completed-sheet th:nth-child(7) button { justify-content: flex-end; text-align: right; }
  .completed-sheet th:last-child,
  .completed-sheet td:last-child { text-align: center; }
  .completed-sheet th:last-child button { justify-content: center; }
  .sort-direction { color: var(--accent-deep); font-size: .75rem; }
  .completed-type { color: var(--muted); font-size: .64rem; font-weight: 760; text-transform: uppercase; }
  .completed-review { display: inline-flex; margin-left: 5px; color: var(--warning); vertical-align: middle; }
  .completed-review svg { width: 13px; height: 13px; }
  .completed-scroll-sentinel { min-height: 32px; display: grid; place-items: center; padding: 10px; color: var(--muted); font-size: .68rem; }
  .completed-scroll-sentinel[hidden] { display: none; }
  .completed-page-label { min-width: 86px; color: var(--muted); font-size: .68rem; text-align: center; }
  .completed-page-button { width: 34px; padding: 0; }
  .completed-page-button:disabled { opacity: .38; cursor: default; }
}

@media (min-width: 1400px) {
  .completed-commandbar { grid-template-columns: minmax(260px, 2fr) repeat(5, minmax(105px, 1fr)); align-items: end; }
  .completed-search-wide { grid-column: auto; }
}
/* AP Library */
.library-page { max-width: 1180px; padding-top: 14px; }
.library-page .page-header { min-height: 44px; margin-bottom: 9px; }
.library-page .page-header h1 { font-size: 1.55rem; }
.library-page .page-header p { margin-top: 2px; font-size: .76rem; }
.library-commandbar { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.library-search { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-muted); }
.library-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(30, 94, 255, .12); }
.library-search svg { width: 16px; color: var(--muted); }
.library-search input { width: 100%; padding: 0; border: 0; outline: 0; background: transparent; }
.library-filters { border-top: 1px solid var(--border); }
.library-filters summary { min-height: 32px; display: flex; align-items: center; gap: 7px; padding: 5px 3px 0; color: var(--muted); font-size: .72rem; font-weight: 760; cursor: pointer; list-style: none; }
.library-filters summary::-webkit-details-marker { display: none; }
.library-filters summary svg { width: 15px; }
.library-filters[open] summary { color: var(--text); }
.library-filter-grid { display: grid; gap: 8px; padding: 7px 2px 2px; }
.library-filter { display: grid; gap: 3px; }
.library-filter > span { color: var(--muted); font-size: .61rem; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.library-filter select { min-width: 0; min-height: 36px; }
.library-check { min-height: 34px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.library-check input { width: 15px; height: 15px; }
.library-list-header { display: flex; justify-content: flex-end; margin: 7px 2px 4px; color: var(--muted); font-size: .68rem; font-weight: 720; }
.library-list { display: grid; gap: 4px; }
.library-card { min-width: 0; min-height: 48px; display: grid; grid-template-columns: 8px minmax(0, 1fr) 12px; align-items: center; gap: 9px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface); content-visibility: auto; contain-intrinsic-size: 48px; }
.library-card:hover { border-color: var(--line-strong); background: var(--raised); }
.library-marker { width: 8px; height: 8px; display: inline-block; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; }
.marker-green-check { border-color: #27b979; background: #27b979; box-shadow: 0 0 0 3px rgba(39, 185, 121, .11); }
.marker-yellow-dot { border-color: #e5ad35; background: #e5ad35; box-shadow: 0 0 0 3px rgba(229, 173, 53, .11); }
.marker-none { opacity: .45; }
.library-card-title { min-width: 0; display: flex; align-items: center; gap: 6px; }
.library-card-title strong { overflow: hidden; font-size: .82rem; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.library-mapped { flex: 0 0 auto; padding: 2px 5px; border-radius: 999px; color: #76d9ad; background: rgba(39, 185, 121, .12); font-size: .52rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.library-card-arrow { color: var(--muted); font-size: 1rem; line-height: 1; }
.library-pagination { min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: .68rem; }
.library-detail-page { max-width: 1080px; }
.library-detail-title { display: flex; align-items: center; gap: 9px; }
.library-detail-title h1 { margin: 0; }
.library-topic-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--border); }
.library-topic-summary > div { min-width: 0; display: grid; gap: 2px; padding: 11px 13px; background: var(--surface); }
.library-topic-summary span { color: var(--muted); font-size: .62rem; font-weight: 740; text-transform: uppercase; }
.library-topic-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-curator-summary, .library-notes, .library-admin { padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }
.library-curator-summary h2, .library-notes h2 { margin: 0 0 7px; }
.library-curator-summary p { margin: 0; white-space: pre-wrap; }
.library-primary-media { display: grid; gap: 8px; }
.library-primary-assets { display: grid; gap: 8px; }
.library-primary-assets .library-image:first-child { grid-column: 1 / -1; }
.library-detail-meta { margin-top: 2px; }
.library-admin summary { cursor: pointer; font-weight: 760; }
.library-admin[open] summary { margin-bottom: 15px; }
.library-admin .form-grid { margin-top: 0; }
.library-admin-subsection { display: grid; grid-column: 1 / -1; gap: 10px; padding-top: 4px; }
.library-admin-subsection h3 { margin: 0; font-size: .86rem; }
.library-admin-help { margin: -2px 0 2px; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.library-admin-curated { padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.library-admin-subsection textarea { min-height: 96px; }
.library-message { display: grid; gap: 8px; padding: 13px 0; border-top: 1px solid var(--border); content-visibility: auto; contain-intrinsic-size: 120px; }
.library-message:first-of-type { border-top: 0; }
.library-message header { display: flex; justify-content: space-between; gap: 12px; }
.library-message header a { color: var(--muted); font-size: .68rem; }
.library-message-text { margin: 0; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.library-message-text a, .library-embed-link { color: #8fb0ff; text-decoration: underline; }
.library-embed-links { display: grid; gap: 5px; }
.library-assets { display: grid; gap: 8px; }
.library-image { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); background: var(--surface-muted); }
.library-image img { width: 100%; max-height: 560px; display: block; object-fit: contain; background: #0c0e12; }
.library-image span { display: block; padding: 7px 9px; overflow: hidden; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.library-document { display: grid; grid-template-columns: 30px minmax(0, 1fr) 16px; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface-muted); }
.library-document svg { width: 18px; color: var(--muted); }
.library-document span { min-width: 0; display: grid; }
.library-document strong, .library-document small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-document small { color: var(--muted); }
.more-page { max-width: 760px; }
.more-grid { display: grid; gap: 10px; }
.more-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) 20px; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.more-card:hover { border-color: var(--line-strong); }
.more-card-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: #8fb0ff; background: rgba(30, 94, 255, .12); }
.more-card-icon svg, .more-card > svg { width: 19px; }
.more-card > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.more-card small { color: var(--muted); line-height: 1.35; }

@media (min-width: 720px) {
  .library-commandbar { grid-template-columns: minmax(280px, 1fr) auto; align-items: center; }
  .library-filters { position: relative; min-width: 150px; border-top: 0; }
  .library-filter-grid { min-width: 420px; grid-template-columns: repeat(2, minmax(130px, 1fr)); position: absolute; z-index: 5; right: 0; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-card); }
  .library-topic-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-assets, .library-primary-assets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-document { grid-column: 1 / -1; }
  .more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1180px) {
  .library-page { max-width: 1480px; }
  .library-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-list > .empty-state { grid-column: 1 / -1; }
}
.game-strategy-guidance {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: .78rem;
}
.game-strategy-guidance summary { color: var(--text); font-weight: 750; cursor: pointer; }
.game-strategy-guidance p { margin: 7px 0; line-height: 1.35; }
.game-strategy-guidance a { color: var(--primary-light); font-weight: 700; }
/* Recoverable startup shell for iOS camera returns and slow connections. */
.app-startup-recovery {
  min-height: 100vh; display: grid; padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  grid-template-columns: minmax(0, 1fr); place-items: center; background: var(--canvas);
}
.app-startup-recovery > section {
  width: min(calc(100vw - 36px), 420px); max-width: 100%; min-width: 0; padding: 22px; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow-card); text-align: center;
}
.app-startup-recovery h1 { margin-bottom: 10px; overflow-wrap: anywhere; font-size: 1.45rem; }
.app-startup-recovery p { margin-bottom: 10px; font-size: .88rem; }
.app-startup-recovery .button { margin-top: 10px; }
@media (max-width: 767px) {
  .bubble-audit-grid { grid-template-columns: minmax(0, 1fr); }
  .bubble-grid-editor, .bubble-grid-readonly { grid-template-columns: 32px repeat(5, minmax(0, 1fr)); gap: 4px; }
  .bubble-grid-toggle, .bubble-grid-cell { min-height: 32px; border-radius: 7px; }
}
/* Crop-based assisted start verification */
.quick-verify-page > .validation-photo { display: none; }
.quick-verify-page .progress-track { margin-bottom: 2px; }
.quick-verify-form { min-width: 0; display: grid; gap: 9px; padding: 12px; border: 1px solid rgba(242,184,75,.42); border-radius: 14px; background: var(--warning-soft); }
.quick-verify-header strong { font: 800 1rem var(--font-display); color: var(--warning); }
.quick-verify-header p { margin: 3px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.35; }
.quick-verify-crops { min-width: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.quick-verify-crop { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #080b10; }
.quick-verify-crop img, .quick-verify-crop .photo-placeholder { width: 100%; height: 112px; display: grid; object-fit: contain; place-items: center; }
.quick-verify-crop figcaption { padding: 4px 6px; color: var(--muted); background: var(--surface); font-size: .6rem; font-weight: 760; text-align: center; }
.quick-verify-values { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.quick-verify-values .quick-field input { min-width: 0; min-height: 42px; }
.quick-verify-key { margin: 0; display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: .62rem; font-weight: 740; }
.quick-verify-key span { display: inline-flex; align-items: center; gap: 5px; }
.quick-verify-key span::before { width: 9px; height: 9px; border-radius: 3px; content: ""; }
.quick-verify-key .verify-key-confused::before { border: 1px solid #f2b84b; background: rgba(242,184,75,.3); }
.quick-verify-key .verify-key-locked::before { border: 1px solid #596171; background: #252a33; }
.quick-verify-form input.quick-verify-confused { border-color: #f2b84b; color: #fff4cc; background: rgba(242,184,75,.16); box-shadow: 0 0 0 1px rgba(242,184,75,.18); }
.quick-verify-form input.quick-verify-locked { cursor: not-allowed; color: #a2a9b5; background: #252a33; border-color: #4a5260; box-shadow: none; }
.quick-verify-form input.quick-verify-confused.quick-verify-locked { border-color: #f2b84b; box-shadow: inset 0 0 0 1px rgba(242,184,75,.22); }
.quick-verify-confused, .verify-field-confused { border-color: #f2b84b !important; color: #fff4cc !important; background: rgba(242,184,75,.16) !important; box-shadow: 0 0 0 1px rgba(242,184,75,.22) !important; }
.quick-verify-locked { cursor: not-allowed; color: #a2a9b5 !important; background: #252a33 !important; border-color: #4a5260 !important; box-shadow: none !important; opacity: 1; }
.quick-verify-form .quick-field.is-resolved .currency-prefix { color: #7f8794; }
.quick-verify-form .quick-field.is-confused .currency-prefix { color: #f2b84b; }
.quick-verify-balls { min-width: 0; padding: 7px; border: 1px solid var(--line); border-radius: 10px; }
.quick-verify-balls legend { padding: 0 4px; color: var(--muted); font-size: .65rem; font-weight: 760; }
.quick-verify-balls > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.quick-verify-balls input { min-width: 0; min-height: 40px; padding: 0 8px; }
.quick-verify-confirm { min-height: 38px; display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .7rem; font-weight: 720; line-height: 1.3; }
.quick-verify-confirm input { width: 19px; height: 19px; flex: 0 0 19px; }
.quick-verify-submit { width: 100%; }
@media (max-width: 390px) {
  .quick-verify-form { padding: 9px; }
  .quick-verify-crops { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-verify-crop img, .quick-verify-crop .photo-placeholder { height: 92px; }
}
/* Admin AI validation failure review */
.validation-failures-page { max-width: 1180px; }
.validation-failure-commandbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.validation-failure-commandbar input,
.validation-failure-commandbar select { width: 100%; min-height: 42px; }
.validation-failure-counts { margin: 10px 0; color: var(--muted); font-size: .76rem; }
.validation-failure-list { display: grid; gap: 10px; }
.validation-failure-card { display: grid; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.validation-failure-card.failure-open { border-color: rgba(239, 68, 68, .5); }
.validation-failure-image { display: block; min-height: 190px; background: #080b10; }
.validation-failure-image img { width: 100%; height: 100%; max-height: 300px; object-fit: contain; }
.validation-failure-content { min-width: 0; padding: 13px; }
.validation-failure-content header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.validation-failure-content h2 { margin: 0; font-size: 1rem; }
.validation-failure-content header p { margin: 3px 0 0; font-size: .68rem; }
.failure-state { padding: 4px 7px; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.state-open { background: var(--danger-soft); color: #ff7c7c; }
.state-reviewed { background: var(--warning-soft); color: var(--warning); }
.state-resolved { background: var(--success-soft); color: var(--success); }
.validation-failure-message { margin: 11px 0; color: var(--text); font-size: .86rem; line-height: 1.45; }
.validation-failure-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: .64rem; overflow-wrap: anywhere; }
.validation-failure-meta code { color: #ff9b9b; }
.validation-failure-warnings { margin: 10px 0 0; padding-left: 18px; color: var(--warning); font-size: .72rem; line-height: 1.45; }
.validation-failure-diagnostic { margin-top: 11px; border-top: 1px solid var(--border); }
.validation-failure-diagnostic summary { padding: 10px 0 4px; color: var(--muted); font-size: .72rem; font-weight: 750; cursor: pointer; }
.validation-failure-diagnostic pre { max-height: 320px; margin: 6px 0; padding: 10px; overflow: auto; border-radius: 8px; background: #090d13; color: #cbd5e1; font: .66rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.validation-failure-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.validation-failure-actions .button { min-height: 40px; padding: 0 12px; font-size: .78rem; }
@media (min-width: 680px) {
  .validation-failure-commandbar { grid-template-columns: minmax(280px, 1fr) 150px 180px; }
  .validation-failure-card { grid-template-columns: 210px minmax(0, 1fr); }
  .validation-failure-image { min-height: 180px; }
  .validation-failure-image img { max-height: none; }
}
@media (min-width: 1100px) {
  .validation-failures-page { width: min(100%, 1480px); max-width: 1480px; padding: 42px 48px 64px; }
  .validation-failure-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .validation-failure-card { grid-template-columns: 180px minmax(0, 1fr); }
}
/* Buffalo Ascension compact state controls */
.ascension-state-fieldset { min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 14px; }
.ascension-state-fieldset legend { padding: 0 6px; font-size: .78rem; font-weight: 800; color: var(--text); }
.ascension-editor-heading { display: grid; grid-template-columns: auto 52px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: .72rem; }
.ascension-config-preview { display: grid; place-items: center; min-height: 34px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-light); font-size: 1.15rem; letter-spacing: .08em; }
.ascension-trigger-preview { justify-self: end; font-weight: 800; color: var(--warning); }
.ascension-trigger-preview.qualifies { color: var(--success); }
.ascension-column-editor { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ascension-column-card { min-width: 0; padding: 7px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.ascension-column-card > strong { display: block; margin-bottom: 5px; font-size: .72rem; text-align: center; }
.ascension-column-card label { display: block; margin-top: 5px; }
.ascension-column-card label span, .ascension-ways-field > span { display: block; margin-bottom: 3px; color: var(--muted); font-size: .61rem; font-weight: 700; }
.ascension-column-card select, .ascension-ways-field input { width: 100%; min-width: 0; min-height: 36px; padding: 5px 7px; font-size: .72rem; }
.ascension-column-card select:disabled { opacity: 1; color: var(--text); -webkit-text-fill-color: var(--text); }
.ascension-ways-field { display: block; margin-top: 7px; }
.ascension-confirm { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: .68rem; font-weight: 700; }
.ascension-confirm input { width: 20px; height: 20px; flex: 0 0 auto; }
.ascension-state-summary { width: 100%; min-width: 0; padding: 9px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); }
.ascension-state-view { min-width: 0; display: grid; grid-template-columns: 72px 92px minmax(0, 1fr); gap: 7px; align-items: stretch; }
.ascension-config, .ascension-trigger { display: flex; flex-direction: column; justify-content: center; padding: 6px; border-radius: 9px; background: var(--surface-muted); }
.ascension-config span, .ascension-trigger span { color: var(--muted); font-size: .58rem; font-weight: 700; text-transform: uppercase; }
.ascension-config strong { font-size: 1.2rem; letter-spacing: .08em; }
.ascension-trigger strong { font-size: .9rem; }
.ascension-trigger small { color: var(--warning); font-size: .58rem; font-weight: 800; }
.ascension-trigger.qualifies small { color: var(--success); }
.ascension-features { min-width: 0; display: grid; gap: 3px; }
.ascension-features span { min-width: 0; display: grid; grid-template-columns: 23px minmax(0, 1fr); gap: 4px; align-items: center; }
.ascension-features b { color: var(--primary-light); font-size: .6rem; }
.ascension-features small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .6rem; }
.ascension-audit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 480px) {
  .ascension-column-card { padding: 5px; }
  .ascension-column-card select { padding-inline: 4px; font-size: .64rem; }
  .ascension-state-view { grid-template-columns: 58px 80px minmax(0, 1fr); }
  .ascension-audit-grid { grid-template-columns: 1fr; }
}
.treasure-requirements-fieldset { border: 1px solid var(--border); border-radius: 1rem; padding: .75rem; }
.treasure-requirement-grid { display: grid; gap: .5rem; }
.treasure-requirement-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.treasure-requirement-row label { display: grid; gap: .3rem; }
.treasure-selected-status { margin: .5rem 0 0; padding: .55rem .7rem; border-radius: .7rem; background: var(--surface-2); }
.treasure-selected-status.automatic,.treasure-selected-status.preferred { color: var(--success); }
.treasure-selected-status.marginal { color: var(--warning); }
.treasure-selected-status.pass { color: var(--danger); }
.treasure-state-summary { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .65rem; text-align: left; }
.treasure-state-view { display: grid; gap: .35rem; }
.treasure-requirement { display: grid; grid-template-columns: minmax(5.5rem,auto) auto 1fr; gap: .5rem; align-items: baseline; padding: .4rem .55rem; border-radius: .55rem; background: var(--surface-2); }
.treasure-requirement.selected { outline: 2px solid var(--primary); }
.treasure-requirement.automatic,.treasure-requirement.preferred { border-left: .25rem solid var(--success); }
.treasure-requirement.marginal { border-left: .25rem solid var(--warning); }
.treasure-requirement.pass { border-left: .25rem solid var(--danger); }
.treasure-requirement small { color: var(--muted); text-align: right; }
.treasure-audit-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.template-guide-tiers { display: grid; gap: .45rem; margin-top: .75rem; }
.template-guide-tier { display: grid; grid-template-columns: 4rem 1fr; gap: .6rem; padding: .55rem .7rem; border-radius: .6rem; background: var(--surface-2); }
@media (max-width: 620px) { .treasure-audit-grid { grid-template-columns: 1fr; } .treasure-requirement { grid-template-columns: auto auto; } .treasure-requirement small { grid-column: 1 / -1; text-align: left; } }
/* Discord staking-play review */
.staking-review-page { max-width: 1240px; }
.staking-commandbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.staking-commandbar select { min-width: 210px; min-height: 42px; }
.staking-state { margin: 10px 0; color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.staking-list { display: grid; gap: 12px; }
.staking-card { overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.staking-card.status-needs_review,.staking-card.status-source_changed { border-color: rgba(239,68,68,.55); }
.staking-card.status-waiting_for_stop { border-color: rgba(245,158,11,.55); }
.staking-card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px; }
.staking-card h2 { margin: 0; font-size: 1rem; }
.staking-card header p { margin: 4px 0 0; color: var(--muted); font-size: .72rem; }
.staking-status { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .65rem; font-weight: 800; text-transform: uppercase; }
.staking-reasons { margin: 0 14px 10px; padding-left: 18px; color: var(--warning); font-size: .72rem; }
.staking-source-links { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 14px 10px; font-size: .72rem; }
.staking-card > .button { margin: 0 14px 14px; }
.staking-card-body { display: grid; gap: 12px; border-top: 1px solid var(--border); }
.staking-card-body:empty { display: none; }
.staking-context,.staking-evidence,.staking-edit-grid,.staking-diagnostics,.staking-actions { margin: 0 14px; }
.staking-context { display: grid; gap: 7px; padding-top: 14px; }
.staking-context h3,.staking-evidence h3 { margin: 0; font-size: .82rem; }
.staking-message { padding: 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.staking-message.is-boundary { border-color: var(--success); }
.staking-message header { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .66rem; }
.staking-message pre { margin: 6px 0 0; color: var(--text); font: .75rem/1.45 ui-monospace,SFMono-Regular,Consolas,monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.staking-evidence > div { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 8px; margin-top: 8px; }
.staking-evidence img { width: 100%; height: 180px; object-fit: contain; border-radius: 8px; background: #080b10; }
.staking-edit-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.staking-field { display: grid; gap: 4px; color: var(--muted); font-size: .68rem; }
.staking-field input,.staking-field select,.staking-field textarea { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface-2); }
.staking-field textarea { min-height: 92px; resize: vertical; }
.staking-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.staking-diagnostics { margin-bottom: 14px; border-top: 1px solid var(--border); }
.staking-diagnostics summary { padding: 12px 0; color: var(--muted); cursor: pointer; }
.staking-diagnostics pre { max-height: 420px; overflow: auto; padding: 10px; border-radius: 8px; background: #090d13; color: #cbd5e1; font: .65rem/1.45 ui-monospace,SFMono-Regular,Consolas,monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 700px) { .staking-edit-grid { grid-template-columns: 1fr; } .staking-card > header { display: grid; } }