/* Management panel: builds on the components in app.css */

.admin-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(to right, var(--surface) 247px, var(--line) 247px 248px, transparent 248px);
}

.admin-side {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    align-self: start;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 14px;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 4px;
}

.admin-side .brand {
    padding: 0 4px;
    min-width: 0;
}

.side-back {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    color: var(--text-2);
    text-decoration: none !important;
}

.side-back:hover {
    background: var(--inset);
    color: var(--text);
}

/* Quick search in sidebar */
.side-search {
    position: relative;
    width: 100%;
}

.side-search-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.side-search-wrap svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

.side-search-input {
    width: 100%;
    min-height: 38px;
    height: 38px;
    padding: 7px 32px 7px 32px;
    font-size: .86rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}

.side-search-input::placeholder {
    color: var(--text-3);
    opacity: 1;
}

.side-search-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent);
}

.side-search-kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-family: inherit;
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-3);
    background: var(--inset);
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    padding: 1px 6px;
    pointer-events: none;
    line-height: 1.3;
}

.side-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--text-3);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: .84rem;
    padding: 0;
    transition: background .12s, color .12s;
}

.side-search-clear:hover {
    background: var(--inset);
    color: var(--text);
}

.side-search-mobile-btn,
.side-search-close-mobile {
    display: none !important;
}

/* Quick search dropdown */
.side-search-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 340px;
    max-width: calc(100vw - 28px);
    max-height: 440px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
    z-index: 100;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.side-search-group-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    padding: 8px 10px 4px;
}

.side-search-group-title:not(:first-child) {
    margin-top: 6px;
    border-top: 1px solid var(--line-soft);
}

.side-search-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    text-align: left;
    border: 0;
    background: transparent;
    color: inherit;
    width: 100%;
    font-family: inherit;
    transition: background .12s;
}

.side-search-item:hover,
.side-search-item.active {
    background: var(--blue-soft);
    outline: none;
}

