/* ============================================================
   Admin shell — built on style_new.css custom properties.
   No Bootstrap dependency.
   ============================================================ */

:root {
    --admin-sidebar-w: 260px;
    --admin-topbar-h: 64px;
    --admin-radius: 12px;
    --admin-radius-lg: 16px;
    --admin-shadow:    0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --admin-shadow-lg: 0 6px 18px rgba(15, 23, 42, .08), 0 18px 40px rgba(15, 23, 42, .10);
}

body.admin-body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: visby, Visby-light, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); }
a:hover { color: var(--navy-deep); }

/* ---------- Topbar -------------------------------------- */

.admin-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--admin-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 50;
}
.admin-topbar .logo {
    height: 38px;
    width: auto;
    display: block;
}
.admin-topbar-burger {
    background: transparent;
    border: 0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    display: none;          /* hidden by default; mobile media query shows it */
    align-items: center;
    justify-content: center;
    transition: background .15s;
    order: 99;              /* push to the right end of the topbar flex row */
}
.admin-topbar-burger:hover { background: var(--bg); }

.admin-topbar-spacer { flex: 1; }

.admin-topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-topbar-user .user-menu {
    position: relative;
}
.admin-topbar-user .user-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navy), var(--navy-deep));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .02em;
    border: 0;
    padding: 0;
    cursor: pointer;
}
.admin-topbar-user .user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: 6px;
    display: none;
    z-index: 1100;
}
.admin-topbar-user .user-menu.is-open .user-menu-dropdown {
    display: block;
}
.admin-topbar-user .user-menu-name {
    display: block;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
    border-bottom: 1px solid var(--border, #e2e8f0);
    margin-bottom: 4px;
}
.admin-topbar-user .user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
}
.admin-topbar-user .user-menu-item:hover {
    background: var(--navy-soft, #f1f5f9);
}

/* ---------- Sidebar ------------------------------------- */

.admin-sidebar {
    position: fixed;
    top: var(--admin-topbar-h);
    bottom: 0;
    left: 0;
    width: var(--admin-sidebar-w);
    background: var(--navy-deep);
    color: #fff;
    overflow-y: auto;
    z-index: 40;
    padding: 8px 0 0;
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
}
.admin-sidebar::-webkit-scrollbar { width: 6px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

.admin-sidebar-label {
    color: rgba(255, 255, 255, .42);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
    padding: 8px 20px 2px;
}

.admin-sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}
.admin-sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 20px 6px 17px;
    color: rgba(255, 255, 255, .78);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    line-height: 1.3;
}
.admin-sidebar-nav li a i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: rgba(255, 255, 255, .55);
    transition: color .15s;
}
.admin-sidebar-nav li a:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    text-decoration: none;
}
.admin-sidebar-nav li a:hover i { color: var(--green); }
.admin-sidebar-nav li a.active {
    background: rgba(255, 255, 255, .08);
    color: #fff;
    border-left-color: var(--green);
}
.admin-sidebar-nav li a.active i { color: var(--green); }

.admin-sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, .08);
    margin: 6px 20px 0;
}

.admin-sidebar-footer {
    margin-top: auto;
    padding: 10px 20px 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.admin-sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, .65);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
}
.admin-sidebar-footer a:hover { color: var(--green); }

/* Tighten further when the sidebar would otherwise overflow on shorter viewports */
@media (max-height: 800px) and (min-width: 901px) {
    .admin-sidebar-nav li a { padding: 4px 20px 4px 17px; font-size: 13px; }
    .admin-sidebar-nav li a i { font-size: 15px; }
    .admin-sidebar-label { padding: 6px 20px 1px; font-size: 10px; }
    .admin-sidebar-divider { margin: 4px 20px 0; }
    .admin-sidebar-footer { padding: 8px 20px 10px; }
}

/* ---------- Grouped flyout nav -------------------------- */

/* The rail is short now (Dashboard + group buttons), so it never needs to
   scroll — let the flyout panels escape the sidebar box instead of being clipped. */
