:root {
    --bg: var(--tg-theme-bg-color, #0b0d12);
    --surface: var(--tg-theme-secondary-bg-color, #151820);
    --surface-2: #1b1f29;
    --text: var(--tg-theme-text-color, #f7f8fa);
    --muted: var(--tg-theme-hint-color, #8d94a3);
    --accent: var(--tg-theme-button-color, #7c5cff);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);

    --border: rgba(255, 255, 255, 0.08);

    --positive: #49d17d;
    --warning: #ffb84d;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Display",
        "Segoe UI",
        sans-serif;
}

body {
    padding:
        env(safe-area-inset-top)
        0
        env(safe-area-inset-bottom);
}

button {
    font: inherit;
}

.app-shell {
    max-width: 520px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px 18px 104px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 30px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-mark {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    border-radius: 14px;

    background:
        linear-gradient(
            135deg,
            #7657ff,
            #9a7bff
        );

    color: white;
    font-weight: 800;
    font-size: 20px;

    box-shadow:
        0 8px 25px rgba(124, 92, 255, 0.35);
}

.brand-name {
    font-weight: 800;
    letter-spacing: 0.04em;
    font-size: 18px;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 11px;
    margin-top: 2px;
}

.status-dot {
    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: var(--warning);

    box-shadow:
        0 0 0 5px rgba(255, 184, 77, 0.10);
}

.status-dot.online {
    background: var(--positive);

    box-shadow:
        0 0 0 5px rgba(73, 209, 125, 0.10);
}

.greeting {
    margin-bottom: 18px;
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;

    letter-spacing: 0.16em;

    color: var(--muted);

    margin-bottom: 7px;
}

h1 {
    margin: 0;

    font-size: 28px;
    line-height: 1.12;

    letter-spacing: -0.03em;
}

.greeting p {
    margin: 8px 0 0;

    color: var(--muted);

    line-height: 1.45;
    font-size: 14px;
}

.hero-card {
    position: relative;
    overflow: hidden;

    padding: 24px;

    border-radius: 26px;

    background:
        radial-gradient(
            circle at 100% 0%,
            rgba(255, 255, 255, 0.20),
            transparent 36%
        ),
        linear-gradient(
            135deg,
            #6846ff,
            #8a6cff
        );

    color: white;

    box-shadow:
        0 18px 50px rgba(92, 61, 255, 0.24);

    margin-bottom: 14px;
}

.hero-label {
    font-size: 13px;
    opacity: 0.80;
}

.hero-value {
    margin-top: 7px;

    font-size: 39px;
    font-weight: 800;

    letter-spacing: -0.05em;
}

.hero-divider {
    height: 1px;

    background:
        rgba(255, 255, 255, 0.18);

    margin: 21px 0 17px;
}

.hero-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.small-label {
    color: var(--muted);

    font-size: 11px;

    margin-bottom: 5px;
}

.hero-card .small-label {
    color:
        rgba(255, 255, 255, 0.65);
}

.small-value {
    font-size: 17px;
    font-weight: 700;
}

.hero-badge {
    font-size: 10px;
    font-weight: 700;

    padding: 7px 10px;

    border:
        1px solid rgba(255, 255, 255, 0.20);

    border-radius: 100px;

    background:
        rgba(255, 255, 255, 0.10);
}

.grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 12px;

    margin-bottom: 12px;
}

.info-card,
.mission-card,
.flow-card,
.system-message {
    border:
        1px solid var(--border);

    background:
        var(--surface);

    border-radius: 22px;
}

.info-card {
    padding: 18px;
    min-height: 150px;
}

.card-icon {
    margin-bottom: 17px;
    font-size: 21px;
}

.card-label {
    color: var(--muted);

    font-size: 11px;

    margin-bottom: 6px;
}

.card-value {
    font-size: 21px;
    font-weight: 750;

    letter-spacing: -0.03em;
}

.card-detail {
    color: var(--muted);

    margin-top: 6px;

    font-size: 11px;
    line-height: 1.35;
}

.mission-card {
    padding: 20px;

    margin-bottom: 12px;
}

.mission-header {
    display: flex;
    gap: 13px;
    align-items: center;
}

.mission-icon {
    width: 43px;
    height: 43px;

    display: grid;
    place-items: center;

    border-radius: 14px;

    background:
        rgba(124, 92, 255, 0.14);
}

.mission-title {
    font-size: 15px;
    font-weight: 700;
}

.mission-text {
    margin:
        17px 0 0;

    line-height: 1.52;

    font-size: 14px;
}

.flow-card {
    padding: 20px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;

    margin-bottom: 19px;
}

.flow-row {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 10px;
}

.flow-value {
    font-size: 15px;
    font-weight: 700;

    white-space: nowrap;
}

.system-message {
    margin-top: 12px;

    padding: 17px;

    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.system-icon {
    font-size: 20px;
}

.system-title {
    font-weight: 700;
    font-size: 14px;
}

.system-text {
    color: var(--muted);

    font-size: 12px;
    line-height: 1.45;

    margin-top: 4px;
}

.hidden {
    display: none !important;
}

.bottom-nav {
    position: fixed;

    left: 50%;
    bottom:
        max(
            12px,
            env(safe-area-inset-bottom)
        );

    transform:
        translateX(-50%);

    width:
        min(
            calc(100% - 24px),
            496px
        );

    height: 72px;

    display: grid;

    grid-template-columns:
        1fr 1fr 70px 1fr 1fr;

    align-items: center;

    padding: 6px 10px;

    background:
        rgba(23, 26, 34, 0.94);

    border:
        1px solid var(--border);

    border-radius: 24px;

    backdrop-filter:
        blur(22px);

    -webkit-backdrop-filter:
        blur(22px);

    box-shadow:
        0 18px 55px rgba(0, 0, 0, 0.25);
}

.nav-item,
.nav-main {
    border: 0;
    color: var(--muted);
    background: transparent;

    cursor: default;
}

.nav-item {
    display: flex;
    flex-direction: column;

    gap: 4px;

    align-items: center;
    justify-content: center;
}

.nav-item span {
    font-size: 18px;
}

.nav-item small {
    font-size: 9px;
}

.nav-item.active {
    color: var(--text);
}

.nav-main {
    width: 54px;
    height: 54px;

    margin: 0 auto;

    border-radius: 18px;

    background:
        linear-gradient(
            135deg,
            #6846ff,
            #967aff
        );

    color: white;

    font-size: 24px;

    box-shadow:
        0 10px 30px rgba(124, 92, 255, 0.35);
}

@media (max-width: 370px) {

    .hero-value {
        font-size: 34px;
    }

    .card-value {
        font-size: 18px;
    }

    .flow-value {
        font-size: 13px;
    }

}

/* =========================================================
   AQSHA v0.12 Navigation
   ========================================================= */

.app-shell {
    padding-bottom:
        calc(
            138px
            + env(safe-area-inset-bottom)
        );
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.page-heading {
    margin-bottom: 22px;
}

.page-heading h1 {
    margin-bottom: 8px;
}

.page-heading p {
    margin: 0;

    color: var(--muted);

    font-size: 14px;
    line-height: 1.5;
}

.summary-card,
.panel-card,
.metric-card,
.ai-orb-card,
.security-note {
    border:
        1px solid var(--border);

    background:
        var(--surface);

    border-radius: 22px;
}

.summary-card {
    padding: 22px;

    margin-bottom: 24px;
}

.summary-value {
    font-size: 36px;

    font-weight: 800;

    letter-spacing: -0.04em;
}

.list-stack {
    display: flex;

    flex-direction: column;

    gap: 10px;
}

.list-row {
    padding: 16px;

    border:
        1px solid var(--border);

    border-radius: 18px;

    background:
        var(--surface);
}

.list-row-top {
    display: flex;

    justify-content: space-between;

    gap: 12px;

    align-items: center;
}

.list-title {
    font-size: 14px;

    font-weight: 700;
}

.list-amount {
    font-size: 16px;

    font-weight: 750;
}

.list-meta {
    color: var(--muted);

    margin-top: 6px;

    font-size: 11px;
}

.loading-row {
    color: var(--muted);

    padding: 16px 2px;

    font-size: 13px;
}

.analytics-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 12px;

    margin-bottom: 12px;
}

.metric-card {
    padding: 18px;
}

.metric-value {
    font-size: 20px;

    font-weight: 750;

    letter-spacing: -0.03em;
}

.panel-card {
    padding: 20px;

    margin-bottom: 12px;
}

.ai-orb-card {
    padding: 28px 22px;

    text-align: center;
}

.ai-orb {
    width: 88px;
    height: 88px;

    margin:
        4px auto 20px;

    display: grid;

    place-items: center;

    border-radius: 30px;

    color: white;

    font-size: 42px;

    background:
        linear-gradient(
            135deg,
            #6544ff,
            #987cff
        );

    box-shadow:
        0 18px 45px
        rgba(124, 92, 255, 0.28);
}

.ai-orb-card h2 {
    margin:
        0 0 8px;
}

.ai-orb-card > p {
    color: var(--muted);
}

.prompt-chip {
    text-align: left;

    padding: 13px 14px;

    margin-top: 9px;

    border-radius: 15px;

    background:
        rgba(124, 92, 255, 0.09);

    font-size: 12px;

    line-height: 1.4;
}

.primary-button {
    width: 100%;

    margin-top: 22px;

    padding: 15px;

    border: 0;

    border-radius: 16px;

    background:
        linear-gradient(
            135deg,
            #6846ff,
            #9275ff
        );

    color: white;

    font-weight: 700;

    cursor: pointer;
}

.profile-header {
    text-align: center;

    padding:
        16px 0 26px;
}

.profile-avatar {
    width: 86px;
    height: 86px;

    display: grid;

    place-items: center;

    margin:
        0 auto 16px;

    border-radius: 28px;

    color: white;

    font-size: 32px;

    font-weight: 800;

    background:
        linear-gradient(
            135deg,
            #6544ff,
            #987cff
        );
}

.profile-header h1 {
    margin-bottom: 5px;
}

.profile-username {
    color: var(--muted);

    font-size: 13px;
}

.profile-row {
    display: flex;

    justify-content: space-between;

    gap: 16px;

    padding:
        14px 0;

    border-bottom:
        1px solid var(--border);

    font-size: 13px;
}

.profile-row:last-child {
    border-bottom: 0;
}

.profile-row span {
    color: var(--muted);
}

.profile-row strong {
    text-align: right;
}

.positive {
    color: var(--positive);
}

.security-note {
    padding: 16px;

    color: var(--muted);

    font-size: 12px;

    line-height: 1.5;
}

.bottom-nav {
    z-index: 100;
}

.nav-item,
.nav-main {
    cursor: pointer;

    -webkit-tap-highlight-color:
        transparent;
}

.nav-item.active {
    color: var(--text);
}

.nav-main.active {
    outline:
        3px solid
        rgba(124, 92, 255, 0.18);
}

@media (max-width: 370px) {

    .summary-value {
        font-size: 31px;
    }

    .metric-value {
        font-size: 17px;
    }

}

/* =========================================================
   AQSHA v0.13B AI Chat
   ========================================================= */

.ai-chat-card {
    border:
        1px solid var(--border);

    background:
        var(--surface);

    border-radius: 24px;

    padding: 16px;

    margin-bottom: 16px;
}

.ai-chat-log {
    display: flex;

    flex-direction: column;

    gap: 14px;

    min-height: 260px;

    max-height: 48vh;

    overflow-y: auto;

    padding:
        4px 2px 12px;

    scroll-behavior: smooth;
}

.chat-message {
    display: flex;

    align-items: flex-end;

    gap: 9px;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.user .chat-avatar {
    display: none;
}

.chat-avatar {
    flex:
        0 0 34px;

    width: 34px;
    height: 34px;

    display: grid;

    place-items: center;

    border-radius: 12px;

    color: white;

    background:
        linear-gradient(
            135deg,
            #6544ff,
            #987cff
        );
}

.chat-bubble {
    max-width: 82%;

    padding:
        12px 14px;

    border-radius:
        17px 17px 17px 5px;

    background:
        var(--surface-2);

    font-size: 13px;

    line-height: 1.45;
}

.chat-message.user .chat-bubble {
    color: white;

    background:
        linear-gradient(
            135deg,
            #6846ff,
            #8d6fff
        );

    border-radius:
        17px 17px 5px 17px;
}

.chat-bubble strong {
    display: block;

    margin-bottom: 4px;

    font-size: 12px;
}

.chat-bubble p {
    margin: 0;
}

.chat-facts {
    margin-top: 10px;

    padding-top: 9px;

    border-top:
        1px solid var(--border);

    color: var(--muted);

    font-size: 11px;

    line-height: 1.45;
}

.chat-facts div + div {
    margin-top: 4px;
}

.chat-message.typing
.chat-bubble {
    color: var(--muted);
}

.quick-prompts {
    display: flex;

    gap: 8px;

    overflow-x: auto;

    padding:
        5px 0 12px;

    scrollbar-width: none;
}

.quick-prompts::-webkit-scrollbar {
    display: none;
}

.quick-prompts .prompt-chip {
    flex:
        0 0 auto;

    margin: 0;

    border: 0;

    color: var(--text);

    cursor: pointer;

    white-space: nowrap;
}

.ai-composer {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        48px;

    gap: 9px;

    align-items: end;

    padding-top: 12px;

    border-top:
        1px solid var(--border);
}

.ai-composer textarea {
    width: 100%;

    min-height: 48px;

    max-height: 130px;

    resize: none;

    border:
        1px solid var(--border);

    border-radius: 16px;

    outline: none;

    padding:
        13px 14px;

    background:
        var(--bg);

    color: var(--text);

    font: inherit;

    font-size: 14px;

    line-height: 1.4;
}

.ai-composer textarea::placeholder {
    color: var(--muted);
}

.ai-composer textarea:focus {
    border-color:
        rgba(124, 92, 255, 0.65);
}

.ai-send-button {
    width: 48px;
    height: 48px;

    border: 0;

    border-radius: 16px;

    color: white;

    background:
        linear-gradient(
            135deg,
            #6846ff,
            #9477ff
        );

    font-size: 20px;

    cursor: pointer;

    box-shadow:
        0 8px 24px
        rgba(124, 92, 255, 0.25);
}

.ai-send-button:disabled {
    opacity: 0.45;

    cursor: default;
}

.ai-hint {
    margin-top: 9px;

    color: var(--muted);

    text-align: center;

    font-size: 10px;
}

.ai-update-warning {
    color: var(--warning);
}

/* =========================================================
   AQSHA v0.13B.1 Telegram Theme Fix
   ========================================================= */

.chat-message.assistant .chat-bubble {
    background:
        var(
            --tg-theme-secondary-bg-color,
            #1b1f29
        );

    color:
        var(
            --tg-theme-text-color,
            #f7f8fa
        );
}

.chat-message.assistant .chat-bubble strong {
    color:
        var(
            --tg-theme-text-color,
            #f7f8fa
        );
}

.chat-message.assistant .chat-facts {
    color:
        var(
            --tg-theme-hint-color,
            #8d94a3
        );
}

.chat-message.user .chat-bubble {
    color: #ffffff;
}

/* =========================================================
   AQSHA v0.13B.2 Chat polish
   ========================================================= */

.ai-chat-log {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ai-chat-log::-webkit-scrollbar {
    display: none;
}

.chat-message.assistant {
    align-items: flex-start;
}

/* =========================================================
   AQSHA v0.13B.3 — Proper AI viewport architecture
   Outer page locked, chat log scrolls internally
   ========================================================= */

html.ai-mode,
html.ai-mode body {
    height: 100%;
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.ai-mode {
    position: fixed;
    inset: 0;
    width: 100%;
}

body.ai-mode .app-shell {
    height:
        var(
            --tg-viewport-height,
            100dvh
        );

    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    padding-bottom:
        calc(
            92px
            + env(safe-area-inset-bottom)
        );
}

body.ai-mode .topbar {
    flex: 0 0 auto;
    margin-bottom: 20px;
}

body.ai-mode main {
    flex: 1 1 auto;

    min-height: 0;

    overflow: hidden;
}

body.ai-mode #view-ai.active {
    height: 100%;

    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;
}

body.ai-mode #view-ai .page-heading {
    flex: 0 0 auto;

    margin-bottom: 14px;
}

body.ai-mode #view-ai .page-heading h1 {
    font-size: clamp(
        29px,
        7vw,
        38px
    );

    line-height: 1.05;
}

body.ai-mode #view-ai .page-heading p {
    margin-top: 8px;

    line-height: 1.35;
}

body.ai-mode .ai-chat-card {
    flex: 1 1 auto;

    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    margin-bottom: 0;
}

body.ai-mode .ai-chat-log {
    flex: 1 1 auto;

    min-height: 0;
    max-height: none;

    overflow-y: auto;

    overscroll-behavior: contain;

    -webkit-overflow-scrolling: touch;
}

body.ai-mode .quick-prompts,
body.ai-mode .ai-composer,
body.ai-mode .ai-hint {
    flex: 0 0 auto;
}

/* =========================================================
   AQSHA v0.13C Voice
   ========================================================= */

.ai-composer {
    grid-template-columns:
        minmax(0, 1fr)
        48px
        48px;
}

.ai-voice-button {
    width: 48px;
    height: 48px;

    border: 0;

    border-radius: 16px;

    background:
        rgba(
            124,
            92,
            255,
            0.12
        );

    color: var(--text);

    font-size: 20px;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        background 0.15s ease;
}

.ai-voice-button.recording {
    color: white;

    background:
        #ef4444;

    transform:
        scale(1.04);

    animation:
        aqsha-recording-pulse
        1.2s
        infinite;
}

.ai-voice-button:disabled {
    opacity: 0.45;
}

@keyframes aqsha-recording-pulse {

    0% {
        box-shadow:
            0 0 0 0
            rgba(
                239,
                68,
                68,
                0.35
            );
    }

    70% {
        box-shadow:
            0 0 0 10px
            rgba(
                239,
                68,
                68,
                0
            );
    }

    100% {
        box-shadow:
            0 0 0 0
            rgba(
                239,
                68,
                68,
                0
            );
    }

}

.ai-hint.recording {
    color: #ef4444;
    font-weight: 600;
}

/* =========================================================
   AQSHA v0.14B — Financial Confirmation
   ========================================================= */

.financial-proposal {
    margin-top: 12px;
}

.financial-proposal-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.financial-proposal-item {
    padding: 10px 11px;

    border-radius: 13px;

    background:
        rgba(
            124,
            92,
            255,
            0.10
        );

    font-size: 12px;

    line-height: 1.4;
}

.financial-proposal-warning {
    margin-top: 10px;

    color:
        var(
            --tg-theme-hint-color,
            var(--muted)
        );

    font-size: 11px;

    line-height: 1.4;
}

.financial-proposal-status {
    margin-top: 9px;

    font-size: 12px;

    font-weight: 700;
}

.financial-proposal-status.saved {
    color: #22c55e;
}

.financial-proposal-status.cancelled {
    color: var(--muted);
}

.financial-proposal-status.edited {
    color: #f59e0b;
}

.financial-proposal-actions {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 8px;

    margin-top: 12px;
}

.proposal-button {
    min-height: 42px;

    border: 0;

    border-radius: 13px;

    padding:
        9px 10px;

    font: inherit;

    font-size: 12px;

    font-weight: 700;

    cursor: pointer;

    -webkit-tap-highlight-color:
        transparent;
}

.proposal-button.save {
    grid-column:
        1 / -1;

    color: white;

    background:
        linear-gradient(
            135deg,
            #6846ff,
            #8d6fff
        );
}

.proposal-button.edit {
    color: var(--text);

    background:
        rgba(
            124,
            92,
            255,
            0.12
        );
}

.proposal-button.cancel {
    color: #ef4444;

    background:
        rgba(
            239,
            68,
            68,
            0.10
        );
}

.proposal-button:disabled {
    opacity: 0.45;

    cursor: default;
}


