/*
 * Книгообеспеченность — оформление в стиле libadwaita (GNOME 48/49)
 * Цвета и метрики повторяют именованные цвета Adwaita (@window_bg_color, @sidebar_bg_color и т.д.)
 */

@font-face { font-family: "Adwaita Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/AdwaitaSans-400.woff2") format("woff2"); }
@font-face { font-family: "Adwaita Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/AdwaitaSans-600.woff2") format("woff2"); }
@font-face { font-family: "Adwaita Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/AdwaitaSans-700.woff2") format("woff2"); }
@font-face { font-family: "Adwaita Sans"; font-weight: 800; font-style: normal; font-display: swap; src: url("fonts/AdwaitaSans-800.woff2") format("woff2"); }

/* ---------- Палитра ---------- */

:root {
  color-scheme: light;

  --accent-bg-color: #3584e4;
  --accent-fg-color: #ffffff;
  --accent-color: #0461be;

  --destructive-bg-color: #e01b24;
  --destructive-fg-color: #ffffff;
  --destructive-color: #c30000;

  --success-bg-color: #2ec27e;
  --success-fg-color: #ffffff;
  --success-color: #1b8553;

  --warning-bg-color: #e5a50a;
  --warning-fg-color: rgb(0 0 0 / 80%);
  --warning-color: #9c6e03;

  --error-bg-color: #e01b24;
  --error-fg-color: #ffffff;
  --error-color: #c30000;

  --window-bg-color: #fafafb;
  --window-fg-color: rgb(0 0 6 / 80%);

  --view-bg-color: #ffffff;
  --view-fg-color: rgb(0 0 6 / 80%);

  --headerbar-bg-color: #ffffff;
  --headerbar-fg-color: rgb(0 0 6 / 80%);
  --headerbar-border-color: rgb(0 0 6 / 80%);
  --headerbar-shade-color: rgb(0 0 6 / 12%);

  --sidebar-bg-color: #ebebed;
  --sidebar-fg-color: rgb(0 0 6 / 80%);
  --sidebar-shade-color: rgb(0 0 6 / 7%);
  --sidebar-border-color: rgb(0 0 6 / 7%);

  --card-bg-color: #ffffff;
  --card-fg-color: rgb(0 0 6 / 80%);
  --card-shade-color: rgb(0 0 6 / 7%);

  --dialog-bg-color: #fafafb;
  --dialog-fg-color: rgb(0 0 6 / 80%);

  --popover-bg-color: #ffffff;
  --popover-fg-color: rgb(0 0 6 / 80%);
  --popover-shade-color: rgb(0 0 6 / 7%);

  --shade-color: rgb(0 0 6 / 7%);
  --scrollbar-outline-color: #ffffff;

  --border-opacity: 15%;
  --dim-opacity: 55%;
  --disabled-opacity: 50%;

  --border-color: color-mix(in srgb, currentColor var(--border-opacity), transparent);
  --hover-bg: color-mix(in srgb, currentColor 7%, transparent);
  --active-bg: color-mix(in srgb, currentColor 16%, transparent);
  --selected-bg: color-mix(in srgb, currentColor 10%, transparent);
  --button-bg: color-mix(in srgb, currentColor 10%, transparent);
  --button-hover-bg: color-mix(in srgb, currentColor 15%, transparent);
  --button-active-bg: color-mix(in srgb, currentColor 30%, transparent);

  --window-radius: 15px;
  --card-radius: 12px;
  --button-radius: 6px;
  --popover-radius: 12px;

  --font-family: "Adwaita Sans", "Cantarell", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --monospace-font-family: "Adwaita Mono", "Source Code Pro", ui-monospace, monospace;

  --sidebar-width: 300px;
  --headerbar-height: 47px;
  --bottombar-height: 58px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --accent-color: #81bcff;
  --destructive-color: #ff938c;
  --success-color: #78e9ab;
  --warning-color: #ffc252;
  --error-color: #ff938c;

  --window-bg-color: #222226;
  --window-fg-color: #ffffff;

  --view-bg-color: #1d1d20;
  --view-fg-color: #ffffff;

  --headerbar-bg-color: #2e2e32;
  --headerbar-fg-color: #ffffff;
  --headerbar-border-color: #ffffff;
  --headerbar-shade-color: rgb(0 0 6 / 36%);

  --sidebar-bg-color: #2e2e32;
  --sidebar-fg-color: #ffffff;
  --sidebar-shade-color: rgb(0 0 6 / 25%);
  --sidebar-border-color: rgb(0 0 6 / 36%);

  --card-bg-color: rgb(255 255 255 / 8%);
  --card-fg-color: #ffffff;
  --card-shade-color: rgb(0 0 6 / 36%);

  --dialog-bg-color: #36363a;
  --dialog-fg-color: #ffffff;

  --popover-bg-color: #36363a;
  --popover-fg-color: #ffffff;
  --popover-shade-color: rgb(0 0 6 / 25%);

  --shade-color: rgb(0 0 6 / 25%);
  --scrollbar-outline-color: rgb(0 0 6 / 50%);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;

    --accent-color: #81bcff;
    --destructive-color: #ff938c;
    --success-color: #78e9ab;
    --warning-color: #ffc252;
    --error-color: #ff938c;

    --window-bg-color: #222226;
    --window-fg-color: #ffffff;

    --view-bg-color: #1d1d20;
    --view-fg-color: #ffffff;

    --headerbar-bg-color: #2e2e32;
    --headerbar-fg-color: #ffffff;
    --headerbar-border-color: #ffffff;
    --headerbar-shade-color: rgb(0 0 6 / 36%);

    --sidebar-bg-color: #2e2e32;
    --sidebar-fg-color: #ffffff;
    --sidebar-shade-color: rgb(0 0 6 / 25%);
    --sidebar-border-color: rgb(0 0 6 / 36%);

    --card-bg-color: rgb(255 255 255 / 8%);
    --card-fg-color: #ffffff;
    --card-shade-color: rgb(0 0 6 / 36%);

    --dialog-bg-color: #36363a;
    --dialog-fg-color: #ffffff;

    --popover-bg-color: #36363a;
    --popover-fg-color: #ffffff;
    --popover-shade-color: rgb(0 0 6 / 25%);

    --shade-color: rgb(0 0 6 / 25%);
    --scrollbar-outline-color: rgb(0 0 6 / 50%);
  }
}