.admin-sidebar { overflow: visible; }
.admin-sidebar-top { margin-bottom: 4px; }

.admin-nav-group { position: relative; }

/* Hide a whole group if the user can't access any item inside it */
.admin-nav-group:not(:has(.admin-sidebar-nav li)) { display: none; }

.admin-nav-group-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: 0;
    border-left: 3px solid transparent;
    padding: 7px 16px 7px 17px;
    color: rgba(255, 255, 255, .78);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.admin-nav-group-btn:hover { text-decoration: none; }
.admin-nav-group-btn > .bi:first-child {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: rgba(255, 255, 255, .55);
    transition: color .15s;
}
.admin-nav-group-name { flex: 1; }
.admin-nav-caret {
    font-size: 12px;
    color: rgba(255, 255, 255, .4);
    transition: transform .18s ease;
}
.admin-nav-group-btn:hover,
.admin-nav-group:focus-within > .admin-nav-group-btn,
.admin-nav-group.is-open > .admin-nav-group-btn {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}
.admin-nav-group-btn:hover > .bi:first-child { color: var(--green); }

/* Highlight the group that holds the current page */
.admin-nav-group:has(a.active) > .admin-nav-group-btn {
    color: #fff;
    border-left-color: var(--green);
}
.admin-nav-group:has(a.active) > .admin-nav-group-btn > .bi:first-child { color: var(--green); }

/* Flyout panel */
.admin-nav-flyout {
    position: absolute;
    left: 100%;
    top: -6px;
    min-width: 210px;
    margin-left: 8px;
    background: #103e63;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(8, 30, 53, .45);
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
    z-index: 60;
}
/* Invisible bridge so the cursor can cross the gap without the flyout closing */
.admin-nav-flyout::before {
    content: "";
    position: absolute;
    top: 0;
    left: -14px;
    width: 14px;
    height: 100%;
}
/* Arrow pointing back at the hovered group button in the rail */
.admin-nav-flyout::after {
    content: "";
    position: absolute;
    top: 13px;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #103e63;
}
.admin-nav-group:hover > .admin-nav-flyout,
.admin-nav-group:focus-within > .admin-nav-flyout,
.admin-nav-group.is-open > .admin-nav-flyout {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}
.admin-nav-group:hover > .admin-nav-group-btn .admin-nav-caret,
.admin-nav-group.is-open > .admin-nav-group-btn .admin-nav-caret { transform: rotate(90deg); }

.admin-nav-flyout-title {
    color: rgba(255, 255, 255, .42);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .1em;
    font-weight: 700;
    padding: 2px 18px 6px;
}

/* Mobile sidebar overlay */
.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: var(--admin-topbar-h) 0 0 0;
    background: rgba(10, 48, 80, .45);
    z-index: 30;
}

/* ---------- Main content -------------------------------- */

.admin-main {
    margin-left: var(--admin-sidebar-w);
    margin-top: var(--admin-topbar-h);
    padding: 32px;
    min-height: calc(100vh - var(--admin-topbar-h));
    transition: margin-left .25s ease;
}

.admin-shell.collapsed .admin-sidebar {
    transform: translateX(-100%);
}
.admin-shell.collapsed .admin-main {
    margin-left: 0;
}

/* ---------- Breadcrumb ---------------------------------- */

.admin-breadcrumb {
    list-style: none;
    padding: 0;
    margin: 0 0 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}
.admin-breadcrumb li + li::before {
    content: '/';
    margin-right: 6px;
    color: var(--line);
}
.admin-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}
.admin-breadcrumb a:hover { color: var(--navy); }
.admin-breadcrumb li:last-child { color: var(--text); font-weight: 600; }

/* ---------- Page title ---------------------------------- */

.admin-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}
.admin-page-title {
    font-size: 28px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--navy-deep);
    margin: 0;
}
.admin-page-subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Cards --------------------------------------- */

.admin-card {
    background: #fff;
    border-radius: var(--admin-radius-lg);
    box-shadow: var(--admin-shadow);
    padding: 24px;
}
.admin-card + .admin-card { margin-top: 24px; }

