/* ============================================================
   Шлагбаумы «17 квартал Люблино» — личный кабинет
   ============================================================ */

:root {
	--bg: #f4f6fa;
	--surface: #ffffff;
	--surface-2: #f8fafc;
	--border: #e3e8ef;
	--text: #0f172a;
	--muted: #64748b;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--accent-soft: #e8efff;
	--ok: #16a34a;
	--ok-soft: #e7f7ed;
	--warn: #d97706;
	--warn-soft: #fff4e0;
	--err: #dc2626;
	--err-soft: #fdecec;
	--header: #0b1b36;
	--header-text: #e6ecf7;
	--radius: 14px;
	--radius-sm: 10px;
	--shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
	--font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b1220;
		--surface: #121b2d;
		--surface-2: #0f1727;
		--border: #22304a;
		--text: #e6ecf7;
		--muted: #94a3b8;
		--accent: #4f86ff;
		--accent-hover: #6b9bff;
		--accent-soft: #1a2a4d;
		--ok: #34d399;
		--ok-soft: #10302a;
		--warn: #fbbf24;
		--warn-soft: #3a2c0c;
		--err: #f87171;
		--err-soft: #3a1515;
		--header: #070d19;
		--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
	}
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.55 var(--font);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 4vw, 32px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p  { margin: 0 0 1em; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---------- Шапка ---------- */

.site-header {
	background: var(--header);
	color: var(--header-text);
	position: sticky;
	top: 0;
	z-index: 50;
}
.site-header .container { display: flex; align-items: center; gap: 20px; min-height: 64px; }

.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; flex: 0 1 auto; }
.brand:hover { text-decoration: none; }
.brand img { height: 36px; width: auto; border-radius: 8px; background: #fff; padding: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: #9fb0cf; }

.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
	color: var(--header-text);
	padding: 8px 12px;
	border-radius: 8px;
	font-size: 14px;
}
.nav a:hover, .nav a.active { background: rgba(255, 255, 255, .08); text-decoration: none; }

.account { display: flex; gap: 8px; align-items: center; }
.account .btn { white-space: nowrap; }

.nav-toggle {
	display: none;
	margin-left: auto;
	background: none;
	border: 0;
	color: #fff;
	padding: 8px;
	cursor: pointer;
	border-radius: 8px;
}
.nav-toggle svg { display: block; }

@media (max-width: 860px) {
	.nav-toggle { display: block; flex-shrink: 0; }
	.site-header .container { flex-wrap: wrap; gap: 12px; }
	.brand { flex: 1 1 0; }
	.brand-sub { display: none; }
	.nav, .account { display: none; width: 100%; }
	.site-header.open .nav { display: flex; flex-direction: column; align-items: stretch; margin: 0; padding-bottom: 8px; }
	.site-header.open .account { display: flex; padding-bottom: 14px; }
	.site-header.open .account .btn { flex: 1; justify-content: center; }
}

/* ---------- Основная часть ---------- */

