:root {
    --stax-black: #000000;
    --stax-surface: #1a1a1a;
    --stax-elevated: #242424;
    --stax-accent: #e63946;
    --stax-accent-hover: #c92a38;
    --stax-text: #ffffff;
    --stax-muted: #a3a3a3;
    --stax-border: rgba(255, 255, 255, 0.08);
    --stax-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --stax-shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.35);
    --stax-radius: 12px;
    --stax-radius-sm: 8px;
    --stax-space: 1rem;
    --stax-font: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --stax-ok: #4ade80;
    --stax-danger: #f87171;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--stax-font);
    background: var(--stax-black);
    color: var(--stax-text);
    line-height: 1.45;
}

a { color: var(--stax-accent); text-decoration: none; }
a:hover { color: var(--stax-accent-hover); }

/* ---------------------------------------------------------------------------
   Top bar (admin + branch)
   --------------------------------------------------------------------------- */
.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.1rem;
    min-height: 3.4rem;
    background: var(--stax-surface);
    border-bottom: 1px solid var(--stax-border);
    box-shadow: var(--stax-shadow-sm);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-brand {
    color: var(--stax-text);
    font-weight: 800;
    letter-spacing: 0.18em;
    font-size: 0.95rem;
    justify-self: start;
    flex-shrink: 0;
}

.topbar-brand.has-logo {
    display: inline-flex;
    align-items: center;
    letter-spacing: 0;
}

.topbar-logo {
    display: block;
    height: 2.1rem;
    max-width: 10rem;
    width: auto;
    object-fit: contain;
}

.topbar-brand:hover { color: var(--stax-text); }

.topbar-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    justify-self: center;
}

.topbar-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.7rem;
    border-radius: var(--stax-radius-sm);
    color: var(--stax-muted);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.topbar-link:hover {
    color: var(--stax-text);
    background: var(--stax-elevated);
}

.topbar-link.is-active {
    color: var(--stax-text);
    background: rgba(230, 57, 70, 0.18);
    box-shadow: inset 0 -2px 0 var(--stax-accent);
}

.topbar-link.is-active:hover { color: var(--stax-text); }

.topbar-logout {
    grid-column: 3;
    justify-self: end;
    flex-shrink: 0;
}

.topbar-end {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.profile-menu {
    position: relative;
}

.profile-menu > summary {
    list-style: none;
    cursor: pointer;
}

.profile-menu > summary::-webkit-details-marker { display: none; }

.profile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem;
    border-radius: 999px;
    color: var(--stax-text);
}

.profile-toggle:hover .profile-avatar,
.profile-menu[open] .profile-avatar,
.profile-toggle.is-active .profile-avatar {
    background: var(--stax-accent);
    color: var(--stax-text);
}

.profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: var(--stax-elevated);
    color: var(--stax-text);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid var(--stax-border);
}

.profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 14.5rem;
    padding: 0.55rem 0 0.4rem;
    background: var(--stax-elevated);
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius-sm);
    box-shadow: var(--stax-shadow);
    z-index: 30;
}

.profile-email {
    margin: 0;
    padding: 0.35rem 0.9rem 0.55rem;
    color: var(--stax-muted);
    font-size: 0.8rem;
    word-break: break-all;
    border-bottom: 1px solid var(--stax-border);
}

.profile-dropdown a {
    display: block;
    padding: 0.5rem 0.9rem;
    color: var(--stax-text);
    font-size: 0.85rem;
    font-weight: 600;
}

.profile-dropdown a:hover {
    color: var(--stax-text);
    background: rgba(230, 57, 70, 0.18);
}

