:root {
    --admin-sidebar: #111827;
    --admin-bg: #f4f7fb;
    --admin-border: #dbe3ef;
    --admin-panel: #ffffff;
    --admin-ink: #172033;
}

body {
    background: var(--admin-bg);
    color: var(--admin-ink);
}

.admin-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.2s ease;
}

.admin-sidebar-collapsed .admin-shell {
    grid-template-columns: 84px minmax(0, 1fr);
}

.admin-sidebar {
    background: var(--admin-sidebar);
    color: #fff;
    padding: 24px;
    transition: padding 0.2s ease;
}

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

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin-bottom: 0;
}

.brand-block small {
    display: block;
    color: #aeb9c8;
}

.brand-mark {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: #229ed9;
    font-weight: 800;
}

.brand-title,
[data-sidebar-label] {
    transition: opacity 0.15s ease, width 0.15s ease;
    white-space: nowrap;
}

.sidebar-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(214, 222, 234, 0.28);
    border-radius: 8px;
    background: transparent;
    color: #ffffff;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
    border-color: rgba(214, 222, 234, 0.55);
    background: #26344d;
}

.sidebar-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    margin: 0 auto;
    border-radius: 2px;
    background: currentColor;
}

.admin-sidebar .nav-link {
    color: #d6deea;
}

.admin-sidebar .nav-link.active,
.admin-sidebar .nav-link:hover {
    background: #26344d;
    color: #ffffff;
}

.admin-sidebar-collapsed .admin-sidebar {
    padding: 20px;
}

.admin-sidebar-collapsed .sidebar-head {
    flex-direction: column;
    gap: 16px;
}

.admin-sidebar-collapsed .brand-title,
.admin-sidebar-collapsed [data-sidebar-label] {
    width: 0;
    opacity: 0;
    overflow: hidden;
}

.admin-sidebar-collapsed .admin-sidebar .nav-link {
    display: flex;
    justify-content: center;
    min-height: 42px;
    padding-right: 0;
    padding-left: 0;
}

.admin-main {
    padding: 28px;
}

.userbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    margin-bottom: 22px;
}

.userbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

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

.auth-card {
    width: min(420px, 100%);
    padding: 28px;
    background: #ffffff;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(24, 39, 75, 0.09);
}

.auth-brand {
    color: var(--admin-ink);
    margin-bottom: 24px;
}

.auth-brand small {
    color: #667085;
}

.profile-panel {
    max-width: 680px;
}

.profile-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.metric-card,
.panel {
    background: var(--admin-panel);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    box-shadow: 0 18px 44px rgba(24, 39, 75, 0.07);
}

.metric-card {
    padding: 18px;
}

.metric-card span {
    display: block;
    color: #667085;
    margin-bottom: 6px;
}

.panel {
    padding: 20px;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.lead-filter-form {
    max-width: 1180px;
}

.lead-filter-form .form-label {
    margin-bottom: 4px;
    font-size: 12px;
}

.lead-filter-form .form-control,
.lead-filter-form .form-select,
.lead-filter-form .btn {
    min-height: 31px;
}

.lead-filter-actions {
    align-items: flex-end;
    flex-wrap: nowrap;
}

.lead-filter-actions .btn {
    white-space: nowrap;
}

.admin-table th {
    color: #667085;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.admin-table td,
.admin-table th {
    padding: 10px 12px;
}

.admin-table td {
    font-size: 14px;
}

.lead-row-new > td {
    background: #f3f8fd;
}

.lead-id-cell {
    white-space: nowrap;
}

.lead-id-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
}

.lead-new-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #0c447c;
}

.lead-status-badge,
.lead-status-select {
    border: 0;
    border-radius: 999px;
    font-weight: 700;
}

.lead-status-badge {
    padding: 5px 10px;
}

.lead-status-select {
    min-width: 104px;
    max-width: 112px;
    padding: 3px 24px 3px 10px;
    font-size: 12px;
}

.lead-status-column {
    width: 116px;
    min-width: 116px;
}

.lead-actions-column {
    width: 72px;
    min-width: 72px;
    text-align: right;
}

.lead-actions-button {
    min-width: 34px;
    padding-right: 8px;
    padding-left: 8px;
    line-height: 1;
}

.lead-table-responsive {
    overflow: visible;
}

.lead-status-new {
    background-color: #e6f1fb;
    color: #0c447c;
}

.lead-status-progress {
    background-color: #faeeda;
    color: #633806;
}

.lead-status-done {
    background-color: #eaf3de;
    color: #27500a;
}

.lead-status-rejected {
    background-color: #f1efe8;
    color: #444441;
}

.support-status-waiting {
    background-color: #eef2ff;
    color: #3730a3;
}

.support-status-reopened {
    background-color: #f8d7da;
    color: #842029;
}

.lead-repeat-badge {
    background: #faeeda;
    color: #633806;
    font-size: 11px;
    vertical-align: middle;
}

.lead-muted-value {
    color: #8a8a84;
}

.lead-text-clip {
    display: inline-block;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.feedback-text-clip {
    max-width: 520px;
}

.spend-deal-name {
    display: inline-block;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.spend-status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.spend-status-ok {
    background: #eaf3de;
    color: #27500a;
}

.spend-status-near_limit {
    background: #faeeda;
    color: #633806;
}

.spend-status-overflow {
    background: #f8d7da;
    color: #842029;
}

.spend-status-missing_budget {
    background: #f1efe8;
    color: #444441;
}

.lead-username-cell {
    white-space: nowrap;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.bots-table-responsive {
    overflow: visible;
}

.assigned-bots-list {
    display: grid;
    max-height: 180px;
    overflow: auto;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #f8fafc;
}

.schema-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.schema-list code,
.command-box {
    background: #edf3fa;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    color: #24446f;
}

.schema-list code {
    padding: 3px 6px;
}

.command-box {
    padding: 10px 12px;
    margin-top: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.code-textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.tenant-tables {
    display: grid;
    gap: 18px;
}

.tenant-table-block {
    display: grid;
    gap: 10px;
}

.tenant-table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.lead-history-list {
    display: grid;
    gap: 10px;
}

.lead-history-item {
    padding: 12px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #f8fafc;
}

.events-list {
    display: grid;
    gap: 12px;
}

.events-list div {
    display: grid;
    gap: 3px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--admin-border);
}

.events-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.events-list span,
.empty-state {
    color: #667085;
}

.empty-state {
    padding: 18px;
    border: 1px dashed var(--admin-border);
    border-radius: 8px;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        min-height: auto;
    }

    .admin-sidebar-collapsed .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar-collapsed .admin-sidebar {
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .admin-sidebar-collapsed .admin-sidebar .nav {
        display: none;
    }

    .admin-sidebar-collapsed .sidebar-head {
        flex-direction: row;
        margin-bottom: 0;
    }

    .admin-sidebar-collapsed .brand-title {
        width: auto;
        opacity: 1;
    }
}

@media (max-width: 640px) {
    .admin-main,
    .admin-sidebar {
        padding: 18px;
    }

    .userbar {
        justify-content: space-between;
    }

    .page-head,
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .table-actions {
        justify-content: flex-start;
    }

    .lead-table-responsive {
        overflow-x: auto;
    }
}
