/* ============================================================
   V9 Settings — left section rail + content pane, flat hairline sections.
   Sections are the shared obsidian-terminal language (no boxy cards): a mono
   terminal label + controls separated by hairlines, like the analytics
   movements / detail-dock disclosures / trade reveals. Lists reuse the
   `.v9-led-row` ledger rows. Scoped under .v9-settings.
   ============================================================ */
.v9-settings { display: grid; grid-template-columns: 15rem 1fr; gap: var(--v9-space-7); align-items: start; max-width: 64rem; }

/* ---- rail ---- */
.v9-settings-rail { display: grid; gap: var(--v9-space-4); position: sticky; top: var(--v9-space-4); align-content: start; }
.v9-settings-group { display: grid; gap: 2px; }
.v9-settings-group-label { font: 500 var(--v9-text-2xs) var(--v9-font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--v9-text-faint); padding: 0 var(--v9-space-2) 4px; }
.v9-settings-link { position: relative; display: block; padding: 6px var(--v9-space-2) 6px var(--v9-space-3); border-radius: var(--v9-r-sm); color: var(--v9-text-mute); font: 500 var(--v9-text-sm) var(--v9-font-ui); cursor: pointer; text-decoration: none; transition: color var(--v9-t-micro) var(--v9-ease), background-color var(--v9-t-micro) var(--v9-ease); }
.v9-settings-link:hover { color: var(--v9-text); background: var(--v9-surface); }
.v9-settings-link:focus-visible { outline: none; box-shadow: var(--v9-focus-glow); }
.v9-settings-link[data-active="true"] { color: var(--v9-accent); }
.v9-settings-link[data-active="true"]::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 2px; height: 1.1rem; border-radius: 2px; background: var(--v9-accent); }

.v9-settings-signout { margin-top: var(--v9-space-4); padding-top: var(--v9-space-4); border-top: 1px solid var(--v9-line); }
.v9-settings-signout button { width: 100%; text-align: left; background: transparent; border: 0; padding: 6px var(--v9-space-3); border-radius: var(--v9-r-sm); color: var(--v9-text-mute); font: 500 var(--v9-text-sm) var(--v9-font-ui); cursor: pointer; transition: color var(--v9-t-micro) var(--v9-ease), background-color var(--v9-t-micro) var(--v9-ease); }
.v9-settings-signout button:hover { color: var(--v9-neg); background: color-mix(in srgb, var(--v9-neg) 12%, var(--v9-surface)); }

/* ---- pane ---- */
.v9-settings-pane { display: grid; gap: var(--v9-space-5); min-width: 0; }
.v9-settings-pane.is-enter { animation: v9-settings-in var(--v9-t-std) var(--v9-ease); }
@keyframes v9-settings-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .v9-settings-pane.is-enter { animation: none; } }
.v9-settings .section-head { margin-bottom: 0; padding-block-end: 0; }
.v9-settings .section-head h1 { margin: 0; }

/* ---- flat section block (replaces legacy .setting-card) ---- */
.v9-set-section { display: grid; gap: var(--v9-space-3); padding-top: var(--v9-space-4); border-top: 1px solid var(--v9-line); }
.v9-set-section:first-of-type { border-top: 0; padding-top: 0; }
.v9-set-section-label { font: 500 var(--v9-text-2xs) var(--v9-font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--v9-text-faint); }
.v9-set-section-desc { margin: 0; font: 400 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text-mute); line-height: 1.5; max-width: 56ch; }
.v9-set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--v9-space-4); }
.v9-set-field { display: grid; gap: 5px; }
.v9-set-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--v9-space-3) var(--v9-space-4); }
.v9-set-lab { font: 500 var(--v9-text-2xs) var(--v9-font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--v9-text-faint); }
.v9-set-actions { display: flex; gap: var(--v9-space-2); flex-wrap: wrap; }
.v9-set-foot { font: 400 var(--v9-text-xs) var(--v9-font-mono); color: var(--v9-text-faint); }