/* Inside a grid, cards live in their own cells — the stacked-margin rule
   above made the first card 24px taller than its row neighbours. */
.admin-grid > .admin-card { margin-top: 0; }

.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.admin-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy-deep);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.admin-card-title i { color: var(--navy); font-size: 18px; }

/* ---------- Grid utilities ------------------------------ */

/* The [hidden] attribute must win over explicit display rules (e.g. .admin-grid). */
[hidden] { display: none !important; }

.admin-grid { display: grid; gap: 24px; }
.admin-grid-tight { gap: 16px; }
.admin-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.admin-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.admin-grid-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.admin-grid-2-1 { grid-template-columns: 2fr 1fr; }
.admin-grid-1-2 { grid-template-columns: 1fr 2fr; }

@media (max-width: 1200px) {
    .admin-grid-6, .admin-grid-7 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .admin-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .admin-grid-3, .admin-grid-2-1, .admin-grid-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .admin-grid-2, .admin-grid-4, .admin-grid-6, .admin-grid-7 { grid-template-columns: 1fr; }
}

/* ---------- Quick action tile --------------------------- */

.admin-quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--admin-radius);
    padding: 24px 16px;
    text-decoration: none;
    color: var(--text);
    text-align: center;
    transition: transform .18s, box-shadow .18s, border-color .18s;
}
.admin-quick-action i {
    font-size: 26px;
    color: var(--navy);
    background: linear-gradient(135deg, rgba(0, 86, 149, .10), rgba(116, 188, 74, .14));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s, color .18s;
}
.admin-quick-action span {
    font-size: 14px;
    font-weight: 600;
    color: var(--navy-deep);
}
.admin-quick-action:hover {
    transform: translateY(-3px);
    box-shadow: var(--admin-shadow-lg);
    border-color: transparent;
    color: var(--text);
    text-decoration: none;
}
.admin-quick-action:hover i {
    background: var(--navy);
    color: var(--green);
}

/* ---------- Stat tiles ---------------------------------- */

.admin-stat {
    position: relative;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--admin-radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 92px;
    justify-content: center;
}
/* Notification badge (e.g. pending users awaiting approval). */
.admin-stat-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #d9534f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 9px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(217, 83, 79, .4);
}
.admin-stat .stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    font-weight: 700;
}
.admin-stat .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--navy-deep);
    line-height: 1.05;
}
.admin-stat.is-accent {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 60%, var(--teal) 130%);
    border-color: transparent;
    color: #fff;
}
.admin-stat.is-accent .stat-label { color: rgba(255, 255, 255, .72); }
.admin-stat.is-accent .stat-value { color: #fff; }
.admin-stat.is-success .stat-value { color: var(--green-dark); }

/* ---------- Buttons ------------------------------------- */

.admin-btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 0;
    background: var(--navy-deep);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.2;
    transition: background .15s, color .15s, transform .1s;
    font-family: inherit;
}
.admin-btn:hover {
    background: var(--navy);
    color: #fff;
    text-decoration: none;
}
.admin-btn:active { transform: translateY(1px); }

.admin-btn-outline {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
}
.admin-btn-outline:hover {
    background: var(--bg);
    color: var(--navy-deep);
    border-color: var(--text-muted);
}

.admin-btn-success { background: var(--green-dark); }
.admin-btn-success:hover { background: var(--green); color: #fff; }

.admin-btn-sm { padding: 6px 12px; font-size: 13px; width: 100%; max-width: 180px; }
.admin-btn-lg { padding: 12px 22px; font-size: 15px; }
.admin-btn i { font-size: 16px; }

/* Live-search hit highlight */
mark.admin-mark {
    background: rgba(116, 188, 74, .25);
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
}

/* ---------- Toggle switch ------------------------------- */

.admin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.admin-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.admin-toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: #c4cad3;
    border-radius: 999px;
    transition: background .15s ease;
    flex: 0 0 auto;
}
.admin-toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
    transition: transform .15s ease;
}
.admin-toggle input:checked + .admin-toggle-slider { background: var(--green); }
.admin-toggle input:checked + .admin-toggle-slider::before { transform: translateX(16px); }
.admin-toggle input:focus-visible + .admin-toggle-slider { box-shadow: 0 0 0 3px rgba(10,48,80,.15); }
.admin-toggle-label { font-size: 12px; color: var(--text-muted); }

