/* ==========================================================================
   SasiPay - Application stylesheet
   Layered on top of Bootstrap 5.3. Brand colours arrive as CSS variables from
   includes/header.php so Admin -> Settings can rebrand the whole app.
   ========================================================================== */

:root {
    --primary: #0B3D91;
    --primary-rgb: 11, 61, 145;
    --primary-dark: #072a66;
    --primary-light: #2f66c4;
    --secondary: #00B67A;
    --secondary-rgb: 0, 182, 122;
    --secondary-dark: #009463;

    --ink: #101828;
    --ink-soft: #344054;
    --muted: #667085;
    --faint: #98a2b3;
    --line: #e4e7ec;
    --line-soft: #f2f4f7;
    --surface: #ffffff;
    --canvas: #f1f4f9;

    --ok: #12b76a;
    --ok-bg: #e7f8f0;
    --warn: #f79009;
    --warn-bg: #fff6e5;
    --bad: #f04438;
    --bad-bg: #fdeceb;
    --info: #0ba5ec;
    --info-bg: #e6f6fe;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow: 0 4px 16px rgba(16, 24, 40, .07);
    --shadow-lg: 0 12px 40px rgba(16, 24, 40, .12);

    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --header-h: 64px;

    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--canvas);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4, h5 { font-weight: 650; letter-spacing: -.015em; color: var(--ink); }

.mono, code, kbd, pre { font-family: var(--mono); }
code {
    background: var(--line-soft);
    padding: .15em .45em;
    border-radius: 5px;
    font-size: .875em;
    color: var(--primary-dark);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.app-body { padding-left: var(--sidebar-w); transition: padding-left .22s ease; }
.app-body.sidebar-collapsed { padding-left: var(--sidebar-w-collapsed); }

.main-content { min-height: 100vh; padding: 24px 28px 64px; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head h1 { font-size: 24px; margin: 0 0 3px; }
.page-head .lede { color: var(--muted); margin: 0; font-size: 14px; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--ink);
    color: #cdd5e0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width .22s ease, transform .22s ease;
}
.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -.02em;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar-brand:hover { color: #fff; }
.brand-logo {
    display: block;
    width: auto;
    max-width: min(180px, 52vw);
    height: 34px;
    object-fit: contain;
    object-position: left center;
}
.brand-logo-on-dark {
    padding: 4px 7px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .96);
}
.sidebar-brand-mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    display: grid; place-items: center;
    font-size: 15px; font-weight: 800; color: #fff;
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 30px;
    height: 30px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}
.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-section-label,
.sidebar-collapsed .nav-link span,
.sidebar-collapsed .sidebar-user-meta { display: none; }