.bell-menu { position: relative; }
.bell-menu > summary {
    list-style: none;
    cursor: pointer;
}
.bell-menu > summary::-webkit-details-marker { display: none; }
.bell-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    margin: 0;
    border-radius: 999px;
    color: var(--stax-text);
    background: transparent;
    box-shadow: none;
}
.bell-toggle:hover,
.bell-menu[open] .bell-toggle {
    background: var(--stax-elevated);
}
.bell-badge {
    position: absolute;
    top: -0.15rem;
    right: -0.15rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--stax-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 1.05rem;
    text-align: center;
}
.bell-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 18rem;
    max-width: 22rem;
    padding: 0.4rem 0;
    background: var(--stax-elevated);
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius-sm);
    box-shadow: var(--stax-shadow);
    z-index: 30;
}
.bell-dropdown a {
    display: block;
    padding: 0.5rem 0.9rem;
    color: var(--stax-text);
    font-size: 0.85rem;
    font-weight: 600;
}
.bell-dropdown a:hover {
    color: var(--stax-text);
    background: rgba(230, 57, 70, 0.18);
}
.bell-preview-note {
    display: block;
    margin-top: 0.15rem;
    color: var(--stax-muted);
    font-weight: 400;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bell-empty {
    margin: 0;
    padding: 0.55rem 0.9rem;
    color: var(--stax-muted);
    font-size: 0.85rem;
}
.bell-view-all {
    border-top: 1px solid var(--stax-border);
    margin-top: 0.25rem;
}

.topbar-branch-label {
    justify-self: center;
    color: var(--stax-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.nav-ico {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   App chrome
   --------------------------------------------------------------------------- */
body.app-body {
    display: block;
    padding: 0;
}

.app-main {
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.page-kicker {
    margin: 0 0 1.15rem;
    color: var(--stax-muted);
    font-size: 0.9rem;
}

.page-title {
    margin: 0 0 1.15rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.panel {
    background: var(--stax-surface);
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius);
    padding: 1.35rem 1.4rem;
    box-shadow: var(--stax-shadow-sm);
}

.panel + .panel,
.dash-grid + .panel {
    margin-top: 1.25rem;
}

.panel > p:first-child {
    margin-top: 0;
    font-weight: 650;
}

label {
    display: block;
    font-size: 0.82rem;
    color: var(--stax-muted);
    margin-bottom: 0.35rem;
}

input[type="email"],
input[type="password"],
input[type="file"],
input[type="text"],
input[type="date"],
select {
    width: 100%;
    padding: 0.62rem 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius-sm);
    background: var(--stax-black);
    color: var(--stax-text);
    font-size: 0.95rem;
    font-family: inherit;
}

input:focus,
select:focus {
    outline: 2px solid rgba(230, 57, 70, 0.45);
    outline-offset: 1px;
}

button {
    width: 100%;
    padding: 0.72rem 1rem;
    border: 0;
    border-radius: var(--stax-radius-sm);
    background: var(--stax-accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(230, 57, 70, 0.28);
}

button:hover { background: var(--stax-accent-hover); }

button.danger {
    background: transparent;
    color: var(--stax-danger);
    border: 1px solid rgba(248, 113, 113, 0.45);
    box-shadow: none;
}

button.danger:hover {
    background: rgba(248, 113, 113, 0.12);
}

button.secondary {
    background: var(--stax-elevated);
    box-shadow: none;
    color: var(--stax-text);
}

button.secondary:hover { background: #2e2e2e; }

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
    gap: 0.75rem 1rem;
    align-items: end;
}

.filters button { width: auto; margin: 0; }

.filter-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: stretch;
    min-width: max-content;
}

.filters .filter-actions button {
    width: auto;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    white-space: nowrap;
    padding: 0.72rem 1rem;
    min-height: 2.75rem;
    box-sizing: border-box;
}

.filters .filter-actions button.btn-icon-only {
    padding: 0.72rem;
    min-width: 2.75rem;
}

button.btn-icon-only.voucher-override-open,
button.btn-icon-only.change-request-open {
    width: auto;
    margin: 0 auto;
    padding: 0.4rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-ico {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.filters input,
.filters select { margin-bottom: 0; }

.table-wrap { overflow-x: auto; }

table.plain {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.plain th,
table.plain td {
    text-align: left;
    padding: 0.62rem 0.55rem;
    border-bottom: 1px solid var(--stax-border);
    vertical-align: top;
}

table.plain th {
    color: var(--stax-muted);
    font-weight: 650;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table.plain th a.th-sort {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}
table.plain th a.th-sort:hover {
    color: var(--stax-accent);
}
.th-sort-ind {
    color: var(--stax-accent);
    font-size: 0.7rem;
    letter-spacing: 0;
}

table.plain tbody tr:hover td {
    background: var(--stax-elevated);
}

#history-table tbody tr.history-pending td {
    background: rgba(34, 197, 94, 0.08);
}

#history-table tbody tr.history-pending td:first-child {
    box-shadow: inset 3px 0 0 #22c55e;
}

#history-table tbody tr.history-pending:hover td {
    background: rgba(34, 197, 94, 0.14);
}

.history-pending-badge {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #86efac;
    background: rgba(34, 197, 94, 0.16);
    border: 1px solid rgba(34, 197, 94, 0.4);
}

a.ff-client-view {
    color: var(--stax-accent);
    font-weight: 700;
    text-decoration: none;
}
a.ff-client-view:hover {
    text-decoration: underline;
}

table.plain.table-center th,
table.plain.table-center td {
    text-align: center;
}

.pager { color: var(--stax-muted); font-size: 0.9rem; }
.muted { color: var(--stax-muted); font-size: 0.85rem; }

.download-na {
    color: var(--stax-muted);
    cursor: default;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.card {
    background: var(--stax-surface);
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius);
    padding: 1.05rem 1.15rem;
    box-shadow: var(--stax-shadow-sm);
}

.card .label { color: var(--stax-muted); font-size: 0.82rem; font-weight: 600; }
.card .n {
    font-size: 1.95rem;
    font-weight: 800;
    margin-top: 0.25rem;
    color: var(--stax-accent);
    letter-spacing: -0.02em;
}

.dash-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 1.25rem;
    align-items: stretch;
}

.chart-wrap {
    position: relative;
    height: 20rem;
}

.chart-empty {
    color: var(--stax-muted);
    margin: 2rem 0 0;
}

details.dups { margin-top: 0.35rem; }
details.dups summary { cursor: pointer; color: var(--stax-accent); }

details.audit-details summary {
    cursor: pointer;
    color: var(--stax-accent);
    white-space: nowrap;
}
details.audit-details[open] {
    min-width: 16rem;
}
.audit-json {
    margin: 0.5rem 0 0;
    padding: 0.6rem 0.7rem;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    color: #e5e5e5;
    font-size: 0.8rem;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 16rem;
    overflow: auto;
}
.audit-json-block {
    margin-top: 0.45rem;
}
.audit-json-block p {
    margin: 0 0 0.2rem;
    color: var(--stax-muted);
    font-size: 0.75rem;
}
.audit-action {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
}
.audit-desc {
    display: block;
    color: var(--stax-muted);
    margin-top: 0.15rem;
}

.dup-list { margin: 0 0 1rem; padding-left: 1.2rem; }

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    align-items: center;
}

.row-actions form { display: inline; margin: 0; }

.row-actions button {
    width: auto;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    margin: 0;
    box-shadow: none;
}

.stack-form { max-width: 28rem; }

.danger-zone {
    border: 1px solid rgba(248, 113, 113, 0.4);
    background: rgba(230, 57, 70, 0.08);
    box-shadow: none;
}
.danger-zone-title {
    color: var(--stax-danger);
    font-weight: 700;
    margin: 0 0 0.5rem;
}
.danger-zone .stack-form { max-width: 28rem; }
.danger-zone .stack-form.reset-form { max-width: 42rem; }
.danger-zone button.danger {
    background: rgba(230, 57, 70, 0.2);
    color: #ffc4ca;
}

.reset-scope-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0.85rem 0 1.1rem;
}

.reset-scope-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius-sm);
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.reset-scope-option:has(input:checked) {
    border-color: var(--stax-accent);
}

.reset-scope-option input {
    margin: 0.2rem 0 0;
    flex-shrink: 0;
    accent-color: var(--stax-accent);
}

.reset-scope-option strong {
    display: block;
    color: var(--stax-text);
    font-weight: 700;
}

.reset-scope-option .settings-hint {
    margin: 0.35rem 0 0;
}

.stack-form input[type="text"],
.stack-form input[type="email"],
.stack-form input[type="password"] {
    margin-bottom: 1rem;
}

.status-active { color: var(--stax-ok); font-weight: 650; }
.status-inactive { color: var(--stax-muted); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}
.panel-head-title { margin: 0; }
.panel-head button {
    width: auto;
    margin: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
}

.stax-modal {
    border: 0;
    border-radius: var(--stax-radius);
    padding: 0;
    background: var(--stax-surface);
    color: var(--stax-text);
    box-shadow: var(--stax-shadow);
    width: min(28rem, calc(100vw - 2rem));
    color-scheme: dark;
}
.stax-modal::backdrop {
    background: rgba(0, 0, 0, 0.7);
}
.stax-modal-inner { padding: 1.15rem 1.25rem 1.25rem; }
.stax-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.stax-modal-title { margin: 0; font-weight: 700; }
.stax-modal-close {
    width: auto;
    margin: 0;
    padding: 0.2rem 0.55rem;
    font-size: 1.35rem;
    line-height: 1;
    background: transparent;
    color: var(--stax-muted);
    box-shadow: none;
}
.stax-modal-close:hover { background: var(--stax-elevated); color: var(--stax-text); }
.stax-modal .stack-form { max-width: none; }
.stax-modal-actions { margin-top: 0.25rem; }
.stax-modal .flash { margin-bottom: 0.85rem; }
.stax-modal .flash[hidden] { display: none; }

.stax-modal.voucher-override-modal {
    width: min(36rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
}
.override-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem 1rem;
    margin: 0 0 0.7rem;
}
.override-meta dt {
    margin: 0;
    font-size: 0.72rem;
    color: var(--stax-muted);
    font-weight: 600;
}
.override-meta dd { margin: 0.1rem 0 0; font-size: 0.9rem; }
.override-meta .span-2 { grid-column: 1 / -1; }
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.toggle-row input { width: auto; margin: 0; }
.override-code {
    font-family: ui-monospace, Consolas, monospace;
    letter-spacing: 0.08em;
    margin: 0 0 0.65rem;
    color: var(--stax-accent);
}
.vc-fields {
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius);
    padding: 0.65rem 0.85rem 0.75rem;
    margin: 0 0 0.7rem;
}
.vc-fields legend {
    padding: 0 0.35rem;
    font-weight: 700;
    font-size: 0.85rem;
}
.vc-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.85rem;
    margin-bottom: 0.25rem;
}
.vc-legend {
    margin: 0 0 0.25rem;
    font-weight: 600;
    font-size: 0.8rem;
}
.vc-fields label { display: block; margin: 0.35rem 0 0.15rem; font-weight: 600; font-size: 0.8rem; }
.vc-fields select,
.vc-fields input,
.vc-fields textarea {
    width: 100%;
    margin-bottom: 0.35rem;
    background: var(--stax-elevated);
    color: var(--stax-text);
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius-sm);
    padding: 0.4rem 0.55rem;
    font-family: inherit;
    font-size: 0.9rem;
}
.vc-fields textarea {
    min-height: 3.1rem;
    resize: none;
}
.radio-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.radio-row input { width: auto; margin: 0; }
#vc-apply { width: auto; }

