/* ============================================================
   Отчётность учреждения культуры — оформление интерфейса
   ============================================================ */

:root {
  --ink: #1c1a24;
  --ink-2: #4a4657;
  --ink-3: #6f6a7d;
  --line: #e4e1ea;
  --line-strong: #cfcada;
  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #fbfafd;

  --accent: #6a3d9a;
  --accent-ink: #4a2670;
  --accent-soft: #f1ebf8;
  --accent-line: #d9c9ec;

  --gold: #b7873b;
  --gold-soft: #fbf3e3;

  --ok: #1f7a52;
  --ok-soft: #e8f6ee;
  --warn: #a86a12;
  --warn-soft: #fdf3e0;
  --err: #b03434;
  --err-soft: #fbeaea;
  --info: #25638c;
  --info-soft: #e8f2f8;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(28, 26, 36, .06), 0 1px 3px rgba(28, 26, 36, .04);
  --shadow: 0 4px 16px rgba(28, 26, 36, .08), 0 1px 3px rgba(28, 26, 36, .04);
  --shadow-lg: 0 24px 60px rgba(28, 26, 36, .18);
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ------------------------------- Layout ------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(185deg, #2b2039 0%, #1e1728 100%);
  color: #e8e4f0;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand { display: flex; gap: 11px; align-items: center; padding: 2px 6px; }
.brand-logo {
  width: 40px; height: 40px; flex: 0 0 auto; object-fit: contain;
  border-radius: 11px; background: #fff; padding: 3px;
  box-shadow: 0 4px 14px rgba(143, 94, 203, .28);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(150deg, #8f5ecb, #b7873b);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 14px rgba(143, 94, 203, .4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 14px; }
.brand-text span { font-size: 11px; color: #a99fc0; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px;
  color: #c9c2dc; background: none; border: 0; cursor: pointer;
  font-size: 13.5px; text-align: left; width: 100%;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: rgba(159, 116, 216, .22); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; height: 18px; opacity: .85; flex: 0 0 auto; }
.nav-item .badge-count {
  margin-left: auto; font-size: 11px; background: rgba(255,255,255,.13);
  padding: 1px 7px; border-radius: 20px;
}

.sidebar-user {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding: 12px 8px 0;
  display: flex; align-items: center; gap: 9px;
}
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(150deg, #8f5ecb, #b7873b);
  color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; text-transform: uppercase;
}
.sidebar-user .who {
  display: flex; flex-direction: column; min-width: 0; line-height: 1.25;
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
}
.sidebar-user .who:hover b { color: #fff; text-decoration: underline dotted; text-underline-offset: 3px; }
.sidebar-user .who b { font-size: 12.5px; color: #f0ecf7; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who span { font-size: 10.5px; color: #a99fc0; }
.sidebar-user .logout {
  margin-left: auto; border: 0; background: rgba(255, 255, 255, .08); color: #cfc7e0;
  border-radius: 8px; padding: 5px 7px; cursor: pointer; display: grid; place-items: center;
}
.sidebar-user .logout:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.sidebar-foot { margin-top: 10px; font-size: 11.5px; color: #8d84a3; padding: 0 8px; }
.sidebar-foot b { color: #c0b7d4; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(246, 245, 249, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.topbar-title { display: flex; flex-direction: column; gap: 1px; margin-right: auto; }
.topbar-title h1 { font-size: 19px; }
.topbar-title span { font-size: 12px; color: var(--ink-3); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.content { padding: 22px 24px 60px; max-width: 1500px; width: 100%; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 60px; }
}

/* ------------------------------- Cards -------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.card-head h2, .card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12px; color: var(--ink-3); }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 12px; color: var(--ink-3); }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 15px 16px; }
.kpi-label { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.kpi-delta { font-size: 12px; display: flex; align-items: center; gap: 5px; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--err); }
.kpi-delta.flat { color: var(--ink-3); }
.kpi-spark { margin-top: 2px; }

.stat-row { display: flex; gap: 22px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--ink-3); }

/* ------------------------------ Controls ------------------------------ */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); padding: 7px 13px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; font-weight: 520;
  transition: background .13s, border-color .13s, box-shadow .13s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--accent-line); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(106, 61, 154, .25); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--err); border-color: #eccaca; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.icon { padding: 6px; }
.btn svg { width: 15px; height: 15px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; color: var(--ink-2); font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--ink-3); }

input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="search"], input[type="email"], input[type="tel"], select, textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
  transition: border-color .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
textarea { resize: vertical; min-height: 64px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%236f6a7d' d='M6 8.5 1.8 4.3l.9-.9L6 6.7l3.3-3.3.9.9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 26px; }

.checkline { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; font-size: 13px; }
.checkline input { margin-top: 2px; flex: 0 0 auto; }
.checkline .cl-text { display: flex; flex-direction: column; gap: 1px; }
.checkline .cl-text small { color: var(--ink-3); font-size: 11.5px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1 1 180px; min-width: 140px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  border: 0; background: var(--surface); padding: 6px 11px; cursor: pointer; font-size: 12.5px;
  color: var(--ink-2); border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ------------------------------- Tables ------------------------------- */

.table-wrap { overflow: auto; max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 8px 11px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th {
  background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--ink-2);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
table.data tbody tr:hover { background: #faf8fd; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--line-strong); }
table.data .sub { color: var(--ink-3); font-size: 11.5px; }
table.data tr.clickable { cursor: pointer; }
table.data.compact th, table.data.compact td { padding: 6px 9px; }

.empty {
  padding: 34px 18px; text-align: center; color: var(--ink-3); font-size: 13px;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.empty svg { width: 34px; height: 34px; opacity: .35; }

/* ------------------------------- Badges ------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 550;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); border-color: #bfe4d0; color: var(--ok); }
.badge.warn { background: var(--warn-soft); border-color: #f0d9ac; color: var(--warn); }
.badge.err { background: var(--err-soft); border-color: #eccaca; color: var(--err); }
.badge.info { background: var(--info-soft); border-color: #c3dceb; color: var(--info); }
.badge.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.badge.gold { background: var(--gold-soft); border-color: #ecd9b0; color: var(--gold); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ------------------------------- Modal -------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(24, 20, 33, .45);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  animation: fade .13s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(720px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  animation: pop .16s cubic-bezier(.2, .9, .3, 1);
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6 } to { transform: none; opacity: 1 } }
.modal.wide { width: min(1040px, 100%); }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }

/* ------------------------------- Toast -------------------------------- */

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: #241d31; color: #f4f1fa; padding: 10px 14px; border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 13px; max-width: 400px;
  display: flex; gap: 9px; align-items: flex-start;
  animation: slide .16s ease;
}
@keyframes slide { from { transform: translateX(14px); opacity: 0 } to { transform: none; opacity: 1 } }
.toast.err { background: #5c2020; }
.toast.ok { background: #1c4c37; }

/* ------------------------------- Charts ------------------------------- */

.chart { width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--ink-3); font-size: 10.5px; }
.chart .bar { fill: var(--accent); transition: opacity .13s; }
.chart .bar.alt { fill: var(--gold); }
.chart .bar.soft { fill: #c9b3e2; }
.chart .area { fill: url(#grad); opacity: .9; }
.chart .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .point { fill: var(--surface); stroke-width: 2; }
.chart .label { font-size: 10.5px; fill: var(--ink-2); }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.donut-legend { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; }
.donut-legend .row { display: flex; align-items: center; gap: 8px; }
.donut-legend .row .name { flex: 1; color: var(--ink-2); }
.donut-legend .row .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.donut-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }

/* ---------------------------- Report tables --------------------------- */

.report-section { display: flex; flex-direction: column; gap: 14px; }
.report-hint { font-size: 12px; color: var(--ink-2); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius-sm); padding: 10px 12px; }
.report-hint ul { margin: 4px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
table.form7 {
  border-collapse: collapse; font-size: 12px; width: 100%;
  background: var(--surface);
}
table.form7 th, table.form7 td {
  border: 1px solid var(--line-strong); padding: 5px 6px; text-align: center; vertical-align: middle;
}
table.form7 th { background: var(--surface-2); font-weight: 600; font-size: 11px; line-height: 1.25; }
table.form7 th.graph-num { background: #efeaf7; font-family: var(--mono); font-weight: 600; font-size: 11px; }
table.form7 td.label { text-align: left; }
table.form7 td.code { font-family: var(--mono); font-weight: 600; background: var(--surface-2); }
table.form7 td.val { text-align: right; font-variant-numeric: tabular-nums; min-width: 54px; }
table.form7 td.val.over { background: var(--warn-soft); position: relative; }
table.form7 td.val.over::after { content: '✎'; position: absolute; top: 0; right: 2px; font-size: 8px; color: var(--warn); }
table.form7 td.val.x { color: var(--ink-3); }
table.form7 td.val:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
table.form7 td.val.editable { cursor: text; }
table.form7 tr:hover td.val.editable { background: var(--accent-soft); }

.checks { display: flex; flex-direction: column; gap: 0; }
.check-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; align-items: flex-start; }
.check-item:last-child { border-bottom: 0; }
.check-item .mark { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; flex: 0 0 auto; font-weight: 700; }
.check-item.ok .mark { background: var(--ok-soft); color: var(--ok); }
.check-item.warn .mark { background: var(--warn-soft); color: var(--warn); }
.check-item.error .mark { background: var(--err-soft); color: var(--err); }
.check-item .msg { color: var(--ink-3); font-size: 11.5px; }

/* --------------------------- Misc components -------------------------- */

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-col { display: flex; flex-direction: column; gap: 10px; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.spacer { margin-left: auto; }
.hr { height: 1px; background: var(--line); border: 0; margin: 12px 0; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 650; }
.tr { text-align: right; }
.pos { color: var(--ok); }
.neg { color: var(--err); }

.accordion-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 13px 16px; background: var(--surface); border: 0; cursor: pointer; text-align: left;
  font-size: 14.5px; font-weight: 620; border-bottom: 1px solid var(--line);
}
.accordion-head:hover { background: var(--surface-2); }
.accordion-head .chev { transition: transform .15s; margin-left: auto; color: var(--ink-3); }
.accordion-head.open .chev { transform: rotate(90deg); }

.tag-list { display: flex; gap: 5px; flex-wrap: wrap; }

.quick-add {
  display: grid; grid-template-columns: 118px 1fr 150px 96px 96px 96px auto;
  gap: 8px; align-items: end;
}
@media (max-width: 1100px) { .quick-add { grid-template-columns: repeat(2, 1fr); } }

.skeleton { background: linear-gradient(90deg, #eee 25%, #f6f6f6 37%, #eee 63%); background-size: 400% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 12px; }
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: 0 0 } }

.scroll-y { max-height: 420px; overflow-y: auto; }

/* ------------------------------- Print -------------------------------- */

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toasts, .sidebar-user { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .report-section { break-inside: avoid; }
  table.form7 { font-size: 9px; }
  table.form7 th, table.form7 td { padding: 2px 3px; }
  @page { size: A4 landscape; margin: 8mm; }
}