/* ---------- Responsive ---------------------------------- */

@media (max-width: 900px) {
    .admin-main {
        margin-left: 0;
        padding: 24px 16px;
    }
    .admin-sidebar { transform: translateX(-100%); overflow-y: auto; }
    .admin-shell.open .admin-sidebar { transform: translateX(0); }
    .admin-shell.open .admin-sidebar-overlay { display: block; }
    .admin-topbar-burger { display: flex; }

    /* In the slide-in drawer there's no room to fly out sideways, so show each
       group's items inline (as a normal expanded list). */
    .admin-nav-flyout {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        min-width: 0;
        margin: 0;
        padding: 0 0 4px;
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .admin-nav-flyout::before { display: none; }
    .admin-nav-caret { display: none; }
}

/* ---------- Forms --------------------------------------- */

.admin-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.admin-form-group:last-child { margin-bottom: 0; }

.admin-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-deep);
    line-height: 1.3;
}
.admin-label .required { color: #d9534f; margin-left: 2px; }

.admin-form-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.admin-form-section-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--navy-deep);
    margin: 4px 0 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.admin-input,
.admin-textarea,
.admin-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}
.admin-textarea {
    min-height: 120px;
    resize: vertical;
}
.admin-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a6776' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 10px;
    padding-right: 36px;
}
.admin-input:focus,
.admin-textarea:focus,
.admin-select:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(0, 86, 149, .15);
}
.admin-input[disabled],
.admin-input[readonly],
.admin-textarea[disabled],
.admin-select[disabled] {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}
.admin-input.is-error,
.admin-textarea.is-error,
.admin-select.is-error {
    border-color: #d9534f;
}
.admin-input.is-error:focus,
.admin-textarea.is-error:focus,
.admin-select.is-error:focus {
    box-shadow: 0 0 0 3px rgba(217, 83, 79, .15);
}

.admin-form-help {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}
.admin-form-error {
    font-size: 12px;
    color: #d9534f;
    font-weight: 600;
    line-height: 1.4;
}

/* Inline checkbox / radio */
.admin-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.admin-check input[type="checkbox"],
.admin-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--navy);
    cursor: pointer;
    margin: 0;
}

/* Inline form row (two-column label/value) */
.admin-form-row {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}
.admin-form-row:last-child { border-bottom: none; }
.admin-form-row .admin-label { padding-top: 10px; }
@media (max-width: 700px) {
    .admin-form-row { grid-template-columns: 1fr; gap: 6px; }
    .admin-form-row .admin-label { padding-top: 0; }
}

/* Submit row */
.admin-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

/* ---------- Tables -------------------------------------- */

.admin-table-wrap {
    width: 100%;
    overflow-x: hidden;
    border: 1px solid var(--line);
    border-radius: var(--admin-radius);
    background: #fff;
}
.admin-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}
.admin-table thead tr {
    background: var(--bg);
}
.admin-table th {
    box-sizing: border-box;
    padding: 12px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
}
.admin-table td {
    box-sizing: border-box;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--text);
    overflow-wrap: anywhere;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(0, 86, 149, .03); }

.admin-table-striped tbody tr:nth-child(odd) { background: rgba(0, 0, 0, .015); }
.admin-table-striped tbody tr:nth-child(odd):hover { background: rgba(0, 86, 149, .04); }

.admin-table-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.admin-table-row-link {
    color: var(--navy-deep);
    font-weight: 600;
    text-decoration: none;
}
.admin-table-row-link:hover { color: var(--navy); text-decoration: underline; }