.stax-modal.request-handle-modal {
    width: min(54rem, calc(100vw - 1.25rem));
    max-height: calc(100vh - 1.5rem);
    overflow: hidden;
}
.request-handle-modal .stax-modal-inner {
    max-height: calc(100vh - 1.5rem);
    overflow: hidden;
    padding: 0.85rem 1rem 1rem;
}
.request-handle-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 0.65rem 1rem;
    align-items: start;
    overflow: hidden;
}
.request-handle-left,
.request-handle-right {
    min-width: 0;
    overflow: hidden;
}
.request-handle-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.request-handle-actions button {
    width: auto;
    min-height: 2.4rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.88rem;
}
button.btn-danger {
    background: transparent;
    color: var(--stax-text);
    border: 1px solid var(--stax-accent);
}
button.btn-danger:hover { background: rgba(230, 57, 70, 0.18); }
.request-row,
.my-request-row { cursor: pointer; }
.request-row:hover,
.my-request-row:hover { background: rgba(255, 255, 255, 0.04); }
button.request-status-btn {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0.15rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: capitalize;
    background: var(--stax-elevated);
    border: 1px solid var(--stax-border);
}
.stax-modal.my-request-modal {
    width: min(28rem, calc(100vw - 2rem));
    overflow: hidden;
}

