:root {
    --black: #0a0a0a;
    --black-2: #151515;
    --white: #ffffff;
    --bg: #f4f4f1;
    --surface: #ffffff;
    --surface-2: #eeeeea;
    --line: #d9d9d2;
    --text: #101010;
    --muted: #6c6c68;
    --muted-2: #9a9a94;
    --radius: 16px;
    --radius-sm: 11px;
    --shadow: 0 18px 50px rgba(0, 0, 0, .075);
}

* { box-sizing: border-box; }
html { min-height: 100%; }

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: -.015em;
}

a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 3vw, 40px); line-height: 1.02; font-weight: 800; letter-spacing: -.045em; }
h2 { margin-bottom: 14px; font-size: 18px; line-height: 1.18; font-weight: 800; letter-spacing: -.03em; }
h3 { font-size: 15px; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 238px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px;
    background: var(--black);
    color: var(--white);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    text-decoration: none;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -.025em;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    background: var(--white);
    color: var(--black);
    font-weight: 800;
}

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

.sidebar-nav a,
.logout {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 11px;
    color: rgba(255,255,255,.76);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.sidebar-nav a:hover,
.logout:hover {
    color: #fff;
    background: rgba(255,255,255,.075);
    border-color: rgba(255,255,255,.2);
}

.sidebar-user {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,.12);
}

.user-name {
    max-width: 100%;
    font-size: 13px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.user-role {
    margin: 4px 0 12px;
    color: rgba(255,255,255,.48);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.content {
    width: 100%;
    max-width: 1180px;
    padding: 30px;
}

.auth-content { min-height: 100vh; }

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

.eyebrow {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.card {
    margin-bottom: 16px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

input, select, textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    background: var(--white);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea { min-height: 78px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { border-color: var(--black); box-shadow: 0 0 0 3px rgba(0,0,0,.07); }

label {
    display: block;
    margin-bottom: 6px;
    color: var(--black-2);
    font-size: 12px;
    font-weight: 800;
}

button,
.button,
.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--black);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    background: var(--black);
    color: var(--white);
    text-decoration: none;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}

button:hover,
.button:hover,
.btn:hover { transform: translateY(-1px); background: var(--black-2); }
button.is-loading { opacity: .72; pointer-events: none; }
.button.ghost,
.button.secondary,
button.secondary {
    background: transparent;
    color: var(--black);
}
.button.ghost:hover,
.button.secondary:hover,
button.secondary:hover {
    background: var(--black);
    color: var(--white);
}
.small { min-height: 34px; padding: 0 11px; font-size: 12px; }

.stack-form { display: grid; gap: 10px; }
.grid-two { display: grid; grid-template-columns: minmax(280px, .72fr) minmax(420px, 1.28fr); gap: 16px; align-items: start; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 10px; align-items: end; }
.inline-form, .search, .mini-form, .search-form { display: flex; gap: 8px; align-items: center; }
.search-form { margin-bottom: 16px; }
.search-form input { max-width: 520px; }

.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.form-hint { margin: -2px 0 4px; color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 10px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }

.list { display: grid; gap: 8px; }
.list.compact { gap: 7px; }
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fbfbfa;
    color: inherit;
    text-decoration: none;
}
.list-item:hover { border-color: var(--black); }
.list-item.vertical { align-items: stretch; flex-direction: column; }
.list-item strong { display: block; margin-bottom: 3px; font-size: 13px; }
.list-item span, .list-item small { color: var(--muted); font-size: 12px; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--black);
    color: var(--white);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.muted { color: var(--muted); }
.empty { padding: 14px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); font-size: 13px; }

.flash-list { margin-bottom: 14px; }
.flash {
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--white);
    color: var(--black);
    font-size: 13px;
}
.flash.error { border-color: var(--black); }
.flash.success { background: var(--black); color: var(--white); }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); }
    .content { padding: 20px; }
    .grid-two { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    body { font-size: 13px; }
    .content { padding: 16px; }
    .card { padding: 16px; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .inline-form, .search-form, .mini-form, .password-row { grid-template-columns: 1fr; display: grid; }
    .sidebar { padding: 16px; }
}

.nav-link-with-badge {
    justify-content: space-between;
    gap: 10px;
}

.unread-badge {
    min-width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 7px;
    border-radius: 999px;
    background: #ffffff;
    color: #0a0a0a;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 0 0 1px rgba(255,255,255,.18);
}


/* --- Обновление бейджей новых сообщений --- */
.nav-link-with-badge {
    justify-content: space-between;
    gap: 10px;
}

.unread-badge,
.unread-badge-list {
    min-width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 7px;
    border: 1px solid rgba(10, 10, 10, .1);
    border-radius: 999px;
    background: #f6f6f3;
    color: #111111;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 8px 22px rgba(0,0,0,.08);
}

.unread-badge[hidden],
.unread-badge-list[hidden] {
    display: none !important;
}

.sidebar .unread-badge {
    border-color: rgba(255,255,255,.36);
    background: #ffffff;
    color: #111111;
    box-shadow: none;
}

/* mobile sidebar toggle */
.mobile-menu-toggle {
    display: none;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        gap: 6px;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 10001;
        border: 0;
        border-radius: 12px;
        padding: 9px 12px;
        background: #111827;
        color: #fff;
        font-size: 14px;
        cursor: pointer;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
    }

    body.mobile-menu-closed .sidebar {
        transform: translateX(-110%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    body.mobile-menu-open .sidebar {
        transform: translateX(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 10000 !important;
    }

    .sidebar {
        transition: transform 0.2s ease, opacity 0.2s ease !important;
    }
}

/* mobile remove sidebar reserved space */
@media (max-width: 768px) {
    body.mobile-menu-closed .sidebar {
        transform: translateX(-110%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
        position: fixed !important;
    }

    body.mobile-menu-open .sidebar {
        transform: translateX(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        z-index: 10000 !important;
    }

    .content,
    .main,
    .main-content,
    .page-content,
    .admin-content,
    .app-content,
    main {
        margin-left: 0 !important;
        padding-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* mobile menu button right */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        left: auto !important;
        right: 10px !important;
        top: 10px !important;
    }
}
