:root {
    --admin-ink: #173a36;
    --admin-text: var(--admin-ink);
    --admin-muted: #657975;
    --admin-ink-muted: var(--admin-muted);
    --admin-line: #dce7e3;
    --admin-surface: #fff;
    --admin-soft: #eef6f2;
    --admin-primary: #0e6f5c;
    --admin-accent: #c99a3b;
    --admin-danger: #b33c47;
    --admin-shadow: 0 12px 30px rgba(23, 58, 54, .06);
}

* { box-sizing: border-box; }
body { margin: 0; background: #f5f8f6; color: var(--admin-ink); font-family: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .admin-button { border: 0; border-radius: .65rem; background: var(--admin-primary); color: #fff; cursor: pointer; padding: .65rem .9rem; text-decoration: none; }
button:hover, .admin-button:hover { filter: brightness(.94); }
.admin-button-secondary { background: var(--admin-soft); color: var(--admin-primary); }
.admin-button-danger { background: var(--admin-danger); }
.admin-button-small { padding: .42rem .65rem; font-size: .8rem; }
.admin-shell { min-block-size: 100vh; display: grid; grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); }
.admin-sidebar { background: var(--admin-ink); color: #f6fbf8; padding: 1.25rem; display: flex; flex-direction: column; gap: 1.5rem; }
.admin-brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.admin-brand-mark { display: grid; place-items: center; inline-size: 2.4rem; block-size: 2.4rem; border-radius: .8rem; background: var(--admin-accent); color: #fff; font-weight: 800; font-size: 1.15rem; flex-shrink: 0; }
.admin-brand small { display: block; color: #b8ccc5; font-size: .75rem; margin-block-start: .15rem; }
.admin-view-site { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font-size: .8rem; font-weight: 700; color: #d8e6e0; padding-block: .45rem; padding-inline: .75rem; border-radius: .55rem; background: rgba(255,255,255,.08); text-decoration: none; transition: background .15s ease, color .15s ease; }
.admin-view-site:hover { background: rgba(255,255,255,.16); color: #fff; }
.admin-nav { display: grid; gap: .15rem; }
.admin-nav a { padding-block: .7rem; padding-inline: .8rem; border-radius: .7rem; color: #d8e6e0; text-decoration: none; }
.admin-nav a:hover, .admin-nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; }

/* Grouped sidebar: <details> supplies the collapse, so the styling only has to
   make the summary look like a header and turn the marker into a chevron that
   follows the writing direction. */
.admin-nav-solo { margin-block-end: .5rem; }
.admin-nav-group { border-radius: .7rem; }
.admin-nav-group + .admin-nav-group { margin-block-start: .15rem; }
.admin-nav-group > summary {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding-block: .6rem;
    padding-inline: .8rem;
    border-radius: .7rem;
    color: #9fb8b1;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
    transition: background .15s ease, color .15s ease;
}
.admin-nav-group > summary::-webkit-details-marker { display: none; }
.admin-nav-group > summary::after {
    content: "";
    inline-size: .45rem;
    block-size: .45rem;
    margin-inline-start: auto;
    border-inline-end: 2px solid currentColor;
    border-block-end: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .18s ease;
}
.admin-nav-group[open] > summary::after { transform: rotate(-135deg); }
.admin-nav-group > summary:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-nav-group > summary:focus-visible { outline: 2px solid var(--admin-accent); outline-offset: 2px; }
.admin-nav-group[open] > summary { color: #fff; }
.admin-nav-group > summary > span:first-child { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
.admin-nav-group-items { display: grid; gap: .15rem; padding-block: .15rem .35rem; padding-inline-start: .55rem; }
/* The rail ties the child links to their group without indenting them off the
   sidebar; it is inline-start, so it flips with the direction. */
.admin-nav-group-items { border-inline-start: 1px solid rgba(255,255,255,.14); margin-inline-start: .8rem; }
/* No box-shadow inset for the active marker: its offsets are physical and would
   sit on the wrong edge in RTL. The background highlight already carries it. */
.admin-nav-group-items a { font-size: .9rem; }
.admin-user { border-block-start: 1px solid rgba(255,255,255,.16); padding-block-start: 1rem; margin-block-start: auto; color: #d8e6e0; }
.admin-user strong { display: block; color: #fff; }
.admin-main { min-inline-size: 0; padding: clamp(1rem, 3vw, 2.5rem); }
.admin-topbar { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-block-end: 1.5rem; }
.admin-topbar h1 { font-size: clamp(1.65rem, 3vw, 2.4rem); margin: .35rem 0 .5rem; }
.admin-eyebrow { color: var(--admin-primary); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.admin-muted { color: var(--admin-muted); margin: 0; }
.admin-status { border: 1px solid var(--admin-line); background: var(--admin-surface); border-radius: .8rem; padding: .7rem .9rem; white-space: nowrap; font-size: .86rem; }
.admin-status::before { content: ""; display: inline-block; inline-size: .55rem; block-size: .55rem; border-radius: 50%; background: #2f9e67; margin-inline-end: .45rem; }
.admin-card { margin-block-end: 1.25rem; background: var(--admin-surface); border: 1px solid var(--admin-line); border-radius: 1rem; overflow: hidden; box-shadow: var(--admin-shadow); }
.admin-card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 1rem; padding-inline: 1.2rem; border-block-end: 1px solid var(--admin-line); }
.admin-card-head h2 { margin: 0; font-size: 1.1rem; }
.admin-card-body { padding-block: 1.2rem; padding-inline: 1.2rem; }
.admin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; margin-block-end: 1.25rem; }
.admin-stat { padding-block: 1rem; padding-inline: 1.1rem; border: 1px solid var(--admin-line); border-radius: .9rem; background: var(--admin-surface); box-shadow: var(--admin-shadow); }
.admin-stat strong { display: block; font-size: 1.8rem; color: var(--admin-primary); }
.admin-stat span { color: var(--admin-muted); font-size: .82rem; }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: .7rem; padding-block: 1rem; padding-inline: 1.2rem; border-block-end: 1px solid var(--admin-line); background: var(--admin-soft); }
.admin-toolbar label, .admin-field { display: grid; gap: .3rem; color: var(--admin-muted); font-size: .78rem; font-weight: 700; }
.admin-field { color: var(--admin-ink); }
.admin-toolbar select, .admin-toolbar input, .admin-field input, .admin-field select, .admin-field textarea { min-inline-size: 0; padding-block: .62rem; padding-inline: .7rem; border: 1px solid var(--admin-line); border-radius: .55rem; background: #fff; color: var(--admin-ink); }
.admin-field textarea { min-block-size: 7rem; resize: vertical; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.admin-field-full { grid-column: 1 / -1; }
.admin-checkbox { display: flex; align-items: center; gap: .55rem; }
.admin-checkbox input { width: auto; }
.admin-seo-editor { margin-top: .55rem; padding: .55rem; border: 1px solid var(--admin-line); border-radius: .65rem; }
.admin-seo-editor summary { cursor: pointer; color: var(--admin-primary); font-weight: 700; }
.admin-seo-editor form { display: grid; gap: .55rem; margin-top: .65rem; }
.admin-form-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-block-start: 1rem; }
.admin-inline-form { display: inline-flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { inline-size: 100%; border-collapse: collapse; min-inline-size: 760px; }
.admin-table th, .admin-table td { text-align: start; vertical-align: top; padding-block: .8rem; padding-inline: 1rem; border-block-end: 1px solid var(--admin-line); }
.admin-table th { color: var(--admin-muted); font-size: .76rem; font-weight: 800; white-space: nowrap; }
.admin-table td { font-size: .86rem; }
.admin-table tr:last-child td { border-block-end: 0; }
.admin-table small { display: block; color: var(--admin-muted); margin-block-start: .2rem; }
.admin-badge { display: inline-flex; padding-block: .25rem; padding-inline: .55rem; border-radius: 999px; background: var(--admin-soft); color: var(--admin-primary); font-size: .72rem; font-weight: 800; }
.admin-badge-danger { background: #fff0f1; color: var(--admin-danger); }
.admin-badge-gold { background: #fff7e5; color: #8c641b; }
.admin-alert { margin-block-end: 1rem; padding-block: .75rem; padding-inline: .9rem; border-radius: .7rem; background: #fff7e5; color: #6b4b0e; }
.admin-alert-error { background: #fff0f1; color: var(--admin-danger); }
.admin-alert-success { background: #eaf8f0; color: #216b45; }
.admin-empty { color: var(--admin-muted); text-align: center; padding-block: 2.5rem; padding-inline: 1rem; }
.admin-link { color: var(--admin-primary); font-weight: 750; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.admin-menu-reorder { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.admin-menu-table { min-inline-size: 820px; }
.admin-menu-item { cursor: grab; }
.admin-menu-item.is-dragging { opacity: .55; background: var(--admin-soft); }
.admin-menu-reorder-cell { min-inline-size: 8.5rem; white-space: nowrap; }
.admin-menu-drag-handle { display: inline-flex; align-items: center; justify-content: center; min-block-size: 2rem; min-inline-size: 2rem; padding: .25rem .5rem; border: 1px dashed var(--admin-line); border-radius: .45rem; background: var(--admin-soft); color: var(--admin-primary); cursor: grab; font-size: 1rem; line-height: 1; }
.admin-menu-drag-handle:focus-visible, .admin-menu-drag-handle:hover { border-color: var(--admin-primary); }
.admin-menu-move-actions { display: inline-flex; gap: .25rem; margin-inline-start: .35rem; }
.admin-menu-move-actions .admin-button { min-block-size: 2rem; min-inline-size: 2rem; padding-inline: .45rem; }
.admin-menu-system-controls { margin-block-start: 1rem; }
.admin-menu-system-controls-list { display: grid; gap: .55rem; margin: 0; }
.admin-menu-system-control { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; padding-block: .65rem; padding-inline: .8rem; border: 1px solid var(--admin-line); border-radius: .6rem; background: var(--admin-soft); }
.admin-menu-system-control dt { color: var(--admin-ink); font-weight: 800; }
.admin-menu-system-control dd { margin: 0; color: var(--admin-muted); text-align: end; }
.admin-code { max-inline-size: 28rem; overflow-wrap: anywhere; font-family: ui-monospace, Consolas, monospace; font-size: .76rem; }
.admin-language { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; color: #d8e6e0; font-size: .82rem; }
.admin-language select { max-inline-size: 10rem; padding: .4rem .5rem; border: 1px solid rgba(255,255,255,.18); border-radius: .55rem; background: #fff; color: var(--admin-ink); }
.admin-subcard { margin-block-end: .85rem; padding: 1rem; border: 1px solid var(--admin-line); border-radius: .85rem; background: #fbfdfc; }
.admin-subcard:last-child { margin-block-end: 0; }
.admin-translation-row { display: grid; grid-template-columns: minmax(12rem, .8fr) minmax(18rem, 2fr) auto; gap: .75rem; align-items: start; padding-block: .8rem; border-block-end: 1px solid var(--admin-line); }
.admin-translation-row:last-child { border-block-end: 0; }
.admin-translation-row code { display: block; overflow-wrap: anywhere; }
.admin-translation-row small { display: block; color: var(--admin-muted); margin-block-start: .25rem; }
.admin-translation-row form { display: flex; gap: .45rem; align-items: start; }
.admin-translation-row textarea { inline-size: 100%; min-block-size: 4.2rem; padding: .55rem .65rem; border: 1px solid var(--admin-line); border-radius: .55rem; resize: vertical; }
.admin-menu-link { display: none; }

@media (max-width: 1000px) { .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .admin-translation-row { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
    .admin-shell { display: block; }
    .admin-sidebar { padding: 1rem; }
    /* The sidebar becomes a stacked block on mobile, so the groups stay
       vertical accordions rather than a horizontal scroller -- eighteen links
       in a scrolling strip is exactly the problem the grouping solves. */
    .admin-nav { display: grid; }
    .admin-nav a { white-space: nowrap; }
    .admin-nav-group > summary { padding-block: .75rem; }
    .admin-user { display: none; }
    .admin-topbar { display: block; }
    .admin-status { display: inline-block; margin-block-start: 1rem; }
    .admin-main { padding: 1rem; }
    .admin-form-grid { grid-template-columns: 1fr; }
    .admin-field-full { grid-column: auto; }
}
@media (max-width: 440px) { .admin-grid { grid-template-columns: 1fr; } .admin-card-head { align-items: start; flex-direction: column; } }

.admin-category-path {
    margin-block-end: .8rem;
    color: var(--admin-muted, #64748b);
    font-size: .85rem;
    font-weight: 700;
}

/* 0.6.4 management tables */
.admin-page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1rem;
    padding-inline: 1.2rem;
}
.admin-page-toolbar h2 { margin: 0 0 .2rem; font-size: 1.12rem; }
.admin-count {
    display: inline-grid;
    place-items: center;
    min-inline-size: 2.25rem;
    block-size: 2.25rem;
    padding-inline: .6rem;
    border-radius: 999px;
    background: var(--admin-soft);
    color: var(--admin-primary);
    font-weight: 800;
}
.admin-record-editor {
    border-color: color-mix(in srgb, var(--admin-primary) 32%, var(--admin-line));
    box-shadow: 0 16px 38px rgba(14, 111, 92, .09);
}
.admin-record-editor .admin-card-head { background: #f8fcfa; }
.admin-table tbody tr { transition: background-color .15s ease; }
.admin-table tbody tr:hover { background: #fbfdfc; }
.admin-table thead th { background: #f8fbf9; position: sticky; inset-block-start: 0; z-index: 1; }
.admin-table td code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; }
.admin-table .admin-actions { min-inline-size: max-content; }
.admin-audit-details { min-inline-size: 15rem; }
.admin-audit-details > summary { cursor: pointer; color: var(--admin-primary); font-weight: 700; }
.admin-audit-snapshots { display: grid; gap: .65rem; margin-block-start: .65rem; }
.admin-audit-snapshots pre { max-inline-size: 32rem; max-block-size: 16rem; overflow: auto; margin-block: .35rem 0; padding: .65rem; border: 1px solid var(--admin-line); border-radius: .55rem; background: var(--admin-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-system-table { min-inline-size: 0; }
.admin-system-table th { inline-size: 15rem; white-space: normal; }
.admin-system-table code { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.admin-actions .admin-inline-form { margin: 0; }
.admin-status-active { background: #eaf8f0; color: #216b45; }
.admin-status-suspended { background: #fff7e5; color: #8c641b; }
.admin-status-banned { background: #fff0f1; color: var(--admin-danger); }
.admin-search-form { margin-block-end: 1rem; }
.admin-search-form input { min-inline-size: min(26rem, 55vw); }
.admin-category-table td:first-child { min-inline-size: 15rem; }
.admin-users-table td:first-child { min-inline-size: 15rem; }
.admin-widgets-table .admin-code { max-inline-size: 22rem; white-space: normal; }
.admin-button-secondary:hover { filter: none; background: #e4f0eb; }
.admin-button-danger:hover { filter: brightness(.92); }

.admin-question-filters { padding-block: 1rem; padding-inline: 1.2rem; border-block: 1px solid var(--admin-line); background: linear-gradient(135deg, #f4faf7, #edf5f1); }
.admin-question-filter-form { display: grid; gap: .9rem; }
.admin-question-filter-grid { display: grid; grid-template-columns: minmax(13rem, 2fr) repeat(4, minmax(9rem, 1fr)); gap: .75rem; align-items: end; }
.admin-question-search { min-inline-size: 0; }
.admin-question-search input { min-inline-size: 0; }
.admin-question-filter-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.admin-filter-count { color: var(--admin-muted); font-size: .8rem; font-weight: 700; }
.admin-pagination-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding-block: .8rem; padding-inline: 1.2rem; border-block-end: 1px solid var(--admin-line); background: #fbfdfc; }
.admin-pagination-summary { margin: 0; color: var(--admin-muted); font-size: .82rem; font-weight: 700; }
.admin-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.admin-pagination .is-active { background: var(--admin-ink); color: #fff; }
.admin-pagination-edge { background: var(--admin-soft); color: var(--admin-primary); }
.admin-pagination-gap { padding-inline: .2rem; color: var(--admin-muted); }
.admin-question-title { display: grid; gap: .15rem; }
.admin-question-title strong { font-size: .95rem; line-height: 1.45; }
.admin-question-status { white-space: nowrap; }
.admin-question-metrics { display: grid; gap: .25rem; color: var(--admin-muted); white-space: nowrap; }
.admin-question-metrics span { font-size: .8rem; }

@media (max-width: 720px) {
    .admin-page-toolbar { align-items: flex-start; }
    .admin-page-toolbar > div { min-inline-size: 0; }
    .admin-table { min-inline-size: 680px; }
    .admin-search-form input { min-inline-size: 12rem; }
    .admin-question-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-question-search { grid-column: 1 / -1; }
    .admin-pagination-row { align-items: flex-start; flex-direction: column; }
    .admin-system-table { min-inline-size: 0; }
    .admin-system-table tbody, .admin-system-table tr, .admin-system-table th, .admin-system-table td { display: block; inline-size: 100%; }
    .admin-system-table tr { padding-block: .7rem; padding-inline: 1rem; border-block-end: 1px solid var(--admin-line); }
    .admin-system-table tr:last-child { border-block-end: 0; }
    .admin-system-table th, .admin-system-table td { padding: 0; border: 0; }
    .admin-system-table td { margin-block-start: .35rem; }
}

@media (max-width: 440px) {
    .admin-question-filter-grid { grid-template-columns: 1fr; }
    .admin-question-search { grid-column: auto; }
    .admin-question-filter-actions > button, .admin-question-filter-actions > .admin-button { flex: 1 1 10rem; text-align: center; }
}

.admin-appearance-card .admin-card-body {
    display: grid;
    gap: 1.5rem;
}

.admin-appearance-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--admin-line);
    border-radius: .8rem;
    background: var(--admin-soft);
}

.admin-appearance-tools p {
    margin-block: .25rem 0;
}

.admin-appearance-import {
    padding-block-start: 1.5rem;
    border-block-start: 1px solid var(--admin-line);
}

.admin-appearance-section {
    padding-block-end: 1.5rem;
    border-block-end: 1px solid var(--admin-line);
}

.admin-section-heading {
    margin-block-end: 1rem;
}

.admin-section-heading h3 {
    margin-block: 0 .25rem;
}

.admin-appearance-color-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Page-region cards on the appearance screen. */
.admin-region-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; }
.admin-region .admin-card-head { align-items: flex-start; gap: .75rem; }
.admin-region h4 { margin: 0; font-size: .95rem; }
.admin-region code { font-size: .75rem; }
.admin-region-widgets { display: grid; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.admin-region-widgets li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .35rem .4rem; border: 1px solid transparent; border-radius: .5rem; background: var(--admin-soft); }
.admin-region-widgets li.is-dragging { opacity: .5; border-color: var(--admin-primary); }
.admin-region-widget-name { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
.admin-region-widget-actions { display: inline-flex; gap: .25rem; margin-inline-start: auto; }
.admin-drag-handle { cursor: grab; color: var(--admin-muted); font-size: 1rem; line-height: 1; }
.admin-region-widgets li:active .admin-drag-handle { cursor: grabbing; }
.admin-region-widgets a { font-weight: 650; }

.admin-color-control {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.admin-color-control input[type="color"] {
    inline-size: 2.6rem;
    block-size: 2.6rem;
    padding: .15rem;
    border: 1px solid var(--admin-line);
    border-radius: .65rem;
    background: var(--admin-surface);
}

.admin-color-control input[type="text"] {
    min-inline-size: 0;
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.admin-appearance-reset {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
}

.admin-language-delete-status {
    display: inline-flex;
    flex-direction: column;
    gap: .15rem;
    max-inline-size: 15rem;
}

.admin-language-delete-status small + small {
    color: var(--admin-ink-muted);
    line-height: 1.5;
}

@media (max-width: 720px) {
    .admin-appearance-color-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 440px) {
    .admin-appearance-tools {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-appearance-color-grid {
        grid-template-columns: 1fr;
    }
}

/* Keep row operations visible while wide management tables scroll. */
:is(.admin-questions-table, .admin-answers-table, .admin-category-table, .admin-tags-table, .admin-users-table, .admin-reports-table, .admin-languages-table, .admin-layouts-table, .admin-sections-table, .admin-widgets-table, .admin-messages-table, .admin-notifications-table) th:last-child,
:is(.admin-questions-table, .admin-answers-table, .admin-category-table, .admin-tags-table, .admin-users-table, .admin-reports-table, .admin-languages-table, .admin-layouts-table, .admin-sections-table, .admin-widgets-table, .admin-messages-table, .admin-notifications-table) td:last-child {
    position: sticky;
    inset-inline-end: 0;
    background: var(--admin-surface);
    box-shadow: -8px 0 14px rgba(23, 58, 54, .035);
}
html[dir="rtl"] :is(.admin-questions-table, .admin-answers-table, .admin-category-table, .admin-tags-table, .admin-users-table, .admin-reports-table, .admin-languages-table, .admin-layouts-table, .admin-sections-table, .admin-widgets-table, .admin-messages-table, .admin-notifications-table) th:last-child,
html[dir="rtl"] :is(.admin-questions-table, .admin-answers-table, .admin-category-table, .admin-tags-table, .admin-users-table, .admin-reports-table, .admin-languages-table, .admin-layouts-table, .admin-sections-table, .admin-widgets-table, .admin-messages-table, .admin-notifications-table) td:last-child {
    box-shadow: 8px 0 14px rgba(23, 58, 54, .035);
}
:is(.admin-questions-table, .admin-answers-table, .admin-category-table, .admin-tags-table, .admin-users-table, .admin-reports-table, .admin-languages-table, .admin-layouts-table, .admin-sections-table, .admin-widgets-table, .admin-messages-table, .admin-notifications-table) tbody tr:hover td:last-child {
    background: #fbfdfc;
}
.admin-category-name {
    padding-inline-start: calc(var(--category-depth, 0) * 1.05rem);
}
.admin-tree-branch {
    display: inline-block;
    margin-inline-end: .35rem;
    color: var(--admin-muted);
    font-weight: 500;
}

/* Administration UI fields inherit the dashboard language direction.
   Technical/content-specific fields can opt out with an explicit dir attribute. */
.admin-toolbar input,
.admin-toolbar select,
.admin-field input:not([dir]),
.admin-field select:not([dir]),
.admin-field textarea:not([dir]),
.admin-search-form input:not([dir]) {
    direction: inherit;
    text-align: start;
}

html[dir="rtl"] .admin-search-form input:not([dir]) { direction: rtl; }
html[dir="ltr"] .admin-search-form input:not([dir]) { direction: ltr; }

.admin-root-category-toggle { align-self: end; min-block-size: 2.8rem; }
[data-category-parent-field].is-disabled { opacity: .55; }
[data-category-parent-field] small { color: var(--admin-muted); font-weight: 500; }

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-block-end: 1rem;
    padding: .45rem;
    border: 1px solid var(--admin-line);
    border-radius: .85rem;
    background: var(--admin-surface);
}
.admin-tabs a {
    padding-block: .55rem;
    padding-inline: .8rem;
    border-radius: .65rem;
    color: var(--admin-muted);
    font-size: .84rem;
    font-weight: 750;
    text-decoration: none;
}
.admin-tabs a:hover,
.admin-tabs a[aria-current="page"] {
    background: var(--admin-soft);
    color: var(--admin-primary);
}
.admin-row-unread td { background: #f4fbf7; }
.admin-message-content {
    margin-block-end: 1rem;
    padding: 1rem;
    border: 1px solid var(--admin-line);
    border-radius: .75rem;
    background: #fbfdfc;
}
.admin-message-content p { margin-block-end: 0; }

.admin-nav a { display:flex; align-items:center; justify-content:space-between; gap:.75rem; }
.admin-nav-badge { display:inline-flex; min-inline-size:1.5rem; block-size:1.5rem; padding-inline:.35rem; align-items:center; justify-content:center; border-radius:999px; background:var(--admin-danger,#b42335); color:#fff; font-size:.72rem; font-weight:800; line-height:1; }
.admin-delivery-tests { margin-block-start: 1rem; padding-block-start: 1rem; border-block-start: 1px solid var(--admin-line); }
.admin-delivery-tests > strong { display:block; margin-block-end:.6rem; }

.admin-mini-check { display:inline-flex; align-items:center; gap:.4rem; margin-block-start:.45rem; font-size:.82rem; color:var(--admin-muted); font-weight:600; }
.admin-mini-check input { inline-size:auto; }

/* Topbar notification center */
.admin-topbar-actions {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
}
.admin-notification-center { position: relative; }
.admin-notification-center > summary { list-style: none; }
.admin-notification-center > summary::-webkit-details-marker { display: none; }
.admin-notification-trigger {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-block-size: 2.7rem;
    padding-inline: .8rem;
    border: 1px solid var(--admin-line);
    border-radius: .8rem;
    background: var(--admin-surface);
    color: var(--admin-text);
    cursor: pointer;
    font-size: .84rem;
    font-weight: 750;
    user-select: none;
}
.admin-notification-center[open] .admin-notification-trigger,
.admin-notification-trigger:hover { background: var(--admin-soft); }
.admin-notification-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 1.45rem;
    block-size: 1.45rem;
    padding-inline: .3rem;
    border-radius: 999px;
    background: var(--admin-danger);
    color: #fff;
    font-size: .7rem;
    line-height: 1;
}
.admin-notification-popover {
    position: absolute;
    z-index: 50;
    inset-block-start: calc(100% + .55rem);
    inset-inline-end: 0;
    inline-size: min(23rem, calc(100vw - 2rem));
    overflow: hidden;
    border: 1px solid var(--admin-line);
    border-radius: .9rem;
    background: var(--admin-surface);
    box-shadow: var(--admin-shadow);
}
.admin-notification-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem .9rem;
    border-block-end: 1px solid var(--admin-line);
}
.admin-notification-head span { color: var(--admin-muted); font-size: .8rem; }
.admin-notification-list { max-block-size: 22rem; overflow: auto; }
.admin-notification-item {
    display: grid;
    gap: .2rem;
    padding: .75rem .9rem;
    border-block-end: 1px solid var(--admin-line);
    color: var(--admin-text);
    text-decoration: none;
}
.admin-notification-item:hover { background: var(--admin-soft); }
.admin-notification-item span,
.admin-notification-item time { color: var(--admin-muted); font-size: .78rem; }
.admin-notification-empty { margin: 0; padding: 1rem; color: var(--admin-muted); }
.admin-notification-all { display: block; padding: .75rem .9rem; text-align: center; font-weight: 750; text-decoration: none; color: var(--admin-primary); }

/* Reports: preserve reporter context and make the reported object inspectable. */
.admin-report-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
    margin-block-end: 1rem;
}
.admin-report-meta-grid > div,
.admin-report-note,
.admin-report-context,
.admin-report-target-preview {
    border: 1px solid var(--admin-line);
    border-radius: .8rem;
    background: var(--admin-soft);
    padding: .85rem;
}
.admin-report-meta-grid span { display: block; margin-block-end: .25rem; color: var(--admin-muted); font-size: .76rem; }
.admin-report-note,
.admin-report-context,
.admin-report-target-preview { margin-block-end: .8rem; }
.admin-report-note p,
.admin-report-context p { margin-block-end: 0; }
.admin-report-target-preview > div {
    margin-block-start: .55rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.8;
}
.admin-report-row-preview { max-inline-size: 28rem; white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 880px) {
    .admin-topbar-actions { margin-block-start: 1rem; flex-wrap: wrap; }
    .admin-report-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .admin-topbar-actions { align-items: stretch; }
    .admin-notification-center { flex: 1 1 auto; }
    .admin-notification-trigger { inline-size: 100%; justify-content: center; }
    .admin-notification-popover { position: fixed; inset-inline: 1rem; inset-block-start: 5rem; inline-size: auto; }
    .admin-report-meta-grid { grid-template-columns: 1fr; }
}

/* Advertising manager */
.admin-ad-placement {
  border: 1px solid var(--admin-border, #dbe1ea);
  border-radius: 14px;
  padding: 1rem;
  margin-block: 1rem;
  min-inline-size: 0;
}
.admin-ad-placement legend {
  padding-inline: .45rem;
  font-weight: 800;
}
.admin-ad-placement textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  max-inline-size: 100%;
}

/* Action Queue Grid */
.admin-action-queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1.25rem;
  margin-block-start: 1rem;
}
.admin-action-queue-col {
  border: 1px solid var(--admin-line);
  border-radius: .85rem;
  background: var(--admin-surface);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.admin-action-queue-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-block-end: 1px solid var(--admin-line);
  padding-block-end: .5rem;
}
.admin-action-queue-col-head h3 {
  font-size: .95rem;
  margin-block: 0;
}
.admin-action-queue-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.admin-action-queue-item {
  border: 1px solid var(--admin-line);
  border-radius: .6rem;
  background: var(--admin-soft);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  text-decoration: none;
  color: inherit;
}
.admin-action-queue-item strong {
  font-size: .88rem;
  overflow-wrap: anywhere;
}
.admin-action-queue-item small {
  color: var(--admin-muted);
  font-size: .75rem;
}
.admin-action-queue-item .admin-actions {
  margin-block-start: .4rem;
}

/* Question Review & Create */
.admin-create-question {
  margin-block-end: 1.25rem;
}
.admin-create-question summary {
  font-weight: 700;
  cursor: pointer;
}
.admin-question-review {
  margin-block-start: .6rem;
  border: 1px solid var(--admin-line);
  border-radius: .6rem;
  padding: .6rem;
  background: var(--admin-soft);
}
.admin-question-review summary {
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--admin-primary);
}
.admin-question-review-body {
  margin-block-start: .5rem;
  padding: .75rem;
  border-radius: .5rem;
  background: var(--admin-surface);
  border: 1px solid var(--admin-line);
  line-height: 1.7;
  font-size: .88rem;
  overflow-wrap: anywhere;
}
.admin-row-unread {
  background: rgba(37, 99, 235, 0.04);
  font-weight: 600;
}
.admin-notification-cards {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem;
}
.admin-notification-card {
  border: 1px solid var(--admin-line);
  border-radius: .75rem;
  padding: 1rem;
  background: var(--admin-surface);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  position: relative;
  transition: border-color .15s ease, background-color .15s ease;
}
.admin-notification-card-unread {
  background: rgba(37, 99, 235, 0.04);
  border-inline-start: 4px solid var(--admin-primary);
}
.admin-notification-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.admin-notification-card-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}
.admin-notification-time {
  font-size: .78rem;
  color: var(--admin-muted);
}
.admin-notification-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--admin-ink);
  overflow-wrap: anywhere;
}
.admin-notification-text {
  margin: 0;
  color: var(--admin-muted);
  font-size: .85rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.admin-badge-report, .admin-badge-new_report { background: #fff0f1; color: var(--admin-danger); }
.admin-badge-question, .admin-badge-new_question { background: var(--admin-soft); color: var(--admin-primary); }
.admin-badge-answer, .admin-badge-new_answer { background: #f0fdf4; color: #166534; }
.admin-badge-comment, .admin-badge-new_comment { background: #faf5ff; color: #6b21a8; }
.admin-badge-message, .admin-badge-contact_message { background: #f1f5f9; color: #475569; }


/* Toggle state.
   A toggle that only swaps its label tells an operator nothing: the language
   table scrolls sideways, so the status column was off-screen and pressing
   "disable" looked like it had done nothing at all. The button now carries the
   state it is in, and the row it belongs to reads as switched off. */
.admin-button-active {
    background: color-mix(in srgb, var(--admin-primary, #0e6f5c) 12%, transparent);
    border: 1px solid var(--admin-primary, #0e6f5c);
    color: var(--admin-primary-dark, #0A5546);
    font-weight: 600;
}

.admin-button-active::before {
    content: '●';
    margin-inline-end: .35rem;
    font-size: .7em;
    vertical-align: middle;
}

.admin-button-muted {
    background: transparent;
    border: 1px solid var(--admin-line, #dce7e3);
    color: var(--admin-ink-muted, #5B6270);
}

.admin-button-muted::before {
    content: '○';
    margin-inline-end: .35rem;
    font-size: .7em;
    vertical-align: middle;
}

.admin-row-disabled > td {
    opacity: .55;
}

.admin-row-disabled > td:last-child {
    opacity: 1;
}

/* Overview action dashboard */
.admin-stat-link{text-decoration:none;color:inherit}.admin-stat-link:hover{border-color:var(--admin-primary,#0e6f5c);transform:translateY(-1px)}.system-health-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:.75rem;padding:1rem}.system-health-item{display:flex;align-items:flex-start;gap:.7rem;padding:.8rem;border:1px solid var(--admin-line,#e7e9ee);border-radius:.75rem;background:var(--admin-surface,#fff)}.system-health-item div{display:grid;gap:.15rem}.system-health-item small{color:var(--admin-muted,#5b6270)}.health-dot{inline-size:.65rem;block-size:.65rem;margin-block-start:.3rem;border-radius:50%;background:#64748b}.health-pass{background:#198754}.health-warn{background:#d97706}.health-fail{background:#b42318}.health-info{background:#3977c9}

.admin-color-row{display:flex;align-items:center;gap:.5rem}.admin-color-row input[type="color"]{inline-size:3rem;block-size:2.2rem;padding:0;border:1px solid var(--admin-border,#e7e9ee);border-radius:.4rem;background:none;cursor:pointer}.admin-color-row code{font-size:.8rem;letter-spacing:.02em}

/* Brand display mode picker and logo preview. */
.admin-brand-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .65rem; border: 0; padding: 0; margin: 0; }
.admin-brand-modes legend { font-weight: 700; margin-block-end: .5rem; }
.admin-brand-mode { display: flex; align-items: flex-start; gap: .55rem; padding: .75rem; border: 1px solid var(--admin-border, #e7e9ee); border-radius: .5rem; cursor: pointer; }
.admin-brand-mode:has(input:checked) { border-color: var(--admin-primary, #0e6f5c); background: rgb(14 111 92 / 4%); }
.admin-brand-mode span { display: grid; gap: .2rem; }
.admin-brand-mode small { color: var(--admin-muted, #5b6270); }
.admin-logo-preview { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; margin-block-start: .5rem; }
.admin-logo-preview code { font-size: .78rem; }
.admin-inline-check { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; }

/* Grouped appearance form. Fieldsets carry the grouping semantically, so a
   screen reader announces which group a field belongs to instead of reading one
   long undifferentiated column. */
.admin-fieldset { border: 1px solid var(--admin-border, #e7e9ee); border-radius: .6rem; padding: 1rem 1.1rem; margin-block-end: 1.25rem; }
.admin-fieldset > legend { padding-inline: .4rem; font-weight: 700; font-size: .9rem; color: var(--admin-muted, #5b6270); }
.admin-fieldset .admin-form-grid { margin-block-end: 0; }
.admin-fieldset .admin-brand-modes { margin-block-start: 1rem; }
