:root {
    --accent: #0f9d8a;
    --accent-2: #ff7448;
    --ink: #1c2430;
    --muted: #647083;
    --paper: #f7f5f1;
    --card: #ffffff;
    --line: #dde3eb;
    --danger: #d64545;
    --success: #2e9b55;
    --shadow-lg: 0 22px 52px rgba(21, 42, 61, 0.12);
    --shadow-sm: 0 6px 20px rgba(21, 42, 61, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Manrope', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 0%, rgba(15, 157, 138, 0.18), transparent 30%),
        radial-gradient(circle at 90% 10%, rgba(255, 116, 72, 0.16), transparent 35%),
        var(--paper);
    min-height: 100vh;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-box {
    background: var(--card);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    padding: 38px;
}

.login-box h1,
.navbar h1,
.section h2 {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.2px;
}

.login-box h1 {
    font-size: 28px;
    margin-bottom: 26px;
    text-align: center;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.form-group input,
.form-group textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    background: #fff;
    transition: 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 157, 138, 0.14);
}

.error {
    margin-top: 10px;
    border: 1px solid rgba(214, 69, 69, 0.3);
    background: rgba(214, 69, 69, 0.08);
    color: var(--danger);
    border-radius: 10px;
    padding: 10px 12px;
}

.btn {
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
    padding: 11px 16px;
}

.btn-primary {
    width: 100%;
    color: #fff;
    background: linear-gradient(120deg, var(--accent), #0c7f71);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-success {
    color: #fff;
    background: linear-gradient(120deg, #2e9b55, #257d44);
}

.btn-success:hover {
    transform: translateY(-1px);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(120deg, #d64545, #bf3535);
}

.btn-small {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-inline {
    width: auto;
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--line);
}

.navbar-content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    font-size: 24px;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
}

.main {
    display: flex;
    min-height: calc(100vh - 70px);
}

.sidebar {
    width: 270px;
    padding: 24px 12px;
}

.nav-menu {
    list-style: none;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
    padding: 10px;
}

.nav-menu a {
    display: block;
    text-decoration: none;
    color: var(--ink);
    border-radius: 12px;
    padding: 11px 14px;
    margin-bottom: 6px;
    transition: 0.2s ease;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: linear-gradient(120deg, rgba(15, 157, 138, 0.16), rgba(255, 116, 72, 0.14));
}

.content {
    flex: 1;
    padding: 24px 22px 28px;
}

.section {
    display: none;
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.section.active {
    display: block;
}

.section h2 {
    margin-bottom: 20px;
    font-size: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    border-radius: 16px;
    background: linear-gradient(130deg, #102a43, #1f3f63);
    color: #fff;
    padding: 18px;
}

.stat-card:nth-child(2n) {
    background: linear-gradient(130deg, #14524a, #1c7a6d);
}

.stat-card:nth-child(3n) {
    background: linear-gradient(130deg, #7f3d2e, #ba5f46);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
}

.stat-label {
    font-size: 13px;
    opacity: 0.92;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.bot-health-block {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    background: #fbfdff;
}

.bot-health-block h3 {
    font-size: 20px;
    margin-bottom: 0;
}

.bot-health-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.bot-health-checked {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}

.bot-health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.bot-health-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: #fff;
}

.bot-health-title {
    font-weight: 800;
    margin-bottom: 8px;
}

.bot-health-state {
    font-size: 18px;
    font-weight: 800;
}

.bot-health-meta {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
}

.bot-health-card.is-online {
    border-color: rgba(46, 155, 85, 0.45);
    box-shadow: inset 0 0 0 1px rgba(46, 155, 85, 0.12);
}

.bot-health-card.is-stale {
    border-color: rgba(255, 116, 72, 0.45);
    box-shadow: inset 0 0 0 1px rgba(255, 116, 72, 0.12);
}

.bot-health-card.is-offline {
    border-color: rgba(214, 69, 69, 0.45);
    box-shadow: inset 0 0 0 1px rgba(214, 69, 69, 0.12);
}

.chart-container {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
}

.search-box {
    margin-bottom: 14px;
}

.search-box.row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box.row input {
    flex: 1;
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    margin-bottom: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f4;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #465367;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover td {
    background: #fdfdfd;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
}

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.user-create-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 14px;
    background: #fbfdff;
}

.user-create-card h3 {
    font-size: 18px;
    margin-bottom: 12px;
}

.user-create-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.twink-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #eef2f5;
}

.twink-item:last-child {
    border-bottom: 0;
}

.twink-item span {
    font-size: 13px;
}

.admins-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.admins-grid h3 {
    font-size: 18px;
    margin-bottom: 10px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(16, 26, 36, 0.58);
    backdrop-filter: blur(6px);
}

.modal-card {
    width: min(1080px, 100%);
    max-height: 92vh;
    overflow: auto;
    border-radius: 22px;
    background: var(--card);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    padding: 18px;
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-header h2 {
    margin-bottom: 0;
    font-size: 24px;
}

.modal-body {
    margin: 16px 0;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.modal-grid .form-group {
    margin-bottom: 0;
}

.modal-grid textarea {
    min-height: 220px;
}

.binding-block {
    margin: 14px 0 10px;
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid var(--line);
}

.binding-block h3 {
    margin-bottom: 6px;
    font-size: 18px;
}

.binding-block p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.binding-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.binding-transfer-grid {
    display: grid;
    grid-template-columns: minmax(220px, 260px) 1fr;
    gap: 12px;
    align-items: end;
}

.binding-transfer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admins-list {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
}

.telegram-ops-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 14px;
}

.telegram-chat-list-wrap,
.telegram-chat-view-wrap {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 12px;
}

.telegram-chat-actions {
    margin-bottom: 10px;
}

.telegram-chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 560px;
    overflow: auto;
}

.telegram-chat-item {
    text-align: left;
    border: 1px solid var(--line);
    background: #f9fbfd;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
}

.telegram-chat-item.selected {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(15, 157, 138, 0.25);
}

.telegram-chat-item-title {
    font-weight: 800;
    margin-bottom: 4px;
}

.telegram-chat-item-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.telegram-chat-item-secondary {
    font-size: 12px;
    color: #4e5f78;
    margin-bottom: 4px;
}

.telegram-chat-item-preview {
    font-size: 13px;
    color: #425066;
}

.telegram-chat-header {
    font-weight: 800;
    margin-bottom: 10px;
}

.telegram-chat-messages {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfdff;
    min-height: 360px;
    max-height: 460px;
    overflow: auto;
    padding: 10px;
    margin-bottom: 10px;
}

.telegram-message {
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 10px;
}

.telegram-message.incoming {
    background: #eef5ff;
}

.telegram-message.outgoing {
    background: #eaf9f2;
}

.telegram-message-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.telegram-message-text {
    white-space: pre-wrap;
}

.telegram-chat-controls textarea {
    width: 100%;
}

.telegram-chat-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eef2f5;
}

.admin-item:last-child {
    border-bottom: 0;
}

.admin-id {
    color: var(--muted);
    font-weight: 700;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.steal-block {
    background: var(--card);
    border: 2px solid var(--accent-2);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
}

.steal-block h3 {
    margin-bottom: 16px;
    color: var(--accent-2);
    font-size: 18px;
}

.quick-steal-user-info {
    margin-top: 16px;
    padding: 16px;
    background: #fafbfd;
    border-radius: 12px;
    border: 1px solid var(--line);
}

.user-info-card {
    background: var(--card);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
}

.user-info-card div {
    padding: 6px 0;
    font-size: 14px;
}

.quick-steal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
}

.btn-success:hover {
    background: #26804a;
}

.btn-secondary {
    background: var(--muted);
    color: white;
    border: none;
}

.btn-secondary:hover {
    background: #525c6d;
}

@media (max-width: 980px) {
    .main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 10px 16px;
    }

    .nav-menu {
        display: flex;
        overflow: auto;
        gap: 6px;
        white-space: nowrap;
    }

    .nav-menu a {
        margin-bottom: 0;
    }

    .content {
        padding: 16px;
    }

    .search-box.row {
        flex-direction: column;
        align-items: stretch;
    }

    .telegram-ops-grid {
        grid-template-columns: 1fr;
    }
}
