/* Вигляд поверх Bootstrap 5.3: бічне меню, спокійні поверхні, читабельні таблиці, зручно на моніторі 16:9 і на телефоні. */

/* --- Токени ------------------------------------------------------------------ */
:root {
  --app-font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --app-accent: #e8590c;           /* бренд: «бітумний» помаранчевий — лише логотип і живі індикатори */
  --app-primary: #2459d6;
  --app-primary-hover: #1d4bb8;
  --app-primary-soft: rgba(36, 89, 214, .1);
  --app-bg: #f5f6f8;
  --app-surface: #ffffff;
  --app-surface-2: #f9fafb;
  --app-border: #e4e7ec;
  --app-text-2: #5d6678;
  --app-sidebar-w: 256px;
  --app-radius: .75rem;
  --app-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --bs-body-font-family: var(--app-font);
  --bs-body-font-size: .9375rem;
  --bs-border-radius: .5rem;
  --bs-border-radius-lg: .625rem;
  --bs-border-radius-sm: .375rem;
  --bs-border-color: var(--app-border);
  --bs-link-color: var(--app-primary);
  --bs-link-color-rgb: 36, 89, 214;
  --bs-link-hover-color: var(--app-primary-hover);
  --bs-primary: var(--app-primary);
  --bs-primary-rgb: 36, 89, 214;
  --bs-focus-ring-color: rgba(36, 89, 214, .25);
}
[data-bs-theme="dark"] {
  --app-primary: #5b8cff;
  --app-primary-hover: #7ba3ff;
  --app-primary-soft: rgba(91, 140, 255, .14);
  --app-bg: #0f1218;
  --app-surface: #171b23;
  --app-surface-2: #1c212b;
  --app-border: #2a303c;
  --app-text-2: #98a2b3;
  --bs-body-bg: var(--app-bg);
  --bs-border-color: var(--app-border);
  --bs-link-color: var(--app-primary);
  --bs-link-color-rgb: 91, 140, 255;
  --bs-link-hover-color: var(--app-primary-hover);
  --bs-primary-rgb: 91, 140, 255;
  --bs-secondary-color: var(--app-text-2);
  --bs-tertiary-bg: var(--app-surface-2);
  --bs-focus-ring-color: rgba(91, 140, 255, .3);
}
body { background: var(--app-bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "tnum" 0; }
::selection { background: var(--app-primary-soft); }

/* --- Каркас: бічне меню + вміст ------------------------------------------------- */
.shell { min-height: 100vh; }
.sidebar {
  --bs-offcanvas-width: min(86vw, var(--app-sidebar-w));
  --bs-offcanvas-bg: var(--app-surface);
  display: flex; flex-direction: column;
  background: var(--app-surface); border-right: 1px solid var(--app-border);
}
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--app-sidebar-w); z-index: 1030; }
  .main { margin-left: var(--app-sidebar-w); }
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.1rem .75rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--bs-body-color); text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; color: #fff;
  background: linear-gradient(140deg, #f08c3c, var(--app-accent)); box-shadow: 0 2px 6px rgba(232, 89, 12, .35); }
.brand-mark .bi { width: 1.1rem; height: 1.1rem; }
.sidebar-inst { padding: 0 1.1rem .75rem; }
.inst-name { font-size: .85rem; font-weight: 500; display: flex; align-items: center; gap: .4rem; color: var(--app-text-2); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .25rem .65rem 1rem; }
.nav-section + .nav-section { margin-top: 1rem; }
.nav-caption { display: block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--app-text-2);
  padding: 0 .5rem .35rem; opacity: .8; }
.sidebar-inst .nav-caption { padding-left: 0; }
.side-link { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; margin: 1px 0; border-radius: .55rem;
  color: var(--bs-body-color); text-decoration: none; font-weight: 500; font-size: .9rem; }
