:root {
    --bg: #07080d;
    --bg-soft: #0f1017;
    --bg-card: rgba(18, 17, 28, 0.86);
    --bg-card-2: rgba(24, 22, 39, 0.95);
    --line: rgba(187, 128, 255, 0.2);
    --line-strong: rgba(187, 128, 255, 0.45);
    --text: #f4ecff;
    --muted: #bbaad6;
    --primary: #a14dff;
    --primary-2: #7e35da;
    --accent: #35d7cf;
    --danger: #ff5f86;
    --warn: #ffb347;
    --ok: #3ddc97;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
    --radius: 18px;
    --radius-lg: 24px;
    --nav-h: 74px;
    --font-main: "Segoe UI", "SF Pro Text", "Helvetica Neue", sans-serif;
    --font-display: "Trebuchet MS", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: radial-gradient(80vw 50vh at 8% -10%, rgba(161,77,255,0.18), transparent 65%),
                radial-gradient(60vw 50vh at 100% 20%, rgba(53,215,207,0.1), transparent 75%),
                var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    line-height: 1.35;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.agreement-body {
    padding-bottom: 24px;
}

.bg-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -2;
}
.bg-layer-a {
    background:
        radial-gradient(500px 280px at 0% 15%, rgba(138, 68, 255, 0.14), transparent 75%),
        radial-gradient(480px 300px at 95% 10%, rgba(77, 44, 156, 0.14), transparent 70%);
    opacity: 0.9;
}
.bg-layer-b {
    background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.25;
    z-index: -1;
}

