/* ===== MEION — Dark Mode · Mobile-First ===== */

:root {
    --bg: #0d0e13;
    --bg-card: #16181f;
    --bg-card-hover: #1c1f28;
    --bg-input: #1c1f28;
    --bg-elevated: #1a1c24;

    --sidebar-bg: #111318;

    --border: #22252e;
    --border-light: #2a2d38;

    --text: #e8e9ed;
    --text-secondary: #8b8fa3;
    --text-muted: #565a6e;

    --accent: #c9a55c;
    --accent-light: #dbb86e;
    --accent-bg: rgba(201,165,92,0.10);
    --accent-glow: rgba(201,165,92,0.06);

    --green: #2dd4a0;
    --green-bg: rgba(45,212,160,0.10);
    --red: #f06060;
    --red-bg: rgba(240,96,96,0.08);
    --orange: #f5a623;
    --orange-bg: rgba(245,166,35,0.10);
    --blue: #5b9fe6;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bottomnav-h: 62px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; touch-action: none; }

a { color: var(--accent-light); text-decoration: none; }

/* ===== Mobile Layout ===== */

.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom));
}

.sidebar { display: none; }

/* ===== Bottom Nav ===== */

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--bottomnav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 100;
}

.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 14px; color: var(--text-muted);
    text-decoration: none; font-size: 0.62rem; font-weight: 500;
    min-width: 56px; transition: color 0.15s ease;
}

.bottom-nav-item.active { color: var(--accent-light); }

/* ===== Top Bar ===== */

.top-bar {
    padding: 16px; display: flex; align-items: center; gap: 12px;
    background: var(--bg); position: sticky; top: 0; z-index: 50;
}

.page-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.4px; flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.top-bar-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.7rem; color: #111; text-decoration: none; flex-shrink: 0;
    list-style: none; cursor: pointer; border: none;
}
.top-bar-avatar::-webkit-details-marker { display: none; }

.top-user-menu { position: relative; }
.top-user-menu summary { list-style: none; }
.top-user-menu summary::-webkit-details-marker { display: none; }
.top-user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    padding: 6px;
    display: none;
    z-index: 120;
}
.top-user-menu[open] .top-user-menu-panel { display: flex; flex-direction: column; gap: 4px; }
.top-user-menu-link {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
}
.top-user-menu-link:hover {
    background: var(--bg-input);
    color: var(--text);
}

.top-notif-menu { position: relative; }
.top-notif-menu summary { list-style: none; }
.top-notif-menu summary::-webkit-details-marker { display: none; }
.top-notif-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
}
.top-notif-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 1px solid var(--bg);
}
.top-notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: min(360px, calc(100vw - 24px));
    max-height: min(420px, 70vh);
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    padding: 8px;
    display: none;
    z-index: 150;
}
.top-notif-menu[open] .top-notif-panel { display: block; }
.top-notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding: 2px 2px 6px;
}
.top-notif-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 6px;
}
.top-notif-item strong { color: var(--text); font-size: 0.76rem; }
.top-notif-item span { font-size: 0.72rem; }
.top-notif-source {
    color: var(--text-muted);
    font-size: 0.66rem !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.top-notif-item.severity-high { border-color: rgba(240,96,96,0.45); }
.top-notif-item.severity-medium { border-color: rgba(245,166,35,0.45); }
.top-notif-item.severity-low { border-color: rgba(91,159,230,0.45); }
.top-notif-empty {
    color: var(--text-secondary);
    font-size: 0.76rem;
    padding: 8px;
}

.mobile-more { position: relative; }
.mobile-more summary { list-style: none; }
.mobile-more summary::-webkit-details-marker { display: none; }
.mobile-more-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 10px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 -16px 35px rgba(0,0,0,0.35);
    padding: 8px;
    display: none;
    z-index: 140;
}
.mobile-more[open] .mobile-more-panel { display: flex; flex-direction: column; gap: 4px; }
.mobile-more-panel a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 500;
}
.mobile-more-panel a:hover {
    background: var(--bg-input);
    color: var(--text);
}

.main-content { flex: 1; display: flex; flex-direction: column; }
.content { padding: 0 16px 24px; flex: 1; }

/* ===== Flash ===== */

.flash-messages { padding: 8px 16px 0; }

.flash {
    padding: 10px 14px; border-radius: var(--radius); font-size: 0.82rem; margin-bottom: 10px;
}

.flash-error { background: var(--red-bg); color: var(--red); }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-info { background: var(--accent-bg); color: var(--accent-light); }

/* ===== Cards ===== */

.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px;
}

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h2 { font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.card-badge {
    font-size: 0.65rem; color: var(--text-muted); background: var(--bg-input);
    padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}

/* ===== KPIs ===== */

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 14px 16px;
}

.kpi-card-link {
    display: block; text-decoration: none; color: inherit;
    cursor: pointer; transition: border-color 0.2s, transform 0.15s;
}
.kpi-card-link:hover {
    border-color: var(--accent); transform: translateY(-1px);
}

.kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-label { font-size: 0.7rem; color: var(--text-secondary); font-weight: 500; }

