.app-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 12% 8%, rgba(7, 94, 232, .09), transparent 28rem),
        linear-gradient(180deg, #f8fbff 0, #f3f7fc 100%);
}

.app-main {
    flex: 1;
    width: 100%;
    padding: clamp(28px, 5vw, 58px) 0 76px;
}

.app-surface {
    padding: clamp(24px, 4.5vw, 54px);
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 22px 60px rgba(7, 31, 75, .09);
}

.app-surface > :first-child { margin-top: 0; }
.app-surface > :last-child { margin-bottom: 0; }

.app-page h1,
.app-page h2 {
    color: var(--brand-navy);
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: -.025em;
}

.app-page h2 {
    margin: 0 0 24px;
    font-size: clamp(1.85rem, 4vw, 2.85rem);
    line-height: 1.08;
}

.app-page h3 {
    margin: 30px 0 12px;
    color: var(--brand-navy);
    font-size: 1.16rem;
}

.app-surface p,
.app-surface li,
.app-surface dd { color: #405471; }

.app-surface a { overflow-wrap: anywhere; }
.app-surface strong { color: var(--ink); }

.app-eyebrow {
    margin: 0 0 8px !important;
    color: var(--brand-blue) !important;
    font-size: .78rem;
    font-weight: 850;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.app-alert,
.app-page [role="alert"] {
    margin: 0 0 22px;
    padding: 13px 16px;
    border: 1px solid #f1c7c7;
    border-radius: 10px;
    color: #822727;
    background: #fff3f3;
}

.app-alert-success,
.app-page [role="status"] {
    border-color: #bcd9c8;
    color: #175d39;
    background: #edf9f2;
}

.app-page form {
    display: grid;
    gap: 15px;
    margin: 24px 0;
}

.app-page form > div,
.app-page form > label:not(:has(input[type="checkbox"])):not(:has(input[type="radio"])) {
    display: grid;
    gap: 7px;
}

.app-page label,
.app-page legend {
    color: var(--ink);
    font-weight: 750;
}

.app-page input:not([type="checkbox"]):not([type="radio"]),
.app-page select,
.app-page textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid #c8d5e6;
    border-radius: 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

.app-page textarea {
    min-height: 120px;
    resize: vertical;
}

.app-page input:focus,
.app-page select:focus,
.app-page textarea:focus {
    border-color: var(--brand-blue);
    outline: 3px solid rgba(7, 94, 232, .14);
    outline-offset: 1px;
}

.app-page input[type="file"] {
    padding: 9px;
    background: #f8fbff;
}

.app-page input[type="checkbox"],
.app-page input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-blue);
}

.app-page fieldset {
    min-width: 0;
    margin: 8px 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
}

.app-page legend { padding: 0 7px; }

