:root {
  --bg-dark: url(/static/img/paris-protest-2026.jpg);
  --bg-light: url(/static/img/paris-protest-2026.jpg);
  --bg-mobile: url(/static/img/paris-protest-2026-m.jpg);
  --radius: 14px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
[data-theme="dark"] {
  --bg: var(--bg-dark);
  --veil: rgba(8, 8, 18, .6);
  --surface: rgba(22, 20, 36, .72);
  --surface-2: rgba(40, 36, 62, .7);
  --border: rgba(255, 255, 255, .12);
  --text: #f1eef8;
  --muted: #b8b0cc;
  --accent: #f0a04b;
  --accent-text: #1b1020;
  --ok: #5fd08a; --warn: #f2c14e; --bad: #ff6b6b; --info: #7ab8ff;
}
[data-theme="light"] {
  --bg: var(--bg-light);
  --veil: rgba(255, 252, 247, .55);
  --surface: rgba(255, 255, 255, .8);
  --surface-2: rgba(246, 241, 236, .85);
  --border: rgba(40, 30, 60, .14);
  --text: #1f1a2e;
  --muted: #5b5470;
  --accent: #b2561b;
  --accent-text: #fff;
  --ok: #1d8a4d; --warn: #9a6a00; --bad: #c62828; --info: #1f5fbf;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.5 var(--font); color: var(--text);
  background: #1a1426 var(--bg) center / cover no-repeat fixed;
}
/* затемняющий и размывающий слой поверх фона */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: var(--veil); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
@media (max-width: 800px) {
  body { background-attachment: scroll; background-image: var(--bg-mobile, var(--bg)); }
  body::before { backdrop-filter: none; }
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px;
  background: var(--surface); border-right: 1px solid var(--border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; margin: 2px 0;
  border-radius: 10px; color: var(--text); text-decoration: none;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent); color: var(--accent-text); }
.nav .badge { background: var(--bad); color: #fff; }
.main { padding: 20px 24px 60px; min-width: 0; }
.topbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .right { display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: var(--gap);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.card.inner { background: var(--surface-2); backdrop-filter: none; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; word-break: break-word; }

button, .btn {
  font: inherit; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 7px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-flex; gap: 6px; align-items: center;
}
button:hover { filter: brightness(1.1); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.danger { color: var(--bad); }
button.ok { color: var(--ok); }
button:disabled { opacity: .5; cursor: progress; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
input[type=checkbox] { width: auto; }

.tag, .badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border); margin: 0 4px 4px 0; white-space: nowrap;
}
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); } .badge.info { color: var(--info); }
.status-pending { color: var(--warn); } .status-approved { color: var(--info); } .status-published { color: var(--ok); }
.status-rejected, .status-failed, .status-revoked { color: var(--bad); }
.warning { border-left: 3px solid var(--warn); padding: 6px 10px; background: rgba(242, 193, 78, .1); border-radius: 6px; margin: 6px 0; }
.danger-box { border-left: 3px solid var(--bad); padding: 6px 10px; background: rgba(255, 107, 107, .1); border-radius: 6px; margin: 6px 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.active { background: var(--accent); color: var(--accent-text); }

.media { width: 100%; border-radius: 10px; background: #0003; display: block; }
.media.thumb { aspect-ratio: 1; object-fit: cover; }
video.media { width: auto; max-width: 100%; max-height: 70vh; margin: 0 auto; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.refs { font-size: 13px; }
.refs li { margin-bottom: 6px; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar .day { min-width: 0; min-height: 110px; padding: 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.calendar .day .num { font-weight: 700; color: var(--muted); }
.calendar .ev { display: block; padding: 3px 6px; margin-top: 4px; border-radius: 6px; background: var(--surface); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid var(--accent); }
.calendar .head { text-align: center; color: var(--muted); font-size: 12px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast div { background: var(--surface); border: 1px solid var(--border); padding: 10px 14px; border-radius: 10px; backdrop-filter: blur(10px); max-width: 360px; }
.toast .err { border-color: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: #0008; display: grid; place-items: center; z-index: 40; padding: 12px; }
.modal { width: min(720px, 100%); max-height: 90vh; overflow: auto; }
.kpi { font-size: 26px; font-weight: 700; }
.bar { height: 8px; border-radius: 4px; background: var(--accent); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1000px) { .grid.wide { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .main { padding: 14px 12px 60px; }
  .hide-mobile { display: none; }
  .calendar { grid-template-columns: 1fr; }
  .calendar .head { display: none; }
  .calendar .day.empty { display: none; }
  .calendar .day { min-height: auto; }
}

.credit { position: fixed; right: 8px; bottom: 6px; z-index: 1; font-size: 11px; color: var(--muted); opacity: .8; max-width: 60vw; text-align: right; }
.credit a { color: inherit; }
@media (max-width: 800px) { .credit { position: static; padding: 8px 12px 14px; max-width: none; } }

.card.focus { outline: 2px solid var(--accent); }
/* Mini App: вырез экрана и системная панель Telegram */
.main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
.sidebar { padding-top: calc(18px + env(safe-area-inset-top)); }

/* связность: карточки сущностей, поиск, крошки */
.elink { color: var(--accent); text-decoration: none; border-bottom: 1px dotted currentColor; }
.elink:hover { border-bottom-style: solid; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px; }
.crumbs a { color: var(--muted); }
.crumbs span { color: var(--text); }
.fields-list { display: grid; grid-template-columns: minmax(110px, 180px) 1fr; gap: 6px 14px; margin: 12px 0 0; }
.fields-list dt { color: var(--muted); font-size: 13px; }
.fields-list dd { margin: 0; min-width: 0; }
.clamp { max-height: 7.5em; overflow: auto; }
.rel-item { padding: 3px 0; }
.btn { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; background: var(--surface-2); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font: 12px var(--font); background: var(--surface-2); }
.palette { width: min(560px, 100%); margin-top: 10vh; }
.palette input { width: 100%; font-size: 16px; }
.pres { max-height: 50vh; overflow: auto; margin: 8px 0; }
.pitem { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.pitem.sel, .pitem:hover { background: var(--surface-2); }
/* скелетоны: каркас виден сразу, место под данные зарезервировано */
.skel { min-height: 140px; }
.skel i { display: block; height: 14px; margin: 14px 0; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel i { animation: none; } }
/* плотность: компактный режим */
[data-density="compact"] body { font-size: 13.5px; line-height: 1.4; }
[data-density="compact"] .card { padding: 10px; margin-bottom: 10px; }
[data-density="compact"] .nav a { padding: 6px 10px; }
@media (max-width: 800px) { .fields-list { grid-template-columns: 1fr; } .fields-list dd { margin-bottom: 6px; } }
