/* ==========================================================================
   Admin panel — internal tool. Denser than the public site by design.
   ========================================================================== */

.admin-body { background: var(--cream-200); }

/* --- Shell --------------------------------------------------------------- */
.admin-bar {
    background: var(--maroon-900);
    color: var(--cream-200);
    border-bottom: 3px solid var(--c-accent);
    position: sticky; top: 0; z-index: 100;
}
.admin-bar .container {
    display: flex; align-items: center; gap: var(--sp-5);
    min-height: 62px; flex-wrap: wrap;
}
.admin-bar .brand { gap: var(--sp-3); }
.admin-bar .brand img { width: 40px; height: 38px; border-width: 1px; }
.admin-bar .brand strong { font-size: var(--fs-base); }
.admin-bar .brand span { font-size: var(--fs-xs); color: var(--gold-300); }

.admin-nav { display: flex; gap: var(--sp-1); margin-inline-start: auto; flex-wrap: wrap; }
.admin-nav a {
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: var(--fs-sm);
    font-weight: 600;
}
.admin-nav a:hover { background: rgba(255,255,255,.12); }
.admin-nav a.is-active { background: var(--c-accent); color: var(--brown-900); }

.admin-user { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-xs); }
.admin-user form { display: inline; }
.admin-user button {
    background: transparent; border: 1px solid rgba(255,255,255,.35);
    color: inherit; border-radius: var(--radius-sm);
    padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs);
}
.admin-user button:hover { background: rgba(255,255,255,.12); }

/* View-as banner. Loud on purpose — it must be impossible to forget. */
.impersonate-bar {
    background: repeating-linear-gradient(45deg, #8A6220, #8A6220 12px, #A87A2E 12px, #A87A2E 24px);
    color: #FFFFFF;
    font-size: var(--fs-sm);
    position: sticky; top: 0; z-index: 120;
    box-shadow: 0 2px 8px rgba(36,26,17,.35);
}
.impersonate-bar .container {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--sp-4); padding-block: var(--sp-3); flex-wrap: wrap;
}
.impersonate-bar strong { color: #FFFFFF; }
.impersonate-bar button {
    background: #FFFFFF; color: var(--brown-900); border: 0;
    border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-4);
    font-size: var(--fs-sm); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.impersonate-bar button:hover { background: var(--cream-200); }
.impersonate-bar + .admin-bar { top: 0; }

/* Panel language toggle */
.admin-lang { display: inline-flex; border: 1px solid rgba(255,255,255,.3); border-radius: var(--radius-sm); overflow: hidden; }
.admin-lang button {
    background: transparent; border: 0; color: inherit;
    padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); cursor: pointer;
}
.admin-lang button:hover { background: rgba(255,255,255,.12); }
.admin-lang button.is-active { background: var(--c-accent); color: var(--brown-900); font-weight: 700; }

/* Permission matrix — first column pinned so role names stay readable while
   scrolling a wide grid on a laptop. */
.perm-table th:first-child,
.perm-table td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--c-surface);
    border-inline-end: 1px solid var(--c-border);
}
.perm-table thead th:first-child { background: var(--cream-100); z-index: 2; }
.perm-table tbody tr:hover td:first-child { background: var(--cream-50); }
.perm-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.perm-table td, .perm-table th { padding: var(--sp-2) var(--sp-4); }

.admin-main { padding-block: var(--sp-6) var(--sp-8); }
.admin-h1 { font-size: var(--fs-xl); color: var(--c-primary); margin-bottom: var(--sp-5); }

