:root {
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --ink: #132036;
    --muted: #607089;
    --primary: #0f9d8f;
    --primary-deep: #0a7f74;
    --accent: #f8c45f;
    --danger: #dc4e47;
    --shadow: 0 20px 45px rgba(7, 21, 53, 0.08);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --line: #dde5ee;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: Manrope, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(700px 420px at 5% 0%, rgba(15, 157, 143, 0.12), transparent 60%),
        radial-gradient(650px 420px at 95% 10%, rgba(248, 196, 95, 0.17), transparent 60%),
        var(--bg);
    position: relative;
}

.background-glow {
    position: fixed;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    z-index: -1;
}

.background-glow-a {
    background: rgba(15, 157, 143, 0.35);
    top: -100px;
    left: -80px;
}

.background-glow-b {
    background: rgba(248, 196, 95, 0.45);
    right: -100px;
    top: 140px;
}

.container {
    width: min(1200px, calc(100vw - 32px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    backdrop-filter: blur(10px);
    background: rgba(244, 247, 251, 0.8);
    border-bottom: 1px solid rgba(19, 32, 54, 0.06);
    z-index: 20;
}

.header-row {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #5ac3a0);
    color: #fff;
    font-family: Unbounded, sans-serif;
    font-size: 17px;
    box-shadow: 0 10px 20px rgba(15, 157, 143, 0.25);
}

.brand-text {
    font-family: Unbounded, sans-serif;
    font-size: 18px;
    color: var(--ink);
}

.main-nav {
    display: flex;
    gap: 10px;
}

.btn {
    border: none;
    border-radius: 12px;
    min-height: 42px;
    padding: 10px 16px;
    font-size: 14px;
    line-height: 1;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #1db48d);
    color: #fff;
    box-shadow: 0 14px 30px rgba(15, 157, 143, 0.25);
}

.btn-soft {
    background: #e9f3f2;
    color: #0f5f58;
}

.btn-ghost {
    background: #f5f8fc;
    color: #334159;
    border: 1px solid var(--line);
}

.btn-danger {
    background: #fde9e8;
    color: #9a2c2c;
}

.hero {
    padding-top: 52px;
}

.hero-card,
.panel,
.auth-card,
.auth-side-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
    padding: 30px;
}

.hero-card h1,
.dashboard-head h1 {
    margin: 12px 0 10px;
    font-family: Unbounded, sans-serif;
    font-size: clamp(32px, 5vw, 54px);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.dashboard-head h1 {
    font-size: clamp(28px, 4vw, 42px);
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: var(--primary-deep);
    font-size: 12px;
}

.lead {
    margin: 0;
    max-width: 760px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.65;
}

.hero-actions {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.metrics {
    margin-top: 28px;
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metrics article {
    background: #fff;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    padding: 16px;
}

.metrics strong {
    display: block;
    font-size: 18px;
}

.metrics span {
    color: var(--muted);
    font-size: 14px;
}

.auth-section {
    margin-top: 22px;
    margin-bottom: 70px;
    display: grid;
    gap: 18px;
    grid-template-columns: 1.15fr 0.85fr;
}

.auth-card h2,
.panel h2 {
    margin: 0 0 14px;
    font-family: Unbounded, sans-serif;
    font-size: 24px;
}

.auth-card p {
    margin: 0 0 14px;
    color: var(--muted);
}

.widget-wrap {
    min-height: 70px;
    display: flex;
    align-items: center;
}

.qr-auth-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.qr-auth-code {
    width: 252px;
    height: 252px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    padding: 6px;
    display: grid;
    place-items: center;
}

.qr-auth-code img {
    border-radius: 10px;
}

.qr-auth-status {
    font-size: 14px;
    font-weight: 600;
    color: #243953;
    text-align: center;
}

.qr-auth-meta {
    font-size: 13px;
    color: var(--muted);
}

.auth-side-card h3 {
    margin-top: 0;
    font-family: Unbounded, sans-serif;
    font-size: 20px;
}

.auth-side-card ul {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 10px;
    color: #3f4d64;
}

.dashboard-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-top: 32px;
}

.user-badge {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 270px;
}

.user-badge img,
.placeholder-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: grid;
    place-items: center;
    background: #d9ecea;
    color: #165952;
    font-weight: 800;
}

.user-badge span {
    color: var(--muted);
    font-size: 13px;
}

.dashboard-grid {
    margin: 18px 0 58px;
    display: grid;
    grid-template-columns: 0.92fr 1.08fr;
    gap: 18px;
}

.list-panel {
    min-height: 200px;
}

.form-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.compact {
    margin-top: 16px;
}

.form-grid label {
    font-size: 13px;
    color: #30415a;
    font-weight: 600;
    display: grid;
    gap: 6px;
}

.form-grid label.full,
.form-grid .full {
    grid-column: 1 / -1;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    min-height: 42px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: #fff;
}

textarea {
    resize: vertical;
    min-height: 70px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #89d5cb;
    box-shadow: 0 0 0 3px rgba(15, 157, 143, 0.14);
}

.bot-list {
    display: grid;
    gap: 14px;
}

.bot-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 18px;
}

.bot-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.bot-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-title h3 {
    margin: 0;
    font-size: 20px;
}

.bot-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.bot-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    object-fit: cover;
    border: 1px solid var(--line);
}

