/* Глобальні стилі (раніше в templates/base.html) */
:root {
    --bg: #f5f5f0;
    --card: #fff;
    --accent: #2c5282;
    --text: #1a202c;
    --muted: #718096;
    --border: #e2e8f0;
}
* { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
.container { max-width: 960px; margin: 0 auto; padding: 1rem; }
/* Bootstrap 5 navbar — кастомізація під тему сайту */
.app-navbar .navbar-brand,
.app-navbar .nav-link:not(.disabled) {
    color: var(--accent) !important;
}
.app-navbar .nav-link:hover:not(.disabled),
.app-navbar .navbar-brand:hover {
    color: #1a365d !important;
}
.app-navbar__inner {
    max-width: 1200px;
    margin: 0 auto;
}
.app-main.container {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}
.app-footer {
    border-top: 1px solid var(--border);
    background: var(--card);
    padding: 1rem 0;
    margin-top: 1.5rem;
}
.app-footer__inner {
    max-width: 960px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
    text-align: center;
}
.app-footer__copy {
    color: var(--muted);
}
.app-system-menu {
    min-width: 280px;
    max-height: min(70vh, 480px);
    overflow-y: auto;
}
/* Меню довше за свою висоту і скролиться — тож заголовок групи липне до верху,
   інакше на середині списку не видно, у якій ти групі. */
.app-system-menu .dropdown-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #6c757d;
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
.card {
    background: var(--card);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  text-align: center;
  background: #0078d4;
  color: #fff;
  text-decoration: none;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  box-shadow: 0 1px 3px rgba(0, 120, 212, 0.35);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn-microsoft:hover {
  background: #106ebe;
  color: #fff;
  filter: none;
  box-shadow: 0 4px 12px rgba(0, 120, 212, 0.35);
  transform: translateY(-1px);
}
.btn-microsoft:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 120, 212, 0.3);
}
.btn-microsoft .bi {
  font-size: 1.15rem;
  flex-shrink: 0;
}
.login-oauth { margin: 0 0 1.25rem; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted, #666);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 1.25rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 15%, var(--border) 85%, transparent);
}
.login-divider span {
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--muted);
}

/* Сторінка входу — центрована картка, сучасна типографіка */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: min(72vh, 560px);
  padding: 2rem 1rem 3rem;
  background: radial-gradient(ellipse 100% 70% at 50% -15%, rgba(44, 82, 130, 0.07), transparent 52%);
}
.login-page__inner {
  width: 100%;
  max-width: 420px;
}
.login-page__title {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 1.5rem;
  text-align: center;
  color: var(--text);
}
.login-card {
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  box-shadow:
    0 4px 6px -1px rgba(15, 23, 42, 0.06),
    0 12px 24px -8px rgba(15, 23, 42, 0.1);
  background: var(--card);
}
.login-card .messages.error {
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
.login-form .form-group {
  margin-bottom: 1.15rem;
}
.login-form .form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 0.4rem;
}
.login-form .btn-primary {
  width: 100%;
  padding: 0.7rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  border-radius: 10px;
  margin-top: 0.25rem;
  box-shadow: 0 2px 4px rgba(44, 82, 130, 0.2);
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}
.login-form .btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 12px rgba(44, 82, 130, 0.28);
}
.login-back {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
}
.login-back a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.login-back a:hover {
  color: #1a365d;
  border-bottom-color: currentColor;
}
.login-oauth-hint {
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 0.75rem 1rem;
  background: #f7fafc;
  border-radius: 10px;
  border: 1px dashed var(--border);
  margin-bottom: 1rem;
}
.login-oauth-hint code {
  font-size: 0.78em;
  word-break: break-all;
}
.btn-danger { background: #c53030; color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th { font-weight: 600; color: var(--muted); font-size: 0.85rem; }
tr:hover { background: #fafafa; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.25rem; }
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="datetime-local"],
textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-size: 1rem;
    line-height: 1.45;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="datetime-local"]:focus,
textarea:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}
textarea { min-height: 60px; resize: vertical; }
/* Flash-повідомлення (Bootstrap alert + кнопка закриття + авто-приховування) */
.app-messages { display: flex; flex-direction: column; gap: 0.5rem; }
.app-flash-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0;
}
.app-flash-message .btn-close {
    flex-shrink: 0;
    margin-top: 0.15rem;
}
.app-flash-message__text {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.45;
}