.kpi-icon { width: 28px; height: 28px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.kpi-icon svg { width: 15px; height: 15px; }
.kpi-icon-balance { background: var(--accent-bg); color: var(--accent); }
.kpi-icon-income { background: var(--green-bg); color: var(--green); }
.kpi-icon-expense { background: var(--red-bg); color: var(--red); }
.kpi-icon-recurring { background: var(--orange-bg); color: var(--orange); }

.kpi-value { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 2px; line-height: 1.2; }
.kpi-unit { font-size: 0.7rem; font-weight: 500; color: var(--text-muted); }
.kpi-sub { font-size: 0.68rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

/* ===== Badges ===== */

.badge { display: inline-flex; padding: 1px 7px; border-radius: 20px; font-size: 0.65rem; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-neutral { background: var(--bg-input); color: var(--text-muted); }

/* ===== Charts ===== */

.charts-grid { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.chart-card { padding-bottom: 12px; }
.chart-container { position: relative; height: 220px; }
.chart-container-doughnut { height: 240px; display: flex; align-items: center; justify-content: center; }

/* ===== Transactions (mobile cards) ===== */

.tx-list { display: flex; flex-direction: column; }

.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; }

.tx-icon {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.8rem;
}
.tx-icon-credit { background: var(--green-bg); color: var(--green); }
.tx-icon-debit { background: var(--red-bg); color: var(--red); }

.tx-details { flex: 1; min-width: 0; }
.tx-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.tx-meta { font-size: 0.68rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.tx-amount { font-size: 0.9rem; font-weight: 600; white-space: nowrap; }

.recurring-badge { width: 16px; height: 16px; border-radius: 50%; background: var(--orange-bg); color: var(--orange); font-size: 0.55rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.category-tag { font-size: 0.65rem; padding: 2px 7px; border-radius: 20px; background: var(--bg-input); color: var(--text-secondary); white-space: nowrap; }

.table-wrapper { display: none; }

/* ===== Utils ===== */

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }

/* ===== Buttons ===== */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: var(--radius); font-family: var(--font);
    font-size: 0.85rem; font-weight: 500; border: none; cursor: pointer; transition: all 0.15s ease;
}

.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-light)); color: #111; font-weight: 600; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 7px 10px; font-size: 0.8rem; }
.btn-ghost:hover { background: var(--bg-input); color: var(--text); }
.btn-full { width: 100%; padding: 12px; }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }

/* ===== Search ===== */

.search-bar {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0 12px; flex: 1; max-width: 100%;
    transition: border-color 0.2s;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; width: 16px; height: 16px; }

.search-input {
    background: none; border: none; color: var(--text); font-family: var(--font);
    font-size: 0.85rem; padding: 9px 0; width: 100%; outline: none;
}
.search-input::placeholder { color: var(--text-muted); }

/* ===== Filters ===== */

.filters-bar { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.filters-bar::-webkit-scrollbar { display: none; }

.filter-btn {
    padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
    background: transparent; color: var(--text-secondary); font-family: var(--font);
    font-size: 0.75rem; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.filter-btn:hover { border-color: var(--text-muted); color: var(--text); }
.filter-btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-light); }

/* ===== Analytics ===== */

.scope-switcher {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 14px;
}

.scope-switcher::-webkit-scrollbar { display: none; }

.scope-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 500;
    text-decoration: none;
    min-height: 34px;
}

.scope-pill.active {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-bg);
}

.scope-pill-btn {
    cursor: pointer;
    font-family: var(--font);
}

.scope-switcher form { margin: 0; }
.period-switcher {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 14px;
}
.period-switcher::-webkit-scrollbar { display: none; }

.card-badge-link {
    border: 1px solid transparent;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.card-badge-link:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

.scope-card { margin-bottom: 12px; }

/* ── Analytics tabs ──────────────────────────────── */
.analytics-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.analytics-tabs::-webkit-scrollbar { display: none; }

.analytics-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.analytics-tab:hover { color: var(--text); }
.analytics-tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.analytics-tab svg { opacity: 0.7; }
.analytics-tab.active svg { opacity: 1; }

.analytics-tab-panel { display: none; }
.analytics-tab-panel.active { display: block; }

/* ── Tab KPI row ─────────────────────────────────── */
.tab-kpi-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.tab-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tab-kpi-label { font-size: 0.72rem; color: var(--text-muted); }
.tab-kpi-value { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }

/* ── Business flow intelligence ───────────────────── */
.flow-intel-card {
    border-color: #2a2f3d;
    background:
        radial-gradient(120% 150% at 0% 0%, rgba(45,212,160,0.07) 0%, rgba(45,212,160,0.01) 40%, transparent 70%),
        linear-gradient(160deg, #151922 0%, #12151c 100%);
}

.flow-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.flow-kpi-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: rgba(12, 14, 20, 0.45);
}
.flow-kpi-btn {
    text-align: left;
    color: inherit;
    font-family: var(--font);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}
.flow-kpi-btn:hover {
    border-color: var(--accent);
    background: rgba(20, 24, 33, 0.72);
}
.flow-kpi-btn:active { transform: translateY(1px); }

.flow-kpi-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.68rem;
    margin-bottom: 4px;
}

