:root {
    --bg: #f3f7fb;
    --bg-deep: #0f1720;
    --panel: #ffffff;
    --panel-strong: #ffffff;
    --line: #dbe7f2;
    --text: #0f1720;
    --muted: #5f7487;
    --accent: #229ed9;
    --accent-strong: #168ac0;
    --accent-soft: rgba(34, 158, 217, 0.12);
    --danger: #d95763;
    --shadow: 0 16px 40px rgba(15, 23, 32, 0.08);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --font-ui: "Bahnschrift", "Segoe UI Variable", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(34, 158, 217, 0.16), transparent 34%),
        radial-gradient(circle at bottom right, rgba(15, 23, 32, 0.08), transparent 30%),
        var(--bg);
}

body {
    min-height: 100svh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 20px;
}

.noise {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.32), transparent 42%);
    opacity: 0.45;
}

.auth-screen,
.dashboard {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
}

.auth-screen {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    gap: 20px;
}

.hero-card,
.auth-card,
.panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.hero-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 36px;
    background:
        linear-gradient(140deg, rgba(34, 158, 217, 0.98), rgba(16, 33, 48, 0.98)),
        var(--bg-deep);
    color: #eef3ef;
}

.hero-copy h1,
.topbar h1,
.panel-head h2 {
    margin: 0;
    line-height: 0.98;
    letter-spacing: -0.04em;
}

.hero-copy h1 {
    font-size: clamp(2.8rem, 5vw, 5.4rem);
}

.hero-copy p {
    max-width: 48ch;
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(238, 243, 239, 0.8);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: inherit;
    opacity: 0.76;
    margin-bottom: 12px;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.hero-stats article {
    padding: 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.hero-stats strong,
.guide-grid strong {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.hero-stats span,
.guide-grid p {
    color: rgba(238, 243, 239, 0.78);
    line-height: 1.45;
}

.auth-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tabs {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 8px;
    padding: 8px;
    border-radius: 999px;
    background: #eaf4fb;
    border: 1px solid #d5e7f5;
}

.mobile-tabs {
    display: none;
}

.tab-button {
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 12px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: 180ms ease;
}

.tab-button.is-active {
    background: var(--accent);
    color: #f9fcff;
}

.tab-panel,
.panel {
    display: none;
}

.tab-panel.is-active,
.panel.is-active,
.auth-tabs + .flash + .tab-panel.is-active,
.auth-tabs + .tab-panel.is-active {
    display: block;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.first-field {
    margin-top: 12px;
}

.stack-form.compact {
    margin-bottom: 18px;
}

.stack-form label,
.toggle-row,
.filter-inline,
.trusted-sources-block {
    display: grid;
    gap: 8px;
}

.stack-form span,
.toggle-row span,
.filter-inline span,
.trusted-sources-head span,
dt,
.log-preview span {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-strong);
    color: var(--text);
    padding: 14px 16px;
    outline: none;
}

input:focus,
select:focus {
    border-color: rgba(34, 158, 217, 0.48);
    box-shadow: 0 0 0 4px rgba(34, 158, 217, 0.12);
}

.toggle-row {
    grid-template-columns: auto 1fr;
    align-items: center;
}

.toggle-row input {
    inline-size: 18px;
    block-size: 18px;
}

.trusted-sources-head,
.trusted-source-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.trusted-sources-list {
    display: grid;
    gap: 8px;
    max-height: 188px;
    overflow: auto;
    padding-right: 2px;
}

.field-note {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.86rem;
}

.icon-button,
.remove-source-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 42px;
    block-size: 42px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #edf4fa;
    color: var(--text);
    cursor: pointer;
}

.primary-button,
.ghost-button,
.danger-button,
.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    transition: 180ms ease;
}

.primary-button {
    background: var(--accent);
    color: #fff;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.ghost-button,
.ghost-link {
    background: #edf4fa;
    color: var(--text);
}

.danger-button {
    background: rgba(185, 79, 67, 0.12);
    color: var(--danger);
}

.form-actions,
.card-actions,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.flash {
    margin: 16px 0;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(34, 158, 217, 0.1);
    border-color: rgba(34, 158, 217, 0.16);
}

.flash-error {
    background: rgba(185, 79, 67, 0.1);
    border-color: rgba(185, 79, 67, 0.16);
}

.dashboard {
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 16px;
}

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

.topbar h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
}

.profile-chip {
    padding: 12px 16px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #dbe7f2;
    display: grid;
}

.profile-chip small {
    color: var(--muted);
}

.workspace {
    display: grid;
    grid-template-columns: 1.02fr 1.08fr 0.9fr;
    gap: 16px;
    min-height: 0;
}

.panel {
    min-height: 0;
    padding: 22px;
}

.workspace .panel {
    display: flex;
    flex-direction: column;
}

.panel-head,
.bot-card-head,
.log-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.panel-head {
    margin-bottom: 18px;
}

.panel-head h2 {
    font-size: 1.65rem;
}

.panel-metric {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(34, 158, 217, 0.1);
    color: var(--accent);
}

.card-list,
.log-list {
    display: grid;
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-right: 2px;
}

.bot-card,
.log-card,
.empty-card,
.guide-grid article,
.system-note {
    border-radius: var(--radius-lg);
    background: #ffffff;
    border: 1px solid var(--line);
    padding: 16px;
}

.bot-card h3,
.empty-card h3,
.guide-grid h3 {
    margin: 0;
}

.bot-card dl {
    margin: 12px 0 0;
    display: grid;
    gap: 10px;
}

.bot-card dl div {
    display: grid;
    gap: 4px;
}

dt {
    margin: 0;
}

dd,
.log-preview p,
.system-note p,
.empty-card p,
.guide-grid p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
    word-break: break-word;
}