.side-search-item .quick-icon-wrap {
    width: 28px;
    height: 28px;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    color: var(--text-2);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.side-search-item.active .quick-icon-wrap,
.side-search-item:hover .quick-icon-wrap {
    background: var(--blue);
    color: #fff;
}

.side-search-item .quick-main {
    display: grid;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.side-search-item .quick-head {
    display: flex;
    align-items: center;
    gap: 6px;
}

.side-search-item .quick-code {
    font-weight: 700;
    font-size: .88rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-search-item .quick-title {
    font-size: .84rem;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-search-item .quick-desc {
    font-size: .76rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.35;
}

.side-search-item.active .quick-title,
.side-search-item:hover .quick-title {
    color: var(--text);
}

.side-search-item.active .quick-desc,
.side-search-item:hover .quick-desc {
    color: var(--text-2);
}

.side-search-item .quick-badge {
    font-size: .68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: var(--r-pill);
    letter-spacing: .02em;
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.side-search-item .quick-badge.act,
.side-search-item .quick-badge.crea {
    background: var(--blue-soft);
    color: var(--blue-strong);
}

.side-search-item .quick-badge.filtro,
.side-search-item .quick-badge.novita,
.side-search-item .quick-badge.da-coprire {
    background: var(--amber-soft);
    color: #8A6508;
}

.side-search-item .quick-badge.sezione,
.side-search-item .quick-badge.home,
.side-search-item .quick-badge.account {
    background: var(--surface-2);
    color: var(--text-2);
}

.side-search-item .quick-badge.q {
    background: var(--inset);
    color: var(--text-2);
}

.side-search-empty {
    padding: 20px 14px;
    text-align: center;
    color: var(--text-3);
    font-size: .86rem;
    line-height: 1.4;
}

.side-search-hint {
    padding: 8px 10px 4px;
    border-top: 1px solid var(--line-soft);
    font-size: .72rem;
    color: var(--text-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.side-search-hint kbd {
    font-family: inherit;
    font-size: .68rem;
    font-weight: 700;
    background: var(--inset);
    border: 1px solid var(--line);
    border-radius: var(--r-xs);
    padding: 1px 4px;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    font-weight: 600;
    font-size: .92rem;
    text-align: left;
}

.admin-nav-item svg {
    color: var(--text-3);
}

.admin-nav-item:hover {
    background: var(--inset);
    color: var(--text);
}

.admin-nav-item.active {
    background: var(--blue-soft);
    color: var(--blue-strong);
}

.admin-nav-item.active svg {
    color: var(--blue);
}

.lbl-short {
    display: none;
}

.tab-count {
    margin-left: auto;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--r-pill);
    display: inline-grid;
    place-items: center;
    font-size: .72rem;
    font-weight: 700;
    background: var(--amber);
    color: #3A2A05;
}

.admin-side-foot {
    margin-top: auto;
    display: grid;
    gap: 14px;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-radius: var(--r-sm);
    color: var(--text);
    text-decoration: none !important;
}

.admin-user:hover {
    background: var(--inset);
}

.admin-user-text {
    display: grid;
    gap: 4px;
    justify-items: start;
    min-width: 0;
}

.admin-user-name {
    font-weight: 600;
    font-size: .9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

.side-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: var(--ink);
    color: var(--bg);
    font-weight: 700;
    font-size: .78rem;
}

.admin-main {
    min-width: 0;
    padding: 32px 36px 0;
    max-width: 1100px;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.admin-main .site-footer {
    margin-top: auto;
}

.admin-main .site-footer {
    padding-left: 0;
    padding-right: 0;
}

.admin-main .admin-section:not([hidden]) {
    margin-bottom: 40px;
}

.head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.page-head-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

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

.admin-toolbar .search-wrap {
    min-width: 240px;
}

.admin-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.admin-select {
    min-height: 40px;
    padding: 0 34px 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237A879E' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") right 10px center/14px no-repeat;
    -webkit-appearance: none;
    appearance: none;
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
}

.admin-select:focus {
    outline: none;
    border-color: var(--blue);
}

.admin-select {
    max-width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
}

.admin-select:disabled {
    opacity: .55;
}

.admin-count {
    font-size: .82rem;
    color: var(--text-3);
    margin: 16px 0 8px;
}

/* Password reset: was the temporary password emailed? */
.pw-mail {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    font-size: .86rem;
    line-height: 1.45;
}

.pw-mail.ok {
    background: var(--green-soft);
    color: var(--green);
}

.pw-mail.warn {
    background: var(--amber-soft);
    color: var(--amber-strong);
}

/* Users who never received the "account activated" email */
.mail-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
    background: var(--blue-soft);
    font-size: .88rem;
}

.mail-banner[hidden] {
    display: none;
}

.mail-banner.warn {
    border-color: color-mix(in srgb, var(--amber) 60%, transparent);
    background: var(--amber-soft);
}

.mail-banner-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--surface);
    color: var(--blue);
}

.mail-banner.warn .mail-banner-icon {
    color: var(--amber-strong);
}

.mail-banner-text {
    flex: 1;
    min-width: 0;
    color: var(--text-2);
    line-height: 1.45;
}

.mail-banner-text strong {
    color: var(--text);
}

.mail-banner .btn {
    flex-shrink: 0;
}

@media (max-width: 560px) {
    .mail-banner {
        flex-wrap: wrap;
    }

    .mail-banner .btn {
        width: 100%;
    }
}

.admin-list {
    display: grid;
    gap: 8px;
}

.admin-empty {
    padding: 28px;
    text-align: center;
    color: var(--text-3);
    border: 1px dashed var(--line);
    border-radius: var(--r-md);
}

.admin-intro {
    color: var(--text-2);
    margin-bottom: 14px;
}

.admin-legend {
    margin: 14px 0 0;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    padding: 0 16px;
}

.admin-legend summary {
    cursor: pointer;
    padding: 12px 0;
    font-weight: 600;
    font-size: .9rem;
}

.admin-legend dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 10px 14px;
    margin: 4px 0 12px;
    align-items: center;
}

.admin-legend dd {
    margin: 0;
    font-size: .88rem;
    color: var(--text-2);
}

.admin-legend p {
    font-size: .85rem;
    color: var(--text-3);
    margin-bottom: 14px;
}

/* Card */
.a-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 14px 16px;
}

.a-card.clickable {
    cursor: pointer;
    transition: border-color .15s;
}

.a-card.clickable:focus-visible {
    border-color: var(--text-3);
}

@media (hover: hover) {
    .a-card.clickable:hover {
        border-color: var(--text-3);
    }
}

.a-card.clickable:active {
    background: var(--surface-2);
}

.a-card.inactive {
    opacity: .62;
}

.a-card.pending {
    border-color: color-mix(in srgb, var(--amber) 60%, transparent);
    background: var(--amber-soft);
}

.a-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.a-code {
    font-family: var(--font-score);
    font-weight: 700;
    font-size: 1.05rem;
}

.a-text {
    margin-top: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.a-meta {
    display: flex;
    gap: 6px 16px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: .8rem;
    color: var(--text-3);
}

.a-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.a-tag {
    font-size: .74rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--inset);
    color: var(--text-2);
}

.pill {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-pill);
    font-size: .74rem;
    font-weight: 600;
    background: var(--inset);
    color: var(--text-2);
}

.pill.green {
    background: var(--green-soft);
}

.pill.red {
    background: var(--red-soft);
}

.pill.gold {
    background: var(--amber-soft);
}

.pill.blue {
    background: var(--blue-soft);
    color: var(--blue);
}

/* Users */
.u-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
}