.admin-table-sort {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: none;
    user-select: none;
}
.admin-table-sort i {
    font-size: 12px;
    opacity: .45;
    transition: opacity .15s ease;
}
.admin-table-sort:hover { color: var(--navy); }
.admin-table-sort:hover i { opacity: .85; }
.admin-table-sort.is-active { color: var(--navy-deep); }
.admin-table-sort.is-active i { opacity: 1; }

/* ---------- Card view (list ⇄ cards toggle) ------------- */
/* Set .is-cards on .admin-table-wrap (server-side, from ?view=cards) to render
   the same table rows as a responsive grid of cards. JS copies each column's
   header text onto its cells (data-label) so the card shows field names. */
.admin-table-wrap.is-cards {
    overflow: visible;
    border: none;
    background: transparent;
}
.admin-table-wrap.is-cards .admin-table { display: block; }
.admin-table-wrap.is-cards .admin-table thead { display: none; }
.admin-table-wrap.is-cards .admin-table tbody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.admin-table-wrap.is-cards .admin-table tbody tr {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--admin-radius);
    background: #fff;
    padding: 16px;
}
.admin-table-wrap.is-cards .admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table-wrap.is-cards .admin-table tbody tr:hover { background: #fff; }
.admin-table-wrap.is-cards .admin-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0;
    border: none;
    text-align: right;
}
.admin-table-wrap.is-cards .admin-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    text-align: left;
    margin-right: auto;
    white-space: nowrap;
}
/* Cells whose column has no header text: drop the empty label box. */
.admin-table-wrap.is-cards .admin-table td[data-label=""]::before { content: none; }
.admin-table-wrap.is-cards .admin-table .admin-table-actions { justify-content: flex-end; }

/* ---------- Pagination ---------------------------------- */
/* Rows paged out by the client-side paginator (works in list and card view). */
.pg-hidden { display: none !important; }

.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.admin-pagination-info {
    font-size: 12.5px;
    color: var(--text-muted);
}
.admin-pagination-pages {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.admin-pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
}
.admin-pagination-btn:hover:not(:disabled):not(.is-active) { border-color: var(--navy); color: var(--navy); }
.admin-pagination-btn.is-active { background: var(--navy); border-color: var(--navy); color: #fff; cursor: default; }
.admin-pagination-btn:disabled { opacity: .45; cursor: default; }
.admin-pagination-ellipsis { padding: 0 4px; color: var(--text-muted); }

/* ---------- Badges -------------------------------------- */

.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--line);
}
.admin-badge-success { background: rgba(116, 188, 74, .14); color: var(--green-dark); border-color: rgba(116, 188, 74, .35); }
.admin-badge-info    { background: rgba(0, 86, 149, .10);   color: var(--navy);       border-color: rgba(0, 86, 149, .25); }
.admin-badge-warning { background: rgba(245, 158, 11, .14); color: #b45309;            border-color: rgba(245, 158, 11, .35); }
.admin-badge-danger  { background: rgba(217, 83, 79, .14);  color: #b91c1c;            border-color: rgba(217, 83, 79, .35); }
.admin-badge-dot::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* ---------- Alerts -------------------------------------- */

.admin-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--admin-radius);
    background: rgba(0, 86, 149, .08);
    border: 1px solid rgba(0, 86, 149, .2);
    color: var(--navy-deep);
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 16px;
}
.admin-alert i.admin-alert-icon {
    font-size: 18px;
    line-height: 1.2;
    flex-shrink: 0;
    margin-top: 1px;
}
.admin-alert-body { flex: 1; }
.admin-alert-title {
    font-weight: 700;
    margin: 0 0 2px;
    font-size: 14px;
}
.admin-alert-close {
    background: transparent;
    border: 0;
    font-size: 18px;
    line-height: 1;
    color: inherit;
    opacity: .6;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    transition: opacity .15s;
}
.admin-alert-close:hover { opacity: 1; }

