/* حسابی — موبایل‌فرست، RTL */

:root {
    --accent: #01754f;
    --accent-light: #e8f5f0;
    --gray: #737174;
    --danger: #c62828;
    --warning: #e65100;
    --success: #2e7d32;
    --radius: 16px;
    --shadow: 0 2px 12px rgba(0,0,0,.08);
    --bg: #f5f5f6;
    --surface: #fff;
    --text: #1a1a1a;
    --text-muted: #737174;
    --border: #e8e8ea;
    --nav-h: 64px;
    --header-h: 56px;
}

[data-theme="dark"] {
    --bg: #000;
    --surface: #1c1c1e;
    --text: #f5f5f6;
    --text-muted: #a0a0a5;
    --border: #2c2c2e;
    --accent-light: #0d3d2e;
    --shadow: 0 2px 12px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .85; }

/* Shell */
.app-shell {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 100%;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.btn-logout {
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    color: var(--danger);
    background: #ffebee;
}

[data-theme="dark"] .btn-logout:hover {
    background: #3d1b1b;
}

.app-main {
    flex: 1;
    padding: 16px 16px calc(var(--nav-h) + 24px);
    max-width: 100%;
    overflow-x: clip;
}

/* Auth */
.auth-body { background: var(--bg); }
.auth-shell {
    max-width: 400px;
    margin: 0 auto;
    padding: 48px 20px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-brand h1 {
    font-size: 1.75rem;
    color: var(--accent);
    font-weight: 700;
}

.auth-brand p {
    color: var(--text-muted);
    font-size: .9rem;
    margin-top: 4px;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    max-width: 100%;
    overflow-x: clip;
}

.card-title {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Summary */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.summary-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.summary-card.full { grid-column: 1 / -1; }

.summary-card .label {
    font-size: .8rem;
    color: var(--text-muted);
}

.summary-card .value {
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 2px;
}

.summary-card.income .value { color: var(--success); }
.summary-card.expense .value { color: var(--danger); }
.summary-card.balance .value { color: var(--accent); }

/* Lists */
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 10px;
}

.section-head h2 {
    font-size: .95rem;
    font-weight: 600;
}

.section-head a {
    font-size: .8rem;
}

.tx-list { list-style: none; }

.tx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.tx-item:last-child { border-bottom: none; }

/* Transaction list rows */
.tx-card .tx-list { padding: 4px 0; }

.tx-row {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.tx-row:last-child { border-bottom: none; }

.tx-row .tx-item {
    padding: 0;
    border-bottom: none;
}

.tx-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
    padding-right: 52px;
}

.tx-act-form { display: inline; margin: 0; }

.tx-act-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    text-decoration: none;
}

.tx-act-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.tx-act-danger:hover {
    background: #ffebee;
    color: var(--danger);
    border-color: #ffcdd2;
}

[data-theme="dark"] .tx-act-danger:hover {
    background: #3d1b1b;
}

.tx-load-more {
    margin-top: 8px;
}
.tx-load-hint {
    margin: 8px 0 0;
    text-align: center;
}
.tx-card .tx-list .tx-item[href] {
    text-decoration: none;
    color: inherit;
    display: flex;
}

.btn-icon-only {
    padding: 8px 10px;
    min-width: auto;
}

/* Bank SMS archive */
.sms-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.sms-item:last-child { border-bottom: none; }

.sms-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.sms-head-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.sms-parsed {
    font-weight: 700;
    font-size: .9rem;
}

.sms-parsed.income { color: var(--success); }
.sms-parsed.expense { color: var(--danger); }

.sms-body {
    font-size: .85rem;
    line-height: 1.65;
    color: var(--text);
    word-break: break-word;
}

.sms-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.sms-actions form { display: inline; }

.sms-preview .sms-body {
    background: var(--bg);
    border-radius: 12px;
    padding: 12px;
    white-space: pre-wrap;
}

.tx-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tx-icon.income { background: #e8f5e9; color: var(--success); }
.tx-icon.expense { background: #ffebee; color: var(--danger); }
[data-theme="dark"] .tx-icon.income { background: #1b3d1f; }
[data-theme="dark"] .tx-icon.expense { background: #3d1b1b; }

.tx-body { flex: 1; min-width: 0; }
.tx-title { font-weight: 500; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: .75rem; color: var(--text-muted); }

.tx-amount { font-weight: 600; font-size: .9rem; white-space: nowrap; }
.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }

/* Badges */
.badge {
    display: inline-block;
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
}
.badge-success { background: #e8f5e9; color: var(--success); }
.badge-danger { background: #ffebee; color: var(--danger); }
.badge-warning { background: #fff3e0; color: var(--warning); }
.badge-muted { background: var(--border); color: var(--text-muted); }
[data-theme="dark"] .badge-success { background: #1b3d1f; }
[data-theme="dark"] .badge-danger { background: #3d1b1b; }
[data-theme="dark"] .badge-warning { background: #3d2a1b; }

/* Forms */
.form-group { margin-bottom: 14px; }

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color .2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.type-toggle input { display: none; }

.type-toggle label {
    text-align: center;
    padding: 10px;
    border-radius: 12px;
    border: 2px solid var(--border);
    cursor: pointer;
    font-weight: 500;
    font-size: .9rem;
    transition: all .2s;
}

.type-toggle input:checked + label.income {
    border-color: var(--success);
    background: #e8f5e9;
    color: var(--success);
}
.type-toggle input:checked + label.expense {
    border-color: var(--danger);
    background: #ffebee;
    color: var(--danger);
}
[data-theme="dark"] .type-toggle input:checked + label.income { background: #1b3d1f; }
[data-theme="dark"] .type-toggle input:checked + label.expense { background: #3d1b1b; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .2s;
}

.btn:hover { opacity: .9; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: .8rem; }
.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
}
.btn-icon:hover { background: var(--border); }

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* Filter tabs */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    overflow-x: auto;
}

.tab {
    padding: 8px 14px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    white-space: nowrap;
}

.tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Due items */
.due-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.due-item:last-child { border-bottom: none; }

.due-body { flex: 1; }
.due-title { font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.due-dir-badge { font-size: .65rem; font-weight: 600; padding: 2px 7px; vertical-align: middle; }
.due-meta { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.due-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
}

/* Admin table */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

table.data-table th,
table.data-table td {
    padding: 10px 8px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

table.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: .75rem;
}

/* Alerts */
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-size: .9rem;
}

.alert-success { background: #e8f5e9; color: var(--success); }
.alert-error { background: #ffebee; color: var(--danger); }
.alert-info { background: var(--accent-light); color: var(--accent); }
[data-theme="dark"] .alert-success { background: #1b3d1f; }
[data-theme="dark"] .alert-error { background: #3d1b1b; }

/* Empty state */
.empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}

.empty p { margin-bottom: 12px; font-size: .9rem; }

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    height: var(--nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 4px env(safe-area-inset-bottom);
    z-index: 20;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: .65rem;
    padding: 6px 8px;
    min-width: 52px;
}

.nav-item.active { color: var(--accent); }

.nav-fab {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    margin-top: -20px;
    box-shadow: var(--shadow);
    justify-content: center;
}

.nav-fab span { display: none; }

/* Theme toggle */
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: .85rem;
    color: var(--text-muted);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-box .num {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-box .lbl {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.inline-actions {
    display: flex;
    gap: 8px;
}

.inline-actions form { display: inline; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--text-muted);
    font-size: .85rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.btn-biometric {
    background: var(--surface);
    color: var(--accent);
    border: 2px solid var(--accent);
    gap: 8px;
}

.device-list {
    list-style: none;
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}

.device-item:last-child { border-bottom: none; }

.recurring-panel {
    background: var(--accent-light);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 14px;
    border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
}

[data-theme="dark"] .recurring-panel {
    background: #0d3d2e;
}

.due-recur-line {
    font-size: .7rem;
    color: var(--text-muted);
}

.account-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.account-item.compact { padding: 8px 0; }
.account-item:last-child { border-bottom: none; }

.account-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.account-body { flex: 1; min-width: 0; }
.account-name { font-weight: 500; font-size: .9rem; }
.account-balance { font-weight: 600; font-size: .9rem; white-space: nowrap; }

.quick-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.quick-link-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    color: inherit;
}

.ql-label { display: block; font-size: .75rem; color: var(--text-muted); }
.ql-value { display: block; font-weight: 700; font-size: .95rem; margin-top: 4px; }
.ql-value.income { color: var(--success); }
.ql-value.expense { color: var(--danger); }

.color-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--swatch);
    cursor: pointer;
    border: 3px solid transparent;
    display: block;
}

.color-swatch input { display: none; }
.color-swatch:has(input:checked) { border-color: var(--text); }

.bottom-nav .nav-item {
    min-width: 46px;
    padding: 6px 4px;
}

.bottom-nav .nav-item span { font-size: .58rem; }

.form-row {
    display: flex;
    gap: 10px;
}

.asset-item,
.transfer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.asset-item:last-child,
.transfer-item:last-child { border-bottom: none; }

.asset-icon,
.transfer-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.asset-body,
.transfer-body { flex: 1; min-width: 0; }

.asset-title,
.transfer-title { font-weight: 600; font-size: .9rem; }

.asset-value,
.transfer-amount {
    font-weight: 700;
    font-size: .9rem;
    white-space: nowrap;
}

.asset-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.asset-summary-row:last-child { border-bottom: none; }

.checkbox-label input { margin-top: 3px; flex-shrink: 0; }

/* Dashboard */
.dash-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, var(--accent) 0%, #025a3d 100%);
    color: #fff;
    border: none;
}

.dash-greeting { font-size: 1.05rem; font-weight: 600; }
.dash-month { font-size: .8rem; opacity: .85; margin-top: 4px; }
.dash-networth { text-align: left; }
.dash-networth .label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .7rem;
    opacity: .9;
    justify-content: flex-end;
}
.dash-networth .value { display: block; font-size: 1rem; font-weight: 700; margin-top: 4px; }

.stat-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 12px 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .stat-icon {
    display: inline-flex;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.stat-card.income .stat-icon { background: #e8f5e9; color: var(--success); }
.stat-card.expense .stat-icon { background: #ffebee; color: var(--danger); }
.stat-card.balance .stat-icon { background: var(--accent-light); color: var(--accent); }
.stat-card-link {
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s;
}
.stat-card-link:active {
    transform: scale(.98);
}
.stat-card-link.is-active {
    box-shadow: inset 0 0 0 2px var(--accent);
}
[data-theme="dark"] .stat-card.income .stat-icon { background: #1b3d1f; }
[data-theme="dark"] .stat-card.expense .stat-icon { background: #3d1b1b; }

.stat-label { display: block; font-size: .65rem; color: var(--text-muted); }
.stat-value { display: block; font-size: .78rem; font-weight: 700; margin-top: 2px; }

.chart-card { margin-bottom: 14px; }
.chart-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 12px;
    color: var(--text);
}
.chart-wrap { position: relative; height: 200px; }
.chart-wrap-pie { height: 220px; max-width: 260px; margin: 0 auto; }
.chart-wrap-tall { height: 240px; }

.icon-tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.icon-tile {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 12px;
    box-shadow: var(--shadow);
    color: inherit;
    text-align: center;
}

.tile-icon {
    display: inline-flex;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.ti-green { background: #e8f5f0; color: var(--accent); }
.ti-blue { background: #e3f2fd; color: #1565c0; }
.ti-red { background: #ffebee; color: var(--danger); }
.ti-gold { background: #fff8e1; color: #f9a825; }
[data-theme="dark"] .ti-green { background: #0d3d2e; }
[data-theme="dark"] .ti-blue { background: #1a2a3d; }
[data-theme="dark"] .ti-red { background: #3d1b1b; }
[data-theme="dark"] .ti-gold { background: #3d351b; }

.tile-label { display: block; font-size: .75rem; color: var(--text-muted); }
.tile-value { display: block; font-size: .85rem; font-weight: 700; margin-top: 4px; }
.tile-value.income { color: var(--success); }
.tile-value.expense { color: var(--danger); }

/* Settings */
.settings-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.settings-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-hero-name { font-weight: 700; font-size: 1.05rem; }
.settings-hero-mobile { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }

.settings-section-title {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 16px 4px 8px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.settings-menu {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 8px;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: inherit;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.settings-item:last-child { border-bottom: none; }
.settings-item:active { background: var(--bg); }

.settings-item-btn {
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    text-align: inherit;
    cursor: pointer;
}

.settings-item-static {
    cursor: default;
}

.settings-item-static:active {
    background: transparent;
}

.settings-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.si-green { background: #e8f5f0; color: var(--accent); }
.si-blue { background: #e3f2fd; color: #1565c0; }
.si-gold { background: #fff8e1; color: #f9a825; }
.si-purple { background: #f3e5f5; color: #6a1b9a; }
.si-red { background: #ffebee; color: var(--danger); }
.si-teal { background: #e0f2f1; color: #00838f; }
.si-orange { background: #fff3e0; color: var(--warning); }
[data-theme="dark"] .si-green { background: #0d3d2e; }
[data-theme="dark"] .si-blue { background: #1a2a3d; }
[data-theme="dark"] .si-gold { background: #3d351b; }
[data-theme="dark"] .si-purple { background: #2d1b3d; }
[data-theme="dark"] .si-red { background: #3d1b1b; }
[data-theme="dark"] .si-teal { background: #1b3d3a; }
[data-theme="dark"] .si-orange { background: #3d2a1b; }

.settings-text { flex: 1; min-width: 0; }
.settings-text strong { display: block; font-size: .92rem; font-weight: 600; }
.settings-text small { display: block; font-size: .72rem; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.settings-item > svg:last-child { color: var(--text-muted); flex-shrink: 0; }

.settings-logout { margin-top: 20px; margin-bottom: 8px; }

.page-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.card-icon-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.lock-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .85rem;
    font-weight: 600;
    margin-top: 12px;
    padding: 6px 12px;
    border-radius: 20px;
}

.lock-status.on { background: #e8f5e9; color: var(--success); }
.lock-status.off { background: var(--border); color: var(--text-muted); }
[data-theme="dark"] .lock-status.on { background: #1b3d1f; }

/* Lock screen */
.lock-screen {
    text-align: center;
    padding: 16px 20px 32px;
    min-height: 70dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    max-width: 360px;
    margin: 0 auto;
    padding-top: max(16px, env(safe-area-inset-top));
}

.lock-screen-brand {
    margin-bottom: 16px;
    width: 100%;
}

.lock-screen-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.lock-screen-icon-wrap {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lock-screen-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.lock-alert {
    width: 100%;
    margin-bottom: 16px;
}

.lock-pin-card {
    width: 100%;
    background: var(--surface);
    border-radius: 20px;
    padding: 20px 16px 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.lock-pin-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
}

.lock-pin-dots {
    display: flex;
    flex-direction: row;
    direction: ltr;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

.lock-pin-dots span {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    background: transparent;
    transition: background .2s, border-color .2s, transform .15s;
    flex-shrink: 0;
}

.lock-pin-dots span.filled {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.15);
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    direction: ltr;
    max-width: 260px;
    margin: 0 auto;
}

.pin-pad-key {
    aspect-ratio: 1;
    max-height: 62px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    font-family: 'Vazirmatn', system-ui, sans-serif;
    font-size: 1.45rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background .12s, transform .1s;
}

.pin-pad-key:active {
    background: var(--accent-light);
    color: var(--accent);
    transform: scale(.94);
}

.pin-pad-del {
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
}

.pin-pad-del:active {
    background: var(--bg);
    color: var(--danger);
}

.pin-pad-empty {
    visibility: hidden;
    pointer-events: none;
}

.lock-logout {
    margin-top: 20px;
    font-size: .85rem;
    color: var(--text-muted);
    padding: 8px 16px;
}

.pin-input { letter-spacing: .3em; font-size: 1.2rem; text-align: center; }
.pin-secure {
    -webkit-text-security: disc;
    text-security: disc;
}

.icon-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.icon-picker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.icon-picker-btn:hover { border-color: var(--accent); }

.icon-picker-btn.active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.cat-manage-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.cat-manage-item:last-child { border-bottom: none; }

.cat-manage-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 15%, var(--surface));
    color: var(--cat-color, var(--accent));
    flex-shrink: 0;
}

.cat-manage-name { flex: 1; font-weight: 500; }

.form-control-color {
    width: 100%;
    height: 44px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
}

@media (display-mode: standalone) {
    .app-shell,
    .auth-shell {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .pwa-install-banner {
        display: none !important;
    }
}

/* PWA install banner */
.pwa-install-banner {
    position: fixed;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 14px 14px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .18);
    animation: pwaSlideUp .35s ease;
}

.pwa-install-banner[hidden] {
    display: none !important;
}

@keyframes pwaSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.pwa-install-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(1, 117, 79, .25);
}

.pwa-install-body {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.pwa-install-body strong {
    display: block;
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.pwa-install-body p {
    margin: 0;
    font-size: .78rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.pwa-install-ios {
    margin-top: 6px !important;
    padding: 8px 10px;
    background: var(--accent-light);
    border-radius: 10px;
    color: var(--accent) !important;
    font-size: .75rem !important;
}

.pwa-install-action {
    flex-shrink: 0;
    padding: 10px 16px;
    font-size: .85rem;
    border-radius: 12px;
    white-space: nowrap;
}

.pwa-install-dismiss {
    position: absolute;
    top: 6px;
    left: 8px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
}

.pwa-install-dismiss:active {
    background: var(--bg);
}

.sms-pending-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--accent);
    background: var(--accent-light);
}

.sms-pending-icon {
    flex-shrink: 0;
    color: var(--accent);
}

.sms-pending-text {
    flex: 1;
    text-align: right;
}

.sms-pending-text strong {
    display: block;
    font-size: .92rem;
}

.sms-pending-text small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .78rem;
}

.sms-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.sms-capture-toast {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    z-index: 250;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: .88rem;
    text-align: right;
}

.sms-capture-toast.ok {
    border-color: var(--success);
    background: #ecfdf3;
}

.sms-capture-toast.error {
    border-color: var(--danger);
    background: #fef2f2;
}

.sms-capture-toast.prompt {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sms-capture-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

[data-theme="dark"] .sms-capture-toast.ok {
    background: #1b3d1f;
}

[data-theme="dark"] .sms-capture-toast.error {
    background: #3d1b1b;
}

.cal-dash-link {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
}

.cal-dash-icon {
    flex-shrink: 0;
    color: var(--accent);
}

.cal-dash-text {
    flex: 1;
    text-align: right;
}

.cal-dash-text strong {
    display: block;
    font-size: .92rem;
}

.cal-dash-text small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .78rem;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.cal-nav-pickers {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
}

.cal-select {
    flex: 1;
    min-width: 0;
    max-width: 148px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    text-align: center;
    direction: rtl;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737174' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 10px center;
    padding-left: 28px;
}

.cal-nav-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.cal-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    background: var(--bg);
}

.cal-nav-btn:active {
    background: var(--accent-light);
    color: var(--accent);
}

.cal-grid-wrap {
    padding: 14px 12px 12px;
    margin-bottom: 14px;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.cal-weekday {
    text-align: center;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-day {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
    transition: background .12s, transform .1s;
}

.cal-day-empty {
    pointer-events: none;
}

.cal-day:active {
    transform: scale(.94);
}

.cal-day.today {
    border: 2px solid var(--accent);
}

.cal-day.selected {
    background: var(--accent);
    color: #fff;
}

.cal-day.selected .cal-day-dot {
    background: #fff;
}

.cal-day.has-data:not(.selected) {
    background: var(--accent-light);
    color: var(--accent);
}

.cal-day-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 3px;
}

.cal-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
    font-size: .72rem;
    color: var(--text-muted);
}

.cal-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
}

.cal-legend-dot.has {
    background: var(--accent-light);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.cal-legend-dot.today {
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.cal-day-panel,
.cal-month-panel {
    margin-bottom: 14px;
}

.cal-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.cal-section-head .card-title {
    margin: 0;
}

.card-subtitle {
    margin: 0;
    font-size: .88rem;
    font-weight: 600;
}

.cal-day-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.cal-mini-stat {
    padding: 10px 8px;
    border-radius: 12px;
    background: var(--bg);
    text-align: center;
}

.cal-mini-stat .label {
    display: block;
    font-size: .7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.cal-mini-stat .value {
    display: block;
    font-size: .78rem;
    font-weight: 700;
}

.cal-mini-stat.income .value { color: var(--income); }
.cal-mini-stat.expense .value { color: var(--expense); }
.cal-mini-stat.balance .value { color: var(--accent); }

.cal-day-list .tx-item {
    text-decoration: none;
    color: inherit;
}

.cal-month-stats {
    margin-top: 12px;
}

.cal-month-meta {
    margin: 12px 0 0;
    text-align: center;
}

.cal-cat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.cal-cat-row:last-child {
    border-bottom: none;
}

.cal-cat-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
}

.cal-cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-cat-amount {
    font-size: .85rem;
    font-weight: 600;
    color: var(--expense);
}

/* Voice entry */
.voice-panel {
    text-align: center;
    padding: 28px 18px 22px;
}

.voice-mic-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.voice-mic-btn {
    position: relative;
    width: 108px;
    height: 108px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #1db954 0%, #01754f 55%, #015a3d 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
        0 10px 28px rgba(1, 117, 79, .38),
        inset 0 1px 0 rgba(255, 255, 255, .25);
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}

.voice-mic-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 14px 32px rgba(1, 117, 79, .42),
        inset 0 1px 0 rgba(255, 255, 255, .28);
}

.voice-mic-btn:active {
    transform: scale(.96);
}

.voice-mic-icon {
    position: relative;
    z-index: 1;
    display: flex;
    line-height: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .2));
}

.voice-mic-icon svg {
    stroke: #fff;
    stroke-width: 2.2;
}

.voice-mic-ring {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    border: 2px solid rgba(29, 185, 84, .45);
    opacity: 0;
    pointer-events: none;
}

.voice-mic-btn.listening {
    background: linear-gradient(145deg, #ff5a5a 0%, #e53935 50%, #b71c1c 100%);
    box-shadow:
        0 10px 30px rgba(229, 57, 53, .45),
        inset 0 1px 0 rgba(255, 255, 255, .22);
}

.voice-mic-btn.listening .voice-mic-ring {
    opacity: 1;
    border-color: rgba(255, 90, 90, .55);
    animation: voiceRing 1.35s ease-out infinite;
}

.voice-mic-btn.listening::after {
    content: '';
    position: absolute;
    inset: -22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 90, 90, .28);
    animation: voiceRing 1.35s ease-out .35s infinite;
    pointer-events: none;
}

@keyframes voiceRing {
    0% { transform: scale(.88); opacity: .85; }
    100% { transform: scale(1.28); opacity: 0; }
}

.voice-intro-icon {
    background: linear-gradient(145deg, #1db954, #01754f) !important;
    color: #fff !important;
}

.voice-transcript {
    margin-top: 18px;
    text-align: right;
    background: var(--bg);
    border-radius: 12px;
    padding: 12px 14px;
}

.voice-transcript p {
    margin: 6px 0 0;
    font-weight: 500;
    line-height: 1.7;
}