.u-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--inset);
    color: var(--text-2);
    font-weight: 700;
    font-size: .85rem;
}

.u-card.is-master .u-avatar {
    background: var(--amber-soft);
    color: var(--amber-strong);
}

.u-name {
    font-weight: 700;
}

.u-email {
    font-size: .86rem;
    color: var(--text-2);
    word-break: break-all;
}

.u-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.u-locked {
    font-size: .8rem;
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.u-more {
    position: relative;
}

.u-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    min-width: 230px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-3);
}

.u-menu button {
    display: flex;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    background: transparent;
    text-align: left;
    border-radius: var(--r-xs);
    font-size: .88rem;
    color: var(--text);
}

.u-menu button:hover {
    background: var(--inset);
}

.u-menu button.danger {
    color: var(--red);
}

.u-menu button.danger:hover {
    background: var(--red-soft);
}

.u-menu hr {
    border: 0;
    border-top: 1px solid var(--line-soft);
    margin: 4px;
}

/* Overview */
.dash-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
    gap: 10px;
}

/* Phones: two tiles per row, an odd last tile takes the whole row */
@media (max-width: 560px) {
    .dash-tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-tiles > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

.dash-tile {
    display: block;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px 18px;
    color: var(--text);
    width: 100%;
}

button.dash-tile:hover {
    border-color: var(--text-3);
}

.dash-tile.attention {
    border-color: color-mix(in srgb, var(--amber) 70%, transparent);
    background: var(--amber-soft);
}

.dash-tile-value {
    font-family: var(--font-score);
    font-weight: 600;
    font-size: 2.3rem;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.dash-tile-label {
    font-size: .84rem;
    color: var(--text-2);
}

.dash-tile-sub {
    font-size: .76rem;
    color: var(--text-3);
    margin-top: 2px;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 14px;
    margin-top: 16px;
}

.dash-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px 18px;
}

.dash-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.dash-panel h2 {
    font-size: .98rem;
    font-weight: 700;
}

.dash-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px solid var(--line-soft);
    font-size: .9rem;
}

.dash-row:first-child {
    border-top: 0;
}

.dash-row-main {
    flex: 1;
    min-width: 0;
}

.dash-row-main small {
    display: block;
    color: var(--text-3);
    font-size: .78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-empty {
    color: var(--text-3);
    font-size: .88rem;
    padding: 6px 0;
}

.dash-bar {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) 44px;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    font-size: .86rem;
}

.dash-bar-track {
    height: 8px;
    border-radius: 4px;
    background: var(--inset);
    overflow: hidden;
}

.dash-bar-track span {
    display: block;
    height: 100%;
    background: var(--src);
    border-radius: 4px;
}

.dash-bar-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
}

.dash-tile.static {
    cursor: default;
}

.dash-panel-note {
    font-size: .76rem;
    color: var(--text-3);
}

