:root {
    --bg: #0b1118;
    --panel: #121b24;
    --panel-soft: #16222f;
    --border: #223244;
    --text: #e8f1f8;
    --muted: #8ea2b5;
    --primary: #2ec4b6;
    --primary-strong: #20a4f3;
    --success: #37d67a;
    --danger: #f25f5c;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: radial-gradient(circle at top, #122131 0%, var(--bg) 48%);
    color: var(--text);
}

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

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: rgba(10, 16, 24, 0.95);
    border-right: 1px solid var(--border);
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    color: #041017;
    font-weight: 700;
}

.brand-title {
    font-weight: 700;
    font-size: 18px;
}

.brand-subtitle,
.muted {
    color: var(--muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-link {
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: var(--panel-soft);
    border-color: var(--border);
}

.nav-link.danger:hover {
    border-color: rgba(242, 95, 92, 0.5);
    color: #ffd7d6;
}

.content-shell {
    padding: 22px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: 12px;
    padding: 10px 12px;
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.grid {
    display: grid;
    gap: 18px;
}

.metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.two-col {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.three-col {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.panel,
.metric-card,
.login-card {
    background: linear-gradient(180deg, rgba(23, 34, 46, 0.95), rgba(17, 27, 36, 0.95));
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.panel,
.login-card {
    padding: 20px;
}

.metric-card {
    padding: 18px;
}

.metric-label {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
    font-size: 14px;
}

.metric-card strong {
    font-size: 32px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(34, 50, 68, 0.8);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(46, 196, 182, 0.12);
    color: #9ff3ea;
    border: 1px solid rgba(46, 196, 182, 0.3);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #0d1620;
    color: var(--text);
}

.btn {
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    color: #041017;
    font-weight: 700;
}

.btn-success {
    background: rgba(55, 214, 122, 0.14);
    color: #93f0b7;
    border-color: rgba(55, 214, 122, 0.35);
}

textarea {
    width: 100%;
    min-height: 140px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #0d1620;
    color: var(--text);
    resize: vertical;
}

.hidden {
    display: none !important;
}

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

.push-auto-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    background: rgba(22, 34, 47, 0.78);
}

.push-auto-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.push-builder {
    display: grid;
    gap: 14px;
}

.push-preview {
    border: 1px solid var(--border);
    border-radius: 22px;
    overflow: hidden;
    background: linear-gradient(180deg, #102030, #0f1823);
}

.push-preview-photo {
    aspect-ratio: 16 / 9;
    background: #0a121b;
}

.push-preview-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.push-preview-body {
    padding: 18px;
    display: grid;
    gap: 14px;
}

.push-preview-text {
    white-space: pre-wrap;
    line-height: 1.55;
}

.btn-preview {
    width: fit-content;
}

.btn-danger {
    background: rgba(242, 95, 92, 0.14);
    color: #ffb6b4;
    border-color: rgba(242, 95, 92, 0.35);
}

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

.pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-soft);
}

.page-link.active {
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    color: #041017;
    font-weight: 700;
}

.details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.details div {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
}

.details dt {
    color: var(--muted);
    margin-bottom: 6px;
}

.details dd {
    margin: 0;
    font-weight: 600;
}

.empty {
    text-align: center;
    color: var(--muted);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(100%, 420px);
}

.brand-login {
    margin-bottom: 18px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert {
    margin: 16px 0;
    padding: 12px 14px;
    background: rgba(242, 95, 92, 0.14);
    border: 1px solid rgba(242, 95, 92, 0.35);
    color: #ffcecc;
    border-radius: 14px;
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-right: 6px;
}

.chat-bubble {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.chat-bubble.user {
    border-color: rgba(32, 164, 243, 0.35);
    background: rgba(32, 164, 243, 0.08);
}

.chat-bubble.bot {
    border-color: rgba(46, 196, 182, 0.35);
    background: rgba(46, 196, 182, 0.08);
}

.chat-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}

.chat-text {
    white-space: pre-wrap;
    line-height: 1.5;
}

.chat-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 18px;
    min-height: 70vh;
}

.chat-sidebar,
.chat-main {
    min-height: 70vh;
}

.chat-main {
    display: flex;
    flex-direction: column;
}

.chat-thread-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-thread {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.chat-thread.active {
    border-color: rgba(46, 196, 182, 0.45);
    background: rgba(46, 196, 182, 0.08);
}

.chat-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #041017;
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-avatar.large {
    width: 64px;
    height: 64px;
}

.chat-thread-content {
    min-width: 0;
}

.chat-thread-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.chat-thread-meta {
    margin-bottom: 6px;
    font-size: 13px;
}

.chat-thread-preview {
    color: var(--text);
    opacity: 0.85;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-selected-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.action-menu {
    position: relative;
    display: inline-block;
}

.action-menu summary {
    list-style: none;
}

.action-menu summary::-webkit-details-marker {
    display: none;
}

.action-menu-trigger {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.action-menu[open] .action-menu-trigger {
    border-color: rgba(46, 196, 182, 0.4);
    background: rgba(46, 196, 182, 0.08);
}

.action-menu-content {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    padding: 8px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(23, 34, 46, 0.98), rgba(17, 27, 36, 0.98));
    box-shadow: var(--shadow);
    z-index: 30;
}

.action-menu-content form + form {
    margin-top: 6px;
}

.action-menu-item {
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.action-menu-item.is-danger {
    color: #ffb6b4;
    border-color: rgba(242, 95, 92, 0.22);
    background: rgba(242, 95, 92, 0.08);
}

.action-menu-item.is-success {
    color: #93f0b7;
    border-color: rgba(55, 214, 122, 0.22);
    background: rgba(55, 214, 122, 0.08);
}

.balance-editor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.metric-editor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.balance-value {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(32, 164, 243, 0.18), rgba(46, 196, 182, 0.18));
    border: 1px solid rgba(46, 196, 182, 0.35);
    color: #aef6ee;
    font-weight: 700;
    box-shadow: 0 0 0 1px rgba(46, 196, 182, 0.08), 0 10px 30px rgba(32, 164, 243, 0.12);
}

.balance-edit-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid rgba(46, 196, 182, 0.28);
    background: rgba(46, 196, 182, 0.08);
    color: #9ff3ea;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 15px;
    line-height: 1;
}

.balance-edit-btn:hover {
    background: rgba(46, 196, 182, 0.16);
    border-color: rgba(46, 196, 182, 0.45);
}

.metric-value {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
}

.referrals-value {
    background: linear-gradient(135deg, rgba(55, 214, 122, 0.16), rgba(46, 196, 182, 0.16));
    border: 1px solid rgba(55, 214, 122, 0.35);
    color: #b8f7cf;
    box-shadow: 0 0 0 1px rgba(55, 214, 122, 0.08), 0 10px 30px rgba(55, 214, 122, 0.12);
}

.metric-edit-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid rgba(55, 214, 122, 0.28);
    background: rgba(55, 214, 122, 0.08);
    color: #93f0b7;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 15px;
    line-height: 1;
}

.metric-edit-btn:hover {
    background: rgba(55, 214, 122, 0.16);
    border-color: rgba(55, 214, 122, 0.45);
}

.hidden-form {
    display: none;
}

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: min(280px, 80vw);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: inline-flex;
    }

    .chat-layout {
        grid-template-columns: 1fr;
    }
}
