/* ══════════════════════════════════════════════════════════
   CSS Variables
══════════════════════════════════════════════════════════ */
:root {
    --bg-dark:           #0f0f0f;
    --bg-panel:          #1a1a1a;
    --bg-panel-hover:    #222222;
    --bg-input:          #111111;
    --border:            #1e1e1e;
    --text-white:        #f0f0f0;
    --text-muted:        #777777;
    --accent-yellow:     #ffcc00;
    --accent-yellow-dim: #b38f00;
    --accent-red:        #e74c3c;
    --accent-green:      #2ecc71;
    --accent-blue:       #3498db;
    --header-height:     58px;
    --radius:            8px;
    --radius-sm:         4px;
    --transition:        0.18s ease;
    --max-width:         100%;
    --padding-x:         24px;
}

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

html { height: 100%; scroll-behavior: smooth; }

body {
    min-height: 100vh;
    background: var(--bg-dark);
    color: var(--text-white);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-yellow); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }

/* ══════════════════════════════════════════════════════════
   Layout
══════════════════════════════════════════════════════════ */
.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* ── Header ──────────────────────────────────────────────── */
.site-header {
    width: 100%;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--padding-x);
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Логотип и всё что слева */
.site-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    order: 1;
}

/* UserBar — справа */
.site-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    order: 100;
    margin-left: 0;
}

/* Переключатель языка стоит между логотипом и userbar,
   но прижимается ВПРАВО (margin-left: auto) */
.site-header-inner > .lang-dropdown {
    order: 50;
    margin-left: auto;
}

/* ── Main ────────────────────────────────────────────────── */
.site-main {
    flex: 1;
    width: 100%;
    padding: 32px 0;
}

.site-main-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--padding-x);
    height: 100%;
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
    width: 100%;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.site-footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 14px var(--padding-x);
    color: var(--text-muted);
    font-size: 0.82em;
    text-align: center;
}

/* ══════════════════════════════════════════════════════════
   Panel
══════════════════════════════════════════════════════════ */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.panel:last-child { margin-bottom: 0; }

.panel-title {
    color: var(--accent-yellow);
    font-size: 1.05em;
    font-weight: 600;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════
   Typography
══════════════════════════════════════════════════════════ */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.6em; }
h2 { font-size: 1.3em; }
h3 { font-size: 1.1em; }

.text-accent  { color: var(--accent-yellow) !important; }
.text-muted   { color: var(--text-muted)    !important; }
.text-danger  { color: var(--accent-red)    !important; }
.text-success { color: var(--accent-green)  !important; }
.text-white   { color: var(--text-white)    !important; }
.font-bold    { font-weight: 600; }
.font-sm      { font-size: 0.85em; }