/* ---------- База ---------- */

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: 14.667px; /* 11pt */
  line-height: 1.38;
  background: var(--window-bg-color);
  color: var(--window-fg-color);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent-color); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent-color) 50%, transparent);
  outline-offset: -2px;
}

[hidden] { display: none !important; }

svg.icon { width: 16px; height: 16px; flex: none; fill: currentColor; display: block; }

.dim-label { opacity: var(--dim-opacity); }
.title-1 { font-size: 26.667px; font-weight: 800; line-height: 1.2; }
.title-2 { font-size: 20px; font-weight: 800; line-height: 1.25; }
.title-3 { font-size: 20px; font-weight: 700; }
.title-4 { font-size: 17.333px; font-weight: 700; }
.heading { font-weight: 700; }
.caption { font-size: 12px; }
.caption-heading { font-size: 12px; font-weight: 700; }
.numeric { font-variant-numeric: tabular-nums; }

/* ---------- Окно ---------- */

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* Сайдбар (AdwNavigationSplitView / AdwSidebar) */
.sidebar {
  width: var(--sidebar-width);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg-color);
  color: var(--sidebar-fg-color);
  box-shadow: inset -1px 0 var(--sidebar-border-color);
  position: relative;
  z-index: 2;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--window-bg-color);
  position: relative;
}

/* ---------- Headerbar ---------- */

.headerbar {
  flex: none;
  height: var(--headerbar-height);
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--headerbar-bg-color);
  color: var(--headerbar-fg-color);
  box-shadow: inset 0 -1px var(--headerbar-shade-color);
  position: relative;
  z-index: 3;
  user-select: none;
}

.sidebar .headerbar {
  background: var(--sidebar-bg-color);
  color: var(--sidebar-fg-color);
  box-shadow: none;
}

.content .headerbar { background: var(--window-bg-color); }
.content .headerbar.raised { box-shadow: inset 0 -1px var(--headerbar-shade-color), 0 1px 5px var(--headerbar-shade-color); }

.headerbar .start, .headerbar .end { display: flex; align-items: center; gap: 6px; min-width: 0; }
.headerbar .end { justify-content: flex-end; }

.headerbar .title-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  line-height: 1.2;
}
.headerbar .title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.headerbar .subtitle {
  font-size: 12px;
  opacity: var(--dim-opacity);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  min-width: 34px;
  padding: 5px 10px;
  border: none;
  border-radius: var(--button-radius);
  background: var(--button-bg);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 200ms;
  text-decoration: none !important;
}
.btn:hover { background: var(--button-hover-bg); }
.btn:active { background: var(--button-active-bg); }
.btn:disabled, .btn.disabled { opacity: var(--disabled-opacity); cursor: default; pointer-events: none; }