.stats-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.stats-grid div {
    background: #f8fbff;
    border: 1px solid #e5edf7;
    border-radius: 12px;
    padding: 10px;
}

.stats-grid strong {
    display: block;
    font-size: 20px;
    color: #1f2f4d;
}

.stats-grid span {
    font-size: 12px;
    color: var(--muted);
}

.ref-link {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f8fff9;
    border: 1px dashed #b8dfc1;
    font-size: 13px;
    word-break: break-all;
}

.ref-link a {
    color: #1d7e47;
}

.bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.alert {
    border-radius: 12px;
    padding: 10px 12px;
    background: #f7fafd;
    border: 1px solid #d9e8f9;
    color: #2f4868;
    margin-bottom: 12px;
}

.alert-error {
    background: #fff2f1;
    border-color: #f2b8b6;
    color: #8d2220;
}

.empty {
    color: var(--muted);
    margin-top: 10px;
}

.botfather-panel {
    margin-top: 16px;
    margin-bottom: 16px;
}

.tg-session-ok,
.tg-session-connect {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tg-session-ok p,
.tg-session-connect p {
    margin: 0;
    color: #30415a;
}

.tg-session-ok span {
    color: var(--muted);
    margin-left: 8px;
}

.mtproto-connect-box {
    width: 100%;
    margin-top: 8px;
    display: grid;
    place-items: center;
    gap: 8px;
}

.jobs-wrap {
    margin-top: 14px;
}

.jobs-wrap h3 {
    margin: 0 0 10px;
    font-family: Unbounded, sans-serif;
    font-size: 18px;
}

.jobs-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e2eaf3;
    border-radius: 10px;
    overflow: hidden;
}

.jobs-table th,
.jobs-table td {
    border-bottom: 1px solid #e8edf5;
    padding: 8px;
    text-align: left;
    font-size: 13px;
}

.jobs-table th {
    background: #f6f9fd;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #576981;
}

.dash-actions-inline {
    margin: 14px 0 0;
}

.stats-filter-panel {
    margin-top: 18px;
}

.stats-filter-row {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.stats-filter-row label {
    min-width: 280px;
    font-size: 13px;
    color: #30415a;
    font-weight: 600;
    display: grid;
    gap: 6px;
}

.scope-note {
    margin: 12px 0 0;
    color: var(--muted);
}

.summary-grid {
    margin: 16px 0;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.summary-card {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 12px;
}

.summary-card span {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.summary-card strong {
    display: block;
    margin-top: 4px;
    font-size: 24px;
    color: #1f2f4d;
}

.chart-panel {
    min-height: 340px;
}

.chart-panel h2 {
    margin-bottom: 10px;
}

.chart-panel canvas {
    width: 100%;
    height: 250px !important;
}

.stats-table-panel {
    margin: 16px 0 58px;
}

.table-wrap {
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.stats-table th,
.stats-table td {
    border-bottom: 1px solid #e8edf5;
    padding: 10px 8px;
    text-align: left;
    font-size: 13px;
}

.stats-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #55657c;
}

.bot-cell strong {
    display: block;
}

.bot-cell span {
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 1060px) {
    .dashboard-grid,
    .auth-section {
        grid-template-columns: 1fr;
    }

    .dashboard-head {
        flex-direction: column;
        align-items: stretch;
    }

    .user-badge {
        min-width: 0;
        width: fit-content;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .container {
        width: min(1200px, calc(100vw - 24px));
    }

    .hero-card,
    .panel,
    .auth-card,
    .auth-side-card {
        padding: 20px;
    }

    .metrics {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .header-row {
        min-height: 68px;
    }

    .brand-text {
        font-size: 16px;
    }
}