.site-main { flex: 1; padding: 28px 0 48px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .lead { color: var(--muted); margin: 4px 0 0; }

.prose { max-width: 760px; }
.prose img { height: auto; border-radius: var(--radius-sm); }
.prose table { border-collapse: collapse; width: 100%; }
.prose td, .prose th { border: 1px solid var(--border); padding: 8px; }

/* ---------- Карточки и сетки ---------- */

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 22px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head .hint { color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.dash > div { display: grid; gap: 16px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.dash .card + .card { margin-top: 0; }

@media (max-width: 900px) {
	.dash, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 700; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Кнопки ---------- */

.btn, .button, input[type=submit].button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	padding: 10px 18px;
	font: 600 15px/1.2 var(--font);
	cursor: pointer;
	background: var(--accent);
	color: #fff;
	text-decoration: none;
	transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover, .button:hover { background: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-light { background: rgba(255, 255, 255, .1); color: #fff; }
.btn-light:hover { background: rgba(255, 255, 255, .18); }
.btn-danger { background: transparent; color: var(--err); border-color: var(--border); }
.btn-danger:hover { background: var(--err-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 22px; font-size: 16px; }

/* ---------- Формы ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 14px; color: var(--muted); font-weight: 500; }

input[type=text], input[type=tel], input[type=email], input[type=password], select, textarea {
	width: 100%;
	min-width: 0;
	max-width: 100%;
	font: 16px/1.3 var(--font);
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 11px 14px;
	transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[disabled] { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 80px; resize: vertical; }

.input-phone { font-size: 20px !important; letter-spacing: .02em; }

/* ---------- Сообщения ---------- */

.alert { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; border: 1px solid transparent; font-size: 15px; }
.alert-ok    { background: var(--ok-soft);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-warn  { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-err, .message_error { background: var(--err-soft); color: var(--err); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; }
.alert-info  { background: var(--accent-soft); color: var(--accent); }

.badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	font-weight: 600;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--muted);
	border: 1px solid var(--border);
	white-space: nowrap;
}
.badge-ok   { background: var(--ok-soft);   color: var(--ok);   border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-err  { background: var(--err-soft);  color: var(--err);  border-color: transparent; }
.badge-info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.hidden { display: none !important; }

/* ---------- Номер автомобиля ---------- */

.plate {
	display: inline-flex;
	align-items: stretch;
	border: 2px solid #111;
	border-radius: 6px;
	background: #fff;
	color: #111;
	font: 700 18px/1 "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
	letter-spacing: .04em;
	overflow: hidden;
	white-space: nowrap;
}
.plate-main { padding: 6px 8px 5px; }
.plate-region {
	border-left: 2px solid #111;
	padding: 3px 6px 2px;
	font-size: 13px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1px;
}
.plate-region small { font-size: 7px; letter-spacing: .05em; display: flex; align-items: center; gap: 2px; }
.plate-region small i { width: 10px; height: 6px; background: linear-gradient(#fff 33%, #1c4fd8 33% 66%, #d52b1e 66%); border: .5px solid #999; }
.plate-sm { font-size: 14px; }
.plate-sm .plate-region { font-size: 10px; }

/* ---------- Автомобили (редактор) ---------- */

.cars { display: grid; gap: 12px; }
.car-row {
	display: grid;
	grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr);
	gap: 12px;
	align-items: center;
	padding: 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
}
.car-num {
	width: 34px; height: 34px;
	border-radius: 50%;
	display: grid; place-items: center;
	background: var(--accent-soft); color: var(--accent);
	font-weight: 700;
}
.car-row input { text-transform: uppercase; font-family: "Roboto Mono", ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; }
.car-row .car-note { grid-column: 2 / -1; font-size: 13px; color: var(--muted); margin-top: -4px; }
.car-row.empty { opacity: .85; }

@media (max-width: 600px) {
	.car-row { grid-template-columns: 34px 1fr; }
	.car-row select { grid-column: 2; }
	.card { padding: 18px; }
	.kv { grid-template-columns: 110px 1fr; }
}

.cars-view { display: flex; flex-wrap: wrap; gap: 10px; }
.car-chip { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }

/* ---------- Списки / таблицы ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }

.passage { display: flex; align-items: center; gap: 12px; }
.passage-thumb { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); flex-shrink: 0; }

.empty-state { text-align: center; color: var(--muted); padding: 24px 12px; }

/* ---------- Главная: шлагбаумы и камеры ---------- */

.hero {
	background: linear-gradient(135deg, #0b1b36 0%, #163a7a 100%);
	color: #fff;
	border-radius: var(--radius);
	padding: 32px;
	margin-bottom: 24px;
	display: grid;
	gap: 18px;
	grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
	align-items: center;
}
.hero h1 { color: #fff; margin-bottom: 8px; }
.hero p { color: #c7d4ee; margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.hero .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .3); }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, .1); }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; padding: 24px; } .hero-actions { justify-content: flex-start; } }

.gates { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 900px) { .gates { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .gates { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gate { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.gate-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.gate.ok .gate-icon { background: var(--ok-soft); color: var(--ok); }
.gate.repair .gate-icon { background: var(--warn-soft); color: var(--warn); }
.gate.offline .gate-icon { background: var(--err-soft); color: var(--err); }
.gate-name { font-weight: 600; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; font-size: 14px; color: var(--muted); text-align: left; }
.consent input { margin-top: 3px; flex-shrink: 0; width: 18px; height: 18px; }
.gate-state { font-size: 13px; color: var(--muted); }


.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; }
.steps li::before {
	content: counter(step);
	width: 28px; height: 28px; flex-shrink: 0;
	border-radius: 50%;
	background: var(--accent-soft); color: var(--accent);
	display: grid; place-items: center;
	font-weight: 700; font-size: 14px;
}

/* ---------- Вход по звонку ---------- */

.auth { max-width: 440px; margin: 0 auto; }
.auth .card { padding: 28px; }
.auth-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 16px; }
.call-number {
	display: block;
	text-align: center;
	font-size: clamp(22px, 6.4vw, 34px);
	white-space: nowrap;
	font-weight: 800;
	letter-spacing: .02em;
	padding: 18px 12px;
	border-radius: var(--radius-sm);
	background: var(--accent-soft);
	color: var(--accent);
	margin: 8px 0 14px;
	text-decoration: none;
}
.call-number:hover { text-decoration: none; filter: brightness(.97); }
.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 14px; margin: 14px 0; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.timer { font-variant-numeric: tabular-nums; }
.form-msg { font-size: 14px; margin-top: 10px; min-height: 1em; }
.form-msg.err { color: var(--err); }
.form-msg.ok { color: var(--ok); }

/* ---------- Гостевые пропуска ---------- */

.guest-code, .guest-code-inline {
	font: 800 28px/1 "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
	letter-spacing: .25em;
	color: var(--accent);
}
.guest-code { display: block; margin-bottom: 4px; }
.guest-code-inline { font-size: 20px; }
.list li.muted { opacity: .6; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; background: var(--surface-2); }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Обращения: переписка ---------- */

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.msg-user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-bottom-right-radius: 4px; }
.msg-staff { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 600px) { .msg { max-width: 100%; } }

.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--ok); color: #fff; font-size: 12px; font-weight: 700; }

/* ---------- Модальное окно ---------- */

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 6, 23, .55); }
.modal.open { display: flex; }
.modal-box { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); padding: 24px; position: relative; }
.modal-close { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }

/* ---------- Корзина / заказ ---------- */

#deliveries { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
#deliveries li { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
#deliveries h3 { margin: 0 0 4px; font-size: 15px; }
#deliveries .description { color: var(--muted); font-size: 14px; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.pagination a { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.pagination a.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Подвал ---------- */

.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 14px; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 12px 32px; justify-content: space-between; }
.site-footer b { color: var(--text); }

/* ---------- Cookie ---------- */

.cookie {
	position: fixed;
	left: 16px; right: 16px; bottom: 16px;
	max-width: 720px;
	margin: 0 auto;
	z-index: 90;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
	padding: 16px 18px;
	display: none;
	font-size: 14px;
}
.cookie p { margin: 0 0 12px; color: var(--muted); }
.cookie-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* Главная: последние новости */
.news-mini { display: grid; gap: 4px; }
.news-mini-item { display: grid; gap: 2px; padding: 10px 12px; margin: 0 -12px; border-radius: 10px; color: inherit; text-decoration: none; }
.news-mini-item:hover { background: var(--surface-2); }
.news-mini-item b { color: var(--text, inherit); }
.news-mini-text { color: var(--muted); font-size: 14px; line-height: 1.4; }