/* ---- inputs / selects / textarea / buttons — match sales/trade ---- */
.v9-settings .input, .v9-settings .select, .v9-settings .textarea { background-color: var(--v9-surface); border: 1px solid var(--v9-line); border-radius: var(--v9-r-sm); color: var(--v9-text); font: 400 var(--v9-text-sm) var(--v9-font-ui); color-scheme: dark; width: 100%; }
.v9-settings .input, .v9-settings .select { height: 2rem; }
.v9-settings .input { padding: 0 var(--v9-space-3); }
.v9-settings .select { padding: 0 1.8rem 0 var(--v9-space-3); }
.v9-settings .textarea { padding: var(--v9-space-2) var(--v9-space-3); min-height: 4.5rem; resize: vertical; line-height: 1.5; }
.v9-settings .input:focus, .v9-settings .select:focus, .v9-settings .textarea:focus { outline: none; border-color: var(--v9-accent); box-shadow: var(--v9-focus-glow); }
.v9-settings .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 1.9rem; padding: 0 var(--v9-space-3); border-radius: var(--v9-r-sm); font: 500 var(--v9-text-sm) var(--v9-font-ui); cursor: pointer; transition: background-color var(--v9-t-micro) var(--v9-ease), border-color var(--v9-t-micro) var(--v9-ease), color var(--v9-t-micro) var(--v9-ease); }
.v9-settings .btn-primary { background: var(--v9-accent); color: var(--v9-accent-ink); border: 1px solid var(--v9-accent); }
.v9-settings .btn-primary:hover:not(:disabled) { background: var(--v9-accent-press); border-color: var(--v9-accent-press); }
.v9-settings .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.v9-settings .btn-ghost { background: transparent; color: var(--v9-text-mute); border: 1px solid var(--v9-line); }
.v9-settings .btn-ghost:hover { color: var(--v9-text); border-color: var(--v9-line-strong); background: var(--v9-hover); }
.v9-settings .btn-secondary { background: var(--v9-surface); color: var(--v9-text-mute); border: 1px solid var(--v9-line); }
.v9-settings .btn-secondary:hover { color: var(--v9-text); border-color: var(--v9-line-strong); }
.v9-settings .btn-danger { background: transparent; color: var(--v9-neg); border: 1px solid color-mix(in srgb, var(--v9-neg) 45%, var(--v9-line)); }
.v9-settings .btn-danger:hover { background: color-mix(in srgb, var(--v9-neg) 14%, var(--v9-surface)); }

/* ---- V9 toggle (restyle of legacy .toggle-switch) ---- */
.v9-toggle { position: relative; display: inline-flex; align-items: center; gap: var(--v9-space-2); cursor: pointer; }
.v9-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.v9-toggle-track { width: 2.1rem; height: 1.15rem; border-radius: var(--v9-r-pill); background: var(--v9-raised); border: 1px solid var(--v9-line-strong); position: relative; flex: 0 0 auto; transition: background-color var(--v9-t-std) var(--v9-ease), border-color var(--v9-t-std) var(--v9-ease); }
.v9-toggle-track::after { content: ''; position: absolute; top: 1px; left: 1px; width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--v9-text-mute); transition: transform var(--v9-t-std) var(--v9-ease), background-color var(--v9-t-std) var(--v9-ease); }
.v9-toggle input:checked + .v9-toggle-track { background: color-mix(in srgb, var(--v9-accent) 30%, var(--v9-raised)); border-color: var(--v9-accent); }
.v9-toggle input:checked + .v9-toggle-track::after { transform: translateX(0.95rem); background: var(--v9-accent); }
.v9-toggle input:focus-visible + .v9-toggle-track { box-shadow: var(--v9-focus-glow); }
@media (prefers-reduced-motion: reduce) { .v9-toggle-track, .v9-toggle-track::after { transition: none; } }

/* ---- Display: flat theme list — each row shows that theme's accent as real
   sample text + a button, no boxy preview cards ---- */