.admin-alert-success { background: rgba(116, 188, 74, .12); border-color: rgba(116, 188, 74, .35); color: #3f6e21; }
.admin-alert-warning { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .35); color: #92400e; }
.admin-alert-danger  { background: rgba(217, 83, 79, .10);  border-color: rgba(217, 83, 79, .35); color: #991b1b; }

/* ---------- Modal --------------------------------------- */

.admin-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 48, 80, .55);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 100;
    padding: 32px 16px;
    overflow-y: auto;
    animation: admin-modal-fade .18s ease-out;
}
.admin-modal-backdrop.is-open { display: flex; }

@keyframes admin-modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes admin-modal-slide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.admin-modal {
    background: #fff;
    border-radius: var(--admin-radius-lg);
    box-shadow: 0 24px 60px rgba(10, 48, 80, .35);
    width: 100%;
    max-width: 520px;
    margin: auto;
    overflow: hidden;
    animation: admin-modal-slide .22s ease-out;
}
.admin-modal-lg { max-width: 760px; }
.admin-modal-sm { max-width: 380px; }

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}
.admin-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy-deep);
    margin: 0;
}
.admin-modal-close {
    background: transparent;
    border: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.admin-modal-close:hover { background: var(--bg); color: var(--text); }

.admin-modal-body { padding: 22px; }

.admin-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 22px;
    border-top: 1px solid var(--line);
    background: var(--bg);
}

/* ---------- Page loader (slow-navigation spinner) ------- */
/* Shown by js/admin.js only when a navigation takes longer than its
   threshold, so fast page loads never flash it. */
.admin-page-loader {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 18px;
    background: rgba(10, 48, 80, .45);
    backdrop-filter: blur(2px);
    z-index: 200;
    animation: admin-modal-fade .18s ease-out;
}
.admin-page-loader.is-visible { display: flex; }
.admin-page-loader-spinner {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    animation: admin-spin .7s linear infinite;
}
.admin-page-loader-text {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
}
@keyframes admin-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .admin-page-loader-spinner { animation-duration: 1.6s; }
}

/* Read-only key/value detail list (e.g. pending-user modal) */
.admin-detail-list { margin: 0; }
.admin-detail-row {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 8px 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.admin-detail-row:last-child { border-bottom: 0; }
.admin-detail-row dt {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    color: var(--text-muted);
}
.admin-detail-row dd {
    margin: 0;
    color: var(--text);
    word-break: break-word;
}
@media (max-width: 480px) {
    .admin-detail-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- Quick actions picker ------------------------ */

.qa-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
@media (max-width: 720px) { .qa-picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .qa-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.qa-pick {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 22px 14px;
    min-height: 132px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--admin-radius);
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, box-shadow .15s, background .15s, transform .15s;
}
.qa-pick:hover { border-color: var(--navy); transform: translateY(-1px); }
.qa-pick input[type="checkbox"] {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--green-dark, #3f6e21);
}
.qa-pick > i {
    font-size: 26px;
    color: var(--navy);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0, 86, 149, .10), rgba(116, 188, 74, .14));
    transition: background .15s, color .15s;
}
.qa-pick span {
    font-size: 14px;
    font-weight: 600;
    color: var(--navy-deep);
    line-height: 1.3;
}
.qa-pick.is-checked {
    border-color: var(--green-dark, #3f6e21);
    background: rgba(116, 188, 74, .08);
    box-shadow: 0 0 0 1px var(--green-dark, #3f6e21) inset;
}
.qa-pick.is-checked > i {
    background: var(--navy);
    color: var(--green);
}

.qa-pick-handle {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: grab;
    border-radius: 50%;
    background: transparent;
    transition: background .15s, color .15s;
}
.qa-pick-handle:hover { background: var(--bg); color: var(--navy); }
.qa-pick-handle:active { cursor: grabbing; }
.qa-pick-handle i { font-size: 16px; }

/* SortableJS state classes */
.qa-pick-ghost {
    opacity: .35;
    background: var(--bg);
}
.qa-pick-chosen {
    box-shadow: 0 8px 20px rgba(10, 48, 80, .18);
}
.qa-pick-dragging {
    transform: rotate(1.5deg);
    opacity: .95;
}

/* ---------- Pagination ---------------------------------- */

.admin-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 16px 0 0;
    justify-content: center;
}
.admin-pagination a,
.admin-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
}
.admin-pagination a:hover {
    background: var(--bg);
    color: var(--navy-deep);
    border-color: var(--text-muted);
}
.admin-pagination .is-active {
    background: var(--navy-deep);
    color: #fff;
    border-color: var(--navy-deep);
}
.admin-pagination .is-disabled {
    color: var(--text-muted);
    opacity: .6;
    pointer-events: none;
}