/* --- Login --------------------------------------------------------------- */
.login-wrap {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: var(--sp-5);
    background:
        radial-gradient(circle at 50% 20%, rgba(201,150,63,.18), transparent 60%),
        linear-gradient(160deg, var(--brown-800), var(--maroon-900) 80%);
}
.login-card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    border-top: 5px solid var(--c-accent);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-7) var(--sp-6);
    width: 100%; max-width: 420px;
    text-align: center;
}
.login-card img {
    width: 88px; height: 84px;
    margin: 0 auto var(--sp-4);
    border-radius: 50%;
    border: 2px solid var(--c-accent);
}
.login-card h1 { font-size: var(--fs-lg); color: var(--c-primary); margin-bottom: var(--sp-2); }
.login-card > p { color: var(--c-text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-6); }
.login-card .field { text-align: start; margin-bottom: var(--sp-4); }
.login-card button { width: 100%; }
.login-card .checkbox {
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: var(--fs-sm); margin-bottom: var(--sp-5);
}
.login-card .checkbox input { width: auto; }
.login-back { margin-top: var(--sp-5); font-size: var(--fs-sm); }
.login-back a { color: var(--maroon-600); }

/* --- Stat tiles ---------------------------------------------------------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.tile {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-inline-start: 4px solid var(--c-accent);
    border-radius: var(--radius);
    padding: var(--sp-5);
}
.tile b { display: block; font-size: var(--fs-2xl); color: var(--c-primary); line-height: 1.1; }
.tile span { font-size: var(--fs-sm); color: var(--c-text-muted); }
.tile--warn { border-inline-start-color: var(--maroon-500); }
.tile--ok { border-inline-start-color: var(--c-success); }

/* --- Card + table -------------------------------------------------------- */
.admin-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.admin-card + .admin-card { margin-top: var(--sp-5); }
.admin-card__head {
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--c-border);
    background: var(--cream-100);
    display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4);
    flex-wrap: wrap;
}
.admin-card__head h2 { font-size: var(--fs-md); color: var(--c-primary); }
.admin-card__body { padding: var(--sp-5); }

.table-scroll { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.admin-table th, .admin-table td {
    padding: var(--sp-3) var(--sp-4);
    text-align: start;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
    white-space: nowrap;
}
.admin-table th {
    background: var(--cream-100);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--brown-500);
}
.admin-table tbody tr:hover { background: var(--cream-50); }
.admin-table td.wrap { white-space: normal; min-width: 220px; }
.admin-table a { color: var(--maroon-600); font-weight: 600; }

.empty-row { text-align: center; color: var(--c-text-muted); padding: var(--sp-7) !important; }

/* --- Badges -------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 3px var(--sp-3);
    border-radius: 999px;
    font-size: var(--fs-xs);
    font-weight: 700;
    border: 1px solid;
    white-space: nowrap;
}
.badge--new       { background: var(--c-accent-soft); border-color: var(--gold-400); color: var(--gold-700); }
.badge--in_review { background: #E8EEF7; border-color: #A9C0DE; color: #2C4C74; }
.badge--approved  { background: var(--c-success-soft); border-color: var(--green-400); color: var(--green-800); }
.badge--rejected  { background: var(--maroon-50); border-color: var(--maroon-200); color: var(--maroon-700); }
.badge--closed    { background: var(--cream-300); border-color: var(--c-border-strong); color: var(--brown-700); }
.badge--type      { background: var(--cream-100); border-color: var(--c-border-strong); color: var(--brown-700); }

/* --- Filters ------------------------------------------------------------- */
.filters { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; }
.filters .field--grow { flex: 1; min-width: 220px; }

/* --- Detail definition list --------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 200px 1fr; gap: var(--sp-3) var(--sp-5); font-size: var(--fs-sm); }
.detail-grid dt { font-weight: 700; color: var(--brown-500); }
.detail-grid dd { margin: 0; color: var(--c-text); word-break: break-word; }

.admin-layout { display: grid; grid-template-columns: 1fr 360px; gap: var(--sp-5); align-items: start; }

/* --- Pagination ---------------------------------------------------------- */
.pagination-wrap { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--c-border); }
.pagination-wrap nav { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; font-size: var(--fs-sm); }
.pagination-wrap a, .pagination-wrap span {
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--maroon-600);
}
.pagination-wrap [aria-current] { background: var(--c-primary); color: var(--c-text-invert); border-color: var(--c-primary); }
.pagination-wrap svg { width: 14px; height: 14px; }