.mono {
    font-family: Consolas, "SFMono-Regular", monospace;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-chip,
.delivery-state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.status-chip.ok,
.delivery-state.success {
    background: rgba(34, 158, 217, 0.12);
    color: var(--accent);
}

.status-chip.off,
.delivery-state.error {
    background: rgba(185, 79, 67, 0.12);
    color: var(--danger);
}

.delivery-state.idle {
    background: rgba(15, 23, 32, 0.08);
    color: var(--muted);
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.pager > div {
    display: flex;
    gap: 8px;
}

.pager a {
    padding: 10px 14px;
    border-radius: 12px;
    background: #edf4fa;
}

.pager a.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.log-card {
    display: grid;
    gap: 10px;
}

.log-card.level-error {
    border-color: rgba(185, 79, 67, 0.22);
}

.log-card.level-info {
    border-color: rgba(34, 158, 217, 0.18);
}

.log-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.log-meta span {
    padding: 6px 10px;
    border-radius: 999px;
    background: #eff6fb;
    color: var(--muted);
    font-size: 0.78rem;
}

.log-preview {
    display: grid;
    gap: 10px;
}

.guide-grid {
    display: grid;
    gap: 12px;
    flex: 1;
}

.guide-grid article {
    background:
        linear-gradient(135deg, rgba(234,244,251,0.9), rgba(255,255,255,1)),
        #ffffff;
}

.guide-grid strong {
    color: var(--accent);
}

.system-note {
    margin-top: 12px;
}

@media (max-width: 1220px) {
    .auth-screen,
    .workspace {
        grid-template-columns: 1fr;
    }

    .hero-card {
        min-height: 0;
    }

    .mobile-tabs {
        display: inline-grid;
        justify-self: start;
    }

    .workspace .panel {
        display: none;
    }

    .workspace .panel.is-active {
        display: flex;
    }
}

@media (max-width: 860px) {
    .app-shell {
        padding: 12px;
    }

    .hero-card,
    .auth-card,
    .panel {
        border-radius: 22px;
        padding: 18px;
    }

    .hero-copy h1 {
        max-width: none;
        font-size: clamp(2.2rem, 10vw, 3.3rem);
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .topbar,
    .topbar-actions,
    .form-actions,
    .card-actions,
    .panel-head,
    .bot-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .trusted-sources-head,
    .trusted-source-row {
        grid-template-columns: 1fr;
    }

    .dashboard {
        grid-template-rows: auto auto auto 1fr;
    }

    .panel-head {
        margin-bottom: 12px;
    }

    .pager,
    .pager > div {
        flex-direction: column;
        align-items: stretch;
    }
}
