/* =========================================================================
   AKEFIN — Mobile Styles
   ========================================================================= */

.m-app {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  background: var(--bg);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: var(--font-sans);
  color: var(--fg);
  position: relative;
  overflow: hidden;
}
.m-app * { box-sizing: border-box; }
.m-app button { font-family: inherit; cursor: pointer; }

.m-app-body {
  flex: 1;
  overflow-y: auto;
  background: transparent;
}
.m-screen { padding-bottom: 16px; }

/* =========================================================================
   HEADER
   ========================================================================= */
.m-header {
  padding: 56px 16px 14px;
  background: var(--bg-translucent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--rule);
}
.m-header-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 32px;
  margin-top: 4px;
}
.m-header-eyebrow {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
  margin-top: 8px;
}
.m-header-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 30px;
  line-height: 1.1;
  color: var(--fg-strong);
  letter-spacing: -0.01em;
  margin-top: 2px;
}
.m-icon-btn {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--fg);
  display: flex; align-items: center; justify-content: center;
}
.m-icon-btn:active { background: var(--btn-ghost-hover); }

/* =========================================================================
   SCOPE STRIP
   ========================================================================= */
.m-scope-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.m-stripe { width: 4px; height: 16px; border-radius: 1px; }
.m-scope-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
}
.m-scope-name {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-strong);
  white-space: nowrap;
}
.m-scope-count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
  margin-left: auto;
}

/* =========================================================================
   LIST + TRANSACTION ROW (queue)
   ========================================================================= */
.m-list {
  display: flex; flex-direction: column;
}
.m-tx-row {
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  width: 100%;
}
.m-tx-row:active { background: var(--btn-ghost-hover); }
.m-tx-top {
  display: flex; align-items: center; gap: 10px;
}
.m-tx-date {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.m-tx-top .m-amount {
  margin-left: auto;
}
.m-tx-payee {
  font-family: var(--font-sans-kr);
  font-size: 16px;
  font-weight: 500;
  color: var(--fg-strong);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m-tx-bottom {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.m-tx-suggest {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.m-tx-suggest .mono { color: var(--fg); }

/* =========================================================================
   ATOMS — mobile-tuned
   ========================================================================= */
.m-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  color: var(--fg-strong);
}
.m-amount.big {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.m-amount.pos { color: var(--conf-rules); }
.m-amount.neg { color: var(--fg-strong); }
.m-amount.muted { color: var(--fg-subtle); }
.m-ccy { color: var(--fg-subtle); font-weight: 400; margin-left: 2px; }

.m-entity-badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px;
  padding: 0 8px 0 5px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--r-sm);
}
.m-entity-badge::before {
  content: "";
  width: 3px; height: 14px;
  border-radius: 1px;
}
.m-entity-badge.personal { background: var(--entity-personal-bg); color: var(--entity-personal); }
.m-entity-badge.personal::before { background: var(--entity-personal); }
.m-entity-badge.tfox     { background: var(--entity-9tfox-bg); color: var(--entity-9tfox); }
.m-entity-badge.tfox::before     { background: var(--entity-9tfox); }
.m-entity-badge.finacode { background: var(--entity-finacode-bg); color: var(--entity-finacode); }
.m-entity-badge.finacode::before { background: var(--entity-finacode); }

.m-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px;
  padding: 0 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}
.m-chip.rules { background: var(--conf-rules-bg); color: var(--conf-rules); }
.m-chip.high  { background: var(--conf-high-bg);  color: var(--conf-high); }
.m-chip.mid   { background: var(--conf-mid-bg);   color: var(--conf-mid); }
.m-chip.low   { background: var(--conf-low-bg);   color: var(--conf-low); }

.m-tier {
  display: inline-flex; align-items: center;
  height: 20px;
  padding: 0 7px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  border-radius: var(--r-sm);
}
.m-tier.rules { color: var(--conf-rules); }
.m-tier.llm { color: var(--conf-high); }
.m-tier.agent { color: var(--conf-mid); }
.m-tier.unmatched { color: var(--conf-low); }

/* =========================================================================
   DETAIL SCREEN
   ========================================================================= */
.m-detail-hero {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.m-detail-payee {
  font-family: var(--font-sans-kr);
  font-size: 24px;
  font-weight: 500;
  color: var(--fg-strong);
  line-height: 1.25;
}
.m-detail-note {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 4px;
}
.m-detail-amount {
  margin-top: 14px;
  margin-bottom: 8px;
}
.m-detail-meta {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--fg-muted);
}
.m-detail-meta .mono { font-family: var(--font-mono); font-size: 12px; color: var(--fg); }
.m-detail-meta .dot { color: var(--fg-faint); }
.m-source {
  font-family: var(--font-sans-kr);
  font-size: 12px;
  color: var(--fg);
  white-space: nowrap;
}

.m-section {
  padding: 16px 16px 18px;
  border-bottom: 1px solid var(--rule);
}
.m-section-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  margin-bottom: 10px;
}

.m-suggestion {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-on-ink);
}
.m-arrow { color: var(--conf-rules); font-weight: 600; }
.m-acct-text { word-break: break-all; }

.m-tier-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--fg-muted);
}
.m-tier-text { flex: 1; }

.m-picker-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg);
  text-align: left;
}
.m-picker-trigger:active { background: var(--btn-ghost-hover); }
.m-acct-path { flex: 1; word-break: break-all; }
.m-acct-path .muted { color: var(--fg-subtle); font-style: italic; }