.v9-theme-list { display: grid; gap: 0; max-width: 30rem; }
.v9-theme-opt { display: flex; align-items: center; justify-content: space-between; gap: var(--v9-space-4); width: 100%; padding: var(--v9-space-3) var(--v9-space-2); background: transparent; border: 0; border-bottom: 1px solid var(--v9-line); cursor: pointer; text-align: left; transition: background-color var(--v9-t-micro) var(--v9-ease); }
.v9-theme-opt:hover { background: var(--v9-surface); }
.v9-theme-opt:focus-visible { outline: none; box-shadow: var(--v9-focus-glow); border-radius: var(--v9-r-sm); }
.v9-theme-opt-name { display: inline-flex; align-items: center; gap: 6px; font: 500 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text-mute); }
.v9-theme-opt[aria-pressed="true"] .v9-theme-opt-name { color: var(--v9-text); }
.v9-theme-opt-check { visibility: hidden; font-size: var(--v9-text-sm); line-height: 1; }
.v9-theme-opt[aria-pressed="true"] .v9-theme-opt-check { visibility: visible; }
.v9-theme-opt-sample { display: inline-flex; align-items: center; gap: var(--v9-space-3); flex: 0 0 auto; }
.v9-theme-opt-text { font: 500 var(--v9-text-sm) var(--v9-font-mono); font-variant-numeric: tabular-nums; }
.v9-theme-opt-btn { font: 600 var(--v9-text-2xs) var(--v9-font-ui); padding: 3px 10px; border-radius: var(--v9-r-sm); }
.v9-set-foot code { font: 400 var(--v9-text-xs) var(--v9-font-mono); color: var(--v9-text-mute); }

/* ---- Account: avatar control + crop widget (logic unchanged; V9 skin) ---- */
.v9-acct-photo { display: flex; align-items: center; gap: var(--v9-space-4); }
.v9-acct-preview { width: 4rem; height: 4rem; flex: 0 0 auto; border-radius: 50%; overflow: hidden; background: var(--v9-raised); border: 1px solid var(--v9-line-strong); display: flex; align-items: center; justify-content: center; font: 600 var(--v9-text-xl) var(--v9-font-ui); color: var(--v9-text-mute); }
.v9-acct-preview img { width: 100%; height: 100%; object-fit: cover; }
.v9-acct-copy { display: grid; gap: var(--v9-space-2); }
.v9-acct-copy strong { font: 500 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text); }
.v9-acct-actions { display: flex; gap: var(--v9-space-2); flex-wrap: wrap; }
.v9-acct-crop { display: grid; gap: var(--v9-space-3); padding: var(--v9-space-4); background: var(--v9-surface); border: 1px solid var(--v9-line); border-radius: var(--v9-r-md); justify-items: center; }
.v9-acct-crop-head { display: grid; gap: 2px; text-align: center; }
.v9-acct-crop-head strong { font: 500 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text); }
.v9-acct-crop-head span { font: 400 var(--v9-text-xs) var(--v9-font-ui); color: var(--v9-text-mute); }
.v9-acct-crop-frame { width: 220px; height: 220px; border-radius: 50%; overflow: hidden; position: relative; cursor: grab; background: var(--v9-bg); border: 1px solid var(--v9-line-strong); touch-action: none; }
.v9-acct-crop-frame:active { cursor: grabbing; }
.v9-acct-crop-frame img { position: absolute; top: 0; left: 0; max-width: none; user-select: none; -webkit-user-drag: none; }
.v9-acct-zoom-row { display: flex; align-items: center; gap: var(--v9-space-3); width: 220px; }
.v9-acct-zoom-row > span { font: 500 var(--v9-text-2xs) var(--v9-font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--v9-text-faint); }
.v9-acct-zoom { flex: 1; accent-color: var(--v9-accent); }
.v9-acct-crop-actions { display: flex; gap: var(--v9-space-2); }

/* ---- Market: daily-batch status + run history ---- */
.v9-settings .market-batch-status { display: flex; align-items: center; gap: var(--v9-space-2); }
.v9-settings .market-batch-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--v9-pos); flex: 0 0 auto; }
.v9-settings .market-batch-status.is-warning .market-batch-dot { background: var(--v9-warn); }
.v9-settings .market-batch-status strong { font: 500 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text); }
.v9-settings .market-batch-history > summary { font: 400 var(--v9-text-xs) var(--v9-font-ui); color: var(--v9-text-mute); cursor: pointer; padding: var(--v9-space-2) 0; list-style: none; }
.v9-settings .market-batch-history > summary::-webkit-details-marker { display: none; }
.v9-settings .market-batch-history > summary::before { content: '▸'; display: inline-block; margin-right: 6px; transition: transform var(--v9-t-micro) var(--v9-ease); }
.v9-settings .market-batch-history[open] > summary::before { transform: rotate(90deg); }
.v9-settings .market-batch-history-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--v9-space-3); font: 400 var(--v9-text-xs) var(--v9-font-mono); }
.v9-settings .market-batch-history-time { color: var(--v9-text-mute); }
.v9-settings .market-batch-history-stats { color: var(--v9-text-faint); text-align: right; }
.v9-settings .market-batch-history-empty { font: 400 var(--v9-text-xs) var(--v9-font-ui); color: var(--v9-text-faint); }