.stax-modal.change-request-modal {
    width: min(32rem, calc(100vw - 2rem));
}
.change-request-modal label {
    display: block;
    margin: 0 0 0.35rem;
    font-weight: 600;
}
.change-request-modal select,
.change-request-modal textarea {
    width: 100%;
    margin-bottom: 1rem;
    background: var(--stax-elevated);
    color: var(--stax-text);
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius);
    padding: 0.55rem 0.7rem;
    font-family: inherit;
    font-size: 1rem;
}
.change-request-modal textarea {
    min-height: 12rem;
    line-height: 1.5;
    resize: vertical;
}

.override-pending {
    margin: 0 0 1rem;
    padding: 0.7rem 0.85rem;
    border-radius: var(--stax-radius-sm);
    background: rgba(230, 57, 70, 0.12);
    border: 1px solid rgba(230, 57, 70, 0.28);
    font-size: 0.88rem;
}
.override-pending p { margin: 0 0 0.4rem; }
.override-pending p:last-child { margin-bottom: 0; }
.override-pending .muted { margin-top: 0.15rem; }

button.btn-row {
    width: auto;
    display: inline-flex;
    margin: 0.15rem 0.2rem 0.15rem 0;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    min-height: 0;
}

#request-handle-modal .vc-fields {
    margin-bottom: 0.55rem;
}