.app-surface button,
.app-surface input[type="submit"] {
    width: fit-content;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid var(--brand-blue);
    border-radius: 9px;
    color: #fff;
    background: var(--brand-blue);
    box-shadow: 0 8px 18px rgba(7, 94, 232, .15);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.app-surface button:hover,
.app-surface input[type="submit"]:hover { background: #034dbf; }
.app-surface button:disabled { opacity: .55; cursor: not-allowed; }

.app-page form[action*="reject"] button,
.app-page form[action*="revoke"] button,
.app-page form[action*="archive"] button,
.app-page form[action*="close"] button,
.app-page form[action*="delete"] button {
    border-color: #b52c2c;
    background: #b52c2c;
    box-shadow: none;
}

.app-surface nav:not(.primary-nav) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 18px 0 26px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.app-surface nav:not(.primary-nav) a { font-weight: 750; }

.app-page section + section {
    margin-top: 34px;
    padding-top: 30px;
    border-top: 1px solid var(--line);
}

.app-page article,
.app-page details {
    margin: 18px 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
}

.app-page article h3:first-child { margin-top: 0; }
.app-page summary { color: var(--ink); font-weight: 800; cursor: pointer; }

.app-page ul,
.app-page ol { padding-left: 22px; }
.app-page li + li { margin-top: 7px; }

.app-page dl {
    display: grid;
    grid-template-columns: minmax(130px, .35fr) minmax(0, 1fr);
    gap: 0;
    margin: 22px 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}

.app-page dt,
.app-page dd {
    margin: 0;
    padding: 12px 15px;
    border-bottom: 1px solid var(--line);
}

.app-page dt { color: var(--ink); background: #f1f6fd; font-weight: 800; }
.app-page dl > :nth-last-child(-n + 2) { border-bottom: 0; }

.app-page table {
    display: block;
    width: 100%;
    margin: 24px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    border-spacing: 0;
    overflow-x: auto;
    background: #fff;
}

.app-page thead,
.app-page tbody { min-width: 100%; }
.app-page th,
.app-page td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.app-page th { color: var(--ink); background: #edf4fe; font-size: .84rem; }
.app-page tr:last-child td { border-bottom: 0; }
.app-page td form { display: inline-flex; margin: 3px; }
.app-page td button { min-height: 36px; padding: 7px 10px; font-size: .82rem; }

.app-page pre,
.app-page code {
    max-width: 100%;
    border-radius: 7px;
    color: #163760;
    background: #edf4fe;
    overflow-wrap: anywhere;
}

.app-page pre { padding: 16px; overflow-x: auto; }
.app-page code { padding: 2px 5px; }

.auth-page .app-surface,
.error-page .app-surface { max-width: 680px; }

/* AJAX registration */
.register-intro { margin: -10px 0 24px; }
.register-form { gap: 18px !important; }
.register-name-grid { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px !important; }
.register-field { align-content: start; }
.register-field small { color: #6d7e96; font-size: .78rem; font-weight: 500; }
.register-field input[aria-invalid="true"] { border-color: #c43838; background: #fffafa; }
.register-field-error { margin: 0 !important; color: #a22222 !important; font-size: .8rem; font-weight: 700; }
.register-error-summary { margin-bottom: 22px; }
.register-error-summary strong { color: #822727; }
.register-error-summary ul { margin: 7px 0 0; padding-left: 20px; }
.register-error-summary li { color: #822727; }
.register-ajax-message { margin-bottom: 20px; }
.register-consent-field { margin-top: 2px; }
.register-consent { display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; line-height: 1.5; cursor: pointer; }
.register-consent input { flex: 0 0 auto; margin-top: 2px; }
.register-submit { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 170px; }
.register-spinner { width: 17px; height: 17px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: register-spin .7s linear infinite; }
.register-success { padding: 30px; border: 1px solid #bcd9c8; border-radius: 16px; background: #edf9f2; text-align: center; }
.register-success-icon { display: grid; width: 54px; height: 54px; margin: 0 auto 14px; place-items: center; border-radius: 50%; background: #177346; color: #fff; font-size: 1.7rem; font-weight: 900; }
.register-success h3 { margin: 0 0 8px; color: #124f32; font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; }
.register-success p { margin: 0 auto 20px; color: #285d43; }
.register-success .btn-primary { color: #fff; }
@keyframes register-spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) { .register-name-grid { grid-template-columns: 1fr; } .register-submit { width: 100% !important; } }
@media (prefers-reduced-motion: reduce) { .register-spinner { animation: none; } }

@media (max-width: 680px) {
    .app-main { padding-top: 22px; padding-bottom: 44px; }
    .app-surface { width: min(100% - 20px, 1180px); padding: 23px 18px; border-radius: 16px; }
    .app-page h2 { font-size: 1.85rem; }
    .app-page fieldset { padding: 16px 13px; }
    .app-page dl { grid-template-columns: 1fr; }
    .app-page dt,
    .app-page dd { border-bottom: 0; }
    .app-page dd { padding-top: 0; border-bottom: 1px solid var(--line); }
    .app-page dl > :last-child { border-bottom: 0; }
.app-surface button,
.app-surface input[type="submit"] { max-width: 100%; }
}

/* Бутон и панели за error / auth съобщения. */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 0 22px; border-radius: 10px;
    color: #fff; background: var(--brand-blue);
    font-weight: 800; text-decoration: none;
    box-shadow: 0 10px 24px rgba(7, 94, 232, .18);
}
.btn-primary:hover { color: #fff; background: #034dbf; }

.error-panel, .auth-notice { max-width: 620px; padding: 8px 0 12px; }
.error-panel h1, .auth-notice h1 {
    margin: 0 0 14px; color: var(--brand-navy);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.9rem, 4vw, 2.8rem); line-height: 1.08; letter-spacing: -.025em;
}
.auth-notice .eyebrow {
    margin: 0 0 8px; color: var(--brand-blue);
    font-size: .78rem; font-weight: 850; letter-spacing: .11em; text-transform: uppercase;
}
.error-links {
    display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
    margin-top: 26px;
}

/* Групирана навигация в администрацията на политическия каталог. */
.catalog-admin-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 14px; }
.catalog-admin-sidebar { position: sticky; top: 88px; }
.catalog-admin-main { min-width: 0; }
.catalog-admin-nav { display: grid; grid-template-columns: 1fr; gap: 16px; margin: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
@media (max-width: 860px) {
    .catalog-admin-layout { grid-template-columns: 1fr; }
    .catalog-admin-sidebar { position: static; }
    .catalog-admin-nav { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}
.catalog-admin-group-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.catalog-admin-links { display: flex; flex-direction: column; gap: 3px; }
.catalog-admin-links a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: #1c365f; font-weight: 700; font-size: .92rem; }
.catalog-admin-links a:hover { background: rgba(7, 94, 232, .07); color: var(--brand-blue); }
.catalog-admin-links a.is-active { background: rgba(7, 94, 232, .12); color: var(--brand-blue); }

/* Заявки за липсващи политици (модерация). */
table.admin-requests-table { display: table; width: 100%; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; border-collapse: collapse; overflow: visible; }
.admin-requests-table td { overflow: visible; }
.admin-requests-table th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; background: #edf4fe; }
.req-role { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.req-link-form { display: flex; gap: 8px; align-items: flex-start; min-width: 280px; }
.req-link-form .combo-field { flex: 1; }
.req-link-form button, .req-reject-btn { padding: 9px 12px; border: 0; border-radius: 8px; font: inherit; font-weight: 800; cursor: pointer; }
.req-link-form button { color: #fff; background: var(--brand-blue); }
.req-reject-form { margin-top: 8px; }
.req-reject-btn { color: #8a1f2b; background: #fdeef0; }

/* --- Управление на често задавани въпроси --- */
.faq-admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.faq-admin-head p { max-width: 640px; color: var(--muted); }
.app-btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 700; text-decoration: none; cursor: pointer; }
.app-btn:hover { border-color: var(--green); color: var(--green); }
.app-btn-primary { border-color: var(--green); background: var(--green); color: #fff; }
.app-btn-primary:hover { background: #034dbf; color: #fff; }

table.faq-admin-table { width: 100%; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; border-collapse: collapse; }
.faq-admin-table th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; background: #edf4fe; text-align: left; padding: 10px 12px; }
.faq-admin-table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: top; }
.faq-admin-table tr.faq-row-inactive { opacity: .6; }
.faq-admin-slug { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.faq-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.faq-badge-on { background: #e5f3ea; color: #1c7a3f; }
.faq-badge-off { background: #f0f2f6; color: var(--muted); }
.faq-admin-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.faq-admin-actions form { margin: 0; }
.faq-linkbtn { border: none; background: none; padding: 0; color: var(--green); font: inherit; font-weight: 650; cursor: pointer; min-height: auto; }
.faq-linkbtn:hover { text-decoration: underline; }
.faq-linkbtn-danger { color: #c0392b; }

.faq-admin-back { margin-bottom: 6px; }
.faq-admin-form { max-width: 720px; display: grid; gap: 18px; margin-top: 12px; }
.faq-field { display: grid; gap: 6px; }
.faq-field > span { font-weight: 700; color: var(--ink); font-size: .9rem; }
.faq-field input, .faq-field select, .faq-field textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
.faq-field textarea { resize: vertical; }
.faq-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.faq-check { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); }
.faq-check input { width: 18px; height: 18px; }
.faq-form-actions { display: flex; gap: 12px; align-items: center; }

@media (max-width: 640px) {
    .faq-field-row { grid-template-columns: 1fr; }
}

/* Централно административно табло и общи трохи. */
.app-surface .admin-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 24px;
    padding: 0 0 15px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}
.admin-breadcrumbs a { color: var(--brand-blue); text-decoration: none; }
.admin-breadcrumbs a:hover { text-decoration: underline; }
.admin-dashboard-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.admin-dashboard-eyebrow { margin: 0 0 7px !important; color: var(--brand-blue) !important; font-size: .76rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.admin-dashboard-head h1 { margin: 0 0 8px; color: var(--brand-navy); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.15rem, 4vw, 3.25rem); line-height: 1.05; }
.admin-dashboard-head p:last-child { max-width: 680px; margin: 0; color: var(--muted); }
.admin-pending-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 36px;
    padding: 28px 32px;
    border: 1px solid #c7daf7;
    border-radius: 18px;
    background: linear-gradient(120deg, #f1f6ff, #fff);
    color: var(--brand-navy);
    text-decoration: none;
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.admin-pending-card:hover { border-color: var(--brand-blue); color: var(--brand-navy); transform: translateY(-2px); box-shadow: 0 14px 32px rgba(22, 64, 122, .1); }
.admin-pending-card.is-readonly:hover { border-color: #c7daf7; transform: none; box-shadow: none; }
.admin-pending-card.has-pending { border-left: 6px solid var(--brand-blue); }
.admin-pending-copy { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 18px; }
.admin-pending-label { grid-column: 1 / -1; color: #50647f; font-size: .82rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.admin-pending-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 3.8rem; line-height: 1; }
.admin-pending-detail { color: var(--muted); font-size: .92rem; }
.admin-pending-action { flex: 0 0 auto; color: var(--brand-blue); font-weight: 850; }
.admin-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.admin-section-heading h2 { margin: 0; font-size: 1.55rem; }
.admin-section-heading > span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.admin-section-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-section-card {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 15px;
    min-height: 118px;
    padding: 19px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.admin-section-card:hover { border-color: #9ebfec; color: var(--ink); box-shadow: 0 10px 26px rgba(22, 64, 122, .08); }
.admin-section-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 12px; background: #eaf2ff; color: var(--brand-blue); }
.admin-section-icon::before { font-size: 1.35rem; font-weight: 900; line-height: 1; }
.admin-section-icon-questions::before { content: "?"; }
.admin-section-icon-requests::before { content: "+"; }
.admin-section-icon-reports::before { content: "!"; }
.admin-section-icon-answers::before { content: "A"; }
.admin-section-icon-catalog::before { content: "≡"; }
.admin-section-icon-access::before { content: "✓"; }
.admin-section-icon-knowledge::before { content: "i"; }
.admin-section-icon-corrections::before { content: "↻"; }
.admin-section-icon-faq::before { content: "?"; }
.admin-section-icon-imports::before { content: "↓"; }
.admin-section-icon-roles::before { content: "●"; }
.admin-section-content { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.admin-section-title { display: flex; align-items: center; gap: 9px; color: var(--brand-navy); font-size: 1rem; }
.admin-section-badge { display: inline-grid; min-width: 24px; height: 24px; padding: 0 7px; place-items: center; border-radius: 999px; background: var(--brand-blue); color: #fff; font-size: .75rem; }
.admin-section-arrow { color: #8090a7; font-size: 1.25rem; transition: transform .18s ease; }
.admin-section-card:hover .admin-section-arrow { color: var(--brand-blue); transform: translateX(3px); }
.question-status-badge { display: inline-flex; align-items: center; max-width: 230px; padding: 6px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; line-height: 1.3; }
.question-status-badge.is-neutral { color: #53647b; background: #edf1f6; }
.question-status-badge.is-info { color: #0758c7; background: #e8f1ff; }
.question-status-badge.is-waiting { color: #76520a; background: #fff3cf; }
.question-status-badge.is-warning { color: #8a4a0b; background: #ffeedc; }
.question-status-badge.is-success { color: #17613c; background: #e5f5ec; }
.question-status-badge.is-danger { color: #942d39; background: #fdebed; }
@media (max-width: 760px) {
    .admin-section-grid { grid-template-columns: 1fr; }
    .admin-pending-card { align-items: flex-start; flex-direction: column; padding: 23px; }
    .admin-pending-copy { grid-template-columns: auto 1fr; }
}
@media (max-width: 460px) {
    .admin-section-card { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 15px; }
    .admin-section-icon { width: 40px; height: 40px; }
    .admin-pending-copy { display: grid; }
}