/* ---- Payments: status line, manual methods, tag chips, flow matrix ---- */
.v9-pay-status { display: flex; align-items: center; gap: var(--v9-space-2); font: 400 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text-mute); margin: 0 0 var(--v9-space-3); }
.v9-pay-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--v9-text-faint); flex: 0 0 auto; }
.v9-pay-status.is-ready { color: var(--v9-pos); }
.v9-pay-status.is-ready::before { background: var(--v9-pos); }
.v9-pay-status.is-issues { color: var(--v9-warn); }
.v9-pay-status.is-issues::before { background: var(--v9-warn); }
.v9-pay-status.is-error { color: var(--v9-neg); }
.v9-pay-status.is-error::before { background: var(--v9-neg); }

.v9-pay-methods { display: grid; gap: 0; }
.v9-pay-method { display: flex; align-items: center; gap: var(--v9-space-3); padding: var(--v9-space-3) 0; border-bottom: 1px solid var(--v9-line); }
.v9-pay-method:last-child { border-bottom: 0; }
.v9-pay-method.is-disabled { opacity: 0.5; }
.v9-pay-method-name { flex: 0 0 auto; min-width: 7rem; font: 500 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text); }
.v9-pay-method .input { flex: 1; min-width: 0; }

.v9-pay-tags { display: flex; flex-wrap: wrap; gap: var(--v9-space-2); margin-bottom: var(--v9-space-3); }
.v9-pay-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--v9-r-pill); border: 1px solid var(--v9-line-strong); background: var(--v9-surface); color: var(--v9-text); font: 500 var(--v9-text-xs) var(--v9-font-ui); cursor: pointer; transition: border-color var(--v9-t-micro) var(--v9-ease), color var(--v9-t-micro) var(--v9-ease); }
.v9-pay-tag:hover { border-color: var(--v9-neg); color: var(--v9-neg); }
.v9-pay-tag strong { font-weight: 600; opacity: 0.55; }
.v9-pay-tags-empty { font: 400 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text-faint); margin-bottom: var(--v9-space-3); }
.v9-pay-tag-form { display: flex; gap: var(--v9-space-2); }
.v9-pay-tag-form .input { flex: 1; max-width: 22rem; }

.v9-pay-flow { display: grid; gap: 0; }
.v9-pay-flow-row { display: grid; grid-template-columns: 1fr auto; gap: var(--v9-space-4); align-items: start; padding: var(--v9-space-3) 0; border-bottom: 1px solid var(--v9-line); }
.v9-pay-flow-row:last-child { border-bottom: 0; }
.v9-pay-flow-label { display: grid; gap: 2px; }
.v9-pay-flow-label strong { font: 500 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text); }
.v9-pay-flow-label span { font: 400 var(--v9-text-xs) var(--v9-font-ui); color: var(--v9-text-mute); }
.v9-pay-flow-checks { display: flex; flex-wrap: wrap; gap: var(--v9-space-3); justify-content: flex-end; }
.v9-pay-flow-check { display: inline-flex; align-items: center; gap: 6px; font: 400 var(--v9-text-xs) var(--v9-font-ui); color: var(--v9-text-mute); cursor: pointer; }
.v9-pay-flow-check input { accent-color: var(--v9-accent); }
.v9-pay-flow-check.is-unavailable { opacity: 0.4; cursor: not-allowed; }