.cred-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.75rem;
}

.creds-panel button.copy-inline {
    width: auto;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    margin: 0;
}

.flash {
    padding: 0.7rem 0.85rem;
    border-radius: var(--stax-radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash-error {
    background: rgba(230, 57, 70, 0.14);
    color: #ffc4ca;
    border: 1px solid rgba(230, 57, 70, 0.28);
}

.flash-ok {
    background: rgba(74, 222, 128, 0.1);
    color: #bbf7d0;
    border: 1px solid rgba(74, 222, 128, 0.22);
}

.settings-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem 1.25rem;
    margin: 0.75rem 0 1.1rem;
}

.settings-thumb {
    width: 12rem;
    max-width: 100%;
    height: auto;
    border-radius: var(--stax-radius-sm);
    border: 1px solid var(--stax-border);
    box-shadow: var(--stax-shadow-sm);
    background: var(--stax-black);
}

.settings-preview form { margin: 0; }
.settings-preview button { width: auto; }

.settings-thumb-logo {
    width: auto;
    max-height: 3.5rem;
    height: 3.5rem;
}

.settings-hint {
    color: var(--stax-muted);
    font-size: 0.9rem;
    margin: 0 0 1rem;
}

.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    margin: 0 0 1.25rem;
    border-bottom: 1px solid var(--stax-border);
}

.settings-tabs a.settings-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.7rem 1rem;
    margin: 0;
    border-radius: 0;
    background: transparent;
    color: var(--stax-muted);
    font-weight: 650;
    font-size: 0.92rem;
    border: 0;
    box-shadow: inset 0 -2px 0 transparent;
}

.settings-tabs a.settings-tab:hover {
    color: var(--stax-text);
    background: var(--stax-elevated);
}

.settings-tabs a.settings-tab.is-active {
    color: var(--stax-text);
    background: transparent;
    box-shadow: inset 0 -2px 0 var(--stax-accent);
}

.settings-tab-panel > .panel + .panel { margin-top: 1.25rem; }