.side-link .bi { width: 1.15rem; height: 1.15rem; color: var(--app-text-2); }
.side-link:hover { background: var(--app-surface-2); color: var(--bs-body-color); }
[data-bs-theme="dark"] .side-link:hover { background: rgba(255, 255, 255, .05); }
.side-link.active { background: var(--app-primary-soft); color: var(--app-primary); font-weight: 600; }
.side-link.active .bi { color: var(--app-primary); }
.sidebar-foot { border-top: 1px solid var(--app-border); padding: .6rem .65rem; }
.user-chip { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .45rem .5rem; border: 0; border-radius: .55rem;
  background: transparent; color: inherit; text-align: left; }
.user-chip:hover { background: var(--app-surface-2); }
.avatar { display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; font-weight: 700; font-size: .85rem;
  background: var(--app-primary-soft); color: var(--app-primary); }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.user-name { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-login { font-size: .75rem; color: var(--app-text-2); }
.dropdown-menu { --bs-dropdown-border-color: var(--app-border); --bs-dropdown-link-active-bg: var(--app-primary); border-radius: .65rem; padding: .35rem; }
.dropdown-item { border-radius: .4rem; display: flex; align-items: center; gap: .55rem; }
.dropdown-item .bi { color: var(--app-text-2); }
.dropdown-item.active .bi, .dropdown-item:active .bi { color: inherit; }

/* Жива варка */
.live-pill { margin-left: auto; display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .5rem; border-radius: 99px;
  font-size: .75rem; font-weight: 600; color: #b54708; background: #fff4e5; text-decoration: none; white-space: nowrap; }
[data-bs-theme="dark"] .live-pill { color: #fdb022; background: rgba(253, 176, 34, .12); }
.live-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--app-accent); box-shadow: 0 0 0 0 rgba(232, 89, 12, .6); animation: live 1.8s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 .4rem rgba(232, 89, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(232, 89, 12, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Верхня панель і нижня навігація — телефон / планшет */
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .5rem; height: 3.5rem; padding: 0 .75rem;
  padding-top: env(safe-area-inset-top); background: color-mix(in srgb, var(--app-bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--app-border); }
.topbar-title { font-weight: 650; line-height: 1.15; min-width: 0; }
.topbar-sub { display: block; font-size: .75rem; font-weight: 400; color: var(--app-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 0; border-radius: .6rem; background: transparent; color: inherit; }
.icon-btn:hover { background: var(--app-surface-2); }
.icon-btn .bi { width: 1.4rem; height: 1.4rem; }
.bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 1025; display: flex; background: var(--app-surface); border-top: 1px solid var(--app-border);
  padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav > a, .bottom-nav > button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .45rem 0 .5rem;
  font-size: .7rem; font-weight: 500; color: var(--app-text-2); text-decoration: none; border: 0; background: none; }
.bottom-nav .ico { position: relative; display: grid; place-items: center; width: 3.2rem; height: 1.8rem; border-radius: 99px; }
.bottom-nav .ico .bi { width: 1.3rem; height: 1.3rem; }
.bottom-nav .ico .live-dot { position: absolute; top: .1rem; right: .7rem; }
.bottom-nav .active { color: var(--app-primary); }
.bottom-nav .active .ico { background: var(--app-primary-soft); }
@media (max-width: 991.98px) { .has-shell .content { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); } }

/* Вміст */
.content { max-width: 1680px; margin: 0 auto; padding: 1rem .85rem 2rem; }
@media (min-width: 768px) { .content { padding: 1.5rem 1.5rem 2.5rem; } }
@media (min-width: 1400px) { .content { padding: 1.75rem 2.25rem 3rem; } }
.auth-page .content { max-width: 1100px; padding-top: 3rem; }

/* Заголовки сторінок: і нова розмітка (.page-head), і наявна (d-flex … h1.h4) */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-title, .content h1.h4 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.015em; margin: 0; }
.page-sub, .content h1.h4 > .text-secondary.fw-normal { display: block; font-size: .85rem; font-weight: 400; color: var(--app-text-2); letter-spacing: 0; margin-top: .15rem; }
.content > .d-flex:first-child:has(> h1), .content > div > .d-flex:first-child:has(> h1) { margin-bottom: 1.25rem !important; }
.section-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--app-text-2); margin: 0 0 .65rem; }