/* ---- Auth: audit events table ---- */
.v9-audit-scroll { overflow-x: auto; }
.v9-audit-table { width: 100%; border-collapse: collapse; font: 400 var(--v9-text-xs) var(--v9-font-ui); }
.v9-audit-table th { text-align: left; white-space: nowrap; font: 500 var(--v9-text-2xs) var(--v9-font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--v9-text-faint); padding: var(--v9-space-2) var(--v9-space-3); border-bottom: 1px solid var(--v9-line-strong); }
.v9-audit-table td { padding: var(--v9-space-2) var(--v9-space-3); border-bottom: 1px solid var(--v9-line); color: var(--v9-text-mute); vertical-align: top; }
.v9-audit-table tbody tr:last-child td { border-bottom: 0; }
.v9-audit-table td:first-child { color: var(--v9-text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.v9-audit-table td:nth-child(3) { text-transform: capitalize; }
.v9-audit-empty { color: var(--v9-text-faint); text-align: center; padding: var(--v9-space-6); }

/* ---- Tax Reports: range mode toggle, preset pills, include rows, actions ---- */
.v9-reports-modes { display: inline-flex; border: 1px solid var(--v9-line-strong); border-radius: var(--v9-r-sm); overflow: hidden; margin-bottom: var(--v9-space-4); }
.v9-reports-mode { padding: var(--v9-space-2) var(--v9-space-4); background: transparent; border: 0; color: var(--v9-text-mute); font: 500 var(--v9-text-xs) var(--v9-font-mono); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; transition: background-color var(--v9-t-micro) var(--v9-ease), color var(--v9-t-micro) var(--v9-ease); }
.v9-reports-mode + .v9-reports-mode { border-left: 1px solid var(--v9-line-strong); }
.v9-reports-mode:hover { color: var(--v9-text); }
.v9-reports-mode[aria-pressed="true"] { background: var(--v9-accent); color: var(--v9-accent-ink); }
.v9-reports-pills { display: flex; flex-wrap: wrap; gap: var(--v9-space-2); }
.v9-reports-pill { padding: var(--v9-space-2) var(--v9-space-3); background: var(--v9-surface); border: 1px solid var(--v9-line); border-radius: var(--v9-r-pill); color: var(--v9-text-mute); font: 500 var(--v9-text-xs) var(--v9-font-ui); cursor: pointer; transition: border-color var(--v9-t-micro) var(--v9-ease), color var(--v9-t-micro) var(--v9-ease); }
.v9-reports-pill:hover { color: var(--v9-text); border-color: var(--v9-line-strong); }
.v9-reports-pill[aria-pressed="true"] { border-color: var(--v9-accent); color: var(--v9-text); }
.v9-reports-custom { display: flex; flex-wrap: wrap; gap: var(--v9-space-4); }
.v9-reports-custom .v9-set-field { min-width: 9rem; }
.v9-reports-inc { display: grid; gap: 0; }
.v9-reports-inc-row { display: flex; align-items: center; justify-content: space-between; gap: var(--v9-space-4); padding: var(--v9-space-3) 0; border-bottom: 1px solid var(--v9-line); }
.v9-reports-inc-row:last-child { border-bottom: 0; }
.v9-reports-inc-row > span { font: 500 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text); }
.v9-reports-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--v9-space-3); }
.v9-reports-status { font: 400 var(--v9-text-sm) var(--v9-font-ui); color: var(--v9-text-mute); }
.v9-reports-status[data-tone="pos"] { color: var(--v9-pos); }
.v9-reports-status[data-tone="neg"] { color: var(--v9-neg); }

/* ---- mobile: master-detail drill-in (rail list ↔ content) ---- */
.v9-settings-back { display: none; }
@media (max-width: 640px) {
  .v9-settings { grid-template-columns: 1fr; gap: var(--v9-space-3); }
  .v9-settings-rail { position: static; }
  .v9-settings[data-mobile-view="list"] .v9-settings-pane { display: none; }
  .v9-settings[data-mobile-view="detail"] .v9-settings-rail { display: none; }
  .v9-settings-back { display: inline-flex; align-items: center; gap: 6px; justify-self: start; background: transparent; border: 0; color: var(--v9-text-mute); font: 500 var(--v9-text-sm) var(--v9-font-ui); cursor: pointer; padding: 0 0 var(--v9-space-2); }
  .v9-settings-back:hover { color: var(--v9-text); }
  /* The back button only makes sense in the detail view — hide it on the rail list. */
  .v9-settings[data-mobile-view="list"] .v9-settings-back { display: none; }
}
