:root {
    --bg: #fdf5f7;
    --card-bg: #ffffff;
    --ink: #3a0e2e;
    --primary: #f43f5e;
    --primary-dark: #be123c;
    --primary-light: #ffe4e9;
    --text: #2d1b24;
    --text-muted: #8a6b78;
    --border: #f3dfe4;
    --success: #2f855a;
    --success-bg: #f0fff4;
    --danger: #c53030;
    --danger-bg: #fff5f5;
    --warning: #b7791f;
    --warning-bg: #fffaf0;
    --accent: #f59e0b;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(58, 14, 46, 0.07);
    --shadow-md: 0 4px 16px rgba(58, 14, 46, 0.10);
    --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: "Inter", sans-serif; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 800; margin: 0 0 16px; color: var(--ink); }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 14px; color: var(--ink); }
h3 { font-size: 14px; font-weight: 700; margin: 0; }

.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------- Каркас приложения: сайдбар + контент ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--ink);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    padding: 6px 10px 22px;
}

.brand-mark {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}

.brand-text { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-text b { font-weight: 800; }

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #c8d6d5;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }

.nav-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.12);
    padding-top: 14px;
    margin-top: 10px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 12px;
}

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

.user-name {
    font-size: 13px;
    color: #e2e8f0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link-logout { color: #f6a09a; }
.nav-link-logout:hover { background: rgba(197,48,48,0.18); color: #fecdca; }

.app-main {
    flex: 1;
    min-width: 0;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 28px;
}

.narrow {
    max-width: 440px;
}

/* ---------- Карточки ---------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* ---------- Таблицы ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfb; }

/* Аватар-инициалы для строк с именами */
.name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-chip {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    flex-shrink: 0;
}

/* ---------- Кнопки ---------- */
a.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(244,63,94,0.25);
}

a.btn:hover, button.btn:hover { background: var(--primary-dark); }
a.btn:active, button.btn:active { transform: translateY(1px); }

.btn-danger { background: var(--danger); box-shadow: 0 1px 2px rgba(197,48,48,0.25); }
.btn-danger:hover { background: #9b2c2c; }

.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { background: #f4f6f7; border-color: #d1d9da; }

.btn-block { width: 100%; text-align: center; }

/* ---------- Формы ---------- */
input, select, textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    margin-bottom: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

label {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* ---------- Бейджи ---------- */
.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: #eef1f2; color: var(--text-muted); }

/* ---------- Алерты ---------- */
.alert {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #feb2b2; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #9ae6b4; }

/* ---------- Статистика на дашборде ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.stat-box .stat-icon {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}

.stat-box .num { font-size: 26px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.stat-box .label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.flex-between h1 { margin-bottom: 0; }

.text-muted { color: var(--text-muted); font-size: 13px; }

.scan-box {
    text-align: center;
    padding: 48px 20px;
}

.scan-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
}

/* ---------- Логин ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ink);
    background-image: radial-gradient(circle at 15% 20%, rgba(244,63,94,0.55), transparent 45%),
                       radial-gradient(circle at 85% 85%, rgba(244,63,94,0.35), transparent 40%);
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
}

.login-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.login-brand span.login-brand-text { color: #fff; font-size: 19px; font-weight: 700; }

.login-wrap .card {
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    border: none;
}

/* ---------- Разное ---------- */
.search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.search-row input[type="text"] {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
}

.search-row select { width: auto; margin-bottom: 0; }

.row-actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.table-scroll { overflow-x: auto; }

/* ---------- График посещений по неделе ---------- */
.chart-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 220px;
    margin-top: 20px;
    padding-top: 10px;
}

.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.chart-value { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }

.chart-bar-track {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.chart-bar {
    width: 60%;
    min-width: 18px;
    background: var(--primary);
    border-radius: 6px 6px 0 0;
    transition: height 0.2s ease;
}

.chart-bar-peak { background: var(--accent); }

.chart-label { margin-top: 8px; font-size: 12px; text-align: center; line-height: 1.4; color: var(--text-muted); }
.chart-label-today { font-weight: 700; color: var(--primary); }

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 900px) {
    .app-shell { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 10;
        flex-direction: row;
        align-items: center;
        padding: 10px 14px;
        gap: 14px;
        overflow-x: auto;
    }

    .brand { padding: 0; flex-shrink: 0; }
    .brand-text { display: none; }

    .sidebar-nav {
        flex-direction: row;
        flex: none;
        gap: 2px;
    }

    .nav-link span { display: none; }
    .nav-link { padding: 9px; }

    .sidebar-footer {
        border-top: none;
        margin: 0 0 0 auto;
        padding: 0;
        flex-shrink: 0;
    }

    .sidebar-user { padding: 0; }
    .user-name { display: none; }
    .nav-link-logout span { display: none; }

    .container { padding: 18px 12px; }

    .card { padding: 15px; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); }

    .search-row { flex-direction: column; }
    .search-row select, .search-row button { width: 100%; }

    table thead { display: none; }
    table, table tbody, table tr, table td { display: block; width: 100%; }

    table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 10px;
        padding: 8px 12px;
    }

    table td {
        border-bottom: none;
        padding: 6px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        text-align: right;
    }

    table td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 12px;
        font-weight: 600;
        text-align: left;
    }

    table td:empty, table td[data-label=""] { justify-content: flex-end; }

    .row-actions { justify-content: flex-end; width: 100%; }

    a.btn, button.btn { padding: 10px 14px; }

    .chart-wrap { height: 160px; gap: 4px; }
    .chart-value { font-size: 11px; }
    .chart-label { font-size: 10px; }
}

.language-picker { display:flex; align-items:center; justify-content:flex-end; gap:10px; padding:8px 16px; background:var(--card-bg); }
.language-picker label { margin:0; font-size:12px; }
.language-picker select { width:auto; margin:0; padding:6px; }