.settings-soon {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
}

.theme-color-form { max-width: 28rem; }
.theme-color-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.theme-color-row input[type="color"] {
    width: 3.25rem;
    height: 2.75rem;
    padding: 0.15rem;
    margin: 0;
    border: 1px solid var(--stax-border);
    background: var(--stax-elevated);
    cursor: pointer;
}
.theme-color-row button { width: auto; }
.theme-color-reset button { width: auto; }

.panel .theme-color-form button,
.panel .theme-color-reset button,
.panel form[enctype="multipart/form-data"] button {
    width: auto;
}

/* ---------------------------------------------------------------------------
   File drop-zone (STAX-014) — JS adds .is-enhanced; without JS the native
   file input stays visible.
   --------------------------------------------------------------------------- */
.dropzone {
    position: relative;
    margin-bottom: 1rem;
}

.dropzone.is-enhanced {
    min-height: 8.75rem;
    padding: 1.35rem 1.1rem;
    border: 2px dashed rgba(255, 255, 255, 0.18);
    border-radius: var(--stax-radius);
    background: var(--stax-black);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.is-enhanced:hover,
.dropzone.is-enhanced.is-dragover {
    border-color: var(--stax-accent);
    background: rgba(230, 57, 70, 0.1);
}

.dropzone.is-enhanced.is-invalid {
    border-color: var(--stax-danger);
}

.dropzone.is-enhanced .dropzone-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.dropzone-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    text-align: center;
    pointer-events: none;
}

.dropzone-ico {
    width: 2rem;
    height: 2rem;
    fill: none;
    stroke: var(--stax-accent);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    margin-bottom: 0.25rem;
}

.dropzone-prompt {
    margin: 0;
    color: var(--stax-text);
    font-size: 0.95rem;
    font-weight: 650;
}

.dropzone-file {
    margin: 0.15rem 0 0;
    color: var(--stax-muted);
    font-size: 0.85rem;
    word-break: break-all;
}

.dropzone-error {
    margin: 0.4rem 0 0;
    color: var(--stax-danger);
    font-size: 0.85rem;
}

.preview-table td.status-ok { color: var(--stax-ok); font-weight: 650; }
.preview-table td.status-bad { color: var(--stax-danger); font-weight: 650; }

.preview-scroll,
.dash-recent-scroll {
    overflow-y: auto;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--stax-accent) var(--stax-elevated);
}
.preview-scroll {
    max-height: 54rem; /* sticky header + ~20 body rows at current .plain padding */
}
.dash-recent-scroll {
    max-height: 20rem; /* match .chart-wrap; 20 rows scroll inside */
}
.preview-scroll::-webkit-scrollbar,
.dash-recent-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.preview-scroll::-webkit-scrollbar-track,
.dash-recent-scroll::-webkit-scrollbar-track {
    background: var(--stax-elevated);
    border-radius: 6px;
}
.preview-scroll::-webkit-scrollbar-thumb,
.dash-recent-scroll::-webkit-scrollbar-thumb {
    background: var(--stax-accent);
    border-radius: 6px;
}
.preview-scroll .preview-table thead th,
.dash-recent-scroll table.plain thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--stax-surface);
    box-shadow: 0 1px 0 var(--stax-border);
}

.preview-summary {
    margin: 0.75rem 0 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(230, 57, 70, 0.28);
    border-radius: var(--stax-radius-sm);
    background: rgba(230, 57, 70, 0.10);
    color: #ffc4ca;
}
.preview-summary p { margin: 0 0 0.4rem; }
.preview-summary ul {
    margin: 0 0 0.6rem;
    padding-left: 1.2rem;
}
.preview-summary p:last-child { margin-bottom: 0; }

.confirm-form {
    margin-top: 1rem;
    max-width: 28rem;
}

.branch-access {
    margin: 0 0 1rem;
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius-sm);
    background: var(--stax-black);
}

.branch-access legend {
    padding: 0 0.35rem;
    color: var(--stax-text);
    font-size: 0.92rem;
}