a { color: #d7adff; text-decoration: none; }
a:hover { color: #ead4ff; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: linear-gradient(180deg, rgba(7,8,13,0.92), rgba(7,8,13,0.72));
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.brand img {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    filter: drop-shadow(0 8px 20px rgba(161, 77, 255, 0.35));
}
.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.brand-text strong {
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 0.02em;
    color: #f6edff;
}
.brand-text small {
    color: var(--muted);
    font-size: 0.73rem;
    white-space: nowrap;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-shell {
    width: min(1180px, calc(100% - 20px));
    margin: 14px auto 0;
}

.screen {
    display: grid;
    gap: 14px;
}

.loading-screen {
    min-height: 42svh;
    place-items: center;
    text-align: center;
    color: var(--muted);
}
.loader-glow {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background:
        conic-gradient(from 30deg, var(--primary), transparent 25%, var(--accent), transparent 55%, var(--primary));
    filter: blur(0.3px) drop-shadow(0 0 20px rgba(161,77,255,0.45));
    animation: spin 1.8s linear infinite;
    position: relative;
}
.loader-glow::after {
    content: "";
    position: absolute;
    inset: 11px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.06);
}
.loader-text { margin-top: -6px; font-size: 0.95rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel {
    background: linear-gradient(180deg, var(--bg-card), rgba(16, 16, 25, 0.86));
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
}
.panel.glass {
    background: linear-gradient(160deg, rgba(161,77,255,0.12), rgba(22,21,36,0.72));
    border-color: rgba(187, 128, 255, 0.2);
}

.hero {
    padding: 18px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(300px 120px at 0% 0%, rgba(161,77,255,0.25), transparent 70%),
        radial-gradient(240px 120px at 100% 20%, rgba(53,215,207,0.14), transparent 70%),
        linear-gradient(180deg, rgba(22,19,34,0.92), rgba(12,11,18,0.92));
    border: 1px solid rgba(187,128,255,0.18);
    box-shadow: 0 20px 60px rgba(6, 6, 11, 0.55);
}
.hero h1 {
    margin: 0;
    font-size: clamp(1.15rem, 4vw, 1.8rem);
    line-height: 1.15;
    font-family: var(--font-display);
}
.hero p {
    margin: 8px 0 0;
    color: var(--muted);
}
.hero-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}
.stat-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stat-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
    padding: 12px;
}
.stat-card small { display: block; color: var(--muted); font-size: 0.75rem; }
.stat-card strong { display: block; margin-top: 6px; font-size: 1.05rem; }

.grid {
    display: grid;
    gap: 14px;
}
.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.row.space { justify-content: space-between; }

.btn {
    appearance: none;
    border: 1px solid transparent;
    background: linear-gradient(180deg, #9c4cff, #752fd2);
    color: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 0.01em;
    box-shadow: 0 12px 30px rgba(126,53,218,0.3);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
    filter: grayscale(0.1);
}
.btn.ghost {
    background: rgba(255,255,255,0.02);
    border-color: rgba(255,255,255,0.08);
    color: var(--text);
    box-shadow: none;
}
.btn.outline {
    background: transparent;
    border-color: var(--line-strong);
    color: #efdfff;
    box-shadow: none;
}
.btn.danger {
    background: linear-gradient(180deg, #ff5f86, #cc345b);
    box-shadow: 0 12px 30px rgba(255,95,134,0.25);
}
.btn.success {
    background: linear-gradient(180deg, #36d88f, #1a9f64);
    box-shadow: 0 12px 30px rgba(54,216,143,0.22);
}
.btn.warn {
    background: linear-gradient(180deg, #ffbd57, #d9861f);
    box-shadow: 0 12px 30px rgba(255,189,87,0.22);
    color: #1b1206;
}
.btn.sm { padding: 8px 10px; font-size: 0.82rem; border-radius: 10px; }
.btn.block { width: 100%; justify-content: center; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: var(--muted);
}
.pill.ok { color: #bff4da; border-color: rgba(61,220,151,0.35); background: rgba(61,220,151,0.08); }
.pill.warn { color: #ffe4ba; border-color: rgba(255,179,71,0.35); background: rgba(255,179,71,0.08); }
.pill.danger { color: #ffd1dd; border-color: rgba(255,95,134,0.35); background: rgba(255,95,134,0.08); }
.pill.primary { color: #f0dcff; border-color: rgba(161,77,255,0.35); background: rgba(161,77,255,0.08); }

.muted { color: var(--muted); }
.tiny { font-size: 0.76rem; }
.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    padding: 3px 6px;
    border-radius: 8px;
    color: #f1ddff;
}

.form {
    display: grid;
    gap: 10px;
}
.field {
    display: grid;
    gap: 6px;
}
.field.inline {
    grid-template-columns: 1fr auto;
    align-items: end;
}
.label {
    font-size: 0.82rem;
    color: #d9cceb;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.input,
.textarea,
.select {
    width: 100%;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    color: var(--text);
    padding: 11px 12px;
    outline: none;
    font: inherit;
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.input::placeholder,
.textarea::placeholder { color: rgba(203, 189, 225, 0.45); }
.input:focus,
.textarea:focus,
.select:focus {
    border-color: rgba(161,77,255,0.5);
    box-shadow: 0 0 0 4px rgba(161,77,255,0.12);
    background: rgba(255,255,255,0.05);
}
.textarea {
    min-height: 110px;
    resize: vertical;
}
.select option { background: #11111a; color: #fff; }

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    cursor: pointer;
}
.check input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.tabs {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}
.tab-btn {
    appearance: none;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.02);
    color: var(--muted);
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
}
.tab-btn.active {
    color: #fff;
    border-color: rgba(161,77,255,0.5);
    background: rgba(161,77,255,0.12);
}

.card-list {
    display: grid;
    gap: 10px;
}
.deal-card,
.chat-card,
.ticket-card,
.case-card,
.tx-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
    padding: 12px;
    display: grid;
    gap: 8px;
}
.deal-card:hover,
.chat-card:hover,
.ticket-card:hover,
.case-card:hover { border-color: rgba(187,128,255,0.22); }

.deal-card .topline,
.chat-card .topline,
.case-card .topline {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: flex-start;
}
.title {
    font-weight: 700;
    color: #f3e7ff;
    margin: 0;
}
.subtitle {
    font-size: 0.8rem;
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 8px;
}

.deal-detail {
    display: grid;
    gap: 12px;
}
.deal-meta {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.kv {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 10px;
}
.kv small { color: var(--muted); display:block; font-size: 0.72rem; }
.kv strong { display:block; margin-top:4px; }

.chat-shell {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}
.chat-list {
    display: grid;
    gap: 8px;
    max-height: 52svh;
    overflow: auto;
    padding-right: 2px;
}
.chat-card.active {
    border-color: rgba(161,77,255,0.45);
    background: rgba(161,77,255,0.08);
}
.messages-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    min-height: 420px;
}
.messages-list {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
    padding: 10px;
    display: grid;
    gap: 8px;
    max-height: 52svh;
    overflow: auto;
}
.msg {
    display: grid;
    gap: 4px;
    max-width: min(92%, 560px);
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(255,255,255,0.02);
}
.msg.self {
    margin-left: auto;
    background: rgba(161,77,255,0.11);
    border-color: rgba(161,77,255,0.25);
}
.msg.system {
    margin-inline: auto;
    max-width: 100%;
    text-align: center;
    color: #d8c8f0;
    background: rgba(255,255,255,0.02);
}
.msg.flagged {
    border-color: rgba(255,95,134,0.25);
    background: rgba(255,95,134,0.06);
}
.msg-author {
    font-size: 0.72rem;
    color: var(--muted);
}
.msg-body {
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-meta {
    font-size: 0.68rem;
    color: rgba(191,182,206,0.8);
}

.timeline {
    display: grid;
    gap: 8px;
}
.timeline-item {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
}

.auth-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
}
.auth-card {
    padding: 14px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(19,18,30,0.9), rgba(12,11,18,0.9));
    border: 1px solid rgba(255,255,255,0.06);
}
.steps {
    display: grid;
    gap: 8px;
}
.step {
    display: grid;
    gap: 6px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    background: rgba(255,255,255,0.02);
}
.step.active {
    border-color: rgba(161,77,255,0.35);
    background: rgba(161,77,255,0.07);
}
.step.done {
    border-color: rgba(61,220,151,0.25);
    background: rgba(61,220,151,0.06);
}

.empty-state {
    padding: 18px;
    text-align: center;
    border-radius: 14px;
    border: 1px dashed rgba(255,255,255,0.08);
    color: var(--muted);
    background: rgba(255,255,255,0.02);
}

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

.mobile-nav {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    height: var(--nav-h);
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    align-items: center;
    padding: 8px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(18,17,29,0.94), rgba(11,10,16,0.94));
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 20px 40px rgba(0,0,0,.45);
    backdrop-filter: blur(12px);
}
.nav-btn {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--muted);
    display: grid;
    place-items: center;
    gap: 3px;
    font-size: 0.67rem;
    padding: 6px 4px;
    cursor: pointer;
    border-radius: 12px;
}
.nav-btn.active {
    color: #fff;
    background: rgba(161,77,255,0.1);
}
.nav-btn-plus {
    position: relative;
    transform: translateY(-14px);
}
.plus-ring {
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 25%, #d8b6ff, #9a45ff 40%, #6623c7 80%);
    box-shadow: 0 14px 30px rgba(154,69,255,.42);
    border: 4px solid rgba(8,8,12,0.95);
}
.plus-core {
    position: relative;
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
}

.icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    position: relative;
}
.icon::before, .icon::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 4px;
}
.icon-deals::before { border: 2px solid currentColor; inset: 1px; border-radius: 5px; }
.icon-deals::after {
    width: 10px; height: 2px; background: currentColor; left: 4px; top: 5px;
    box-shadow: 0 4px 0 currentColor, 0 8px 0 currentColor;
    border-radius: 999px;
}
.icon-chat::before { border: 2px solid currentColor; inset: 1px 1px 4px 1px; border-radius: 6px; }
.icon-chat::after {
    width: 6px; height: 6px; left: 5px; bottom: 0; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: skewX(-20deg);
}
.icon-profile::before { border: 2px solid currentColor; inset: 3px 4px auto 4px; height: 6px; border-radius: 999px; }
.icon-profile::after { border: 2px solid currentColor; inset: 9px 2px 1px 2px; border-radius: 8px 8px 5px 5px; }
.icon-support::before { border: 2px solid currentColor; inset: 1px; border-radius: 50%; }
.icon-support::after {
    width: 2px; height: 7px; background: currentColor; left: 8px; top: 4px; border-radius: 999px;
    box-shadow: 0 9px 0 currentColor;
}

.toast-stack {
    position: fixed;
    top: calc(70px + env(safe-area-inset-top));
    right: 10px;
    z-index: 120;
    display: grid;
    gap: 8px;
    max-width: min(92vw, 360px);
}
.toast {
    background: rgba(17,16,26,0.96);
    border: 1px solid rgba(255,255,255,0.08);
    border-left: 3px solid var(--primary);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 12px 34px rgba(0,0,0,.35);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }
.toast small { display:block; color: var(--muted); margin-top: 2px; }

.modal-root {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 14px;
    background: rgba(4,4,8,0.66);
    backdrop-filter: blur(8px);
}
.modal-root[hidden] {
    display: none !important;
}
.modal {
    width: min(680px, 100%);
    max-height: 88svh;
    overflow: auto;
    background: linear-gradient(180deg, rgba(20,18,32,0.98), rgba(11,10,16,0.98));
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,.5);
    padding: 14px;
}

.site-footer {
    width: min(1180px, calc(100% - 20px));
    margin: 18px auto 0;
    padding: 12px 4px calc(6px + env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.78rem;
}

.agreement-page {
    width: min(980px, calc(100% - 20px));
    margin: 14px auto;
    display: grid;
    gap: 14px;
}
.agreement-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.agreement-page h1 { margin: 0; font-size: clamp(1.1rem, 3vw, 1.6rem); }
.agreement-page h2 { margin: 0 0 8px; font-size: 1.02rem; }
.agreement-page p { margin: 0; color: #e0d2f2; }
.agreement-page .panel { display: grid; gap: 10px; }
.list { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: #e0d2f2; }
.agreement-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.8rem;
    padding: 4px 2px 12px;
}

.desktop-only { display: none; }

@media (min-width: 760px) {
    .app-shell { margin-top: 18px; }
    .hero-grid { grid-template-columns: 1.3fr 1fr; align-items: start; }
    .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .split { grid-template-columns: 1.1fr 0.9fr; }
    .chat-shell { grid-template-columns: 350px 1fr; }
    .messages-panel { min-height: 520px; }
    .mobile-nav { left: 50%; right: auto; width: min(680px, calc(100% - 32px)); transform: translateX(-50%); }
}

@media (min-width: 1024px) {
    .desktop-only { display: initial; }
    .topbar { padding-left: 20px; padding-right: 20px; }
    .panel, .hero { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
    .loader-glow { animation: none; }
    .btn, .input, .textarea, .select { transition: none; }
}