.dash-foot {
    font-size: .76rem;
    color: var(--text-3);
    margin-top: 8px;
}

.dash-sub {
    font-size: .76rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 14px 0 6px;
}

/* Clickable rows (hardest references, content checks) */
.dash-row-btn {
    width: 100%;
    text-align: left;
    background: none;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    color: var(--text);
    cursor: pointer;
    border-radius: 0;
}

.dash-row-btn:first-child {
    border-top: 0;
}

.dash-row-btn:hover:not(:disabled) .dash-row-main {
    color: var(--blue-strong);
}

.dash-row-btn:disabled {
    cursor: default;
    color: var(--text-2);
}

.dash-row-btn:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Study activity */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

@media (max-width: 520px) {
    .dash-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.dash-stat {
    background: var(--inset);
    border-radius: var(--r-sm, 10px);
    padding: 10px 12px;
    min-width: 0;
}

.dash-stat-value {
    font-family: var(--font-score);
    font-weight: 600;
    font-size: 1.6rem;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.dash-stat-label {
    font-size: .8rem;
    color: var(--text-2);
}

.dash-stat-sub {
    font-size: .72rem;
    color: var(--text-3);
    margin-top: 2px;
    overflow-wrap: anywhere;
}

/* Share of correct answers / counts on the right of a row */
.dash-pct, .dash-count {
    flex-shrink: 0;
    min-width: 44px;
    text-align: center;
    padding: 3px 8px;
    border-radius: var(--r-pill);
    font-size: .8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.dash-pct.low, .dash-count.warn {
    color: var(--red);
    background: var(--red-soft);
}

.dash-pct.mid, .dash-count.info {
    color: var(--amber-strong);
    background: var(--amber-soft);
}

.dash-pct.ok, .dash-count.ok {
    color: var(--green);
    background: var(--green-soft);
}

/* Small counters */
.dash-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.dash-chip {
    display: inline-flex;
    gap: 4px;
    align-items: baseline;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    background: var(--inset);
    font-size: .8rem;
    color: var(--text-2);
}

.dash-chip strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.dash-chip.warn {
    background: var(--amber-soft);
    color: var(--amber-strong);
}

/* Questions by difficulty */
.dash-stack {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    gap: 2px;
    background: var(--inset);
}

.dash-stack span {
    min-width: 3px;
}

.dash-stack .diff-e, .dash-legend i.diff-e {
    background: var(--green);
}

.dash-stack .diff-m, .dash-legend i.diff-m {
    background: var(--blue);
}

.dash-stack .diff-d, .dash-legend i.diff-d {
    background: var(--amber);
}

.dash-stack .diff-dd, .dash-legend i.diff-dd {
    background: var(--red);
}

.dash-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 8px;
    font-size: .78rem;
    color: var(--text-2);
}

.dash-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dash-legend i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.d-icon.sm {
    width: 28px;
    height: 34px;
    font-size: .5rem;
    padding-bottom: 4px;
    flex-shrink: 0;
}

/* Reports */
.f-item {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
}

.f-item-head {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: .82rem;
    color: var(--text-3);
    align-items: center;
}

.f-item-head strong {
    color: var(--text);
}

.f-note {
    margin-top: 4px;
    font-size: .9rem;
    white-space: pre-line;
}

/* Editor */
.editor-box {
    max-width: 760px;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 8px;
}

.editor-head .modal-title {
    margin: 0;
}

.editor-body {
    padding: 8px 22px;
    overflow: auto;
    flex: 1;
}

.editor-foot {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 14px 22px;
    border-top: 1px solid var(--line-soft);
    background: var(--surface-2);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.editor-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: start;
}

#r-editor .editor-row {
    grid-template-columns: 1fr 1fr;
}

.ans-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto 34px;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.ans-letter {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--inset);
    font-family: var(--font-score);
    font-weight: 700;
    color: var(--text-2);
}

.ans-row.correct .ans-letter {
    background: var(--green);
    color: #fff;
}

.ans-row.correct .form-input {
    border-color: color-mix(in srgb, var(--green) 60%, transparent);
}

.ans-correct {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .84rem;
    color: var(--text-2);
    white-space: nowrap;
    cursor: pointer;
}