.m-ledger-preview {
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-on-ink);
}
.m-ledger-row {
  display: grid;
  grid-template-columns: 1fr auto 40px;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  font-variant-numeric: tabular-nums;
}
.m-ledger-acct { color: var(--fg-on-ink); }
.m-ledger-amt { text-align: right; }
.m-ledger-ccy { color: var(--fg-on-ink-muted); text-align: right; }
.m-ledger-foot {
  padding: 6px 14px;
  border-top: 1px solid var(--rule-ink);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--conf-rules);
}
.m-ledger-empty {
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--surface);
  border: 1px dashed var(--rule-ink);
  border-radius: var(--r-sm);
}

.m-detail-actions {
  display: flex; gap: 8px;
  padding: 16px;
  position: sticky;
  bottom: 56px;
  background: var(--bg-translucent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--rule);
}
.m-action {
  flex: 1;
  height: 44px;
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg);
}
.m-action.primary {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-color: var(--btn-bg);
  flex: 1.4;
}
.m-action:active { transform: scale(0.99); }

/* =========================================================================
   SHEET (account picker)
   ========================================================================= */
.m-sheet-overlay {
  position: absolute; inset: 0;
  background: rgba(20, 18, 12, 0.32);
  z-index: 100;
  display: flex; flex-direction: column; justify-content: flex-end;
  animation: m-fade var(--dur-slow) var(--ease);
}
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
.m-sheet {
  background: var(--paper);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border: 1px solid var(--rule);
  max-height: 80%;
  overflow-y: auto;
  animation: m-slide var(--dur-slow) var(--ease);
}
@keyframes m-slide { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.m-sheet-handle {
  width: 36px; height: 4px;
  background: var(--rule-strong);
  border-radius: 2px;
  margin: 8px auto 0;
}
.m-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--rule);
}
.m-sheet-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--fg-strong);
}
.m-link {
  background: none; border: none;
  font-size: 13px; color: var(--link);
  padding: 4px 0;
}
.m-link.strong { font-weight: 600; }
.m-sheet-search {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
}
.m-sheet-search input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg);
}
.m-sheet-section { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.m-sheet-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
  padding: 8px 16px 4px;
}
.m-sheet-row {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg);
}
.m-sheet-row:active { background: var(--btn-ghost-hover); }
.m-sheet-row.active { background: var(--btn-ghost-hover); }
.m-sheet-row .mono { flex: 1; word-break: break-all; }
.m-sheet-row.create { color: var(--fg-muted); }
.m-mru {
  font-size: 9px;
  letter-spacing: 0.16em;
  background: var(--bg-deep);
  color: var(--fg-subtle);
  padding: 2px 6px;
  border-radius: 2px;
}

/* =========================================================================
   IMPORT SCREEN
   ========================================================================= */
.m-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px 16px;
}
.m-stat {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 10px;
  display: flex; flex-direction: column; gap: 3px;
}
.m-stat-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--fg-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.m-stat-lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
}

.m-import-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 6px;
}
.m-import-row-top {
  display: flex; align-items: center; gap: 10px;
}
.m-import-when {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.m-import-row-src {
  font-family: var(--font-sans-kr);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-strong);
}
.m-import-bar {
  display: flex;
  height: 6px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.m-import-row-meta {
  font-size: 11px;
  color: var(--fg-muted);
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.m-import-row-meta .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.m-import-row-meta .dot { color: var(--fg-faint); }

/* =========================================================================
   LEDGER SCREEN (mobile)
   ========================================================================= */
.m-ledger-entity {
  margin: 12px 0;
}
.m-ledger-entity-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.m-ledger-entity-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-strong);
}
.m-ledger-entity-meta {
  font-size: 11px;
  color: var(--fg-muted);
  margin-left: auto;
  letter-spacing: 0.06em;
}
.m-ledger-acct-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
  align-items: center;
}
.m-ledger-acct-row.branch {
  background: var(--paper);
  font-weight: 600;
  color: var(--fg-strong);
}
.m-ledger-acct-row.leaf {
  padding-left: 28px;
}
.m-ledger-acct-row .m-ledger-acct-full {
  display: none;
}

/* =========================================================================
   RULES SCREEN (mobile)
   ========================================================================= */
.m-rule-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 10px;
}
.m-rule-top {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.m-rule-pattern {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--rule-ink);
  padding: 3px 8px;
  border-radius: 2px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m-rule-map {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-on-ink);
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 2px;
  border: 1px solid var(--rule-ink);
}
.m-rule-foot {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.m-rule-occ {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  text-transform: uppercase;
}
.m-rule-occ .num {
  font-size: 14px;
  color: var(--fg-strong);
  margin-right: 4px;
}
.m-rule-promote {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bg);
  border-radius: 2px;
  padding: 6px 10px;
}

/* =========================================================================
   TAB BAR
   ========================================================================= */
.m-tabbar {
  display: flex;
  height: 70px;
  background: var(--bg-translucent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--rule);
  padding: 4px 0 22px;
}
.m-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.m-tab.active { color: var(--fg-strong); }
.m-tab.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 24px;
  height: 2px;
  background: var(--fg-strong);
  border-radius: 1px;
}
.m-tab { position: relative; }

/* scrollbar */
.m-app *::-webkit-scrollbar { width: 0; height: 0; }
