:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
    --topbar-height: 56px;
}

* { box-sizing: border-box; }

.cursor-pointer { cursor: pointer; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
}

/* ── Layout ─────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 16px 12px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    border-bottom: 1px solid #334155;
    letter-spacing: .02em;
}

.sidebar-logo small {
    display: block;
    font-size: .7rem;
    font-weight: 400;
    color: #94a3b8;
    margin-top: 2px;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}

.sidebar-nav a:hover {
    background: #334155;
    color: #fff;
}

.sidebar-nav a.active {
    background: #1d4ed8;
    color: #fff;
    border-left-color: var(--sidebar-active);
}

.sidebar-section-title {
    padding: 16px 16px 4px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #334155;
    font-size: .8rem;
    color: #64748b;
}

.sidebar-footer a { color: #94a3b8; text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
}

.topbar-user {
    font-size: .85rem;
    color: #64748b;
}

/* ── Impersonate banner ─────────────────────────────── */
.impersonate-banner {
    background: #fef3c7;
    border-bottom: 2px solid #f59e0b;
    color: #92400e;
    padding: 8px 24px;
    font-size: .875rem;
    display: flex;
    align-items: center;
}

/* ── Page content ───────────────────────────────────── */
.page-body {
    padding: 24px;
    flex: 1;
}

/* ── Cards / Stats ──────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px 24px;
    border: 1px solid #e2e8f0;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: .8rem;
    color: #64748b;
    margin-top: 4px;
}

/* ── Tables ─────────────────────────────────────────── */
.table-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.table-card .table {
    margin: 0;
}

.table th {
    background: #f8fafc;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    border-color: #e2e8f0;
}

/* ── Alerts ─────────────────────────────────────────── */
.alert { border-radius: 8px; }

/* ── Auth page ──────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    padding: 40px 36px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.auth-logo p {
    font-size: .85rem;
    color: #64748b;
    margin: 4px 0 0;
}

.border-dashed {
    border-style: dashed !important;
}

/* ── Mobile / Responsive ────────────────────────────── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 4px 8px;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    margin-right: 4px;
    flex-shrink: 0;
}
.sidebar-toggle:hover { color: #1e293b; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
    transition: opacity .2s;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 991.98px) {
    .sidebar-toggle { display: block; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }

    .main-content { margin-left: 0 !important; }

    .page-body { padding: 16px; }

    .topbar { padding: 0 12px; gap: 8px; }

    /* Таблицы — горизонтальная прокрутка */
    .table-card { overflow-x: auto; }
    .table-responsive-auto { overflow-x: auto; }

    /* Stat cards — полная ширина на телефоне */
    .stat-card { padding: 14px 16px; }
    .stat-card .stat-value { font-size: 1.5rem; }

    /* Impersonate banner */
    .impersonate-banner { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
}

@media (max-width: 575.98px) {
    .topbar-title { font-size: .875rem; }
    .page-body { padding: 12px; }
}