.yn-choice {
    display: flex;
    gap: 10px;
}

.yn-choice label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-weight: 600;
}

.yn-choice label:has(input:checked) {
    border-color: var(--green);
    background: var(--green-soft);
}

.ref-picker {
    position: relative;
    display: grid;
    gap: 8px;
}

.ref-picked {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ref-picked:empty {
    display: none;
}

.ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 4px 4px 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: .84rem;
}

.ref-chip-title {
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

.ref-chip button {
    border: 0;
    background: transparent;
    color: var(--text-3);
    width: 24px;
    height: 24px;
    border-radius: 5px;
}

.ref-chip button:hover {
    background: var(--red-soft);
    color: var(--red);
}

.ref-suggest {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 10;
    max-height: 300px;
    overflow: auto;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-3);
}

.ref-suggest-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--r-xs);
    cursor: pointer;
    font-size: .88rem;
}

.ref-suggest-item .t {
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ref-suggest-item.active, .ref-suggest-item:hover {
    background: var(--blue-soft);
}

.ref-suggest-empty {
    padding: 10px;
    color: var(--text-3);
    font-size: .88rem;
}

.editor-flags {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    background: var(--amber-soft);
}

.editor-usage {
    margin-top: 4px;
    font-size: .88rem;
    color: var(--text-2);
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: var(--r-sm);
}

.editor-usage a {
    cursor: pointer;
    font-weight: 600;
}

.pw-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    background: var(--inset);
}

.pw-box code {
    flex: 1;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: .06em;
    word-break: break-all;
}

@media (max-width: 860px) {
    .admin-shell {
        grid-template-columns: minmax(0, 1fr);
        background: none;
    }

    .admin-side {
        position: sticky;
        top: 0;
        z-index: 30;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 8px 12px;
        padding-top: calc(8px + env(safe-area-inset-top, 0));
        border-right: 0;
        border-bottom: 1px solid var(--line);
        /* Solid background: a backdrop-filter here would trap the fixed bottom navigation inside this bar */
        background: var(--surface);
    }

    .admin-side .brand-text {
        display: flex;
    }

    .side-brand {
        flex: 1;
        min-width: 0;
    }

    .side-search-mobile-btn {
        display: grid !important;
        place-items: center;
        width: 36px;
        height: 36px;
        border-radius: var(--r-sm);
        margin-left: auto;
        color: var(--text-2);
        flex-shrink: 0;
    }

    .side-search-mobile-btn:hover {
        background: var(--inset);
        color: var(--text);
    }

    .side-search {
        display: none;
    }

    .admin-side.search-open .side-brand {
        display: none;
    }

    .admin-side.search-open .side-search {
        display: block;
        flex: 1;
        min-width: 0;
    }

    .admin-side.search-open .side-search-wrap {
        gap: 6px;
    }

    .admin-side.search-open .side-search-input {
        height: 40px;
        font-size: 16px;
        padding-right: 36px;
    }

    .admin-side.search-open .side-search-kbd {
        display: none;
    }

    .admin-side.search-open .side-search-close-mobile {
        display: grid !important;
        place-items: center;
        width: 40px;
        height: 40px;
        border-radius: var(--r-sm);
        border: 0;
        background: var(--inset);
        color: var(--text);
        flex-shrink: 0;
        cursor: pointer;
    }

    .admin-side.search-open .side-search-menu {
        position: fixed;
        top: calc(56px + env(safe-area-inset-top, 0));
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        max-height: calc(100vh - 72px - env(safe-area-inset-bottom, 0));
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
    }

    /* Sections become a bottom navigation bar, like the quiz portal */
    .admin-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        gap: 0;
        height: calc(64px + env(safe-area-inset-bottom, 0));
        padding-bottom: env(safe-area-inset-bottom, 0);
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--line);
        overflow: visible;
    }

    .admin-nav-item {
        position: relative;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        width: auto;
        min-width: 0;
        min-height: 0;
        padding: 4px 2px;
        border-radius: 0;
        font-size: .66rem;
        text-align: center;
        background: transparent !important;
        color: var(--text-3);
    }

    .admin-nav-item svg {
        display: block;
        width: 22px;
        height: 22px;
        color: inherit;
    }

    .admin-nav-item .lbl {
        display: none;
    }

    .admin-nav-item .lbl-short {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .admin-nav-item.active {
        color: var(--text);
    }

    .admin-nav-item.active svg {
        color: var(--blue);
    }

    .admin-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        width: 28px;
        margin-left: -14px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--amber);
    }

    .admin-nav-item .tab-count {
        position: absolute;
        top: 4px;
        left: 50%;
        margin-left: 6px;
        min-width: 18px;
        height: 16px;
        font-size: .62rem;
        padding: 0 4px;
    }

    .admin-side-foot {
        display: none;
    }

    .admin-main {
        padding: 20px 16px 0;
        min-height: calc(100dvh - 60px);
    }

    .admin-main .site-footer {
        padding-bottom: calc(64px + 24px + env(safe-area-inset-bottom, 0));
    }

    .admin-toolbar .search-wrap {
        min-width: 0;
        flex: 1 1 100%;
    }

    .admin-toolbar .admin-select {
        flex: 1;
    }

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

    .u-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .u-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .d-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .d-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .d-order {
        flex-direction: row;
    }

    .d-order .icon-btn {
        height: 40px;
    }

    .editor-row, #r-editor .editor-row, #r-editor .change-fieldset .editor-row {
        grid-template-columns: 1fr;
    }

    .ans-row {
        grid-template-columns: 28px minmax(0, 1fr) 34px;
    }

    .ans-correct {
        grid-column: 2;
        grid-row: 2;
    }

    .admin-legend dl {
        grid-template-columns: 1fr;
    }

    .dash-bar {
        grid-template-columns: 110px minmax(0, 1fr) 40px;
    }

    #us-modal {
        place-items: stretch;
        padding: 0;
    }

    #us-modal .us-box {
        max-width: none;
    }

    .us-src {
        grid-template-columns: minmax(0, 1fr) 90px;
    }

    .us-src-bar {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .us-facts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .us-tile-value {
        font-size: 1.5rem;
    }
}


