:root {
	--bg: #f5f7fb;
	--panel: #ffffff;
	--muted: #6b7280;
	--text: #111827;
	--accent: #2563eb;
	--accent-2: #0ea5e9;
	--danger: #ef4444;
	--border: #e5e7eb;
	--shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

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

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

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.title {
	margin: 0 0 16px 0;
	font-size: 22px;
	font-weight: 700;
}

label {
	display: block;
	margin: 12px 0 6px;
	font-weight: 600;
	color: var(--muted);
}

input,
select,
button,
textarea {
	outline: none;
	font-size: 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    /* Smooth, crisp interactions */
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease, opacity .15s ease;
}

input,
select,
textarea {
	width: 100%;
	padding: 12px 14px;
	outline: none;
}

/* Remove default outlines but keep clear, accessible focus styles */
*:focus { outline: none; }
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

/* For inputs specifically: remove any focus border/halo entirely */
input:focus,
input:focus-visible,
select:focus,
select:focus-visible,
textarea:focus,
textarea:focus-visible {
	border-color: inherit;
	box-shadow: none;
}

input::placeholder {
	color: #9aa3b2;
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
    background: var(--accent);
    border: 1px solid transparent;
    color: #ffffff;
	font-weight: 700;
	padding: 12px 16px;
	cursor: pointer;
    border-radius: 10px;
	margin-top: 15px;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    transition: background-color .15s ease, box-shadow .15s ease, transform .12s ease;
}

.btn:hover { background: #1e40af; transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 0 0 rgba(0,0,0,0); }

.btn-danger {
	background: var(--danger);
	color: #fff;
}

.btn-outline {
	background: #ffffff;
	color: var(--accent-2);
	border-color: var(--accent-2);
	box-shadow: none;
}

.btn-outline:hover {
	background: var(--accent-2);
	color: #ffffff;
}

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

.grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
}

@media (max-width: 720px) {
	.grid {
		grid-template-columns: 1fr;
	}
}

/* Side-by-side actions that stack on small screens */
.actions-row { display:flex; gap:10px; }

@media (max-width: 720px) {
	.actions-row { flex-direction: column; }
	.actions-row .btn { width: 100%; }
}

table {
	width: 100%;
	border-collapse: collapse;
}

.table-wrap {
	width: 100%;
	overflow-x: auto;
	max-height: 70vh;
	overflow-y: auto;
}

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

th {
	color: var(--muted);
	font-weight: 700;
}

.topbar {
	display: flex;
	gap: 10px;
	align-items: center;
    flex-wrap: wrap;
}

.topbar a {
    color: var(--accent);
	text-decoration: none;
}

.topbar a:hover {
	text-decoration: underline;
}

/* Ensure anchor buttons look like real buttons */
a.btn {
	color: #ffffff;
	text-decoration: none;
}

a.btn:hover {
	text-decoration: none;
}

.actions a {
	color: var(--accent-2);
	margin-right: 10px;
}

.qr-wrap {
	text-align: center;
}

.qr-wrap img {
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* Subtle animated entrances */
.card { animation: fadeInUp .25s ease-out both; }

@keyframes fadeInUp {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

/* Utility animations (optional use) */
.fade-in { animation: fadeIn .2s ease-out both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { transition: none !important; animation: none !important; }
}
/* ---- дополнения Django-версии ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; font-size: 26px; }
.stack > * + * { margin-top: 12px; }
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.alert { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-size: 14px; }
.alert-success { color: #166534; border-color: rgba(22,163,74,.4); background: rgba(22,163,74,.06); }
.alert-error { color: #b91c1c; border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.06); }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--danger); font-size: 13px; }
.hint { margin-top: 6px; background: rgba(234,179,8,0.12); color: #92400e; border-radius: 8px; padding: 6px 10px; border: 1px solid rgba(234,179,8,0.6); font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 10px; margin-top: 0; font-size: 12px; font-weight: 600; }
.btn-danger:hover { background: #b91c1c; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 16px; }
.link-btn:hover { text-decoration: underline; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.filters label { margin-top: 0; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } }
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 14px; }
.pagination a, .pagination span { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; color: var(--text); background: #fff; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.nowrap { white-space: nowrap; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; padding: 18px; overflow-y: auto; }
.modal-overlay.open { display: block; animation: fadeIn .18s ease-out both; }
.modal-card { max-width: 680px; margin: 56px auto; background: var(--panel); border-radius: 14px; padding: 22px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.qr-img { width: 300px; max-width: 100%; height: auto; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 10px; }
.winners-list { display: flex; flex-direction: column; gap: 10px; }
.winner-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.winner-num { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: rgba(37,99,235,.10); color: var(--accent); font-weight: 800; flex: 0 0 auto; }
.winner-name { font-weight: 800; font-size: 16px; }
.winner-phone a { color: var(--accent-2); text-decoration: none; font-weight: 700; }
.checkbox { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); }
.checkbox input { width: auto; }
/* a.btn из оригинала красит текст в белый и перебивает .btn-outline */
a.btn.btn-outline { color: var(--accent-2); }
a.btn.btn-outline:hover { color: #fff; }
.page-head .topbar { font-size: 16px; font-weight: 600; }
.topbar a.active { text-decoration: underline; text-underline-offset: 4px; }
.subnav { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: -4px 0 14px; font-size: 14px; }
.subnav a { color: var(--muted); text-decoration: none; }
.subnav a:hover, .subnav a.active { color: var(--accent); }
.subnav a.active { font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 28px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }
.bars { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.bar { height: 7px; border-radius: 4px; min-width: 2px; }
.bar-unique { background: #2563eb; }
.bar-subs { background: #f59e0b; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.preview-frame { width: 100%; height: 760px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.sticky { position: sticky; top: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2ff; color: #3730a3; }
.badge-ok { background: rgba(22,163,74,.12); color: #166534; }
.badge-warn { background: rgba(234,179,8,.15); color: #92400e; }
.badge-err { background: rgba(239,68,68,.12); color: #b91c1c; }
.badge-off { background: #f3f4f6; color: #6b7280; }
.section-title { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.preset { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: #fff; cursor: pointer; font-size: 13px; }
.preset i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.1); }
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 12px; }
.colors input[type=color] { height: 42px; padding: 4px; }
input[type=range] { padding: 0; }
.code { font-family: ui-monospace, Menlo, monospace; background: #f3f4f6; padding: 2px 6px; border-radius: 6px; font-size: 13px; }
textarea { font-family: inherit; line-height: 1.45; }
.actions-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.actions-wrap form { display: inline; }
.choice-list.inline { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.choice-list ul { list-style: none; margin: 0; padding: 0; }
.cond-group[hidden] { display: none !important; }
.opt-rows { display: flex; flex-direction: column; gap: 8px; }
.opt-row { border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fafafa; }
.opt-line { display: flex; gap: 8px; align-items: center; }
.opt-line input { flex: 1; }
.opt-line .btn { margin-top: 0; white-space: nowrap; }
.opt-line .link-btn { font-size: 18px; color: var(--muted); padding: 0 4px; }
.opt-line .opt-del:hover { color: var(--danger); }
.opt-panel { margin-top: 8px; padding: 8px 4px 2px; border-top: 1px dashed var(--border); }