.btn.flat { background: transparent; }
.btn.flat:hover { background: var(--button-bg); }
.btn.flat:active { background: var(--button-active-bg); }

.btn.image-button { padding: 0; width: 34px; }
.btn.circular { border-radius: 9999px; }

.btn.suggested-action { background: var(--accent-bg-color); color: var(--accent-fg-color); }
.btn.suggested-action:hover { background: color-mix(in srgb, var(--accent-bg-color), currentColor 10%); }
.btn.suggested-action:active { background: color-mix(in srgb, var(--accent-bg-color), black 20%); }

.btn.destructive-action { background: var(--destructive-bg-color); color: var(--destructive-fg-color); }

.btn.pill { border-radius: 9999px; padding: 10px 32px; min-height: 0; }

.btn .spinner { width: 16px; height: 16px; }

.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Навигационный сайдбар ---------- */

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 0 12px; }

.sidebar-section + .sidebar-section { margin-top: 6px; }

.sidebar-section-title {
  padding: 12px 18px 6px;
  font-size: 12px;
  font-weight: 700;
  opacity: var(--dim-opacity);
}

.navigation-sidebar { display: flex; flex-direction: column; gap: 2px; padding: 0 6px; }

.sidebar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--button-radius);
  color: inherit;
  text-decoration: none !important;
  cursor: pointer;
  transition: background-color 150ms;
}
.sidebar-row:hover { background: var(--hover-bg); }
.sidebar-row:active { background: var(--active-bg); }
.sidebar-row.selected { background: var(--selected-bg); }
.sidebar-row.selected:hover { background: color-mix(in srgb, currentColor 13%, transparent); }
.sidebar-row .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Нижний бар (AdwViewSwitcherBar) ---------- */

.view-switcher-bar {
  display: none;
  flex: none;
  height: calc(var(--bottombar-height) + env(safe-area-inset-bottom, 0px));
  padding: 0 6px env(safe-area-inset-bottom, 0px);
  background: var(--headerbar-bg-color);
  color: var(--headerbar-fg-color);
  box-shadow: inset 0 1px var(--headerbar-shade-color);
  gap: 6px;
  align-items: stretch;
  user-select: none;
}
.content .view-switcher-bar { background: var(--sidebar-bg-color); }

.view-switcher-button {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 6px 0;
  padding: 4px 2px;
  border-radius: var(--button-radius);
  color: inherit;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 700;
  transition: background-color 150ms;
}
.view-switcher-button .icon { width: 16px; height: 16px; }
.view-switcher-button .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-switcher-button:hover { background: var(--hover-bg); }
.view-switcher-button.selected { background: var(--selected-bg); }

/* ---------- Баннер (AdwBanner) ---------- */

.banner {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 46px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--accent-bg-color) 30%, var(--window-bg-color));
  text-align: center;
  font-weight: 700;
}
.banner.warning { background: color-mix(in srgb, var(--warning-bg-color) 30%, var(--window-bg-color)); }

/* ---------- Прокручиваемая область и clamp ---------- */

.scroller {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, currentColor 30%, transparent) transparent;
}

.clamp {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 12px 36px;
}
.clamp.wide { max-width: 1200px; }
.clamp.narrow { max-width: 640px; }

.page-enter { animation: page-enter 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94); }
@keyframes page-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- AdwStatusPage ---------- */

.status-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 12px;
  gap: 0;
}
.status-page .status-icon {
  width: 128px;
  height: 128px;
  margin-bottom: 36px;
  opacity: var(--dim-opacity);
}
.status-page .status-icon svg { width: 100%; height: 100%; }
.status-page .title-1 { margin-bottom: 12px; }
.status-page .description { max-width: 520px; }
.status-page .status-actions { margin-top: 24px; }

.status-page.compact { padding: 24px 12px; }
.status-page.compact .status-icon { width: 64px; height: 64px; margin-bottom: 18px; }
.status-page.compact .title-1 { font-size: 20px; }

/* ---------- AdwPreferencesGroup / boxed-list ---------- */

.pref-group { margin-bottom: 24px; }
.pref-group:last-child { margin-bottom: 0; }