.change-fieldset {
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 12px 14px 0;
    margin: 4px 0 16px;
    min-width: 0;
}

.change-fieldset legend {
    font-weight: 700;
    font-size: .9rem;
    padding: 0 6px;
}

.change-fieldset > .form-hint {
    margin: 0 0 12px;
}

#r-editor .change-fieldset .editor-row {
    grid-template-columns: 1fr 1fr;
}

.a-card-top .change-badge {
    margin-left: 2px;
}

/* User overview (read-only) */
#us-modal .us-box {
    max-width: 640px;
}

.us-readonly {
    font-size: .82rem;
    color: var(--text-3);
    margin: 0 0 10px;
}

.us-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    font-size: .84rem;
    color: var(--text-2);
    margin-bottom: 16px;
}

.us-tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.us-tile {
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    padding: 12px 14px;
}

.us-tile-value {
    font-family: var(--font-score);
    font-weight: 600;
    font-size: 1.9rem;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.us-tile-value small {
    font-size: .5em;
    color: var(--text-3);
    margin-left: .55em;
    padding-left: .55em;
    border-left: 2px solid var(--line);
    vertical-align: .18em;
}

.us-tile-label {
    font-size: .8rem;
    color: var(--text-3);
}

.us-h {
    font-size: .92rem;
    font-weight: 700;
    margin: 20px 0 8px;
}

.us-sources {
    display: grid;
    gap: 6px;
}

.us-src {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr) 96px;
    gap: 10px;
    align-items: center;
    font-size: .86rem;
}

.us-src-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    min-width: 0;
}

.us-src-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--red-soft);
    overflow: hidden;
}

.us-src-bar span {
    display: block;
    height: 100%;
    background: var(--green);
}

.us-src-bar.empty {
    background: var(--inset);
}

.us-src-num {
    text-align: right;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

.us-src-num strong {
    color: var(--text);
}

.us-weak {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
}

.us-weak li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    padding: 7px 10px;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    font-size: .88rem;
}

.us-weak-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-2);
}