/* Застарілий варіант списку (якщо десь лишився) */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: 0.75rem; border-radius: 6px; margin-bottom: 0.5rem; }
.messages .success { background: #c6f6d5; color: #22543d; }
.messages .error { background: #fed7d7; color: #742a2a; }
.pagination { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.pagination a,
.pagination span {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
}
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.search-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    align-items: center;
}
.search-form input,
.search-form select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}
.meta { color: var(--muted); font-size: 0.85rem; }
.dl-grid { display: grid; grid-template-columns: 140px 1fr; gap: 0.5rem 1rem; }
.dl-grid dt { font-weight: 500; color: var(--muted); }
.dl-grid dd { margin: 0; }

/* Допоміжні класи (замість inline style у шаблонах) */
.nav-logout-form { display: inline; }
.btn-nav-logout { padding: 0.25rem 0.5rem; }
.index-actions { list-style: none; padding: 0; margin: 0; }
.index-actions li { margin-bottom: 0.5rem; }
.index-actions__meta { margin-bottom: 0.5rem; }
.meta--mt { margin-top: 1rem; }
.form-actions-row { margin-top: 1rem; }
.form-mt { margin-top: 1rem; }
.th-col-actions { width: 11rem; }
.th-col-actions.th-col-actions--icon {
    width: 3.75rem;
    min-width: 3.25rem;
    max-width: 4rem;
    text-align: center;
}
/* Кнопки-іконки в таблицях (довідники, доступ) */
.btn-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
}
.btn-icon-action i {
    font-size: 1.15rem;
    line-height: 1;
}
.is-hidden { display: none !important; }

/* Випадаюче меню «Довідники» */
nav details.nav-dicts { position: relative; }
nav details.nav-dicts > summary {
    list-style: none;
    cursor: pointer;
    color: var(--accent);
    padding: 0.2rem 0.35rem;
    border-radius: 0;
    font-weight: 500;
}
nav details.nav-dicts > summary::-webkit-details-marker { display: none; }
nav details.nav-dicts[open] > summary { text-decoration: underline; }
nav .nav-dicts-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 2px);
    min-width: 280px;
    max-height: min(70vh, 420px);
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 0.4rem 0;
    z-index: 200;
}
nav .nav-dicts-menu a {
    display: block;
    padding: 0.45rem 0.9rem;
    margin: 0;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 0;
}
nav .nav-dicts-menu a:hover {
    background: #edf2f7;
    text-decoration: none;
}
nav .nav-dicts-menu .nav-dicts-sep {
    height: 1px;
    background: var(--border);
    margin: 0.35rem 0;
}
nav .nav-dicts-menu .nav-dicts-hint {
    padding: 0.35rem 0.9rem 0.2rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

/* ── Language switcher ── */
.app-lang-switcher {
    display: flex;
    align-items: center;
}
.app-lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1.5px solid #cbd5e0;
    border-radius: 50%;
    background: #fff;
    color: #4a5568;
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    line-height: 1;
}
.app-lang-btn:hover {
    background: #edf2f7;
    border-color: #a0aec0;
    color: #2d3748;
}
.app-lang-btn:active {
    transform: scale(0.93);
}

/* ── Profile menu ── */
.app-profile-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 0.45rem;
}
.app-profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    line-height: 1;
    flex-shrink: 0;
}
.app-profile-menu {
    min-width: 260px;
    padding-top: 0;
}
.app-profile-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, #f7f8fc 0%, #eef1f8 100%);
    border-bottom: 1px solid var(--border, #dee2e6);
}
.app-profile-header__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.app-profile-header__info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.app-profile-header__name {
    font-size: 0.88rem;
    line-height: 1.3;
    word-break: break-word;
}
.app-profile-header__email {
    font-size: 0.76rem;
    color: var(--muted, #6c757d);
    word-break: break-all;
}
.app-profile-header__role {
    font-size: 0.74rem;
    color: var(--muted, #6c757d);
}
.app-profile-header__badge {
    margin-top: 0.2rem;
    align-self: flex-start;
    font-size: 0.65rem;
    letter-spacing: 0.03em;
}

/* Глобальний індикатор довгого завантаження сторінки (внутрішні посилання / форми) */
.app-nav-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2000;
    pointer-events: none;
    overflow: hidden;
    background: rgba(44, 82, 130, 0.12);
}
.app-nav-loading[hidden] {
    display: none !important;
}
.app-nav-loading__bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 38%;
    max-width: 280px;
    border-radius: 0 2px 2px 0;
    background: linear-gradient(90deg, #2c5282, #4299e1);
    box-shadow: 0 0 12px rgba(66, 153, 225, 0.55);
    animation: app-nav-loading-march 0.95s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    will-change: transform;
}
@keyframes app-nav-loading-march {
    0% {
        transform: translateX(-105%);
    }
    100% {
        transform: translateX(290%);
    }
}
@media (prefers-reduced-motion: reduce) {
    .app-nav-loading__bar {
        animation: none;
        left: 0;
        width: 100%;
        max-width: none;
        transform: none;
        opacity: 0.85;
    }
}

/*
 * Головна (index): резервна сітка карток статистики.
 * Якщо css/home.css не підвантажився, посилання не зливаються в один «паркан».
 * Дублікат breakpoints узгоджено з home.css (після нього правила з home перезапишуть те саме).
 */
.home-stats-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.75rem;
    grid-template-columns: 1fr;
}
@media (min-width: 576px) {
    .home-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 992px) {
    .home-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
.home-stats-grid > a.home-stat-card--link {
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}