.sidebar-toggle {
    background: rgba(255, 255, 255, .07);
    border: 0; color: #cdd5e0;
    width: 28px; height: 28px;
    border-radius: 7px;
    display: grid; place-items: center;
    cursor: pointer;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.sidebar-collapsed .sidebar-toggle i { transform: rotate(180deg); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 3px; }

.sidebar-section-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #6b7789;
    font-weight: 700;
    padding: 16px 12px 7px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: #cdd5e0;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    position: relative;
}
.sidebar .nav-link i { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar .nav-link.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar .nav-link .badge-count {
    margin-left: auto;
    background: var(--bad);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    min-width: 19px;
    text-align: center;
}
.sidebar-collapsed .nav-link .badge-count {
    position: absolute; top: 4px; right: 6px; margin: 0; padding: 0;
    width: 7px; height: 7px; min-width: 0; border-radius: 50%; font-size: 0;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, .07);
    padding: 12px 10px;
    flex-shrink: 0;
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    color: #cdd5e0;
}
.sidebar-user:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary-light);
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.sidebar-user-meta { overflow: hidden; }
.sidebar-user-meta strong { display: block; font-size: 13px; color: #fff; font-weight: 600; }
.sidebar-user-meta small { color: #8b95a6; font-size: 11.5px; }

/* Mobile sidebar */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(16, 24, 40, .5);
    z-index: 1035;
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

.mobile-bar {
    display: none;
    position: sticky; top: 0; z-index: 1020;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}
.mobile-bar button {
    background: none; border: 0; font-size: 22px;
    color: var(--ink); padding: 0; line-height: 1;
}

@media (max-width: 991.98px) {
    .app-body, .app-body.sidebar-collapsed { padding-left: 0; }
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-collapsed .sidebar-brand-text,
    .sidebar-collapsed .nav-link span,
    .sidebar-collapsed .sidebar-section-label,
    .sidebar-collapsed .sidebar-user-meta { display: revert; }
    .mobile-bar { display: flex; }
    .main-content { padding: 18px 16px 56px; }
    .page-head h1 { font-size: 21px; }
}

/* ==========================================================================
   Cards & stats
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 15px 20px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
}
.card-header h2, .card-header h3 { font-size: 15.5px; margin: 0; font-weight: 650; }
.card-body { padding: 20px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-label {
    font-size: 12px; text-transform: uppercase; letter-spacing: .055em;
    color: var(--muted); font-weight: 650; margin-bottom: 7px;
    display: flex; align-items: center; gap: 6px;
}
.stat-value { font-size: 25px; font-weight: 750; letter-spacing: -.025em; line-height: 1.15; }
.stat-value .cur { font-size: 14px; font-weight: 600; color: var(--muted); margin-right: 3px; }
.stat-meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.stat-meta .up { color: var(--ok); font-weight: 600; }
.stat-meta .down { color: var(--bad); font-weight: 600; }

.stat.accent-primary { border-left: 3px solid var(--primary); }
.stat.accent-ok { border-left: 3px solid var(--ok); }
.stat.accent-warn { border-left: 3px solid var(--warn); }
.stat.accent-bad { border-left: 3px solid var(--bad); }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    margin: 0;
    font-size: 14px;
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    background: var(--line-soft);
    color: var(--ink-soft);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .055em;
    font-weight: 700;
    padding: 11px 16px;
    border: 0;
    white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
}
.table tbody td {
    padding: 13px 16px;
    border-top: 1px solid var(--line);
    vertical-align: middle;
}
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .ref { font-family: var(--mono); font-size: 12.5px; }

/* Merchant collections stay within the content area on desktop and become
   scan-friendly payment cards on phones. */
.collections-table-wrap { width: 100%; overflow: visible; }
.collections-table { table-layout: fixed; }
.collections-table .col-api { width: 15%; }
.collections-table .col-customer { width: 23%; }
.collections-table .col-money { width: 9%; }
.collections-table .col-status { width: 12%; }
.collections-table .col-created { width: 11%; }
.collections-table .col-actions { width: 72px; }
.collections-table td { overflow-wrap: anywhere; }
.collection-actions { white-space: nowrap; }

@media (max-width: 1199.98px) {
    .collections-table thead th,
    .collections-table tbody td { padding-left: 10px; padding-right: 10px; }
    .collections-table { font-size: 13px; }
}

@media (max-width: 767.98px) {
    .collections-list-card { border: 0; background: transparent; box-shadow: none; }
    .collections-table,
    .collections-table tbody { display: block; }
    .collections-table colgroup,
    .collections-table thead { display: none; }
    .collections-table tbody { display: grid; gap: 12px; }
    .collections-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 16px;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }
    .collections-table tbody tr:hover { background: var(--surface); }
    .collections-table tbody td {
        display: grid;
        align-content: start;
        gap: 4px;
        min-width: 0;
        padding: 11px 14px;
        border-top: 1px solid var(--line-soft);
        text-align: left !important;
        white-space: normal;
    }
    .collections-table tbody td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 10.5px;
        font-weight: 700;
        letter-spacing: .055em;
        text-transform: uppercase;
    }
    .collections-table tbody td:nth-child(1) { border-top: 0; }
    .collections-table tbody td:nth-child(1),
    .collections-table tbody td:nth-child(2) { grid-column: 1 / -1; }
    .collections-table tbody td:nth-child(2),
    .collections-table tbody td:last-child { grid-column: 1 / -1; }
    .collections-table .truncate { max-width: 100% !important; }
    .collections-table .collection-actions {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 8px;
        background: var(--line-soft);
    }
    .collections-table .collection-actions::before { margin-right: auto; }
    .collections-list-card > .card-body { padding-left: 0; padding-right: 0; }
}