/* ---------- Empty state --------------------------------- */

.admin-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.admin-empty > i {
    font-size: 40px;
    color: var(--line);
    margin-bottom: 12px;
    display: block;
}
.admin-empty-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
}
.admin-empty-text {
    font-size: 14px;
    margin: 0 0 16px;
}

/* ---------- Section divider ----------------------------- */

.admin-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin: 32px 0 12px;
}
.admin-section-title:first-child { margin-top: 0; }

/* ---------- Accordion ----------------------------------- */

.admin-accordion { display: flex; flex-direction: column; gap: 10px; }

.admin-accordion-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--admin-radius);
    overflow: hidden;
}

.admin-accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: var(--navy-deep);
    text-align: left;
    transition: background .15s;
    font-family: inherit;
}
.admin-accordion-trigger:hover { background: var(--bg); }
.admin-accordion-trigger::after {
    content: '\f282';
    font-family: 'bootstrap-icons';
    font-size: 14px;
    color: var(--text-muted);
    transition: transform .2s;
    font-weight: normal;
}
.admin-accordion-item.is-open .admin-accordion-trigger::after {
    transform: rotate(180deg);
}

.admin-accordion-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    padding: 3px 10px;
    border-radius: 999px;
    margin-left: auto;
    margin-right: 12px;
}
.admin-accordion-item.is-open .admin-accordion-count {
    background: rgba(0, 86, 149, .10);
    color: var(--navy);
}

.admin-accordion-panel {
    display: none;
    padding: 0 18px 16px;
    border-top: 1px solid var(--line);
}
.admin-accordion-item.is-open .admin-accordion-panel { display: block; }

/* ---------- Search bar ---------------------------------- */

.admin-searchbar {
    display: flex;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px 4px 4px 12px;
    align-items: center;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
.admin-searchbar:focus-within {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(0, 86, 149, .15);
}
.admin-searchbar i {
    color: var(--text-muted);
    font-size: 16px;
    flex-shrink: 0;
}
.admin-searchbar input {
    flex: 1;
    border: 0;
    outline: none;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    font-family: inherit;
    padding: 6px 0;
    min-width: 0;
}
.admin-searchbar button { flex-shrink: 0; }

/* ---------- Stat-as-link variant ------------------------ */

a.admin-stat {
    text-decoration: none;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.admin-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--admin-shadow);
    border-color: var(--navy);
}
a.admin-stat .stat-label { color: var(--text-muted); }
a.admin-stat .stat-value { color: var(--navy-deep); }
a.admin-stat.is-active {
    border-color: var(--navy);
    box-shadow: 0 0 0 2px rgba(0, 86, 149, .12);
}

/* ---------- Toolbar ------------------------------------- */

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.admin-toolbar-left,
.admin-toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.admin-toolbar-left { flex: 1; min-width: 0; }

/* ---------- Filter chips -------------------------------- */

.admin-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
}
.admin-chip:hover {
    background: var(--bg);
    color: var(--navy-deep);
    text-decoration: none;
}
.admin-chip.is-active {
    background: var(--navy-deep);
    color: #fff;
    border-color: var(--navy-deep);
}
.admin-chip-count {
    background: rgba(255, 255, 255, .2);
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.admin-chip:not(.is-active) .admin-chip-count {
    background: var(--bg);
    color: var(--text-muted);
}