.branch-access-list {
    display: grid;
    gap: 0.4rem;
}

.branch-access-list label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    color: var(--stax-text);
    cursor: pointer;
    font-weight: 400;
}

.branch-access-list input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--stax-accent);
}

.confirm-form button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

#preview-result { margin-top: 1rem; }

.upload-preview-btn-wrap {
    display: flex;
    justify-content: center;
}

#upload-preview-btn {
    width: auto;
    min-width: 12rem;
    margin: 0 0 0.25rem;
}
#upload-preview-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---------------------------------------------------------------------------
   Login
   --------------------------------------------------------------------------- */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: 100vh;
    background: radial-gradient(ellipse at top, #1a1a1a 0%, #000000 62%);
    position: relative;
}

body.login-page.has-bg {
    background-color: #000;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

body.login-page.has-bg::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 0;
}

.login-wrap {
    width: 100%;
    max-width: 26rem;
    position: relative;
    z-index: 1;
}

.login-brand {
    text-align: center;
    margin-bottom: 1.25rem;
}

.login-brand .mark {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.22em;
}

.login-brand p {
    margin: 0.4rem 0 0;
    color: var(--stax-muted);
    font-size: 0.92rem;
}

.login-card {
    background: var(--stax-surface);
    border: 1px solid var(--stax-border);
    border-radius: var(--stax-radius);
    padding: 1.6rem 1.5rem 1.45rem;
    box-shadow: var(--stax-shadow);
}

.login-or {
    margin: 1rem 0 0.85rem;
    text-align: center;
    color: var(--stax-muted);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

a.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.72rem 1rem;
    border-radius: var(--stax-radius-sm);
    background: #ffffff;
    color: #1f1f1f;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

a.btn-google:hover {
    background: #f2f2f2;
    color: #1f1f1f;
}

.btn-google-ico {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
}

.dev-autofill {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0 0 1rem;
}

.dev-autofill button.dev-fill {
    width: auto;
    align-self: flex-start;
    padding: 0;
    font-size: 0.75rem;
    font-weight: 500;
    background: transparent;
    color: var(--stax-muted);
    box-shadow: none;
    border: 0;
}

.dev-autofill button.dev-fill:hover {
    color: var(--stax-text);
    background: transparent;
    text-decoration: underline;
}

/* ---------------------------------------------------------------------------
   Branch dashboard
   --------------------------------------------------------------------------- */
body.branch-page { display: block; padding: 0; }

.branch-main {
    width: 100%;
    max-width: 52rem;
    margin: 0 auto;
    padding: 1.35rem 1.1rem 2.5rem;
}

.branch-chart-wrap { height: 16rem; }

/* Space between voucher/redeem (or empty-pool) panel and the STAX-042 stat cards */
.branch-main .cards {
    margin-top: 1.75rem;
}

.code-label {
    margin: 0 0 0.4rem;
    color: var(--stax-muted);
    font-size: 0.85rem;
}

.code-display {
    font-size: 2.35rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.2;
    user-select: all;
    word-break: break-all;
    margin: 0 0 0.6rem;
    color: var(--stax-accent);
}

.code-meta { color: var(--stax-muted); }

#reserved-panel,
#empty-panel {
    text-align: center;
}

#reserved-panel {
    --stax-progress: #22c55e;
    --stax-progress-dim: #3f3f3f;
    --stax-progress-glow: rgba(34, 197, 94, 0.42);
}

.redeem-resume {
    margin: 0.85rem auto 0;
    max-width: 28rem;
    padding: 0.55rem 0.85rem;
    border-radius: var(--stax-radius-sm);
    background: rgba(230, 57, 70, 0.12);
    border: 1px solid rgba(230, 57, 70, 0.4);
    color: #fecaca;
    font-size: 0.92rem;
    font-weight: 600;
}

.redeem-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.15rem;
    list-style: none;
    margin: 1.35rem 0 0.35rem;
    padding: 0;
}

.redeem-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    min-width: 4.6rem;
    color: #6b6b6b;
    flex: 0 0 auto;
}

