:root {
    color-scheme: light;
    --bg: #f4f2ed;
    --surface: #ffffff;
    --surface-soft: #f8f7f2;
    --text: #182016;
    --muted: #687264;
    --line: #ddd8cb;
    --accent: #607c37;
    --accent-dark: #425929;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --success-soft: #eef8e8;
    --success: #47692c;
    --shadow: 0 16px 50px rgba(35, 39, 29, .10);
    --radius: 22px;
    --sidebar: 280px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 10%, rgba(96, 124, 55, .14), transparent 28%),
        radial-gradient(circle at 90% 20%, rgba(150, 125, 72, .12), transparent 30%),
        var(--bg);
    color: var(--text);
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: rgba(255, 255, 255, .72);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand, .mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow);
}

.brand small { display: block; color: var(--muted); margin-top: 2px; }

.nav-list { display: grid; gap: 8px; margin-top: 28px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    color: var(--text);
    font-weight: 650;
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.nav-link:hover, .nav-link.active {
    background: var(--surface);
    border-color: var(--line);
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(35,39,29,.06);
}

.nav-form { margin: 0; }
.nav-button { text-align: left; }

.mobile-topbar { display: none; }
.mobile-drawer { display: none; }

.content {
    width: min(1180px, 100%);
    padding: 34px;
}

.hero-card, .card, .stat-card {
    background: rgba(255, 255, 255, .82);
    border: 1px solid rgba(221, 216, 203, .9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero-card {
    display: grid;
    grid-template-columns: 1fr 250px;
    gap: 22px;
    padding: clamp(24px, 4vw, 42px);
    align-items: stretch;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
}

h1, h2, h3, p { overflow-wrap: anywhere; }

h1 {
    margin: 0;
    font-size: clamp(34px, 6vw, 66px);
    line-height: 1;
    letter-spacing: -.05em;
}

h2 { margin: 0 0 12px; font-size: 24px; letter-spacing: -.02em; }

.lead {
    max-width: 720px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.65;
}

.muted { color: var(--muted); line-height: 1.6; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-weight: 750;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { min-height: 36px; padding: 8px 12px; font-size: 14px; }
.btn.full { width: 100%; }

.vk-card {
    display: grid;
    align-content: center;
    gap: 8px;
    min-height: 180px;
    padding: 22px;
    border-radius: 22px;
    background: linear-gradient(135deg, #2787f5, #125fb4);
    color: #fff;
    text-decoration: none;
}

.vk-card:hover { text-decoration: none; }
.vk-logo { font-size: 38px; font-weight: 900; letter-spacing: -.06em; }
.vk-card small { opacity: .84; }

.grid { display: grid; gap: 18px; margin-top: 18px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card { padding: 24px; }
.card p { color: var(--muted); line-height: 1.65; }
.news-placeholder { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 20px; align-items: center; margin-top: 18px; }
.placeholder-lines { display: grid; gap: 12px; }
.placeholder-lines span { height: 16px; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--line); }
.placeholder-lines span:nth-child(2) { width: 76%; }
.placeholder-lines span:nth-child(3) { width: 52%; }

.page-head {
    margin-bottom: 18px;
}
.page-head p { color: var(--muted); max-width: 760px; line-height: 1.65; }
.page-head.with-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.page-head.narrow { max-width: 760px; }

.auth-page { min-height: calc(100vh - 68px); display: grid; place-items: center; }
.auth-card { width: min(460px, 100%); }

.form-stack, .form-grid { display: grid; gap: 16px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }

label { display: grid; gap: 7px; font-weight: 700; }
label span { color: var(--text); }
input, select, textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row input { width: auto; min-height: auto; }
.form-actions { display: flex; gap: 10px; justify-content: flex-start; }
.form-note { color: var(--muted); }

.alert {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
}
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert ul { margin-bottom: 0; }

.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.profile-header { display: flex; gap: 18px; align-items: center; }
.avatar-xl {
    width: 122px;
    height: 122px;
    flex: 0 0 auto;
    border-radius: 28px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
    overflow: hidden;
    font-size: 34px;
    font-weight: 900;
    color: var(--accent-dark);
}
.avatar-xl img { width: 100%; height: 100%; object-fit: cover; }

.info-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 22px 0 0; }
.info-list.small { grid-template-columns: 1fr; }
.info-list div { padding: 14px; border-radius: 16px; background: var(--surface-soft); border: 1px solid var(--line); }
.info-list dt { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.info-list dd { margin: 0; font-weight: 750; }
.side-stack { display: grid; gap: 18px; }
.compact-card h2 { font-size: 20px; }
.team-mini { display: flex; align-items: center; gap: 12px; }
.team-mini img { width: 48px; height: 48px; border-radius: 14px; object-fit: cover; }
.qr-placeholder { width: 118px; height: 118px; border-radius: 18px; display: grid; place-items: center; background: #fff; border: 1px dashed var(--line); color: var(--muted); font-weight: 900; }
.badge { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-weight: 800; font-size: 13px; }
.badge-soft { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.ban-banner { display: grid; gap: 5px; margin-bottom: 18px; padding: 16px; border-radius: 18px; background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(180, 35, 24, .25); }

.stat-card { padding: 22px; }
.stat-card span { display: block; font-size: 36px; font-weight: 900; letter-spacing: -.05em; }
.stat-card small { color: var(--muted); font-weight: 750; }
.action-card { color: var(--text); text-decoration: none; }
.action-card:hover { text-decoration: none; transform: translateY(-2px); }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 16px; }
.table-card { padding: 0; overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--surface-soft); color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
td small { color: var(--muted); }
.pagination { padding: 16px; }
.danger-section { margin-top: 18px; }

@media (max-width: 980px) {
    .app-shell { display: block; }
    .sidebar { display: none; }
    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 16px;
        background: rgba(255,255,255,.88);
        border-bottom: 1px solid var(--line);
        backdrop-filter: blur(18px);
    }
    .mobile-brand { font-weight: 900; }
    .menu-button, .menu-close {
        width: 44px;
        height: 44px;
        border-radius: 14px;
        border: 1px solid var(--line);
        background: #fff;
        font-size: 24px;
    }
    .mobile-drawer {
        position: fixed;
        inset: 0;
        z-index: 50;
        display: none;
        background: rgba(0,0,0,.35);
    }
    .mobile-drawer.open { display: block; }
    .mobile-drawer__panel {
        margin-left: auto;
        width: min(360px, calc(100vw - 36px));
        min-height: 100%;
        padding: 18px;
        background: var(--surface);
        box-shadow: -20px 0 60px rgba(0,0,0,.22);
    }
    .mobile-drawer__head { display: flex; justify-content: space-between; align-items: center; }
    .content { padding: 20px 16px 34px; }
    .hero-card, .profile-grid, .news-placeholder { grid-template-columns: 1fr; }
    .two-columns, .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .hero-card, .card { padding: 20px; }
    .form-grid, .info-list { grid-template-columns: 1fr; }
    .page-head.with-actions { align-items: flex-start; flex-direction: column; }
    .search-row { grid-template-columns: 1fr; }
    .profile-header { align-items: flex-start; flex-direction: column; }
    .avatar-xl { width: 104px; height: 104px; }
}

.field-shell {
    display: grid;
    gap: 7px;
    font-weight: 700;
    position: relative;
}

.field-label { color: var(--text); }

.ajax-select { position: relative; }

.ajax-select__button {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    text-align: left;
}

.ajax-select__popover {
    position: absolute;
    z-index: 30;
    inset-inline: 0;
    top: calc(100% + 8px);
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow);
}

.ajax-select__search { border-radius: 12px; }

.ajax-select__hint {
    margin: 8px 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.ajax-select__options {
    display: grid;
    gap: 6px;
    max-height: 270px;
    overflow: auto;
    padding-right: 2px;
}

.ajax-select__option {
    width: 100%;
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.ajax-select__option:hover,
.ajax-select__option.active {
    border-color: var(--accent);
    background: var(--success-soft);
}

.ajax-select__option small {
    color: var(--muted);
    font-weight: 600;
}

.ajax-select__empty {
    padding: 12px;
    color: var(--muted);
    font-weight: 650;
}

.readonly-field {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
}

.readonly-field span,
.readonly-field small { color: var(--muted); }

.danger-toolbar {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.danger-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.danger-toolbar__actions form { margin: 0; }

body.modal-open { overflow: hidden; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    padding: 22px;
    overflow-y: auto;
}

.modal.open { display: grid; place-items: center; }

.modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(24, 32, 22, .52);
    backdrop-filter: blur(8px);
}

.modal__panel {
    position: relative;
    z-index: 1;
    width: min(620px, 100%);
    max-height: calc(100vh - 44px);
    overflow: auto;
    padding: 24px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 24px 90px rgba(0, 0, 0, .26);
}

.modal__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 16px;
}

.modal__close {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.check-list {
    display: grid;
    gap: 8px;
    max-height: 320px;
    overflow: auto;
    padding-right: 4px;
}

.check-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
}

.check-card input { width: auto; min-height: auto; margin-top: 4px; }
.check-card span { display: grid; gap: 2px; }
.check-card small { color: var(--muted); font-weight: 600; }
.checkbox-master { margin-bottom: 4px; }

.qr-box {
    width: 142px;
    min-height: 142px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    border: 1px dashed var(--line);
    background: #fff;
    padding: 10px;
}

.qr-box img {
    width: 120px;
    height: 120px;
    display: block;
}

@media (max-width: 760px) {
    .danger-toolbar { align-items: stretch; flex-direction: column; }
    .danger-toolbar__actions { justify-content: flex-start; }
    .modal { padding: 12px; align-items: start; }
    .modal.open { place-items: start center; }
    .modal__panel { max-height: calc(100vh - 24px); padding: 18px; }
}