/* ══════════════════════════════════════════════════════════
   Buttons
══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: opacity var(--transition), background var(--transition),
                border-color var(--transition), color var(--transition);
    white-space: nowrap;
    user-select: none;
}
.btn:hover      { opacity: 0.85; text-decoration: none; }
.btn:active     { opacity: 0.7; }
.btn[disabled]  { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-sm         { padding: 6px 14px; font-size: 0.82em; }
.btn-full       { width: 100%; }

.btn-primary    { background: var(--accent-yellow); color: #0f0f0f; font-weight: 700; }
.btn-secondary  {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
    opacity: 1;
}
.btn-danger     { background: var(--accent-red);   color: #fff; }
.btn-success    { background: var(--accent-green); color: #0f0f0f; }
.btn-ghost      { background: transparent; color: var(--text-white); border: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════
   Forms
══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85em;
    margin-bottom: 7px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-white);
    border: 1px solid var(--border);
    padding: 10px 13px;
    border-radius: var(--radius);
    font-size: 0.95em;
    outline: none;
    transition: border-color var(--transition);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    font-family: inherit;
}
.form-control:focus        { border-color: var(--accent-yellow); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled     { opacity: 0.5; cursor: not-allowed; }

/* ── Select со стрелкой ──────────────────────────────────── */
select.form-control {
    cursor: pointer;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%23777777' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

select.form-control:focus {
    border-color: var(--accent-yellow);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%23ffcc00' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
}

/* Маленький select в таблице пользователей */
select.form-control.form-control-sm {
    padding: 5px 30px 5px 9px;
    font-size: 0.82em;
    background-position: right 9px center;
}

textarea.form-control { resize: vertical; min-height: 90px; }


/* ══════════════════════════════════════════════════════════
   Alerts
══════════════════════════════════════════════════════════ */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius);
    font-size: 0.9em;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-danger  { background: #2d0f0f; border-color: #6b1f1f; color: var(--accent-red);    }
.alert-success { background: #0a2010; border-color: #1a5c30; color: var(--accent-green);  }
.alert-info    { background: #1a1a0a; border-color: #555500; color: var(--accent-yellow); }
.alert-gray    { background: #1a1a1a; border-color: var(--border); color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════
   Badge
══════════════════════════════════════════════════════════ */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.03em;
    border: 1px solid transparent;
    vertical-align: middle;
}
.badge-yellow { background: #2a2200; color: var(--accent-yellow); border-color: var(--accent-yellow-dim); }
.badge-green  { background: #0a2010; color: var(--accent-green);  border-color: #1a5c30; }
.badge-red    { background: #2d0f0f; color: var(--accent-red);    border-color: #6b1f1f; }
.badge-blue   { background: #0a1a2d; color: var(--accent-blue);   border-color: #1a3a5c; }
.badge-gray   { background: #1a1a1a; color: var(--text-muted);    border-color: var(--border); }

/* ══════════════════════════════════════════════════════════
   Table
══════════════════════════════════════════════════════════ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}
.table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.82em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td  { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-panel-hover); }

/* ══════════════════════════════════════════════════════════
   Divider
══════════════════════════════════════════════════════════ */
.divider { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* ══════════════════════════════════════════════════════════
   Utilities
══════════════════════════════════════════════════════════ */
.d-flex          { display: flex; }
.d-grid          { display: grid; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-wrap       { flex-wrap: wrap; }
.gap-4           { gap: 4px; }
.gap-8           { gap: 8px; }
.gap-12          { gap: 12px; }
.gap-16          { gap: 16px; }
.gap-24          { gap: 24px; }
.mt-8            { margin-top: 8px; }
.mt-16           { margin-top: 16px; }
.mt-24           { margin-top: 24px; }
.mb-8            { margin-bottom: 8px; }
.mb-16           { margin-bottom: 16px; }
.mb-24           { margin-bottom: 24px; }
.w-full          { width: 100%; }
.text-center     { text-align: center; }
.text-right      { text-align: right; }

/* ══════════════════════════════════════════════════════════
   Responsive
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root { --padding-x: 16px; }
    .site-main { padding: 20px 0; }
    .panel     { padding: 16px; }
    .table th,
    .table td  { padding: 8px 10px; }
}

@media (max-width: 480px) {
    :root {
        --padding-x:    12px;
        --header-height: 52px;
    }
    h1      { font-size: 1.3em; }
    h2      { font-size: 1.15em; }
    .btn    { padding: 8px 14px; }
    .btn-sm { padding: 5px 10px; }
}

@media (max-width: 768px) {
    .site-header-inner { gap: 8px; flex-wrap: wrap; }
    .site-main         { padding: 16px 0; }
}
@media (max-width: 480px) {
    .site-header-inner {
        height: auto;
        min-height: var(--header-height);
        padding: 8px var(--padding-x);
        flex-wrap: wrap;
    }
}

/* ══════════════════════════════════════════════════════════
   Установка / First install
══════════════════════════════════════════════════════════ */
.install-notice {
    max-width: 720px;
    margin: 80px auto;
    padding: 50px 40px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7);
}

.install-notice h1 {
    color: var(--accent-yellow);
    margin-bottom: 24px;
    font-size: 2rem;
}

.install-notice p {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.65;
    margin-bottom: 32px;
}

.btn-install {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--accent-yellow);
    color: #111;
    padding: 16px 36px;
    font-size: 1.15rem;
    font-weight: 700;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.25s ease;
}

.btn-install:hover {
    background: #ffe033;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 204, 0, 0.3);
}

.install-note {
    margin-top: 40px;
    font-size: 0.9rem;
    color: #555;
}

/* ── Переключатель языка на странице установки ───────────── */
.install-lang-switcher {
    position: absolute;
    top: 20px;
    right: 30px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.install-lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: border-color var(--transition),
                color var(--transition),
                background var(--transition);
}

.install-lang-btn:hover {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
    text-decoration: none;
}

.install-lang-btn.active {
    background: var(--accent-yellow);
    color: #111;
    border-color: var(--accent-yellow);
    font-weight: 700;
}

.install-lang-flag {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .install-lang-switcher {
        top: 12px;
        right: 12px;
    }
    .install-lang-btn span {
        display: none; /* На мобильном — только флаги */
    }
}