.redeem-step-icon {
    width: 2.65rem;
    height: 2.65rem;
    border-radius: 50%;
    border: 2px solid var(--stax-progress-dim);
    background: #141414;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #8a8a8a;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.redeem-step-num { line-height: 1; }

.redeem-step-label {
    font-size: 0.78rem;
    font-weight: 700;
    max-width: 6.2rem;
    line-height: 1.2;
}

.redeem-step.is-active {
    color: var(--stax-progress);
}

.redeem-step.is-active .redeem-step-icon {
    border-color: var(--stax-progress);
    color: var(--stax-progress);
    box-shadow: 0 0 0 4px var(--stax-progress-glow);
}

.redeem-step.is-done {
    color: var(--stax-progress);
}

.redeem-step.is-done[data-step="1"],
.redeem-step.is-done[data-step="2"] {
    cursor: pointer;
}

.redeem-step.is-done .redeem-step-icon {
    background: var(--stax-progress);
    border-color: var(--stax-progress);
    color: #052e16;
    box-shadow: none;
}

.redeem-step.is-done .redeem-step-num { display: none; }

.redeem-step.is-done .redeem-step-icon::after {
    content: "✓";
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
}

.redeem-step-arrow {
    width: 1.7rem;
    height: 2.65rem;
    display: flex;
    align-items: center;
    color: #3f3f3f;
    flex: 0 0 auto;
}

.redeem-step-arrow svg {
    width: 100%;
    height: 0.85rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.redeem-step-arrow.is-done {
    color: #22c55e;
}

#reserved-panel .redeem-fields {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0.85rem;
}

.redeem-step-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 22rem;
}

.redeem-step-panel[hidden] { display: none; }

#reserved-panel .redeem-fields label {
    margin-top: 0.15rem;
    text-align: center;
    width: 100%;
    max-width: 22rem;
}

#reserved-panel .redeem-fields input,
#reserved-panel .redeem-step-panel button {
    width: 100%;
    max-width: 22rem;
    text-align: center;
}

.redeem-fields { margin-top: 1rem; }
.redeem-fields label { margin-top: 0.15rem; }
.redeem-fields #member-id,
.redeem-fields #invoice-number { margin-bottom: 0.85rem; }

.redeem-step-hint {
    margin: 0 0 0.85rem;
    color: var(--stax-muted);
    font-size: 0.9rem;
}

.revealed-code {
    color: var(--stax-progress, #22c55e);
    font-size: 1.65rem;
    margin-bottom: 0.85rem;
}

.redeem-success {
    margin: 0.85rem 0 0;
    color: #86efac;
    font-weight: 800;
}

#step1-next,
#get-code-btn,
#step3-next,
#redeem-btn { min-height: 3rem; }

#step1-next:disabled,
#get-code-btn:disabled,
#step3-next:disabled,
#redeem-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

@media (max-width: 56rem) {
    .dash-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 40rem) {
    .topbar {
        grid-template-columns: 1fr auto;
        padding: 0.45rem 0.7rem;
    }

    .topbar-brand { grid-column: 1; grid-row: 1; }
    .topbar-logout,
    .profile-menu,
    .topbar-end {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }
    .topbar-nav,
    .topbar-branch-label {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
        width: 100%;
        justify-content: center;
    }

    body.branch-page .code-display {
        font-size: clamp(1.65rem, 8vw, 2.35rem);
    }

    body.branch-page #step1-next,
    body.branch-page #get-code-btn,
    body.branch-page #step3-next,
    body.branch-page #redeem-btn {
        min-height: 3.25rem;
        padding: 0.95rem 1rem;
        font-size: 1.1rem;
    }

    .redeem-step {
        min-width: 3.5rem;
    }

    .redeem-step-icon {
        width: 2.15rem;
        height: 2.15rem;
        font-size: 0.85rem;
    }

    .redeem-step-arrow {
        width: 1.1rem;
        height: 2.15rem;
    }

    .redeem-step-label {
        font-size: 0.68rem;
        max-width: 4.4rem;
    }
}
