*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0f1117;
    --surface:      #1a1d27;
    --surface-2:    #21253a;
    --border:       #2a2d3a;
    --accent:       #3b82f6;
    --accent-h:     #2563eb;
    --text:         #e2e8f0;
    --text-muted:   #6b7280;
    --error:        #ef4444;
    --warn:         #f59e0b;
    --success:      #10b981;
    --sidebar-w:    220px;
    --topbar-h:     52px;
    --radius:       8px;
}

[data-theme="light"] {
    --bg:         #f3f4f6;
    --surface:    #ffffff;
    --surface-2:  #f9fafb;
    --border:     #e5e7eb;
    --text:       #111827;
    --text-muted: #6b7280;
}

@media (prefers-color-scheme: light) {
    [data-theme="system"] {
        --bg:         #f3f4f6;
        --surface:    #ffffff;
        --surface-2:  #f9fafb;
        --border:     #e5e7eb;
        --text:       #111827;
        --text-muted: #6b7280;
    }
}

html, body { height: 100%; }

body {
    font-family: 'Roboto Condensed', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
}

.logo-text {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.logo-text em {
    font-style: normal;
    color: var(--accent);
}

.nav-list {
    list-style: none;
    padding: 10px 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 15px;
    color: var(--text-muted);
    transition: background 0.12s, color 0.12s;
    position: relative;
    user-select: none;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-item.active {
    background: rgba(59,130,246,0.12);
    color: var(--accent);
}

.badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.badge-red { background: var(--error); }

/* ── SIDEBAR FOOTER ── */
.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    border-radius: 6px;
    display: flex;
    transition: color 0.12s, background 0.12s;
}

.btn-logout:hover {
    color: var(--error);
    background: rgba(239,68,68,0.1);
}

.btn-logout svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ── MAIN WRAP ── */
.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.page-title {
    font-size: 17px;
    font-weight: 600;
}

.connector-button {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 7px 11px;
    color: var(--text);
    background: var(--surface-2);
    cursor: pointer;
}

.connector-button[hidden] { display: none; }
.connector-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.connector-button[data-status="connected"] .connector-dot { background: var(--success); }
.connector-button[data-status="error"] .connector-dot { background: var(--error); }

.connector-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.62);
}

.connector-modal[hidden] { display: none; }
.connector-card { position: relative; width: min(420px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); text-align: center; }
.connector-card h3 { margin-bottom: 8px; }
.connector-card p { color: var(--text-muted); }
.connector-close { position: absolute; top: 9px; right: 12px; border: 0; background: transparent; color: var(--text-muted); font-size: 25px; cursor: pointer; }
.qr-frame { width: 270px; height: 270px; margin: 20px auto 14px; display: grid; place-items: center; border-radius: 12px; background: #fff; color: #4b5563; overflow: hidden; }
.qr-frame img { width: 246px; height: 246px; }
.connector-hint { font-size: 13px; }
.connector-success { color: var(--success); font-size: 72px; }
.two-factor-form { display: grid; gap: 10px; margin: 16px 0; text-align: left; }
.two-factor-form[hidden] { display: none; }
.two-factor-form label { color: var(--text-muted); font-size: 13px; }
.two-factor-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--text); }
.two-factor-form button { padding: 10px 12px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; cursor: pointer; }