.us-weak-num {
    flex-shrink: 0;
    color: var(--red);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.us-weak .us-none {
    color: var(--text-3);
}

.us-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.us-facts div {
    padding: 8px 10px;
    border-radius: var(--r-xs);
    background: var(--surface-2);
}

.us-facts dt {
    font-size: .76rem;
    color: var(--text-3);
}

.us-facts dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Documents */
.d-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
}

.d-icon {
    width: 40px;
    height: 48px;
    border-radius: 5px 12px 5px 5px;
    display: grid;
    place-items: end center;
    padding-bottom: 6px;
    background: var(--inset);
    color: var(--text-2);
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .04em;
}

.d-title {
    font-weight: 700;
}

.d-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.d-order {
    display: flex;
    flex-direction: column;
}

.d-order .icon-btn {
    height: 26px;
}

#d-editor .editor-box {
    max-width: 560px;
}

.dropzone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 6px;
    text-align: center;
    cursor: pointer;
    padding: 22px 16px;
    border: 2px dashed var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text-2);
    transition: border-color .15s, background .15s;
}

.dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone:hover, .dropzone.drag {
    border-color: var(--blue);
    background: var(--blue-soft);
}

.dropzone.has-file {
    border-style: solid;
    border-color: var(--green);
    background: var(--green-soft);
    color: var(--text);
}

.dropzone:focus-within {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.dropzone-text {
    font-weight: 600;
    font-size: .9rem;
    word-break: break-all;
}

.d-current {
    font-size: .85rem;
    color: var(--text-2);
    margin-top: 6px;
}

.upload-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--inset);
    overflow: hidden;
    margin-top: 4px;
}

.upload-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--blue);
    transition: width .15s;
}

/* ---------- Touch and mobile devices ---------- */
.editor-row > * {
    min-width: 0;
}

@media (pointer: coarse) {
    .side-back {
        width: 44px;
        height: 44px;
    }

    .admin-nav-item {
        min-height: 44px;
    }

    .admin-select, .admin-toolbar .search-input {
        font-size: 16px;
        min-height: 44px;
    }

    .admin-nav-item {
        min-height: 44px;
    }

    .ref-chip button {
        width: 36px;
        height: 36px;
    }

    .u-menu button {
        padding: 13px 12px;
    }

    .ref-suggest-item {
        padding: 12px 10px;
    }
}

@media (max-width: 860px) {
    /* Full-screen editors */
    #q-editor, #r-editor, #d-editor {
        place-items: stretch;
        padding: 0;
    }

    #d-editor .editor-box {
        max-width: none;
    }

    .editor-box {
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: 0;
        padding: 0;
        animation: sheet .22s ease-out;
    }

    .editor-head {
        padding: calc(12px + env(safe-area-inset-top, 0)) 16px 8px;
        border-bottom: 1px solid var(--line-soft);
    }

    .editor-body {
        padding: 14px 16px;
    }

    .editor-foot {
        flex-wrap: wrap;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
        border-radius: 0;
    }

    .editor-foot .spacer {
        display: none;
    }

    .editor-foot .btn {
        flex: 1 1 0;
    }

    .editor-foot .btn-primary {
        flex-basis: 100%;
        order: -1;
    }

    .u-menu {
        position: fixed;
        left: 8px;
        right: 8px;
        top: auto;
        bottom: calc(8px + env(safe-area-inset-bottom, 0));
        min-width: 0;
        border-radius: var(--r-lg);
        box-shadow: var(--shadow-3);
        animation: sheet .22s ease-out;
        z-index: 80;
    }

    .u-more.open::before {
        content: '';
        position: fixed;
        inset: 0;
        z-index: 79;
        background: rgba(8, 15, 30, .45);
    }

    .dash-row {
        flex-wrap: wrap;
    }

    .head-actions {
        width: 100%;
    }

    .head-actions .btn {
        flex: 1;
    }
}

/* Simulation reports: details of the reported action */
.sim-detail {
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: .82rem;
    background: var(--surface-2);
}

.sd-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px;
    padding: 3px 0;
    border-top: 1px solid var(--line-soft);
}

.sd-row:first-child {
    border-top: 0;
}

.sd-row span:first-child {
    color: var(--text-3);
}

.f-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
    flex-wrap: wrap;
}

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