.pref-group-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px 12px;
  margin: 0 0 12px;
  padding: 0 2px;
}
.pref-group-header .titles { flex: 1 1 200px; min-width: 0; }
.pref-group-header .group-title { font-weight: 700; margin: 0; font-size: inherit; }
.pref-group-header .group-description { font-size: 14.667px; opacity: var(--dim-opacity); margin-top: 3px; }
.pref-group-header .suffix { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.boxed-list, .card {
  background: var(--card-bg-color);
  color: var(--card-fg-color);
  border-radius: var(--card-radius);
  box-shadow: 0 0 0 1px rgb(0 0 6 / 3%), 0 1px 3px 1px rgb(0 0 6 / 7%), 0 2px 6px 2px rgb(0 0 6 / 3%);
  overflow: hidden;
}
:root[data-theme="dark"] .boxed-list, :root[data-theme="dark"] .card {
  box-shadow: 0 0 0 1px rgb(0 0 6 / 9%), 0 1px 3px 1px rgb(0 0 6 / 30%), 0 2px 6px 2px rgb(0 0 6 / 15%);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .boxed-list, :root[data-theme="auto"] .card {
    box-shadow: 0 0 0 1px rgb(0 0 6 / 9%), 0 1px 3px 1px rgb(0 0 6 / 30%), 0 2px 6px 2px rgb(0 0 6 / 15%);
  }
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 8px 12px;
  position: relative;
  color: inherit;
  text-decoration: none !important;
}
.boxed-list > .row + .row, .boxed-list > .row + .row-wrap, .boxed-list > .row-wrap + .row, .boxed-list > .row-wrap + .row-wrap {
  box-shadow: inset 0 1px color-mix(in srgb, currentColor 10%, transparent);
}
.row.activatable { cursor: pointer; transition: background-color 150ms; }
.row.activatable:hover { background: color-mix(in srgb, currentColor 3%, transparent); }
.row.activatable:active { background: color-mix(in srgb, currentColor 8%, transparent); }
.row.disabled { opacity: var(--disabled-opacity); pointer-events: none; }

.row .prefix { display: flex; align-items: center; gap: 12px; flex: none; }
.row .titles { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 0; }
.row .row-title { overflow-wrap: anywhere; }
.row .row-subtitle { font-size: 12px; opacity: var(--dim-opacity); overflow-wrap: anywhere; }
.row .suffix { display: flex; align-items: center; gap: 6px; flex: none; max-width: 55%; }
.row .suffix .value {
  opacity: var(--dim-opacity);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.row .chevron { opacity: var(--dim-opacity); }

.row.combo .suffix { max-width: 60%; }
.row.combo.has-value .value { opacity: 1; }

.row-icon { width: 16px; height: 16px; opacity: 0.8; }

/* Row list в отчётах на мобильных */
.row.report-row .titles { gap: 3px; }
.row.report-row .row-title { font-weight: 400; }
.row.report-row .meta { font-size: 12px; opacity: var(--dim-opacity); display: flex; flex-wrap: wrap; gap: 2px 10px; }

/* ---------- Switch ---------- */

.switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex: none;
  border-radius: 14px;
  background: color-mix(in srgb, currentColor 15%, transparent);
  cursor: pointer;
  transition: background-color 200ms;
  border: none;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
  transition: transform 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.switch[aria-checked="true"] { background: var(--accent-bg-color); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.switch:hover { background: color-mix(in srgb, currentColor 20%, transparent); }
.switch[aria-checked="true"]:hover { background: color-mix(in srgb, var(--accent-bg-color), currentColor 10%); }

/* ---------- Spinner ---------- */

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 20%, transparent);
  border-top-color: currentColor;
  animation: spin 900ms linear infinite;
  flex: none;
  opacity: 0.8;
}
.spinner.large { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  justify-content: center;
  padding: 80px 12px;
  opacity: 0.8;
}

/* ---------- Значки книгообеспеченности ---------- */

.provision {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  padding: 2px 9px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.45;
}
.provision.good { background: color-mix(in srgb, var(--success-bg-color) 22%, transparent); color: var(--success-color); }
.provision.low { background: color-mix(in srgb, var(--warning-bg-color) 25%, transparent); color: var(--warning-color); }
.provision.zero { background: color-mix(in srgb, var(--error-bg-color) 20%, transparent); color: var(--error-color); }
.provision.na { background: color-mix(in srgb, currentColor 10%, transparent); opacity: 0.75; font-weight: 600; }
.provision.large { font-size: 26.667px; font-weight: 800; padding: 4px 18px; min-width: 96px; }

/* ---------- Шапка отчёта ---------- */

.report-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  margin-bottom: 24px;
}
.report-hero .hero-text { flex: 1; min-width: 0; }
.report-hero .hero-kicker { font-size: 12px; font-weight: 700; opacity: var(--dim-opacity); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.report-hero .hero-title { font-size: 20px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.report-hero .hero-subtitle { margin-top: 6px; opacity: var(--dim-opacity); overflow-wrap: anywhere; }
.report-hero .hero-value { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; text-align: center; }
.report-hero .hero-value .caption { opacity: var(--dim-opacity); max-width: 140px; }
.report-hero .hero-actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; align-items: center; }
.legend .item { display: inline-flex; gap: 6px; align-items: center; opacity: 0.85; }
.legend .provision { min-width: 0; font-size: 11px; padding: 0 7px; }

.update-info { margin-top: 18px; font-size: 12px; opacity: var(--dim-opacity); text-align: center; line-height: 1.6; }

/* ---------- Поиск (AdwSearchEntry) ---------- */

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.search-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 8px 0 10px;
  border-radius: var(--button-radius);
  background: color-mix(in srgb, currentColor 10%, transparent);
  min-width: 240px;
  flex: 1;
  max-width: 420px;
  transition: box-shadow 150ms;
}
.search-entry:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 50%, transparent); }
.search-entry input { flex: 1; min-width: 0; border: none; background: transparent; padding: 6px 0; }
.search-entry input:focus, .search-entry input:focus-visible { outline: none; box-shadow: none; }
.search-entry input::placeholder { color: inherit; opacity: var(--dim-opacity); }
.search-entry input::-webkit-search-cancel-button { display: none; }
.search-entry .icon { opacity: var(--dim-opacity); }
.search-entry .clear { width: 24px; height: 24px; min-width: 24px; min-height: 24px; border-radius: 50%; }