.empty-state { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-state i { font-size: 40px; color: var(--faint); display: block; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; margin: 0 0 5px; color: var(--ink-soft); }
.empty-state p { margin: 0 0 18px; font-size: 14px; }

/* ==========================================================================
   Badges, buttons, forms
   ========================================================================== */

.badge-status {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status.success { background: var(--ok-bg); color: #08794a; }
.badge-status.warning { background: var(--warn-bg); color: #b54708; }
.badge-status.danger { background: var(--bad-bg); color: #b42318; }
.badge-status.info { background: var(--info-bg); color: #026aa2; }
.badge-status.secondary { background: var(--line-soft); color: var(--muted); }

.btn { font-weight: 600; border-radius: var(--radius-sm); padding: 8px 16px; font-size: 14px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-success { background: var(--secondary); border-color: var(--secondary); }
.btn-success:hover { background: var(--secondary-dark); border-color: var(--secondary-dark); }
.btn-light { background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft); }
.btn-light:hover { background: var(--line-soft); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .55; }

/* ==========================================================================
   Forms
   These override Bootstrap's defaults on the stock classes, so every existing
   form picks the new treatment up without markup changes. The extra component
   classes below (.field, .form-switch-row, .segmented, .money-input) are opt-in
   for the forms that deserve more.
   ========================================================================== */

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 650;
    letter-spacing: .008em;
    color: var(--ink-soft);
    margin-bottom: 6px;
}
.form-label .hint,
.form-label small { font-weight: 400; color: var(--muted); letter-spacing: 0; }
.form-label .req { color: var(--bad); margin-left: 2px; }

.form-control,
.form-select,
textarea.form-control {
    width: 100%;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 14.5px;
    font-family: inherit;
    line-height: 1.45;
    color: var(--ink);
    background-color: var(--surface);
    /* A hairline inset lifts the field off the card instead of looking pasted on */
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, .04);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
    appearance: none;
}
.form-control:hover:not(:disabled):not(:focus),
.form-select:hover:not(:disabled):not(:focus) { border-color: #cfd6e0; }

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    background-color: var(--surface);
    box-shadow: 0 0 0 3.5px rgba(var(--primary-rgb), .14), inset 0 1px 2px rgba(16, 24, 40, .03);
    outline: none;
}
.form-control::placeholder { color: var(--faint); opacity: 1; }

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: var(--line-soft);
    color: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
}

textarea.form-control { min-height: 84px; resize: vertical; }

/* Native spinners fight the tabular alignment on money fields */
.form-control[type="number"] { -moz-appearance: textfield; }
.form-control[type="number"]::-webkit-outer-spin-button,
.form-control[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Amounts, references and keys read better in figures that line up */
.form-control[type="number"],
.form-control[type="tel"],
.form-control.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.form-control.mono { font-family: var(--mono); font-size: 13.5px; }

.form-control-lg { padding: 13px 15px; font-size: 16px; border-radius: 11px; }
.form-select-sm, .form-control-sm { padding: 7px 11px; font-size: 13.5px; border-radius: 8px; }

/* Custom chevron — the native select arrow is the giveaway of an unstyled form */
.form-select {
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23667085' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}
.form-select-sm { padding-right: 32px; background-position: right 9px center; background-size: 14px; }

.form-text {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 5px;
    line-height: 1.5;
}

/* ---- Input groups: seamless affixes rather than bolted-on boxes ---------- */

.input-group > .form-control,
.input-group > .form-select { box-shadow: none; }
.input-group:focus-within {
    border-radius: 10px;
    box-shadow: 0 0 0 3.5px rgba(var(--primary-rgb), .14);
}
.input-group:focus-within > .form-control,
.input-group:focus-within > .form-select { box-shadow: none; }
.input-group:focus-within .input-group-text {
    border-color: var(--primary);
    color: var(--primary-dark);
    background: rgba(var(--primary-rgb), .05);
}
.input-group-text {
    background: var(--line-soft);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    padding: 10px 13px;
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

/* ---- Field with a leading icon ------------------------------------------ */

.field { position: relative; }
.field > .bi {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--faint);
    pointer-events: none;
    transition: color .15s ease;
    z-index: 3;
}
/* The direct-child form of these selectors would break the moment forms.js
   wraps a password input in .pw-wrap, so match at either depth. */
.field > .form-control,
.field > .pw-wrap > .form-control { padding-left: 40px; }
.field > .form-control-lg,
.field > .pw-wrap > .form-control-lg { padding-left: 44px; }
.field:has(.form-control-lg) > .bi { left: 15px; font-size: 17px; }
.field:focus-within > .bi { color: var(--primary); }
/* A password field carries an icon on the left and the toggle on the right */
.field > .pw-wrap { display: block; }

/* ---- Checkboxes and radios ---------------------------------------------- */

.form-check { padding-left: 1.85em; margin-bottom: .35rem; }
.form-check-input {
    width: 1.15em;
    height: 1.15em;
    margin-left: -1.85em;
    margin-top: .18em;
    border: 1.5px solid #c3cbd8;
    background-color: var(--surface);
    box-shadow: inset 0 1px 1px rgba(16, 24, 40, .04);
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
    cursor: pointer;
}
.form-check-input[type="checkbox"] { border-radius: 5px; }
.form-check-input:hover:not(:checked):not(:disabled) { border-color: var(--primary-light); }
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: none;
}
.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3.5px rgba(var(--primary-rgb), .14);
    outline: none;
}
.form-check-input:disabled { opacity: .5; cursor: not-allowed; }
.form-check-label { font-size: 14px; color: var(--ink-soft); cursor: pointer; line-height: 1.5; }
.form-check-label .form-text { margin-top: 2px; }

/* ---- Switch: for settings that are plainly on or off -------------------- */

.form-switch-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line-soft);
}
.form-switch-row:last-child { border-bottom: 0; }
.form-switch-row .switch-copy { flex: 1; min-width: 0; }
.form-switch-row .switch-copy strong { display: block; font-size: 14px; font-weight: 600; }
.form-switch-row .switch-copy span { font-size: 12.5px; color: var(--muted); display: block; margin-top: 3px; line-height: 1.5; }

.switch { position: relative; flex-shrink: 0; width: 44px; height: 25px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
    position: absolute; inset: 0;
    background: #ccd3de;
    border-radius: 25px;
    transition: background-color .2s ease;
    pointer-events: none;
}
.switch .track::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 19px; height: 19px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .28);
    transition: transform .2s cubic-bezier(.3, .8, .3, 1);
}
.switch input:checked + .track { background: var(--secondary); }
.switch input:checked + .track::after { transform: translateX(19px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3.5px rgba(var(--primary-rgb), .18); }

/* ---- Segmented control: nicer than two stacked radios ------------------- */

.segmented {
    display: inline-flex;
    padding: 3px;
    background: var(--line-soft);
    border: 1.5px solid var(--line);
    border-radius: 10px;
    gap: 3px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
    margin: 0;
    padding: 7px 15px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--muted);
    border-radius: 7px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
    white-space: nowrap;
}
.segmented label:hover { color: var(--ink-soft); }
.segmented input:checked + label {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.segmented input:focus-visible + label { box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .2); }