.flow-kpi-value {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.flow-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.flow-section h3 {
    font-size: 0.78rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.flow-row { margin-bottom: 8px; }

.flow-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.flow-row-top strong {
    color: var(--text);
    font-size: 0.74rem;
}

.flow-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    overflow: hidden;
}

.flow-fill {
    display: block;
    height: 100%;
    min-width: 2%;
    border-radius: inherit;
}

.flow-client { background: linear-gradient(90deg, #2dd4a0, #65e8c0); }
.flow-supplier { background: linear-gradient(90deg, #f06060, #ff8c8c); }
.flow-payroll { background: linear-gradient(90deg, #f97316, #fb923c); }
.flow-taxes { background: linear-gradient(90deg, #f5a623, #f7bf57); }
.flow-credit { background: linear-gradient(90deg, #a78bfa, #c4b5fd); }
.flow-fees { background: linear-gradient(90deg, #ef4444, #f87171); }
.flow-subscriptions { background: linear-gradient(90deg, #5b9fe6, #8abcf0); }
.flow-transfer { background: linear-gradient(90deg, #22c55e, #4ade80); }
.flow-refund { background: linear-gradient(90deg, #10b981, #34d399); }
.flow-other { background: linear-gradient(90deg, #6b7280, #9ca3af); }

.analytics-hero {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    background:
        radial-gradient(120% 150% at 0% 0%, rgba(91,159,230,0.15) 0%, rgba(91,159,230,0.03) 35%, transparent 60%),
        linear-gradient(160deg, #171a23 0%, #12141b 100%);
}

.analytics-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.analytics-hero-top h2 {
    font-size: 0.98rem;
    line-height: 1.2;
    margin-bottom: 3px;
}

.analytics-hero-top p {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.analytics-metrics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 12px;
    background: rgba(13,14,19,0.46);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.metric-sub {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.analytics-grid { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.analytics-grid-revamp { margin-bottom: 12px; }

.recurring-list { display: flex; flex-direction: column; }
.recurring-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.recurring-item:last-child { border-bottom: none; }
.recurring-item-btn {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    color: inherit;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.recurring-item-btn:hover { background: var(--bg-card-hover); }
.recurring-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.recurring-merchant { font-weight: 500; font-size: 0.85rem; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.recurring-freq { font-size: 0.68rem; color: var(--text-muted); }
.recurring-amount { text-align: right; display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.recurring-amount .amount { font-weight: 600; font-size: 0.85rem; }
.amount-unit { font-weight: 400; font-size: 0.68rem; color: var(--text-muted); }
.recurring-total { font-size: 0.68rem; }

/* Leaks */
.leaks-card .card-header h2 { color: var(--orange); }
.leaks-list { display: flex; flex-direction: column; }
.leak-item { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.leak-item:last-child { border-bottom: none; }
.leak-top-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.leak-severity { font-size: 0.7rem; font-weight: 500; display: flex; align-items: center; gap: 5px; }
.severity-dot { width: 7px; height: 7px; border-radius: 50%; }
.severity-high { background: var(--red); }
.severity-medium { background: var(--orange); }
.severity-low { background: var(--blue); }
.leak-message { font-weight: 500; font-size: 0.82rem; overflow-wrap: anywhere; word-break: break-word; }
.leak-type { font-size: 0.68rem; color: var(--text-muted); }
.leak-cost { font-weight: 600; font-size: 0.82rem; }
.empty-inline { color: var(--text-secondary); font-size: 0.78rem; padding: 8px 0; }

/* Forecasts */
.forecast-card { margin-bottom: 16px; }
.forecast-disclaimer { font-size: 0.74rem; margin-bottom: 10px; }
.forecast-projections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.forecast-pill {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    background: var(--bg-elevated);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.forecast-pill.is-critical {
    border-color: rgba(240, 96, 96, 0.45);
    background: rgba(240, 96, 96, 0.08);
}
.forecast-pill-label {
    color: var(--text-muted);
    font-size: 0.68rem;
}
.forecast-pill-value {
    font-size: 1rem;
    font-weight: 700;
}
.forecast-pill-sub {
    font-size: 0.68rem;
    color: var(--text-secondary);
}
.forecast-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.forecast-toolbar .text-muted {
    font-size: 0.7rem;
}
.forecast-snapshot {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.forecast-snapshot-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.forecast-snapshot-item strong { font-size: 0.76rem; }
.forecast-snapshot-item span { font-size: 0.72rem; color: var(--text-secondary); }
.forecast-alerts,
.forecast-timeline,
.forecast-notifications {
    margin-top: 12px;
}
.forecast-timeline-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.forecast-count { font-size: 0.72rem; }
.forecast-type-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.forecast-type-filters::-webkit-scrollbar { display: none; }
.forecast-type-filters .filter-btn { font-size: 0.72rem; padding: 5px 12px; }
.forecast-alerts h3,
.forecast-timeline h3,
.forecast-notifications h3 {
    font-size: 0.8rem;
    margin-bottom: 6px;
}
.forecast-event-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: inherit;
}
.forecast-event-btn:hover { background: rgba(255, 255, 255, 0.02); }
.forecast-type-tag {
    display: inline-flex;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.62rem;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.02);
    vertical-align: 1px;
}
.forecast-type-vat { border-color: rgba(91,159,230,0.45); color: #8cb8ea; }
.forecast-type-charges { border-color: rgba(245,166,35,0.45); color: #f3be6a; }
.forecast-type-subscription { border-color: rgba(45,212,160,0.45); color: #7be8c1; }
.forecast-alert,
.forecast-notification {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px;
    background: var(--bg-elevated);
    margin-bottom: 8px;
}
.forecast-alert-title { font-size: 0.77rem; font-weight: 600; }
.forecast-alert-message { font-size: 0.73rem; color: var(--text-secondary); }
.forecast-notification p {
    font-size: 0.74rem;
    color: var(--text-secondary);
    margin: 2px 0;
}
.forecast-alert.severity-high,
.forecast-notification.severity-high { border-color: rgba(240,96,96,0.45); }
.forecast-alert.severity-medium,
.forecast-notification.severity-medium { border-color: rgba(245,166,35,0.45); }
.forecast-alert.severity-low,
.forecast-notification.severity-low { border-color: rgba(91,159,230,0.45); }

.forecast-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
}
.forecast-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.76rem;
    color: var(--text-secondary);
}
.forecast-event-explanation {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    background: var(--bg-input);
}
.forecast-event-explanation h4 {
    font-size: 0.78rem;
    margin-bottom: 4px;
}
.forecast-event-explanation p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

/* ===== Audit ===== */

.audit-page { max-width: 1000px; margin: 0 auto; padding-bottom: 18px; }
.audit-hero { margin-bottom: 12px; }
.audit-hero h2 { font-size: 0.95rem; margin-bottom: 4px; }
.audit-hero p { font-size: 0.76rem; color: var(--text-secondary); }
.audit-filters-card { margin-bottom: 12px; }
.audit-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
.audit-filters .form-group { gap: 6px; }
.audit-filters .form-group label {
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.audit-filters .form-group input,
.audit-filters .form-group select {
    width: 100%;
    min-width: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    padding: 9px 10px;
}
.audit-filters .form-group input:focus,
.audit-filters .form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.audit-filters-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.audit-filters-actions .btn { width: 100%; }
.audit-list { display: flex; flex-direction: column; gap: 8px; }
.audit-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    overflow: hidden;
}
.audit-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
    padding: 10px;
}
.audit-summary::-webkit-details-marker { display: none; }
.audit-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.audit-action { font-size: 0.8rem; font-weight: 600; overflow-wrap: anywhere; }
.audit-meta { color: var(--text-muted); font-size: 0.68rem; }
.audit-details {
    border-top: 1px solid var(--border);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.74rem;
    color: var(--text-secondary);
}
.audit-metadata pre {
    margin-top: 6px;
    background: rgba(13,14,19,0.62);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    overflow: auto;
    font-size: 0.7rem;
    color: var(--text);
}

.subscription-drawer {
    position: fixed;
    inset: 0;
    z-index: 180;
    pointer-events: none;
}

.subscription-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 8, 15, 0.55);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.subscription-panel {
    position: absolute;
    inset: 0;
    max-height: 100dvh;
    background: var(--bg-card);
    border-top: none;
    border-radius: 0;
    padding: 10px 14px calc(14px + var(--safe-bottom));
    overflow-y: auto;
    transform: translateY(105%);
    transition: transform 0.24s ease, opacity 0.24s ease;
    box-shadow: none;
}

.subscription-drawer.open {
    pointer-events: auto;
}

.subscription-drawer.open .subscription-backdrop {
    opacity: 1;
}

.subscription-drawer.open .subscription-panel {
    transform: translateY(0);
}

.subscription-panel-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    position: sticky;
    top: -10px;
    background: linear-gradient(180deg, rgba(22,24,31,0.98) 0%, rgba(22,24,31,0.93) 100%);
    padding: 6px 0 8px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

.subscription-panel-header h3 {
    font-size: 1rem;
    line-height: 1.3;
    letter-spacing: -0.2px;
}

.subscription-panel-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-light);
    margin: 2px auto 8px;
}

.subscription-panel-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.subscription-panel-meta div {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.subscription-panel-meta strong {
    font-size: 0.85rem;
    line-height: 1.25;
}

.subscription-panel-meta-filters { grid-template-columns: 1fr; }

.subscription-filter-input {
    background: transparent;
    padding: 4px 0;
    appearance: none;
}

.subscription-panel-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.subscription-timeline h4 {
    font-size: 0.82rem;
    margin: 8px 0;
}

.timeline-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.timeline-row:last-child {
    border-bottom: none;
}

.timeline-main {
    min-width: 0;
    flex: 1;
}

.timeline-date {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.timeline-desc {
    font-size: 0.78rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.timeline-amount {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--red);
    white-space: nowrap;
}

.candidate-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 520px) {
    .candidate-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .candidate-actions {
        width: 100%;
        justify-content: space-between;
    }
}

/* ===== Banking ===== */

.accounts-list { display: flex; flex-direction: column; gap: 12px; }

.account-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}

.account-top { display: flex; align-items: center; gap: 12px; }

.account-bank-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-bg), var(--accent-glow));
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem; color: var(--accent-light); flex-shrink: 0;
    overflow: hidden;
}
.account-bank-logo { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.scope-pill-logo {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    object-fit: contain;
    background: #fff;
    margin-right: 6px;
    vertical-align: -2px;
}

.account-info { flex: 1; min-width: 0; }
.account-bank-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-iban { font-size: 0.68rem; color: var(--text-muted); font-family: 'SF Mono', monospace; }
.account-balance { font-size: 1.15rem; font-weight: 700; text-align: right; }
.account-actions { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.account-actions .btn { flex: 1; }
.account-sync-date { font-size: 0.65rem; color: var(--text-muted); text-align: center; }
.accounting-help { font-size: 0.75rem; margin-bottom: 10px; }
.accounting-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.accounting-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.accounting-panel {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
}
.accounting-panel h3 { font-size: 0.82rem; margin-bottom: 8px; }
.accounting-candidates-filters { margin-bottom: 8px; }
.accounting-list { max-height: 380px; overflow: auto; }
.accounting-draft-row .candidate-actions { flex-wrap: wrap; justify-content: flex-end; }

/* Banks grid */
.banks-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.bank-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 14px 16px; display: flex; align-items: center; gap: 14px;
    cursor: pointer; transition: all 0.15s ease; width: 100%; text-align: left;
    font-family: var(--font); color: var(--text);
}
.bank-card:hover { border-color: var(--accent); }

.bank-icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--bg-input); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: var(--text); flex-shrink: 0;
}

.bank-details { flex: 1; }
.bank-name { font-weight: 600; font-size: 0.85rem; }
.bank-country { font-size: 0.68rem; color: var(--text-muted); }
.bank-arrow { color: var(--text-muted); flex-shrink: 0; }

/* Empty */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; color: var(--accent-light); }
.empty-state h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 20px; max-width: 280px; margin-left: auto; margin-right: auto; }

/* ===== Auth Pages ===== */

.auth-page {
    min-height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg); padding: 24px 20px;
    position: relative; overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute; top: -120px; left: -80px;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(201,165,92,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.auth-container { width: 100%; max-width: 380px; position: relative; z-index: 1; }

.auth-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-xl); padding: 32px 24px;
}

.auth-header { text-align: center; margin-bottom: 28px; }

.logo { display: flex; align-items: center; gap: 10px; }

.logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, #c9a55c, #e8c97a, #b89350);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.15rem; color: #111;
}

.logo-text { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.5px; }

.auth-header .logo { justify-content: center; margin-bottom: 14px; }
.auth-subtitle { color: var(--text-secondary); font-size: 0.85rem; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); }

.input-wrapper {
    position: relative; display: flex; align-items: center;
}

.form-group input {
    padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg-input); color: var(--text); font-family: var(--font);
    font-size: 0.88rem; outline: none; width: 100%; transition: border-color 0.2s;
}

.form-group select {
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
    appearance: none;
}

.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.form-group input::placeholder { color: var(--text-muted); }

.input-wrapper input { padding-right: 42px; }

.toggle-password {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 2px; display: flex; align-items: center; justify-content: center;
}
.toggle-password:hover { color: var(--text-secondary); }

.auth-footer { text-align: center; margin-top: 22px; font-size: 0.82rem; color: var(--text-secondary); }

.auth-divider {
    display: flex; align-items: center; gap: 12px; margin-top: 20px;
    font-size: 0.72rem; color: var(--text-muted);
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

.btn-test {
    margin-top: 12px; width: 100%; padding: 11px;
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text-secondary); font-family: var(--font); font-size: 0.82rem;
    font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.btn-test:hover { border-color: var(--accent); color: var(--accent-light); background: var(--accent-bg); }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-header h2 { font-size: 0.92rem; font-weight: 600; }

/* ===== Users Management ===== */

.users-page { max-width: 1100px; margin: 0 auto; padding-bottom: 20px; }

.users-hero {
    margin-bottom: 14px;
    background:
        radial-gradient(120% 130% at 100% 0%, rgba(201,165,92,0.18) 0%, rgba(201,165,92,0.04) 40%, transparent 72%),
        linear-gradient(160deg, #181b25 0%, #12151d 100%);
}

.users-hero h2 { font-size: 1rem; margin-bottom: 4px; letter-spacing: -0.2px; }
.users-hero p { color: var(--text-secondary); font-size: 0.78rem; margin-bottom: 12px; }

.users-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.users-kpi {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(13,14,19,0.45);
    padding: 9px 10px;
}

.users-kpi span {
    display: block;
    color: var(--text-muted);
    font-size: 0.66rem;
    margin-bottom: 2px;
}

.users-kpi strong {
    font-size: 1rem;
    letter-spacing: -0.3px;
}

.users-layout { display: grid; gap: 12px; }
.users-create-card { margin-bottom: 0; order: 2; }
.users-list-card { margin-bottom: 0; order: 1; }
.users-helper { color: var(--text-secondary); font-size: 0.75rem; margin: -4px 0 12px; }

.users-list { display: flex; flex-direction: column; gap: 10px; }

.user-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    padding: 11px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-row.is-inactive {
    border-style: dashed;
    opacity: 0.9;
}

.user-row-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.user-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.dot-active { background: var(--green); box-shadow: 0 0 0 4px var(--green-bg); }
.dot-inactive { background: var(--red); box-shadow: 0 0 0 4px var(--red-bg); }

.user-main strong {
    font-size: 0.84rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.user-meta {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.user-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }

.role-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.role-form select,
.reset-form input {
    min-width: 0;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
}

.role-form select:focus,
.reset-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

.reset-box {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.reset-box summary {
    list-style: none;
    cursor: pointer;
    padding: 9px 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.reset-box summary::-webkit-details-marker { display: none; }

.reset-box[open] summary {
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.reset-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
}

.reset-form .input-wrapper input {
    padding-right: 52px;
}

.reset-form .toggle-password,
.users-create-card .toggle-password {
    right: 10px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.reset-form .toggle-password:hover,
.users-create-card .toggle-password:hover {
    color: var(--accent-light);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Onboarding ===== */

.onboarding-wrap { max-width: 760px; margin: 0 auto; padding-bottom: 20px; }

.onboarding-hero {
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    background:
        radial-gradient(120% 140% at 0% 0%, rgba(91,159,230,0.2) 0%, rgba(91,159,230,0.05) 38%, transparent 72%),
        linear-gradient(160deg, #181c27 0%, #12141c 100%);
}

.onboarding-step {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--accent-light);
    font-size: 0.66rem;
    margin-bottom: 8px;
    background: rgba(201,165,92,0.08);
}

.onboarding-hero h2 { font-size: 1.02rem; margin-bottom: 4px; letter-spacing: -0.3px; }
.onboarding-hero p { color: var(--text-secondary); font-size: 0.78rem; max-width: 56ch; }

.onboarding-form { margin-bottom: 0; }
.onboarding-grid { display: grid; gap: 14px; }
.onboarding-submit { margin-top: 8px; min-height: 46px; font-size: 0.9rem; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.kpi-card, .card, .account-card, .bank-card { animation: fadeIn 0.2s ease forwards; }
.kpi-card:nth-child(2) { animation-delay: 0.03s; }
.kpi-card:nth-child(3) { animation-delay: 0.06s; }
.kpi-card:nth-child(4) { animation-delay: 0.09s; }

/* ============= TABLET 600px+ ============= */
@media (min-width: 600px) {
    .banks-grid { grid-template-columns: 1fr 1fr; }
    .chart-container { height: 260px; }
    .analytics-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .subscription-panel-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .subscription-panel-meta-filters { grid-template-columns: 1fr 1fr; }
    .onboarding-grid { grid-template-columns: 1fr 1fr; }
    .user-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .audit-filters {
        grid-template-columns: 1.2fr 1fr 1fr;
    }
    .audit-filters .form-group:nth-child(4),
    .audit-filters .form-group:nth-child(5),
    .audit-filters-actions {
        grid-column: span 1;
    }
    .audit-summary { padding: 12px; }
    .forecast-projections { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .forecast-snapshot { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .forecast-form { grid-template-columns: 1fr 1fr; }
    .forecast-form .btn { grid-column: 1 / -1; justify-self: start; }
}

/* ============= DESKTOP 900px+ ============= */
@media (min-width: 900px) {
    :root { --sidebar-width: 240px; }
    .app-layout { flex-direction: row; padding-bottom: 0; }

    .sidebar {
        display: flex; flex-direction: column; width: var(--sidebar-width);
        background: var(--sidebar-bg); position: fixed; top: 0; left: 0; bottom: 0;
        z-index: 100; overflow: hidden; border-right: 1px solid var(--border);
    }
    .sidebar::before {
        content: ''; position: absolute; top: -50px; left: -50px;
        width: 300px; height: 220px;
        background: radial-gradient(ellipse at top left, rgba(201,165,92,0.12) 0%, transparent 70%);
        pointer-events: none; z-index: 0;
    }
    .sidebar > * { position: relative; z-index: 1; }
    .bottom-nav { display: none; }
    .main-content { margin-left: var(--sidebar-width); }
    .content { padding: 24px 28px; }
    .top-bar { padding: 16px 28px; border-bottom: 1px solid var(--border); }
    .flash-messages { padding: 12px 28px 0; }

    .sidebar-header { padding: 22px 20px; display: flex; align-items: center; }
    .sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
    .nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 14px; border-radius: var(--radius); color: var(--text-muted); font-size: 0.85rem; font-weight: 500; transition: all 0.15s; text-decoration: none; }
    .nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text-secondary); }
    .nav-item.active { background: var(--accent-bg); color: var(--accent-light); }
    .nav-item.active svg { stroke: var(--accent-light); }

    .sidebar-footer { padding: 14px 10px; border-top: 1px solid var(--border); }
    .user-menu {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: rgba(13, 14, 19, 0.45);
        margin-bottom: 6px;
        overflow: hidden;
    }
    .user-menu summary { list-style: none; cursor: pointer; }
    .user-menu summary::-webkit-details-marker { display: none; }
    .user-info { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: inherit; text-decoration: none; }
    .user-info:hover { background: rgba(255,255,255,0.04); }
    .user-menu-chevron {
        margin-left: auto;
        color: var(--text-muted);
        transition: transform 0.16s ease;
    }
    .user-menu[open] .user-menu-chevron { transform: rotate(180deg); }
    .user-menu-panel {
        padding: 6px;
        border-top: 1px solid var(--border);
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-light)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.78rem; color: #111; flex-shrink: 0; }
    .user-details { display: flex; flex-direction: column; overflow: hidden; }
    .user-company { font-size: 0.8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .user-email { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .logout-btn { color: var(--text-muted) !important; }
    .logout-btn:hover { color: var(--red) !important; background: var(--red-bg) !important; }
    .top-user-menu { display: none; }
    .mobile-more-panel { display: none !important; }
    .top-notif-btn { width: 34px; height: 34px; }

    .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
    .kpi-card { padding: 18px 20px; }
    .kpi-value { font-size: 1.5rem; }
    .kpi-icon { width: 34px; height: 34px; }
    .kpi-icon svg { width: 17px; height: 17px; }

    .charts-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
    .chart-container { height: 280px; }

    .table-wrapper { display: block; }
    .tx-list-mobile { display: none; }
    .data-table { width: 100%; border-collapse: collapse; }
    .data-table th { text-align: left; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); padding: 9px 14px; border-bottom: 1px solid var(--border); }
    .data-table td { padding: 12px 14px; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
    .data-table tbody tr:hover { background: var(--bg-card-hover); }
    .data-table tbody tr:last-child td { border-bottom: none; }
    .tx-description { display: flex; align-items: center; gap: 8px; font-weight: 500; }

    .analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
    .accounting-grid { grid-template-columns: 1fr 1fr; }
    .analytics-grid .full-width { grid-column: 1 / -1; }
    .forecast-card { padding: 20px; }
    .card { padding: 20px; margin-bottom: 20px; }
    .banks-grid { grid-template-columns: 1fr 1fr 1fr; }
    .analytics-hero { padding: 20px; margin-bottom: 20px; }
    .scope-switcher { margin-bottom: 18px; }
    .users-layout {
        grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.4fr);
        align-items: start;
        gap: 16px;
    }
    .users-create-card { order: 1; }
    .users-list-card { order: 2; }
    .users-hero h2 { font-size: 1.2rem; }
    .users-hero p { font-size: 0.82rem; max-width: 72ch; }
    .users-kpi strong { font-size: 1.2rem; }
    .user-row { padding: 13px; }
    .user-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .reset-box { grid-column: 1 / -1; }
    .audit-filters {
        grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr auto;
        align-items: end;
    }
    .audit-filters-actions {
        grid-template-columns: 1fr 1fr;
        min-width: 220px;
    }
    .audit-action { font-size: 0.85rem; }
    .audit-meta { font-size: 0.72rem; }
    .audit-details { font-size: 0.78rem; }

    .account-card { flex-direction: row; align-items: center; gap: 20px; padding: 18px 20px; }
    .account-top { flex: 1; }
    .account-actions { border-top: none; border-left: 1px solid var(--border); padding-top: 0; padding-left: 16px; flex-direction: column; }
    .account-actions .btn { flex: none; }
    .search-bar { max-width: 260px; flex: none; }
    .subscription-panel {
        inset: auto;
        left: auto;
        right: 28px;
        bottom: 28px;
        width: min(620px, calc(100vw - 320px));
        border-radius: var(--radius-lg);
        border-top: 1px solid var(--border-light);
        border: 1px solid var(--border-light);
        max-height: 78vh;
        transform: translateY(20px);
        opacity: 0;
        padding: 12px 16px 16px;
        box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.45);
    }
    .subscription-panel-header { top: -12px; }
    .subscription-panel-handle { display: none; }
    .subscription-drawer.open .subscription-panel {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (min-width: 1200px) {
    :root { --sidebar-width: 260px; }
    .content { padding: 28px 36px; }
    .kpi-value { font-size: 1.65rem; }
    .kpi-card { padding: 22px 24px; }
    .banks-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ======================== TRANSACTION DETAIL MODAL ======================== */
.tx-clickable { cursor: pointer; }
.tx-clickable:hover { background: var(--bg-card-hover); }
tr.tx-clickable:hover td { background: var(--bg-card-hover); }

.tx-modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
}
.tx-modal-overlay[aria-hidden="false"] { opacity: 1; pointer-events: auto; }

.tx-modal {
    width: 100%;
    max-height: 88vh; max-height: 88dvh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    transform: translateY(40px);
    transition: transform 0.28s cubic-bezier(0.22,1,0.36,1);
    -webkit-overflow-scrolling: touch;
}
.tx-modal-overlay[aria-hidden="false"] .tx-modal { transform: translateY(0); }

/* Handle bar (mobile) */
.tx-modal::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    margin: 10px auto 4px;
}

.tx-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg-card); z-index: 2;
}
.tx-modal-header h3 { font-size: 0.92rem; font-weight: 600; }
.tx-modal-close {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-muted); font-size: 1.1rem; cursor: pointer;
    transition: all 0.15s; flex-shrink: 0;
}
.tx-modal-close:hover { color: var(--text); border-color: var(--accent); }

.tx-modal-body { padding: 16px; padding-bottom: calc(16px + var(--safe-bottom, 0px)); }

.tx-modal-loading {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 40px 0; color: var(--text-muted); font-size: 0.85rem;
}
.tx-modal-spinner {
    width: 20px; height: 20px; border: 2px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: txSpin 0.6s linear infinite;
}
@keyframes txSpin { to { transform: rotate(360deg); } }

.tx-modal-summary { display: flex; flex-direction: column; gap: 8px; }
.tx-modal-row {
    display: flex; flex-direction: column; gap: 2px;
}
.tx-modal-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }
.tx-modal-value { font-size: 0.84rem; color: var(--text); word-break: break-word; line-height: 1.45; }
.tx-modal-desc { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; }
.tx-modal-amount { font-weight: 700; font-size: 1.15rem; }

.tx-modal-divider { height: 1px; background: var(--border); margin: 14px 0; }

.tx-modal-section { margin-bottom: 6px; }
.tx-modal-section-title {
    display: block; font-size: 0.72rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em;
}
.tx-modal-sublabel { display: block; font-size: 0.68rem; color: var(--text-muted); margin-bottom: 4px; }

.tx-modal-select {
    width: 100%; padding: 11px 12px;
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: var(--font); font-size: 0.82rem;
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b8fa3' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: border-color 0.15s;
}
.tx-modal-select:focus { border-color: var(--accent); outline: none; }
.tx-modal-select-sm { padding: 9px 10px; font-size: 0.78rem; }

.tx-modal-input {
    width: 100%; padding: 9px 10px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: var(--font); font-size: 0.82rem;
}
.tx-modal-input:focus { border-color: var(--accent); outline: none; }

.tx-modal-vat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.tx-modal-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tx-modal-att-item {
    position: relative; width: 64px; height: 64px;
    border-radius: var(--radius-sm); overflow: hidden;
    border: 1px solid var(--border); background: var(--bg-input);
}
.tx-modal-att-item img { width: 100%; height: 100%; object-fit: cover; }
.tx-modal-att-item .att-pdf {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; font-size: 0.6rem; color: var(--text-muted); text-align: center; padding: 4px;
}
.tx-modal-att-remove {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(0,0,0,0.7); color: #fff; border: none;
    font-size: 0.7rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 1;
}

.tx-modal-upload-zone {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 12px; border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm); cursor: pointer;
    color: var(--text-muted); font-size: 0.76rem;
    transition: all 0.15s;
}
.tx-modal-upload-zone:hover { border-color: var(--accent); color: var(--accent-light); background: var(--accent-bg); }
.tx-modal-upload-zone svg { flex-shrink: 0; width: 18px; height: 18px; }

.tx-modal-upload-progress { font-size: 0.75rem; color: var(--accent); padding: 6px 0; }

.tx-modal-actions {
    display: flex; gap: 10px; margin-top: 12px;
    padding-bottom: calc(4px + var(--safe-bottom, 0px));
}
.tx-modal-actions .btn { flex: 1; padding: 12px; font-size: 0.84rem; }

.tx-modal-toast {
    position: fixed; bottom: calc(24px + var(--safe-bottom, 0px)); left: 50%; transform: translateX(-50%);
    padding: 10px 20px; border-radius: var(--radius);
    background: var(--green); color: #111; font-size: 0.82rem; font-weight: 600;
    z-index: 300; opacity: 0; transition: opacity 0.3s;
    pointer-events: none; white-space: nowrap;
}
.tx-modal-toast.show { opacity: 1; }
.tx-modal-toast.error { background: var(--red); color: #fff; }

/* ---- Desktop: center modal ---- */
@media (min-width: 600px) {
    .tx-modal-overlay { align-items: center; }
    .tx-modal {
        max-width: 520px;
        border-radius: var(--radius-lg);
        border-bottom: 1px solid var(--border);
        max-height: 85vh;
    }
    .tx-modal::before { display: none; }
    .tx-modal-header { padding: 16px 24px; }
    .tx-modal-body { padding: 24px; padding-bottom: 24px; }
    .tx-modal-row { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 16px; }
    .tx-modal-label { min-width: 110px; }
    .tx-modal-value { text-align: right; }
    .tx-modal-desc { max-width: 320px; }
    .tx-modal-vat-grid { gap: 12px; }
    .tx-modal-att-item { width: 72px; height: 72px; }
    .tx-modal-att-remove { opacity: 0; }
    .tx-modal-att-item:hover .tx-modal-att-remove { opacity: 1; }
    .tx-modal-actions { padding-bottom: 0; }
}
