@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #080c0a;
  --surface: #111915;
  --surface-2: #16221c;
  --glass: rgba(13, 20, 16, 0.86);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f3f7f4;
  --text-2: #b9c7bf;
  --muted: #7f9488;
  --accent: #00ff7f;
  --accent-ink: #041d10;
  --accent-text: #00ff7f;
  --accent-soft: rgba(0, 255, 127, 0.12);
  --accent-border: rgba(0, 255, 127, 0.34);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --wa: #25d366;
  --wa-soft: rgba(37, 211, 102, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --mono: ui-monospace, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f2f6f3;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --glass: rgba(255, 255, 255, 0.88);
  --border: #e1e8e3;
  --border-strong: #cad5ce;
  --text: #0b120e;
  --text-2: #3b4a42;
  --muted: #687a70;
  --accent: #00e673;
  --accent-ink: #041b0f;
  --accent-text: #007d44;
  --accent-soft: #e4fbef;
  --accent-border: rgba(0, 168, 90, 0.36);
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --wa: #16a34a;
  --wa-soft: #dcfce7;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; padding: 0; overscroll-behavior-y: none; }
body {
  font-family: "Vazirmatn", system-ui, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.28s var(--ease), color 0.28s var(--ease);
}

button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); }
.ic { width: 20px; height: 20px; flex: none; stroke-width: 1.95; }
.ic-sm { width: 16px; height: 16px; flex: none; stroke-width: 2; }

/* Brand */
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: #0b140f;
  border: 1px solid var(--accent-border); display: grid; place-items: center; flex: none;
}
.brand-mark img { width: 20px; height: 22px; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.brand-wm {
  display: block; width: 92px; height: 19px; background: var(--text);
  -webkit-mask: url("brand/wordmark.svg") no-repeat center/contain;
  mask: url("brand/wordmark.svg") no-repeat center/contain;
}
.brand-sub { font-size: 11px; font-weight: 700; color: var(--accent-text); line-height: 1.2; }

/* Auth Screen */
.m-auth {
  min-height: 100dvh; max-width: 480px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 16px;
}
.m-auth-top { display: flex; align-items: center; justify-content: space-between; }
.m-auth-hero { text-align: center; padding: 6px 6px 2px; animation: popUp 0.35s var(--ease); }
.m-emblem {
  width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 12px;
  background: linear-gradient(145deg, #102419, #09110d); border: 1px solid var(--accent-border);
  display: grid; place-items: center; box-shadow: 0 12px 32px rgba(0, 255, 127, 0.18);
}
.m-emblem img { width: 34px; height: 36px; }
.m-auth-hero h1 { font-size: 20px; font-weight: 900; margin: 0 0 6px; line-height: 1.4; }
.m-auth-hero p { margin: 0; font-size: 13px; color: var(--text-2); }

/* Mobile Shell */
.m-shell {
  height: 100dvh; max-width: 540px; margin: 0 auto;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
  background: var(--bg);
}
@media (min-width: 560px) {
  .m-shell { border-inline: 1px solid var(--border); box-shadow: 0 0 80px rgba(0, 0, 0, 0.35); }
}

.m-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border); flex: none; z-index: 20;
}
.m-head-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-mini-mark {
  width: 34px; height: 34px; border-radius: 10px; background: #0b140f;
  border: 1px solid var(--accent-border); display: grid; place-items: center; flex: none;
}
.m-mini-mark img { width: 19px; height: 20px; }
.m-head-info { min-width: 0; }
.m-head-info b { display: block; font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.m-head-info small { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.m-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.m-dot.ok { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.m-head-actions { display: flex; align-items: center; gap: 7px; }

.m-icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  cursor: pointer; transition: all 0.16s var(--ease);
}
.m-icon-btn:active { transform: scale(0.92); }

.m-content { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; display: flex; flex-direction: column; }
.m-page { padding: 14px 14px 24px; animation: popUp 0.26s var(--ease); }
@keyframes popUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Cards & Controls */
.m-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 15px; margin-bottom: 12px;
}
.m-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.m-card-head h2 { margin: 0; font-size: 14.5px; font-weight: 800; }
.m-desc { margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); }
.m-stack { display: flex; flex-direction: column; gap: 11px; }
.m-field { display: flex; flex-direction: column; gap: 5px; }
.m-field label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.m-input, .m-textarea {
  width: 100%; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font-size: 15px; transition: border-color 0.15s;
}
.m-input:focus, .m-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.m-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; padding: 0 15px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font-weight: 700; font-size: 13.5px; cursor: pointer;
  transition: transform 0.15s var(--ease), background-color 0.15s ease;
}
.m-btn:active:not(:disabled) { transform: scale(0.96); }
.m-btn:disabled { opacity: 0.55; }
.m-btn.lg { width: 100%; height: 46px; font-size: 14.5px; border-radius: 12px; }
.m-btn.sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.m-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(0, 255, 127, 0.22); }
.m-btn.soft { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text); }
.m-btn.danger { background: var(--danger-soft); border-color: rgba(248, 113, 113, 0.3); color: var(--danger); }
.m-link-btn { border: 0; background: none; color: var(--accent-text); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 2px 0; }
.m-row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.m-seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 4px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border);
}
.m-seg button {
  border: 0; background: transparent; color: var(--muted); padding: 8px 6px;
  border-radius: 8px; font-weight: 700; font-size: 12.5px; cursor: pointer; transition: all 0.18s var(--ease);
}
.m-seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }

.m-divider { text-align: center; margin: 14px 0 12px; position: relative; }
.m-divider::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.m-divider span { position: relative; background: var(--surface); padding: 0 10px; font-size: 11.5px; color: var(--muted); }

/* Hero KPI Card */
.m-hero-card {
  background: linear-gradient(145deg, rgba(0, 255, 127, 0.16) 0%, var(--surface) 75%);
  border: 1px solid var(--accent-border); border-radius: 18px; padding: 18px; margin-bottom: 12px;
}
.m-hero-card.compact { padding: 15px 16px; }
.m-hero-top { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text-2); }
.m-hero-val { font-size: 25px; font-weight: 900; margin: 6px 0 3px; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.m-hero-sub { font-size: 12px; color: var(--muted); }
.m-pill-btn {
  border: 1px solid var(--accent-border); background: var(--accent-soft); color: var(--accent-text);
  border-radius: 99px; padding: 4px 10px; font-size: 11.5px; font-weight: 700; cursor: pointer;
}

.m-kpi-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.m-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 15px; padding: 13px; }
.m-kpi span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; }
.m-kpi b { display: block; font-size: 16px; font-weight: 900; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.m-kpi small { display: block; font-size: 11px; color: var(--muted); }

.m-list { display: flex; flex-direction: column; gap: 8px; }
.m-bank-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
}
.m-bank-row b { display: block; font-size: 13.5px; }
.m-bank-row small { display: block; font-size: 11px; color: var(--muted); }
.m-bank-bal { font-weight: 800; color: var(--accent-text); font-size: 13.5px; white-space: nowrap; }
.m-muted-box { background: var(--surface-2); border-radius: 11px; padding: 11px 12px; font-size: 12.5px; color: var(--text-2); white-space: pre-line; }

/* Chat Screen */
.m-chat-screen { display: flex; flex-direction: column; flex: 1; height: 100%; min-height: 0; }
.m-chat-list { flex: 1; overflow-y: auto; padding: 14px 12px 10px; display: flex; flex-direction: column; gap: 12px; }
.m-chat-empty { margin: auto; text-align: center; padding: 16px 12px; animation: popUp 0.32s var(--ease); }
.m-chat-empty h2 { font-size: 17px; font-weight: 900; margin: 10px 0 5px; }
.m-chat-empty p { font-size: 13px; color: var(--text-2); margin: 0; }

.m-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 89%; animation: popUp 0.22s var(--ease); }
.m-msg.user { align-self: flex-start; }
.m-msg.assistant { align-self: flex-end; flex-direction: row-reverse; }
.m-msg-bub {
  padding: 11px 13px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word;
}
.m-msg.user .m-msg-bub { background: var(--accent-soft); border-color: var(--accent-border); border-bottom-right-radius: 5px; }
.m-msg.assistant .m-msg-bub { border-bottom-left-radius: 5px; }
.m-msg-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 5px; font-size: 10.5px; color: var(--muted); }