.content {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

/* ── ПУСТОЕ СОСТОЯНИЕ ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 10px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    fill: var(--border);
}

.empty-state p { font-size: 15px; }

/* ── ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ ── */
.theme-switcher {
    display: flex;
    gap: 2px;
    padding: 6px 8px 4px;
    border-top: 1px solid var(--border);
}

.theme-btn {
    flex: 1;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1;
}

.theme-btn:hover { background: var(--surface-2); }

.theme-btn.active {
    background: var(--surface-2);
    border-color: var(--border);
}

/* ── СКРОЛЛБАР ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── COMPACT ICON SIDEBAR ── */
:root { --sidebar-w: 86px; }
.sidebar { background: #173449; border-right-color: rgba(255,255,255,.1); color: #d9efff; align-items: stretch; }
.account-control { position: relative; }
.account-tile { width: 100%; min-height: 78px; padding: 9px 4px 7px; border: 0; border-bottom: 1px solid rgba(255,255,255,.12); background: transparent; color: inherit; font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.account-tile:hover, .account-tile[aria-expanded="true"] { background: rgba(255,255,255,.08); }
.account-avatar { width: 34px; height: 34px; background: transparent; border: 1px solid #9dc0d3; color: #d9efff; }
.account-label { font-size: 12px; color: #b9d7e9; }
.account-tile .user-name { display: none; }
.account-menu[hidden] { display: none; }
.account-menu { position: absolute; z-index: 1100; top: 8px; left: calc(100% + 8px); width: 190px; padding: 7px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 12px 32px rgba(0,0,0,.28); color: var(--text); }
.account-menu-user { padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-item { width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; display: flex; align-items: center; gap: 9px; cursor: pointer; text-align: left; }
.account-menu-item:hover, .account-menu-item:focus-visible { background: var(--surface-2); outline: none; }
.account-menu-item svg { width: 19px; height: 19px; fill: currentColor; flex: 0 0 auto; }
.account-menu-logout { color: var(--error); }
.nav-list { padding: 7px 4px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { min-height: 64px; padding: 6px 2px; border-radius: 5px; flex-direction: column; justify-content: center; gap: 4px; font-size: 12px; line-height: 1.05; text-align: center; color: #a9ccdf; border: 0; background: transparent; width: 100%; font-family: inherit; }
.nav-item svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.25; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(27,183,229,.14); color: #fff; }
.nav-item.active svg { color: #2cc5ef; fill: rgba(44,197,239,.18); }
.nav-item .badge { position: absolute; top: 5px; right: 7px; margin: 0; }
.nav-tool { flex: 0 0 auto; margin: 0 4px 5px; width: calc(100% - 8px); cursor: pointer; }
.sidebar-footer { padding: 8px 4px 10px; justify-content: center; border-top-color: rgba(255,255,255,.12); }
.inbox-launcher-wrap { margin-top: auto; }
.inbox-launcher { position: relative; width: 52px; height: 52px; border: 0; border-radius: 8px; background: transparent; color: #a9ccdf; cursor: pointer; display: grid; place-items: center; }
.inbox-launcher:hover, .inbox-launcher[aria-expanded="true"] { color: #fff; background: rgba(255,255,255,.08); }
.inbox-launcher svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.15; }
.inbox-launcher-badge { position: absolute; right: 0; top: 1px; display: block; }
.inbox-launcher-badge[hidden] { display: none; }
.inbox-drawer[hidden] { display: none; }
.inbox-drawer { position: fixed; z-index: 900; left: var(--sidebar-w); top: 0; bottom: 0; width: min(390px, calc(100vw - var(--sidebar-w))); background: var(--surface); color: var(--text); border-right: 1px solid var(--border); box-shadow: 12px 0 30px rgba(0,0,0,.26); display: flex; flex-direction: column; }
.inbox-drawer-head { min-height: 62px; padding: 11px 10px 10px 15px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.inbox-drawer-search { min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; }
.inbox-drawer-search svg { width: 21px; height: 21px; fill: currentColor; flex: 0 0 auto; }
.inbox-drawer-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; }
.inbox-drawer-close { width: 32px; height: 32px; border: 0; background: transparent; color: var(--text-muted); font-size: 25px; cursor: pointer; }
.inbox-drawer-list { overflow-y: auto; flex: 1; }
.inbox-drawer-vk-export { padding: 10px 12px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: center; background: var(--surface-2); }
.inbox-drawer-vk-export[hidden] { display: none; }
.inbox-drawer-vk-export strong, .inbox-drawer-vk-export span { grid-column: 1 / -1; }
.inbox-drawer-vk-export input, .inbox-drawer-vk-export button { min-height: 34px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); padding: 5px 8px; font: inherit; }
.inbox-drawer-vk-export button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); }
.inbox-drawer-vk-export span { min-height: 16px; color: var(--text-muted); font-size: 12px; }
.inbox-drawer-state { padding: 24px; color: var(--text-muted); text-align: center; }
.inbox-drawer-item { width: 100%; min-height: 82px; padding: 11px 12px 10px 16px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; display: grid; grid-template-columns: 43px minmax(0,1fr) auto; column-gap: 10px; text-align: left; cursor: pointer; font: inherit; }
.inbox-drawer-item:hover { background: var(--surface-2); }
.inbox-drawer-avatar { grid-row: 1 / 3; width: 43px; height: 43px; border-radius: 50%; background: #64748b; color: white; display: grid; place-items: center; font-size: 18px; font-weight: 600; }
.inbox-drawer-title { font-size: 15px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.inbox-drawer-time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.inbox-drawer-preview { grid-column: 2 / 4; color: var(--text-muted); font-size: 14px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.inbox-drawer-channel { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-right: 4px; padding: 0 3px; border-radius: 5px; color: #fff; background: #38a169; font-size: 10px; text-transform: uppercase; vertical-align: 1px; }
.btn-logout { width: 100%; min-height: 52px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #a9ccdf; font-family: inherit; font-size: 11px; }
.btn-logout svg { width: 25px; height: 25px; }
.topbar { padding-left: 18px; }
@media (max-height: 680px) {
    .nav-item { min-height: 54px; }
    .account-tile { min-height: 68px; }
}