/* --- Компоненти ------------------------------------------------------------- */
.card { --bs-card-bg: var(--app-surface); --bs-card-border-color: var(--app-border); --bs-card-border-radius: var(--app-radius);
  --bs-card-inner-border-radius: calc(var(--app-radius) - 1px); --bs-card-cap-padding-y: .8rem; --bs-card-cap-padding-x: 1.1rem;
  --bs-card-spacer-x: 1.1rem; box-shadow: var(--app-shadow); }
.card-header { background: transparent; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-header > a.d-block, .card-header > a.text-decoration-none { color: inherit; flex: 1; display: flex !important; align-items: center; gap: .5rem; }
.card-header > a[data-bs-toggle="collapse"]::after { content: ""; margin-left: auto; width: .55rem; height: .55rem; border-right: 2px solid var(--app-text-2);
  border-bottom: 2px solid var(--app-text-2); transform: rotate(45deg); transition: transform .15s; }
.card-header > a[data-bs-toggle="collapse"][aria-expanded="true"]::after { transform: rotate(-135deg); }
.card-header .bi, .card-header > span > .bi { color: var(--app-text-2); }
.card-footer { background: var(--app-surface-2); border-top-color: var(--app-border); }
.list-group { --bs-list-group-bg: transparent; --bs-list-group-border-color: var(--app-border); }

.btn { --bs-btn-font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn.w-100 { display: flex; }
.btn-primary { --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: var(--app-primary-hover);
  --bs-btn-hover-border-color: var(--app-primary-hover); --bs-btn-active-bg: var(--app-primary-hover); --bs-btn-active-border-color: var(--app-primary-hover);
  --bs-btn-disabled-bg: var(--app-primary); --bs-btn-disabled-border-color: var(--app-primary); }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0b1020; --bs-btn-hover-color: #0b1020; --bs-btn-active-color: #0b1020; --bs-btn-disabled-color: #0b1020; }
.btn-outline-primary { --bs-btn-color: var(--app-primary); --bs-btn-border-color: color-mix(in srgb, var(--app-primary) 45%, transparent);
  --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary); --bs-btn-active-bg: var(--app-primary);
  --bs-btn-active-border-color: var(--app-primary); }
.btn-outline-secondary { --bs-btn-color: var(--bs-body-color); --bs-btn-border-color: var(--app-border); --bs-btn-hover-bg: var(--app-surface-2);
  --bs-btn-hover-color: var(--bs-body-color); --bs-btn-hover-border-color: var(--app-border); --bs-btn-active-bg: var(--app-surface-2);
  --bs-btn-active-color: var(--bs-body-color); background: var(--app-surface); }
.btn-check:checked + .btn-outline-primary { --bs-btn-active-color: #fff; }
.btn-icon { padding: .3rem .45rem; }
.btn-lg { --bs-btn-padding-y: .65rem; --bs-btn-font-size: 1.05rem; }
.form-control, .form-select { border-color: var(--app-border); background-color: var(--app-surface); }
.form-control:focus, .form-select:focus { border-color: var(--app-primary); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .3rem; }
.input-group-text { background: var(--app-surface-2); border-color: var(--app-border); color: var(--app-text-2); }
.alert { border-radius: .65rem; }
.badge { font-weight: 600; }
.modal-content { border: 1px solid var(--app-border); border-radius: .9rem; background: var(--app-surface); }

/* Сегментований перемикач (розмір варки, періоди) */
.seg { display: flex; flex-wrap: wrap; gap: .35rem; }
.seg .btn { flex: 1 1 auto; min-height: 3rem; }
/* Сітка кнопок: 2×2 у вузькій колонці, в один ряд — коли колонці вистачає місця (а не екрану) */
.seg-box { container-type: inline-size; }
.seg-box .seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg-box .seg .btn { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: .3rem; }
@container (min-width: 32rem) { .seg-box .seg { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Показники */
.stat .value { font-size: 1.65rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .value small, .stat .value .unit { font-size: .9rem; font-weight: 500; color: var(--app-text-2); letter-spacing: 0; }
.stat .label { color: var(--app-text-2); font-size: .82rem; font-weight: 500; margin-bottom: .2rem; }
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* План варки на пульті */
.plan-summary { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.plan-cell { display: flex; flex-direction: column; padding: .65rem .8rem; border-radius: .6rem; background: var(--app-surface-2); border: 1px solid var(--app-border); }
.plan-cell .label { font-size: .75rem; color: var(--app-text-2); font-weight: 500; }
.plan-cell .value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-cell .value small { font-size: .8rem; font-weight: 500; color: var(--app-text-2); }
.plan-cell .hint { font-size: .72rem; color: var(--app-text-2); }
.plan-cell.is-warn { background: #fffaeb; border-color: #fedf89; }
[data-bs-theme="dark"] .plan-cell.is-warn { background: rgba(253, 176, 34, .1); border-color: rgba(253, 176, 34, .35); }

/* Відмітка «Кран бітуму відкритий» */
.valve-check { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border-radius: .65rem; cursor: pointer;
  border: 2px dashed #f79009; background: #fffaeb; }
.valve-check .form-check-input { width: 1.6rem; height: 1.6rem; margin: 0; flex: none; cursor: pointer; }
.valve-check:has(input:checked) { border-style: solid; border-color: #12b76a; background: #ecfdf3; }
[data-bs-theme="dark"] .valve-check { background: rgba(247, 144, 9, .08); }
[data-bs-theme="dark"] .valve-check:has(input:checked) { background: rgba(18, 183, 106, .1); }

/* Тестове середовище */
body.test-mode { border-top: 4px solid transparent; border-image: repeating-linear-gradient(-45deg, #f79009 0 12px, #1d2939 12px 24px) 4; }
.test-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem .9rem; margin-bottom: 1rem;
  border-radius: .65rem; border: 2px dashed #f79009; background: #fffaeb; font-size: .875rem; }
.test-banner form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; flex: 1 1 18rem; }
.test-banner select { flex: 1 1 14rem; max-width: 26rem; }
[data-bs-theme="dark"] .test-banner { background: rgba(247, 144, 9, .08); }

/* Таблиці */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--app-surface-2); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; border-bottom-color: var(--app-border); }
.table-sm > :not(caption) > * > * { padding: .4rem .6rem; }
.table thead th { white-space: nowrap; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--app-text-2);
  background: var(--app-surface-2); border-bottom: 1px solid var(--app-border); }
.card > .table-responsive:first-child .table thead th:first-child, .card > .table-responsive:first-child { border-top-left-radius: calc(var(--app-radius) - 1px); }
.card > .table-responsive { border-radius: calc(var(--app-radius) - 1px); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table-sticky thead th { position: sticky; top: 0; z-index: 1; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--app-primary); }
tr.clickable { cursor: pointer; }
.excluded td { text-decoration: line-through; color: var(--bs-secondary-color); }
.excluded td.reason { text-decoration: none; }
.dev-pos { color: var(--bs-warning-text-emphasis); }
.dev-neg { color: var(--bs-danger-text-emphasis); }
.filters .form-select, .filters .form-control { min-width: 9rem; }
.htmx-request #list, #list.htmx-request { opacity: .55; transition: opacity .15s; }
.pager-jump { width: 6.5rem; }
.progress { height: .5rem; border-radius: 99px; background: var(--app-surface-2); }
.counter { font-family: ui-monospace, "JetBrains Mono", "Cascadia Mono", Menlo, monospace; font-weight: 600; letter-spacing: .02em; }

/* Вхід */
.auth-card { max-width: 420px; margin: 0 auto; }
.auth-logo { width: 3.25rem; height: 3.25rem; margin: 0 auto .75rem; border-radius: 1rem; }
.auth-logo .bi { width: 1.6rem; height: 1.6rem; }

@media print {
  /* друк завжди світлий: у темній темі фон не друкується, і світлий текст зникав на білому папері */
  :root, [data-bs-theme="dark"] { color-scheme: light; --bs-body-bg: #fff; --bs-body-color: #111; --bs-emphasis-color: #000;
    --bs-secondary-color: #555; --bs-tertiary-bg: #f5f5f5; --bs-border-color: #ccc; --app-bg: #fff; --app-surface: #fff;
    --app-surface-2: #f5f5f5; --app-border: #ccc; --app-text-2: #555; --bs-table-color: #111; --bs-table-bg: #fff; }
  .sidebar, .topbar, .bottom-nav, .no-print, .btn, .test-banner { display: none !important; }
  .main { margin: 0 !important; }
  .content { max-width: none; padding: 0 !important; }
  body { background: #fff !important; color: #111 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; background: #fff !important; }
  .table-responsive { overflow: visible !important; }
  tr, .stat { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* Графіки: кольори з еталонної палітри; світла і темна теми — окремо підібрані кроки */
.viz-root { --series-1: #257de0; --series-2: #f47230; --series-3: #00b894; --series-4: #f2a600; --series-5: #ee7fac; --series-6: #008a17;
  --div-pos: #257de0; --div-neg: #ec4647; --reference: #8a8a8a; --viz-grid: rgba(0,0,0,.07); --viz-text: #666666; --viz-surface: #ffffff; }
[data-bs-theme="dark"] .viz-root { --series-1: #338ced; --series-2: #e76624; --series-3: #00a888; --series-4: #d28e05; --series-5: #e24d8b; --series-6: #0aac23;
  --div-pos: #338ced; --div-neg: #eb6263; --reference: #8a8a8a; --viz-grid: rgba(255,255,255,.08); --viz-text: #9c9c9c; --viz-surface: #171b23; }
.viz-box { position: relative; height: 300px; }
.viz-box.small { height: 200px; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .8rem; font-weight: 400; color: var(--app-text-2); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.legend-line { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; background: var(--reference); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.bar-cell { position: relative; min-width: 7rem; }
.bar-cell .bar { height: .45rem; border-radius: 99px; background: var(--series-1); opacity: .85; }
.bar-track { background: var(--app-surface-2); border-radius: 99px; }

.kb-body { line-height: 1.65; }
.kb-body img { max-width: 100%; height: auto; }
.kb-body table { width: 100%; margin-bottom: 1rem; border-collapse: collapse; }
.kb-body th, .kb-body td { border: 1px solid var(--bs-border-color); padding: .3rem .5rem; }
.kb-body pre { background: var(--bs-tertiary-bg); padding: .75rem; border-radius: .375rem; }
.kb-body blockquote { border-left: 4px solid var(--bs-border-color); padding-left: 1rem; color: var(--bs-secondary-color); }

/* Картки з кольоровою смугою зліва (border-start border-4 border-*) */
.card.border-start.border-4 { border-width: 1px !important; border-left-width: 4px !important;
  border-top-color: var(--app-border) !important; border-right-color: var(--app-border) !important; border-bottom-color: var(--app-border) !important; }
/* Посилання без підкреслення — підкреслюються при наведенні */
a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a.btn:hover, a.side-link:hover, .bottom-nav a:hover, a.brand:hover, a.dropdown-item:hover, a.live-pill:hover, .card-header > a:hover { text-decoration: none; }
[data-bs-theme="dark"] .text-bg-light { background-color: var(--app-surface-2) !important; color: var(--bs-body-color) !important; }
.pagination { --bs-pagination-active-bg: var(--app-primary); --bs-pagination-active-border-color: var(--app-primary); --bs-pagination-color: var(--app-primary);
  --bs-pagination-border-color: var(--app-border); --bs-pagination-bg: var(--app-surface); --bs-pagination-hover-bg: var(--app-surface-2); }

/* Календар варок */
.cal { overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head > div { padding: .45rem .5rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--app-text-2);
  border-bottom: 1px solid var(--app-border); background: var(--app-surface-2); }
.cal-day { min-height: 5.5rem; padding: .35rem .45rem; border-right: 1px solid var(--app-border); border-bottom: 1px solid var(--app-border); min-width: 0; }
.cal-grid > .cal-day:nth-child(7n) { border-right: 0; }
.cal-grid:last-child .cal-day { border-bottom: 0; }
.cal-day.out { background: var(--app-surface-2); color: var(--app-text-2); opacity: .7; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--app-primary); }
.cal-date { display: flex; justify-content: space-between; align-items: baseline; gap: .25rem; font-weight: 600; font-size: .85rem; }
.cal-date a { text-decoration: none; }
.cal-t { font-size: .72rem; font-weight: 600; color: var(--app-primary); white-space: nowrap; }
.cal-count { margin-top: .4rem; display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; border-radius: 99px;
  background: var(--app-primary-soft); color: var(--app-primary); font-weight: 700; font-size: .8rem; }
.cal-list { list-style: none; margin: .25rem 0 0; padding: 0; font-size: .75rem; line-height: 1.3; }
.cal-list li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--series-1, #257de0); padding-left: .3rem; margin-bottom: 2px; }
.cal-list a { color: inherit; text-decoration: none; }
.cal-list a:hover { text-decoration: underline; }
.cal-list li.st-active, .cal-legend.st-active { border-left-color: var(--app-accent); }
.cal-list li.st-cancelled { border-left-color: #adb5bd; text-decoration: line-through; opacity: .7; }
.cal-legend { display: inline-block; border-left: 3px solid #adb5bd; padding-left: .3rem; margin-left: .5rem; }
@media (max-width: 767.98px) { .cal-day { min-height: 3.6rem; padding: .25rem; } .cal-head > div { padding: .35rem .25rem; text-align: center; } }

/* База знань: фото, відео, PDF у статті */
.kb-gallery { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.kb-gallery figure { margin: 0; }
.kb-gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: .5rem; border: 1px solid var(--app-border); background: var(--app-surface-2); }
.kb-gallery figcaption { font-size: .78rem; color: var(--app-text-2); margin-top: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-video { display: block; width: 100%; max-height: 75vh; background: #000; border-bottom-left-radius: var(--app-radius); border-bottom-right-radius: var(--app-radius); }
.kb-pdf > summary { cursor: pointer; list-style: none; }
.kb-pdf > summary::-webkit-details-marker { display: none; }
.kb-pdf iframe { display: block; width: 100%; height: 80vh; border: 0; }
@media print { .kb-pdf iframe, .kb-video { display: none; } }

/* Швидкий вибір місяця (календар варок) */
.month-picker { width: 17rem; max-height: min(22rem, 70vh); overflow-y: auto; }
.mp-year { padding: .4rem .5rem .5rem; border-bottom: 1px solid var(--app-border); }
.mp-year:last-child { border-bottom: 0; }
.mp-year-title { position: sticky; top: 0; z-index: 1; font-weight: 600; font-size: .85rem; padding: .15rem .25rem .3rem; background: var(--bs-dropdown-bg, var(--app-surface)); }
.mp-year.current .mp-year-title { color: var(--app-primary); }
.mp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.mp-month { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 2.6rem; border-radius: 6px;
  font-size: .82rem; text-decoration: none; color: var(--app-text-2); border: 1px solid transparent; line-height: 1.1; }
.mp-month small { font-size: .66rem; color: var(--app-primary); font-weight: 600; }
.mp-month.has { color: var(--bs-body-color); font-weight: 600; background: var(--app-surface-2); }
.mp-month:hover { border-color: var(--app-primary); color: var(--app-primary); }
.mp-month.today { border-color: var(--app-border); box-shadow: inset 0 0 0 1px var(--app-primary); }
.mp-month.selected { background: var(--app-primary); color: #fff; }
.mp-month.selected small { color: #fff; }

/* Калькулятори: поля в одному ряду вирівнюються по низу, навіть коли підпис переноситься */
.calc-fields > [class*="col"]:has(> input, > select, > .input-group) { display: flex; flex-direction: column; justify-content: flex-end; }
.calc-nav { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Модальні форми: <form> обгортає header/body/footer, тож прокручуємо тіло всередині форми,
   а шапка з кнопкою закриття і кнопки внизу лишаються на екрані */
.modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; max-height: 100%; }
.modal-content > form > .modal-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.modal-content > form > .modal-header, .modal-content > form > .modal-footer { flex-shrink: 0; }
.cal-t.ship { color: var(--series-2, #f47230); text-decoration: none; }
.cal-list li.ship, .cal-legend.ship { border-left-color: var(--series-2, #f47230); }
.cal-count.ship { background: var(--series-2, #f47230); color: #fff; }
.dev-good { color: var(--bs-success-text-emphasis); }