/* --- Dashboard sections -------------------------------------------------- */
.dash-h2 {
    font-size: var(--fs-md);
    color: var(--brown-500);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: var(--sp-7) 0 var(--sp-4);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--c-border);
}
.dash-h2:first-of-type { margin-top: 0; }

a.tile { color: inherit; transition: border-color .15s, transform .15s; }
a.tile:hover { border-color: var(--c-accent); transform: translateY(-2px); }
a.tile.is-active { border-inline-start-width: 6px; background: var(--cream-50); }

/* --- Ledger -------------------------------------------------------------- */
/* A cancelled entry stays in the table on purpose — it is the record of what
   happened, not a row to be swept away. Struck through so it reads as history
   at a glance rather than as a live number. */
.admin-table tr.is-reversed td { opacity: .62; }
.admin-table tr.is-reversed td:first-child,
.admin-table tr.is-reversed td:nth-child(2) { text-decoration: line-through; }

.admin-table details summary {
    cursor: pointer; list-style: none;
    display: inline-block; padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-xs);
}
.admin-table details summary::-webkit-details-marker { display: none; }
.admin-table details[open] summary { margin-bottom: var(--sp-2); }
.admin-table details input[type="text"] {
    width: 100%; padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm);
    font: inherit; font-size: var(--fs-sm);
}

/* --- Report bars ---------------------------------------------------------
   Horizontal, single series, with the value written beside every bar. The
   length is a reading aid; the number is the data — so nothing here depends on
   reading a colour, and it survives print and a colourblind reader unchanged.
   One hue per chart, and never a second series sharing the track. */
.bars { list-style: none; padding: 0; margin: 0; }
.bars li {
    display: grid;
    grid-template-columns: 62px 1fr auto;
    align-items: center;
    gap: var(--sp-3);
    padding-block: var(--sp-2);
    font-size: var(--fs-sm);
}
.bars li + li { border-top: 1px solid var(--c-border); }
.bars__label { color: var(--c-text-muted); font-size: var(--fs-xs); white-space: nowrap; }
.bars__track { background: var(--cream-200); border-radius: 999px; height: 10px; overflow: hidden; }
.bars__fill {
    display: block; height: 100%;
    background: var(--maroon-600);
    /* Rounded only at the data end, anchored flat to the baseline. */
    border-radius: 0 4px 4px 0;
}
.bars__fill--alt { background: var(--green-600); }
.bars__value { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }

.pct { display: inline-flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; }
.pct__track { width: 68px; height: 8px; background: var(--cream-200); border-radius: 999px; overflow: hidden; }
.pct__fill { display: block; height: 100%; background: var(--c-accent); border-radius: 0 4px 4px 0; }
.pct__num { font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: end; }

/* --- Office-bearer visibility switches ----------------------------------- */
.visibility-set {
    margin-top: var(--sp-5);
    border: 1px solid var(--c-border);
    border-inline-start: 4px solid var(--c-accent);
    border-radius: var(--radius);
    padding: var(--sp-4) var(--sp-5);
    background: var(--cream-50);
}
.visibility-set legend {
    font-weight: 700; font-size: var(--fs-sm); color: var(--c-primary);
    padding-inline: var(--sp-2);
}
.visibility-set .checkbox {
    display: flex; align-items: center; gap: var(--sp-3);
    padding-block: var(--sp-2); font-size: var(--fs-sm);
}
.visibility-set .checkbox input { width: 18px; height: 18px; }
.visibility-set .hint { display: block; margin-top: var(--sp-3); }

@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; gap: var(--sp-1) 0; }
    .detail-grid dd { margin-bottom: var(--sp-3); }
}
