:root {
    --primary: #4f6ef7;
    --primary-dark: #3b57d9;
    --green: #2ea043;
    --red: #d1242f;
    --gray: #8b949e;
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --border: #e3e5eb;
    --text: #1f2328;
    --text-muted: #656d76;
}

* { box-sizing: border-box; }

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

h1 { font-size: 24px; margin-bottom: 20px; }
h2 { font-size: 17px; margin: 0 0 14px; }

/* Топ-панель */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text); }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a { color: var(--text-muted); text-decoration: none; font-size: 14px; }
.nav a:hover { color: var(--primary); }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-muted); }

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

/* Форми */
.form-card { max-width: 480px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--text-muted); }
input[type=text], input[type=password], input[type=datetime-local], select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox-label input { width: auto; }

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 11px 18px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn-block { display: block; width: 100%; margin-top: 20px; }
.btn-link { color: var(--primary); text-decoration: none; font-size: 14px; }
.btn-link:hover { text-decoration: underline; }

/* Номінали */
.nominal-choice { display: flex; gap: 10px; }
.nominal-option {
    flex: 1;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    margin: 0;
}
.nominal-option input { display: none; }
.nominal-option:has(input:checked) {
    border-color: var(--primary);
    background: #eef1ff;
    color: var(--primary-dark);
}

/* Алерти */
.alert { padding: 14px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #dafbe1; color: #116329; border: 1px solid #b7f0c2; }
.alert-error { background: #ffebe9; color: #82071e; border: 1px solid #ffc1bc; }

/* Логін */
.auth-wrap { display: flex; justify-content: center; padding-top: 60px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { text-align: center; font-size: 20px; }

/* Таблиці */
.data-table, .kv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.kv-table th { text-align: left; color: var(--text-muted); padding: 6px 12px 6px 0; }
.kv-table td { padding: 6px 0; }

/* Бейджі статусів */
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-active { background: #dafbe1; color: #116329; }
.badge-redeemed { background: #ddeaff; color: #1a3fb0; }
.badge-expired { background: #ffebe9; color: #82071e; }
.badge-cancelled { background: #eceef1; color: #57606a; }

/* Фільтри */
.filter-bar { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.filter-field { display: flex; flex-direction: column; min-width: 160px; }
.filter-field label { margin: 0 0 6px; }
.filter-submit { flex-direction: row; align-items: center; gap: 10px; }

/* Пагінація */
.pagination { display: flex; gap: 8px; margin-top: 16px; }
.pagination a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); font-size: 14px; }
.pagination a.page-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Статистика */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.stat-sub { font-size: 13px; margin-top: 6px; font-weight: 600; }
.stat-active .stat-value { color: var(--green); }
.stat-redeemed .stat-value { color: var(--primary); }
.stat-expired .stat-value { color: var(--red); }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { min-height: 260px; }
.chart-wide { grid-column: 1 / -1; }

.readonly-info { margin-top: 16px; font-size: 13px; color: var(--text-muted); }

@media (max-width: 700px) {
    .chart-grid { grid-template-columns: 1fr; }
    .nominal-choice { flex-direction: column; }
    .topbar-inner { flex-wrap: wrap; }
}