/* ---- Money input: the field that matters most --------------------------- */

.money-input { position: relative; }
.money-input .cur {
    position: absolute;
    left: 15px; top: 50%;
    transform: translateY(-50%);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    pointer-events: none;
    z-index: 3;
}
.money-input input {
    padding-left: 56px !important;
    font-size: 22px !important;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}
.money-input:focus-within .cur { color: var(--primary); }

/* ---- Validation states -------------------------------------------------- */

.form-control.is-invalid,
.form-select.is-invalid,
.was-validated .form-control:invalid {
    border-color: var(--bad);
    background-image: none;
}
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 3.5px rgba(240, 68, 56, .16);
}
.form-select.is-invalid { padding-right: 38px; }
.field-error {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--bad);
    margin-top: 5px;
}
.form-control.is-valid, .form-select.is-valid { border-color: var(--ok); }

/* ---- Grouping ----------------------------------------------------------- */

.form-section { margin-bottom: 26px; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .085em;
    color: var(--faint);
    margin-bottom: 14px;
}
.form-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 18px;
    margin-top: 22px;
    border-top: 1px solid var(--line);
}
.form-actions .spacer { flex: 1; }

/* ---- Platform brand assets --------------------------------------------- */

.brand-assets-grid { display: grid; gap: 10px; }
.brand-asset {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
}
.brand-asset-preview {
    height: 66px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #eef1f5 25%, transparent 25%),
        linear-gradient(-45deg, #eef1f5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eef1f5 75%),
        linear-gradient(-45deg, transparent 75%, #eef1f5 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    display: grid;
    place-items: center;
    overflow: hidden;
}
.brand-asset-preview img { display: block; width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.brand-asset-preview.square img { width: 58px; }
.brand-file-input { max-width: 260px; }

@media (max-width: 575.98px) {
    .brand-asset { grid-template-columns: 72px minmax(0, 1fr); gap: 10px; }
    .brand-asset-preview { height: 64px; }
    .brand-asset-copy .btn { width: 100%; }
    .brand-file-input { max-width: none; width: 100%; }
}

/* ---- Filter bar --------------------------------------------------------- */

.filter-bar {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.filter-bar .form-label { margin-bottom: 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.filter-bar > div { min-width: 150px; }

/* ---- Password field affordances (see assets/js/forms.js) ---------------- */

.pw-wrap { position: relative; display: block; }
.pw-wrap .form-control { padding-right: 44px; }
.pw-toggle {
    position: absolute;
    top: 50%; right: 6px;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border: 0; padding: 0;
    background: transparent;
    color: var(--faint);
    border-radius: 7px;
    cursor: pointer;
    z-index: 4;
    transition: color .15s ease, background-color .15s ease;
}
.pw-toggle:hover { color: var(--ink-soft); background: var(--line-soft); }
.pw-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .22); color: var(--primary); }
.pw-toggle .bi { font-size: 16px; pointer-events: none; }
/* Inside an input group the toggle must clear the trailing affix */
.input-group .pw-wrap { flex: 1 1 auto; width: 1%; }

.pw-meter { margin-top: 8px; }
.pw-meter-track {
    height: 4px;
    border-radius: 3px;
    background: var(--line);
    overflow: hidden;
    display: flex;
    gap: 3px;
}
.pw-meter-track i {
    flex: 1;
    background: var(--line);
    border-radius: 3px;
    transition: background-color .25s ease;
}
.pw-meter-label {
    display: flex; justify-content: space-between; gap: 10px;
    font-size: 11.5px; font-weight: 600;
    margin-top: 5px;
    color: var(--muted);
}
.pw-meter[data-score="1"] .pw-meter-track i:nth-child(-n+1),
.pw-meter[data-score="2"] .pw-meter-track i:nth-child(-n+2) { background: var(--bad); }
.pw-meter[data-score="3"] .pw-meter-track i:nth-child(-n+3) { background: var(--warn); }
.pw-meter[data-score="4"] .pw-meter-track i { background: var(--ok); }
.pw-meter[data-score="1"] .pw-meter-label b,
.pw-meter[data-score="2"] .pw-meter-label b { color: var(--bad); }
.pw-meter[data-score="3"] .pw-meter-label b { color: #b54708; }
.pw-meter[data-score="4"] .pw-meter-label b { color: #08794a; }

.pw-caps {
    display: none;
    align-items: center; gap: 5px;
    font-size: 12px; font-weight: 600;
    color: #b54708;
    margin-top: 6px;
}
.pw-caps.on { display: flex; }

/* ==========================================================================
   Secret reveal (API keys, webhook secrets)
   ========================================================================== */

.secret-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--line-soft);
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font-family: var(--mono);
    font-size: 13px;
    word-break: break-all;
}
.secret-box .value { flex: 1; min-width: 0; }
.secret-box.masked .value { letter-spacing: .12em; }
.secret-warning {
    background: var(--warn-bg);
    border-left: 3px solid var(--warn);
    border-radius: var(--radius-sm);
    padding: 12px 15px;
    font-size: 13.5px;
    color: #7a2e0e;
}

/* ==========================================================================
   Code blocks (docs & integration snippets)
   ========================================================================== */

pre.code {
    background: #0d1424;
    color: #d6deeb;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 12.8px;
    line-height: 1.65;
    margin: 0;
    tab-size: 2;
}
pre.code .k { color: #c792ea; }
pre.code .s { color: #ecc48d; }
pre.code .n { color: #f78c6c; }
pre.code .c { color: #637777; font-style: italic; }
pre.code .p { color: #82aaff; }

.code-tabs { display: flex; gap: 4px; margin-bottom: -1px; flex-wrap: wrap; }
.code-tab {
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
}
.code-tab.active { color: var(--primary); background: var(--surface); border-color: var(--line); border-bottom-color: var(--surface); }

/* ==========================================================================
   Auth pages
   ========================================================================== */

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside {
    background: linear-gradient(150deg, var(--primary-dark), var(--primary) 55%, var(--secondary-dark));
    color: #fff;
    padding: 56px 52px;
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-aside::after {
    content: ''; position: absolute; right: -120px; bottom: -140px;
    width: 420px; height: 420px; border-radius: 50%;
    background: rgba(255, 255, 255, .06);
}
.auth-aside h2 { color: #fff; font-size: 30px; line-height: 1.25; margin: 0 0 14px; max-width: 15em; }
.auth-aside p { color: rgba(255, 255, 255, .82); font-size: 15px; max-width: 30em; }
.auth-points { list-style: none; padding: 0; margin: 30px 0 0; }
.auth-points li { display: flex; gap: 11px; margin-bottom: 15px; font-size: 14.5px; color: rgba(255, 255, 255, .92); }
.auth-points i { color: var(--secondary); font-size: 18px; flex-shrink: 0; }

.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 25px; margin: 0 0 6px; }
.auth-card .lede { color: var(--muted); margin: 0 0 28px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 20px; color: var(--ink); margin-bottom: 34px; }
.turnstile-wrap { width: 100%; min-height: 1px; overflow: hidden; }
.turnstile-wrap > div:first-child { width: 100%; }

.api-breakdown-list { display: grid; }
.api-breakdown-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.7fr) repeat(3, minmax(110px, 1fr));
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
}
.api-breakdown-row:first-child { border-top: 0; }
.api-breakdown-row > div:not(.api-breakdown-name) { display: grid; gap: 2px; }
.api-breakdown-row small { color: var(--muted); font-size: 11px; }
.api-breakdown-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.api-breakdown-name > i {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 6px;
    background: rgba(var(--primary-rgb), .09);
    color: var(--primary);
}
.api-breakdown-name > div { min-width: 0; display: grid; }
.api-breakdown-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 575.98px) {
    .api-breakdown-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 16px;
        padding: 14px 16px;
    }
    .api-breakdown-name { grid-column: 1 / -1; }
    .api-breakdown-row > .num { text-align: left !important; }
}

@media (max-width: 991.98px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* ==========================================================================
   Hosted payment page (/pay/{code}) and receipt
   ========================================================================== */

.pay-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: var(--canvas); }
.pay-card {
    width: 100%; max-width: 448px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.pay-head { padding: 30px 30px 22px; text-align: center; border-bottom: 1px solid var(--line); }
.pay-merchant-logo {
    width: 62px; height: 62px; border-radius: 15px;
    object-fit: cover; margin: 0 auto 14px; display: block;
    border: 1px solid var(--line); background: var(--line-soft);
}
.pay-merchant-fallback {
    width: 62px; height: 62px; border-radius: 15px; margin: 0 auto 14px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; font-size: 24px; font-weight: 750;
}
.pay-merchant-name { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.pay-title { font-size: 19px; font-weight: 650; margin: 0 0 8px; }
.pay-amount { font-size: 33px; font-weight: 780; letter-spacing: -.03em; color: var(--primary); }
.pay-amount .cur { font-size: 16px; font-weight: 600; color: var(--muted); }
.pay-body { padding: 26px 30px 30px; }
.pay-footer {
    padding: 15px 30px; background: var(--line-soft);
    text-align: center; font-size: 12px; color: var(--muted);
    border-top: 1px solid var(--line);
}
.pay-footer strong { color: var(--ink-soft); }

.pay-network-hints { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.pay-network-hints span {
    font-size: 11px; padding: 3px 9px; border-radius: 20px;
    background: var(--line-soft); color: var(--muted); font-weight: 600;
}

.pay-status { text-align: center; padding: 12px 0; }
.pay-spinner {
    width: 46px; height: 46px; margin: 0 auto 18px;
    border: 3.5px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: pay-spin .85s linear infinite;
}
@keyframes pay-spin { to { transform: rotate(360deg); } }

.pay-result-icon {
    width: 66px; height: 66px; border-radius: 50%;
    display: grid; place-items: center; margin: 0 auto 18px;
    font-size: 33px;
}
.pay-result-icon.ok { background: var(--ok-bg); color: var(--ok); }
.pay-result-icon.bad { background: var(--bad-bg); color: var(--bad); }

.receipt-row {
    display: flex; justify-content: space-between; gap: 16px;
    padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px;
}
.receipt-row:last-child { border-bottom: 0; }
.receipt-row dt { color: var(--muted); font-weight: 500; margin: 0; }
.receipt-row dd { margin: 0; font-weight: 600; text-align: right; word-break: break-all; }

/* ==========================================================================
   Misc
   ========================================================================== */

.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 9px; }
.toast-item {
    background: var(--ink); color: #fff;
    padding: 12px 17px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 14px; font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    animation: toast-in .22s ease;
    max-width: 380px;
}
.toast-item.ok { background: #05603a; }
.toast-item.bad { background: #912018; }
@keyframes toast-in { from { opacity: 0; transform: translateX(22px); } }

.alert { border: 0; border-radius: var(--radius-sm); font-size: 14px; padding: 12px 16px; }
.alert-success { background: var(--ok-bg); color: #05603a; }
.alert-danger { background: var(--bad-bg); color: #912018; }
.alert-warning { background: var(--warn-bg); color: #7a2e0e; }
.alert-info { background: var(--info-bg); color: #065986; }

.pagination { margin: 0; }
.page-link { color: var(--ink-soft); border-color: var(--line); font-size: 13.5px; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

.nav-tabs { border-bottom-color: var(--line); }
.nav-tabs .nav-link { color: var(--muted); font-weight: 600; font-size: 14px; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--primary); background: transparent; border-bottom-color: var(--primary); }

.modal-content { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-size: 17px; }

.spinner-inline {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff;
    border-radius: 50%; animation: pay-spin .7s linear infinite;
    vertical-align: -2px;
}

.text-muted { color: var(--muted) !important; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }

@media print {
    .sidebar, .mobile-bar, .page-head-actions, .no-print { display: none !important; }
    .app-body { padding-left: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