.m-quick-chips {
  display: flex; gap: 7px; overflow-x: auto; padding: 6px 12px 8px; flex: none;
  scrollbar-width: none;
}
.m-quick-chips::-webkit-scrollbar { display: none; }
.m-quick-chips button {
  flex: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: 99px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.m-quick-chips button:active { background: var(--accent-soft); color: var(--accent-text); }

.m-composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px 10px;
  border-top: 1px solid var(--border); background: var(--surface); flex: none;
}
.m-composer textarea {
  flex: 1; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface-2);
  padding: 9px 12px; font-size: 14.5px; max-height: 100px; min-height: 42px; resize: none; outline: none;
}
.m-composer textarea:focus { border-color: var(--accent); }
.m-mic, .m-send {
  width: 42px; height: 42px; border-radius: 13px; border: 0; flex: none;
  display: grid; place-items: center; cursor: pointer; transition: transform 0.15s var(--ease);
}
.m-mic { background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2); }
.m-mic.recording { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: 0 0 0 6px var(--danger-soft); animation: pulseRec 1.1s infinite; }
.m-send { background: var(--accent); color: var(--accent-ink); }
.m-mic:active, .m-send:active { transform: scale(0.92); }
@keyframes pulseRec { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

.thinking-dots { display: inline-flex; gap: 5px; padding: 4px 2px; }
.thinking-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: bounce 1.1s infinite ease-in-out; }
.thinking-dots i:nth-child(2) { animation-delay: 0.16s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* Audit & Debtors Cards */
.m-issue {
  background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--warn);
  border-radius: 14px; padding: 13px; margin-bottom: 10px;
}
.m-issue.critical { border-inline-start-color: var(--danger); }
.m-tag { display: inline-flex; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.m-tag.err { background: var(--danger-soft); color: var(--danger); }
.m-tag.warn { background: var(--warn-soft); color: var(--warn); }
.m-tag.ok { background: var(--accent-soft); color: var(--accent-text); }

.m-search-wrap {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 42px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border-strong); margin-bottom: 12px;
}
.m-search-wrap input { flex: 1; border: 0; background: transparent; outline: none; font-size: 14px; }

.m-debtor {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 15px; padding: 14px; margin-bottom: 10px;
}
.m-debtor-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.m-debtor-amt { font-weight: 900; color: var(--accent-text); font-size: 14.5px; white-space: nowrap; }
.m-pay-preview {
  background: var(--surface-2); border-radius: 10px; padding: 9px 11px; margin: 9px 0 10px;
  font-size: 12px; color: var(--text-2); white-space: pre-line;
}
.m-deb-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.m-act {
  display: flex; align-items: center; justify-content: center; gap: 4px; height: 35px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font-size: 11.5px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.m-act.wa { background: var(--wa-soft); border-color: rgba(37, 211, 102, 0.35); color: var(--wa); }
.m-act:active { transform: scale(0.95); }

/* More Screen Helpers */
.m-code-box {
  background: var(--surface-2); border: 1px solid var(--accent-border); color: var(--accent-text);
  border-radius: 12px; padding: 13px; text-align: center; font-size: 20px; font-weight: 900;
  letter-spacing: 3px; margin: 10px 0;
}
.m-ios-steps {
  background: var(--surface-2); border-radius: 11px; padding: 10px 12px;
  font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
}
.m-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 700; }
.switch { position: relative; display: inline-flex; width: 44px; height: 24px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border-strong); transition: 0.2s; }
.switch-track::after { content: ""; position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: 0.22s var(--bounce); }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(-20px); background: var(--accent-ink); }

/* Bottom Native Glass Tab Bar */
.m-tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border); flex: none; z-index: 25;
}
.m-tab {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 6px 2px; border-radius: 12px; cursor: pointer; font-size: 10.5px; font-weight: 700;
  transition: all 0.2s var(--ease);
}
.m-tab.active { color: var(--accent-text); background: var(--accent-soft); }
.m-tab:active { transform: scale(0.92); }

/* Toast */
.m-toast {
  position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -14px) scale(0.95);
  background: var(--surface); border: 1px solid var(--accent-border); color: var(--text);
  padding: 10px 16px; border-radius: 99px; font-size: 12.5px; font-weight: 700;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4); opacity: 0; pointer-events: none; z-index: 999;
  transition: all 0.25s var(--bounce); max-width: 90vw; text-align: center;
}
.m-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.m-toast.err { border-color: rgba(248, 113, 113, 0.5); color: var(--danger); }

.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
