:root {
    --bg: #ffffff;
    --text: #111111;
    --muted: #666666;
    --line: #e9e9e9;
    --brand: #f5a623;
    --tg: #26a5e4;
    --max: #8b5cf6;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f8f8fa;
    color: var(--text);
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.page { min-height: calc(100vh - 140px); padding-top: 24px; padding-bottom: 36px; }
.muted { color: var(--muted); }

.topbar {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 64px;
}
.logo {
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
}
.logo span { color: var(--brand); }
.nav { display: flex; gap: 14px; align-items: center; }
.nav a { text-decoration: none; color: #333; }
.nav a:hover { color: var(--brand); }

h1 { margin: 0 0 12px; font-size: 32px; }
.panel-head { margin-bottom: 18px; }

/* Не переопределяем .card / .stats-grid — для панели используется static/css/style.css (после этого файла порядок в base: сначала style, потом app). */
.narrow { max-width: 520px; margin: 24px auto; }

.form-grid {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}
.form-grid.two { grid-template-columns: 1fr 1fr; }
label { display: grid; gap: 8px; font-weight: 500; }
input, select, button {
    font: inherit;
    border-radius: 10px;
}
input, select {
    border: 1px solid #d7d7d7;
    padding: 10px 12px;
}
.btn, button {
    border: 1px solid #d8d8d8;
    background: #fff;
    padding: 10px 14px;
    cursor: pointer;
}
.btn { text-decoration: none; color: #111; display: inline-block; }
.btn-primary {
    background: linear-gradient(135deg, var(--brand), #e8940a);
    border-color: var(--brand);
    color: #111111;
    font-weight: 600;
}
.form-actions { display: flex; gap: 10px; align-items: center; }

.flash-wrap { display: grid; gap: 10px; margin-bottom: 14px; }
.flash { border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.flash-success { background: #edf8ef; border: 1px solid #cde8d3; }
.flash-error { background: #fdeeee; border: 1px solid #f4caca; }

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

.table-wrap { overflow: auto; }
table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}
th, td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    font-size: 14px;
}
.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.row-actions form { margin: 0; }

.footer {
    border-top: 1px solid var(--line);
    color: #888;
    font-size: 13px;
    padding: 20px 0;
}

@media (max-width: 767px) {
    .container { padding: 0 14px; }
    h1 { font-size: 24px; }
    .topbar-inner { min-height: 58px; }
    .nav { gap: 8px; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
    .form-grid.two { grid-template-columns: 1fr; }
    .list-head { flex-direction: column; align-items: flex-start; }
    .head-actions { width: 100%; flex-wrap: wrap; }
    .head-actions form, .head-actions select { width: 100%; }
}

/* Пользователь: карточка «как профиль» + бейджи каналов в таблице */
.badge-channel-tg {
    background: #e3f4fc;
    color: #0b5cab;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
}
.badge-channel-max {
    background: #ede9fe;
    color: #5b21b6;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
}
.badge-channel-internal {
    background: #f4f4f5;
    color: #3f3f46;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
}

.user-profile-page { margin-bottom: 2rem; }
.user-profile-back { margin-bottom: 12px; }
.user-profile-hero {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.25rem;
}
.user-profile-cover {
    height: 120px;
    background: linear-gradient(120deg, #26a5e4 0%, #8b5cf6 45%, #f5a623 100%);
    opacity: 0.92;
}
.user-profile-hero-inner {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 1.25rem;
    padding: 0 1.5rem 1.5rem;
    margin-top: -56px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: #fff;
    border-radius: 0 0 14px 14px;
}
.user-profile-avatar-wrap { flex-shrink: 0; }
.user-profile-avatar {
    width: 132px;
    height: 132px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    display: block;
    background: #f0f0f0;
}
.user-profile-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    color: #444;
}
.user-profile-hero-text { flex: 1; min-width: 220px; padding-bottom: 4px; }
.user-profile-name {
    margin: 0 0 6px;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.user-profile-alias { margin: 0 0 8px; font-size: 0.95rem; }
.user-profile-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 8px;
}
.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #e6e6e6;
    background: #fafafa;
}
.chip-tg { border-color: #b9e3fb; background: #eef8ff; color: #0b5cab; }
.chip-max { border-color: #ddd6fe; background: #f5f3ff; color: #5b21b6; }
.chip-internal { border-color: #e4e4e7; background: #fafafa; color: #3f3f46; font-weight: 600; }
.chip-muted { color: #666; font-weight: 500; }
.chip-role { border-color: #fde68a; background: #fffbeb; }
.chip-ok { border-color: #bbf7d0; background: #ecfdf5; color: #166534; }
.chip-warn { border-color: #e5e5e5; background: #f4f4f5; color: #52525b; }
.user-profile-messenger-hint {
    margin: 0 0 8px;
    font-size: 0.92rem;
    line-height: 1.45;
    max-width: 720px;
}
.user-profile-meta-line { margin: 0; font-size: 0.88rem; }

.profile-grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}
.profile-card .card-body { padding-top: 0.5rem; }
.dl-spec {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr;
    gap: 10px 16px;
    margin: 0;
    font-size: 14px;
}
.dl-spec dt {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
}
.dl-spec dd { margin: 0; word-break: break-word; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

@media (max-width: 640px) {
    .user-profile-hero-inner { margin-top: -48px; padding: 0 1rem 1.25rem; }
    .user-profile-avatar, .user-profile-avatar-fallback { width: 104px; height: 104px; }
    .dl-spec { grid-template-columns: 1fr; }
    .dl-spec dt { border-top: 1px solid var(--line); padding-top: 8px; }
    .dl-spec dt:first-of-type { border-top: none; padding-top: 0; }
}