/* ---------- Таблицы отчётов ---------- */

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }

table.report {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
table.report th, table.report td {
  padding: 10px 12px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent);
}
table.report tbody tr:last-child td { border-bottom: none; }
table.report th {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: color-mix(in srgb, currentColor 3%, transparent);
  position: relative;
}
table.report th .th-inner { display: inline-flex; align-items: center; gap: 5px; }
table.report td.num-cell { width: 44px; opacity: var(--dim-opacity); }
table.report td.text-cell, table.report th.text-cell { text-align: left; }
table.report td.text-cell { min-width: 220px; }
table.report tbody tr { transition: background-color 120ms; }
table.report tbody tr:hover { background: color-mix(in srgb, currentColor 3%, transparent); }
table.report td .sub { font-size: 12px; opacity: var(--dim-opacity); margin-top: 2px; }
table.report td a.discipline-link { font-weight: 600; }
table.report th.group-start, table.report td.group-start { box-shadow: inset 1px 0 color-mix(in srgb, currentColor 10%, transparent); }
table.report .bib { white-space: normal; line-height: 1.45; overflow-wrap: anywhere; }

.help-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  background: color-mix(in srgb, currentColor 15%, transparent);
  cursor: help;
}

/* Подсказки (GtkTooltip) */
[data-tooltip] { position: relative; }
.tooltip-bubble {
  position: fixed;
  z-index: 1000;
  max-width: 280px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgb(0 0 0 / 80%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  pointer-events: none;
  white-space: normal;
  text-align: left;
  animation: fade-in 120ms ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Пагинация */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pager .page-info { padding: 0 8px; font-size: 13px; opacity: 0.8; font-variant-numeric: tabular-nums; }
.pager .btn.current { background: var(--accent-bg-color); color: var(--accent-fg-color); }

/* Мобильный список вместо таблицы */
.report-list { display: none; }

/* ---------- Попапы, меню, диалоги ---------- */

.popover-overlay { position: fixed; inset: 0; z-index: 500; }

.popover {
  position: fixed;
  z-index: 501;
  min-width: 180px;
  max-width: min(560px, calc(100vw - 16px));
  padding: 6px;
  border-radius: var(--popover-radius);
  background: var(--popover-bg-color);
  color: var(--popover-fg-color);
  box-shadow: 0 0 0 1px rgb(0 0 6 / 10%), 0 2px 8px 2px rgb(0 0 6 / 14%), 0 6px 24px rgb(0 0 6 / 12%);
  display: flex;
  flex-direction: column;
  animation: popover-in 150ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: top center;
}
:root[data-theme="dark"] .popover { box-shadow: 0 0 0 1px rgb(0 0 6 / 50%), 0 2px 8px 2px rgb(0 0 6 / 40%), inset 0 1px rgb(255 255 255 / 4%); }
@keyframes popover-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

.popover .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: var(--button-radius);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}
.popover .menu-item:hover, .popover .menu-item.focused { background: var(--hover-bg); }
.popover .menu-item:active { background: var(--active-bg); }
.popover .menu-item .label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.popover .menu-item .check { visibility: hidden; color: var(--accent-color); }
.popover .menu-item.selected .check { visibility: visible; }
.popover .menu-item .shortcut { opacity: var(--dim-opacity); font-size: 12px; }
.popover .separator { height: 1px; margin: 6px 0; background: color-mix(in srgb, currentColor 15%, transparent); }

.popover .list-scroll { overflow-y: auto; max-height: 50vh; display: flex; flex-direction: column; gap: 1px; }
.popover .search-entry { margin: 0 0 6px; max-width: none; min-width: 0; }
.popover .empty { padding: 18px 12px; text-align: center; opacity: var(--dim-opacity); }

/* Переключатель темы (как в GNOME Text Editor / Nautilus) */
.style-switcher { display: flex; justify-content: center; gap: 18px; padding: 6px 12px 12px; }
.style-switcher button {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgb(0 0 6 / 15%);
  transition: box-shadow 150ms;
}
.style-switcher button.system { background: linear-gradient(-45deg, #222226 49.99%, #ffffff 50.01%); }
.style-switcher button.light { background: #ffffff; }
.style-switcher button.dark { background: #222226; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 10%); }
.style-switcher button:hover { box-shadow: inset 0 0 0 1px rgb(0 0 6 / 15%), 0 0 0 3px color-mix(in srgb, currentColor 10%, transparent); }
.style-switcher button.selected { box-shadow: 0 0 0 2px var(--accent-bg-color); }
.style-switcher button .check {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-bg-color);
  color: #ffffff;
  display: none;
  align-items: center;
  justify-content: center;
}
.style-switcher button .check svg { width: 12px; height: 12px; }
.style-switcher button.selected .check { display: flex; }

/* Диалог (AdwDialog) / нижний лист на мобильных */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgb(0 0 0 / 40%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 200ms ease-out;
}
.dialog {
  width: min(420px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border-radius: var(--window-radius);
  background: var(--dialog-bg-color);
  color: var(--dialog-fg-color);
  box-shadow: 0 0 0 1px rgb(0 0 6 / 5%), 0 8px 32px rgb(0 0 6 / 30%);
  animation: dialog-in 220ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}
@keyframes dialog-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.dialog .dialog-close { position: absolute; top: 12px; right: 12px; z-index: 1; }

.about { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px 24px 24px; gap: 6px; }
.about .app-icon {
  width: 128px;
  height: 128px;
  border-radius: 28px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #62a0ea, #1c71d8 60%, #1a5fb4);
  color: #ffffff;
  box-shadow: inset 0 -6px rgb(0 0 0 / 18%), 0 4px 12px rgb(26 95 180 / 35%);
}
.about .app-icon svg { width: 72px; height: 72px; }
.about .version {
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--accent-bg-color) 15%, transparent);
  color: var(--accent-color);
  font-weight: 700;
  font-size: 13px;
}
.about .boxed-list { width: 100%; margin-top: 18px; text-align: left; }

/* ---------- Тосты (AdwToast) ---------- */

.toast-overlay {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  max-width: calc(100vw - 24px);
  padding: 6px 6px 6px 18px;
  border-radius: 9999px;
  background: color-mix(in srgb, #ffffff 10%, #1e1e22);
  color: #ffffff;
  box-shadow: 0 2px 8px 2px rgb(0 0 6 / 25%);
  pointer-events: auto;
  font-weight: 600;
  animation: toast-in 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.toast .btn { color: #ffffff; }
.toast.leaving { animation: toast-out 200ms ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* ---------- Справка ---------- */

.help-text { padding: 14px 16px; line-height: 1.55; }
.help-text p { margin: 0 0 10px; }
.help-text p:last-child { margin-bottom: 0; }
.help-text ul { margin: 0 0 10px; padding-left: 22px; }
.help-text li { margin: 3px 0; }
.help-text .note {
  padding: 10px 12px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent-bg-color) 12%, transparent);
  margin: 10px 0;
}
.help-text code { font-family: var(--monospace-font-family); font-size: 13px; padding: 1px 5px; border-radius: 4px; background: color-mix(in srgb, currentColor 8%, transparent); }

.api-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.api-table td { padding: 8px 14px; border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent); vertical-align: top; }
.api-table tr:last-child td { border-bottom: none; }
.api-table td:first-child { font-family: var(--monospace-font-family); white-space: nowrap; }

/* ---------- Мобильная раскладка ---------- */

.mobile-only { display: none !important; }

@media (max-width: 1000px) {
  :root { --sidebar-width: 248px; }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .view-switcher-bar { display: flex; }
  .mobile-only { display: flex !important; }
  .desktop-only { display: none !important; }

  .clamp { padding: 18px 12px 28px; }

  .report-hero { flex-direction: column; align-items: stretch; text-align: left; gap: 14px; }
  .report-hero .hero-value { flex-direction: row; justify-content: space-between; text-align: left; }
  .report-hero .hero-value .caption { max-width: none; }

  .table-card.responsive { display: none; }
  .report-list { display: block; }

  .toolbar { gap: 8px; }
  .toolbar .search-entry { min-width: 0; max-width: none; flex: 1 1 100%; }
  .toolbar .spacer { display: none; }

  .toast-overlay { bottom: calc(var(--bottombar-height) + 16px + env(safe-area-inset-bottom, 0px)); }

  /* Попап выбора на телефоне — нижний лист */
  .popover.sheet {
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: auto !important;
    max-width: none;
    max-height: 80dvh;
    border-radius: var(--window-radius) var(--window-radius) 0 0;
    padding: 6px 6px calc(12px + env(safe-area-inset-bottom, 0px));
    animation: sheet-in 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  .popover.sheet::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: color-mix(in srgb, currentColor 25%, transparent);
    margin: 4px auto 10px;
    flex: none;
  }
  .popover.sheet .list-scroll { max-height: 60dvh; }
  .popover-overlay.dim { background: rgb(0 0 0 / 35%); animation: fade-in 200ms; }

  .dialog-backdrop { align-items: flex-end; padding: 0; }
  .dialog { width: 100%; border-radius: var(--window-radius) var(--window-radius) 0 0; animation: sheet-in 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94); }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }

@media (max-width: 400px) {
  .view-switcher-button .label { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- Печать ---------- */

@media print {
  :root, :root[data-theme] {
    color-scheme: light;
    --window-bg-color: #ffffff;
    --window-fg-color: #000000;
    --card-bg-color: #ffffff;
    --card-fg-color: #000000;
    --view-bg-color: #ffffff;
    --success-color: #1b8553;
    --warning-color: #9c6e03;
    --error-color: #c30000;
  }
  html, body { height: auto; overflow: visible; background: #ffffff; color: #000000; font-size: 11pt; }
  .app { display: block; height: auto; }
  .sidebar, .headerbar, .view-switcher-bar, .banner, .toolbar, .pager, .hero-actions,
  .toast-overlay, .help-badge, .no-print { display: none !important; }
  .content, .scroller { display: block; overflow: visible; height: auto; }
  .clamp { max-width: none; padding: 0; }
  .card, .boxed-list { box-shadow: none !important; border: 1px solid #999; border-radius: 0; }
  .report-hero { border: none !important; padding: 0 0 12px; }
  .table-card.responsive { display: block !important; }
  .report-list { display: none !important; }
  table.report th { background: #eeeeee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.report th, table.report td { border: 1px solid #999; padding: 4px 6px; }
  table.report tr { break-inside: avoid; }
  .provision { padding: 0 4px; background: none !important; }
  a { color: #000000; text-decoration: none; }
  .page-enter { animation: none; }
}

/* ---------- AdwViewSwitcher в заголовке ---------- */

.view-switcher { display: flex; align-items: stretch; gap: 6px; height: 34px; }
.view-switcher-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  padding: 0 12px;
  border: none;
  border-radius: var(--button-radius);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms;
}
.view-switcher-tab:hover { background: var(--hover-bg); }
.view-switcher-tab:active { background: var(--active-bg); }
.view-switcher-tab.selected { background: var(--selected-bg); }
.view-switcher-tab .label { overflow: hidden; text-overflow: ellipsis; }

/* Узкое окно: иконка над подписью (narrow policy) */
@media (max-width: 860px) {
  .view-switcher { height: 40px; gap: 2px; margin: -2px 0; }
  .view-switcher-tab { flex-direction: column; gap: 2px; padding: 2px 8px; font-size: 12px; }
}
@media (max-width: 400px) {
  .view-switcher-tab { padding: 2px 5px; font-size: 11px; }
}
@media print { .view-switcher { display: none; } }

/* ---------- Справка: документация API ---------- */

.api-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* AdwToggleGroup */
.toggle-group {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.toggle-group .toggle {
  min-height: 28px;
  padding: 2px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 150ms, box-shadow 150ms;
}
.toggle-group .toggle:hover { background: color-mix(in srgb, currentColor 7%, transparent); }
.toggle-group .toggle.active {
  background: var(--view-bg-color);
  box-shadow: 0 1px 3px rgb(0 0 6 / 15%), 0 0 0 1px rgb(0 0 6 / 4%);
}
:root[data-theme="dark"] .toggle-group .toggle.active { background: color-mix(in srgb, #ffffff 18%, transparent); box-shadow: none; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .toggle-group .toggle.active { background: color-mix(in srgb, #ffffff 18%, transparent); box-shadow: none; }
}

/* AdwExpanderRow */
.row-wrap.expander { display: block; }
.expander .expander-arrow { transition: transform 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.expander.expanded .expander-arrow { transform: rotate(180deg); }
.expander .expander-content { display: none; }
.expander.expanded .expander-content {
  display: block;
  padding: 4px 14px 16px;
  background: color-mix(in srgb, currentColor 2.5%, transparent);
  box-shadow: inset 0 1px color-mix(in srgb, currentColor 8%, transparent);
  animation: fade-in 150ms ease-out;
}
.method-path { font-family: var(--monospace-font-family); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

.api-about { margin: 12px 0 4px; line-height: 1.5; }
.api-subheading { margin: 16px 0 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: var(--dim-opacity); }
.api-note { margin-top: 10px; font-size: 13px; }

.api-params { display: flex; flex-direction: column; gap: 8px; }
.api-param { display: grid; grid-template-columns: minmax(170px, 230px) 1fr; gap: 4px 14px; align-items: baseline; }
.api-param-name { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.api-param-name code, .api-param-desc code, .api-error code, .help-text code, .boxed-list code.value {
  font-family: var(--monospace-font-family);
  font-size: 13px;
  padding: 1px 5px;
  border-radius: 4px;
  background: color-mix(in srgb, currentColor 8%, transparent);
  overflow-wrap: anywhere;
}
.boxed-list code.value { opacity: 1; white-space: nowrap; }
.api-param-desc { line-height: 1.45; font-size: 14px; }

.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}
.status-tag.required { background: color-mix(in srgb, var(--accent-bg-color) 18%, transparent); color: var(--accent-color); }
.status-tag.optional { background: color-mix(in srgb, currentColor 10%, transparent); }
.status-tag.error { background: color-mix(in srgb, var(--error-bg-color) 18%, transparent); color: var(--error-color); }

.api-errors { display: flex; flex-direction: column; gap: 6px; }
.api-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }

/* Блок кода */
.code-block {
  margin-top: 8px;
  border-radius: 9px;
  overflow: hidden;
  background: color-mix(in srgb, currentColor 6%, var(--card-bg-color));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 8%, transparent);
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 2px 4px 2px 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 0 -1px color-mix(in srgb, currentColor 8%, transparent);
}
.code-header .code-label { opacity: var(--dim-opacity); }
.code-header .code-copy { width: 30px; min-width: 30px; min-height: 30px; }
.code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--monospace-font-family);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  tab-size: 4;
}

@media (max-width: 720px) {
  .api-toolbar { justify-content: space-between; }
  .api-param { grid-template-columns: 1fr; }
  .boxed-list .row .suffix code.value { display: none; }
}
.api-param-example { margin-top: 3px; font-size: 13px; }
@media (max-width: 720px) {
  .api-param-name { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
}

/* ---------- Поиск дисциплин ---------- */

.search-header { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.search-entry.large { max-width: none; min-height: 42px; padding: 0 10px 0 14px; font-size: 16px; border-radius: 9px; }
.search-entry.large .icon { width: 18px; height: 18px; }
.search-results .status-page.compact { padding-top: 12px; }
mark.match {
  background: color-mix(in srgb, var(--accent-bg-color) 22%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 700;
}
a.row:focus-visible { outline-offset: -3px; border-radius: inherit; }
.pref-group > .legend { margin-top: 12px; padding: 0 2px; }
@media (max-width: 420px) {
  .view-switcher-bar { gap: 0; padding-left: 2px; padding-right: 2px; }
  .view-switcher-button { padding-left: 0; padding-right: 0; }
}

/* ComboRow: выбранное значение и подсказка — всегда справа, длинные значения в две строки */
.row.combo .titles { flex: 1 1 auto; min-width: min-content; }
.row.combo .row-title { overflow-wrap: normal; }
.row.combo .suffix { flex: 0 1 auto; min-width: 0; max-width: 60%; }
.row.combo .suffix .value {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-align: right;
  line-height: 1.3;
}

/* Пункты выпадающего списка не сжимаются по высоте — длинные названия переносятся без наложения */
.popover .list-scroll > * { flex-shrink: 0; }
.popover .menu-item { align-items: flex-start; line-height: 1.35; padding-top: 8px; padding-bottom: 8px; }
.popover .menu-item .check { margin-top: 2px; }
.popover > * { flex-shrink: 0; }
.popover > .list-scroll { flex-shrink: 1; min-height: 0; }