:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-soft: #f7f9fb;
    --ink: #152536;
    --muted: #687786;
    --line: #dce3e9;
    --navy: #0b1b2a;
    --navy-2: #132c42;
    --blue: #1769aa;
    --blue-dark: #0e4e83;
    --gold: #c59a42;
    --success: #177b57;
    --danger: #b33f49;
    --warning: #9a6518;
    --shadow: 0 14px 34px rgba(27, 45, 62, .08);
    --radius: 16px;
    --radius-sm: 10px;
    --max: 1440px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); color: var(--ink); }
body { margin: 0; min-height: 100vh; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; background: #edf2f6; padding: .16rem .35rem; border-radius: 5px; }

.bank-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 76px; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: white; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px max(22px, calc((100vw - var(--max)) / 2)); box-shadow: 0 4px 18px rgba(4, 17, 28, .22); position: relative; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: white; min-width: 0; }
.brand:hover { color: white; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-family: Georgia, serif; font-weight: 700; font-size: 22px; color: #f2d38e; background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.14), transparent 55%), #142f45; box-shadow: inset 0 0 0 3px rgba(197,154,66,.14); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: .01em; }
.brand small { color: rgba(255,255,255,.64); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.top-link { color: rgba(255,255,255,.78); padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.top-link:hover { color: white; background: rgba(255,255,255,.08); }
.top-link.danger:hover { background: rgba(179,63,73,.28); }

.admin-nav { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; padding: 0 max(22px, calc((100vw - var(--max)) / 2)); overflow-x: auto; white-space: nowrap; position: sticky; top: 0; z-index: 15; }
.admin-nav a { color: var(--muted); padding: 14px 13px 12px; border-bottom: 3px solid transparent; font-weight: 650; font-size: 14px; }
.admin-nav a:hover { color: var(--ink); }
.admin-nav a.active { color: var(--blue-dark); border-color: var(--blue); }

.page-wrap { width: min(var(--max), calc(100% - 32px)); margin: 0 auto; padding: 28px 0 44px; flex: 1; }
.site-footer { display: flex; justify-content: space-between; gap: 24px; color: #74818d; font-size: 12px; border-top: 1px solid var(--line); width: min(var(--max), calc(100% - 32px)); margin: 0 auto; padding: 20px 0 26px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-kicker, .eyebrow { display: inline-block; color: var(--blue-dark); font-size: 11px; text-transform: uppercase; letter-spacing: .13em; font-weight: 800; }
.eyebrow { color: var(--gold); }
.muted { color: var(--muted); }
.optional { color: var(--muted); font-weight: 400; font-size: .88em; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 3.2vw, 44px); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin-bottom: 8px; font-size: 21px; letter-spacing: -.015em; }
p { color: var(--muted); }

.alert { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; border: 1px solid; box-shadow: 0 10px 25px rgba(30,44,58,.06); }
.alert-success { color: #0f6748; background: #e9f7f1; border-color: #bde4d4; }
.alert-error { color: #8f2b35; background: #fff0f1; border-color: #f0c5ca; }
.alert-warning { color: #82520f; background: #fff8e8; border-color: #edd8a9; }
.alert-close { border: 0; background: transparent; color: inherit; font-size: 24px; line-height: 1; opacity: .7; }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; transition: .16s ease; text-decoration: none; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--blue); color: white; border-color: var(--blue); box-shadow: 0 7px 17px rgba(23,105,170,.2); }
.btn-primary:hover { background: var(--blue-dark); color: white; }
.btn-secondary { background: #fff; color: var(--ink); border-color: #cad5de; }
.btn-secondary:hover { border-color: #9fb0be; color: var(--blue-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: #efc1c6; }
.btn-large { min-height: 50px; padding-inline: 22px; }
.btn-small { min-height: 34px; padding: 6px 10px; border-radius: 8px; font-size: 13px; }

.stack-form { display: grid; gap: 15px; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 13px; color: #34485a; }
input, select, textarea { width: 100%; border: 1px solid #cfd9e1; background: #fff; color: var(--ink); border-radius: 9px; padding: 10px 11px; min-height: 42px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus { border-color: #4b91c7; box-shadow: 0 0 0 3px rgba(23,105,170,.12); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; min-height: 0; padding: 0; accent-color: var(--blue); }
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.field-help { margin: 0; font-size: 12px; color: var(--muted); }
.radio-row, .check-row { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-radius: 9px 0 0 9px; }
.input-suffix span { min-width: 50px; display: grid; place-items: center; border: 1px solid #cfd9e1; border-left: 0; border-radius: 0 9px 9px 0; background: #f1f5f8; color: #496173; font-weight: 800; }

.login-layout { min-height: calc(100vh - 190px); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); align-items: center; gap: clamp(32px, 7vw, 100px); padding: 40px 3vw; }
.login-copy { max-width: 720px; }
.login-copy h1 { color: var(--navy); margin-top: 12px; }
.login-copy > p { max-width: 620px; font-size: 17px; }
.feature-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 30px; }
.feature-strip div { border-left: 3px solid var(--gold); padding: 4px 12px; }
.feature-strip strong, .feature-strip span { display: block; }
.feature-strip span { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-card { padding: 28px; }
.login-card h2 { font-size: 28px; margin-top: 5px; }

.account-hero { border-radius: 20px; background: linear-gradient(135deg, var(--navy), #173c58); color: white; padding: 28px 30px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; box-shadow: 0 18px 38px rgba(11,27,42,.18); }
.account-hero h1 { margin-top: 7px; margin-bottom: 12px; font-size: clamp(28px, 4vw, 42px); }
.identity-line { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; color: rgba(255,255,255,.72); font-size: 13px; }
.identity-line strong { color: white; }
.faction-chip { display: inline-flex; align-items: center; gap: 7px; color: white; }
.faction-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--faction, #8b98a4); box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
.status-badge { display: inline-flex; align-items: center; gap: 6px; width: fit-content; border-radius: 999px; padding: 4px 8px; background: #edf1f4; color: #536473; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-ok { background: #e5f6ef; color: #126d4e; }
.status-danger { background: #fae9eb; color: #a3313d; }
.status-warning { background: #fff4db; color: #8a5b13; }
.account-hero .status-badge { margin-top: 4px; }

.announcement { margin-top: 16px; border: 1px solid #ead7ab; background: #fffaf0; border-radius: 12px; padding: 12px 15px; display: flex; gap: 14px; align-items: baseline; }
.announcement strong { color: #8a5c14; white-space: nowrap; }
.announcement span { color: #66563e; }

.summary-grid { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 16px; margin-top: 18px; }
.summary-grid .card { padding: 20px; min-height: 145px; display: flex; flex-direction: column; justify-content: space-between; }
.money-value { display: block; font-size: clamp(32px, 4vw, 50px); line-height: 1; letter-spacing: -.045em; color: var(--navy); }
.money-secondary { display: block; font-size: 23px; color: var(--navy); margin: 10px 0 4px; }
.account-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; color: var(--navy); margin: 12px 0 4px; }
.countdown { color: var(--blue-dark); font-size: 12px; font-weight: 800; margin-top: 5px; }

.bank-grid { display: grid; grid-template-columns: minmax(340px, .8fr) minmax(0, 1.2fr); gap: 18px; margin-top: 18px; align-items: start; }
.transfer-card, .statement-card, .admin-section { padding: 22px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 17px; }
.section-heading h2 { margin: 3px 0 0; }
.limit-note { color: var(--muted); font-size: 12px; white-space: nowrap; }
.transfer-form { display: grid; gap: 15px; }
.recipient-field { position: relative; }
.recipient-results { position: absolute; z-index: 30; top: calc(100% + 5px); left: 0; right: 0; background: white; border: 1px solid #cdd8e0; border-radius: 11px; box-shadow: 0 16px 35px rgba(17,35,51,.16); max-height: 330px; overflow-y: auto; }
.recipient-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; border: 0; border-bottom: 1px solid #edf1f4; background: white; text-align: left; padding: 11px 12px; color: var(--ink); }
.recipient-option:last-child { border-bottom: 0; }
.recipient-option:hover, .recipient-option:focus { background: #f3f7fa; }
.recipient-option strong, .recipient-option span { display: block; }
.recipient-option small { color: var(--muted); }
.selected-recipient { border: 1px solid #b9d7ea; background: #eff8fd; color: #154c70; padding: 9px 11px; border-radius: 9px; font-weight: 700; font-size: 13px; }
.inline-warning { border-radius: 10px; padding: 12px; background: #fff0f1; color: #922f39; border: 1px solid #efc8cd; }
.transaction-list { display: grid; }
.transaction-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 0; border-top: 1px solid #edf1f4; }
.transaction-row:first-child { border-top: 0; }
.tx-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; }
.tx-icon.in { color: #116a4b; background: #e4f6ee; }
.tx-icon.out { color: #a13541; background: #fbeaec; }
.tx-main { min-width: 0; }
.tx-main strong, .tx-main span, .tx-main small { display: block; }
.tx-main strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.tx-main small { color: #516474; font-size: 12px; margin-top: 3px; }
.tx-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-amount.positive { color: var(--success); }
.tx-amount.negative { color: var(--danger); }

.empty-state, .center-state { display: grid; place-items: center; text-align: center; gap: 5px; padding: 45px 25px; color: var(--muted); }
.empty-state strong, .center-state h1 { color: var(--ink); }
.empty-state span { font-size: 13px; }
.center-state { min-height: 350px; }
.state-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: #fff0f1; color: var(--danger); font-weight: 900; font-size: 25px; }

.admin-login { width: min(440px, 100%); margin: 70px auto; padding: 28px; }
.admin-login h1 { font-size: 31px; margin-top: 6px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 22px; margin-bottom: 22px; }
.page-heading h1 { margin-top: 7px; margin-bottom: 6px; }
.page-heading p { margin-bottom: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 18px; min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; }
.metric > span { color: var(--muted); font-weight: 700; font-size: 13px; }
.metric > strong { font-size: 29px; color: var(--navy); letter-spacing: -.035em; }
.metric > small { color: var(--muted); }
.metric .metric-small { font-size: 17px; letter-spacing: -.01em; }
.admin-section { margin-bottom: 18px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; color: #647482; text-transform: uppercase; letter-spacing: .07em; font-size: 10px; padding: 10px 11px; background: #f6f8fa; border-bottom: 1px solid var(--line); }
.data-table td { padding: 11px; border-bottom: 1px solid #edf1f4; vertical-align: middle; }
.data-table tbody tr:hover { background: #fafcfd; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td small { display: block; color: var(--muted); margin-top: 3px; }
.active-row { background: #f2f9f6; }
.actions-cell { display: flex; justify-content: flex-end; gap: 7px; }
.faction-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--faction, #9aa6af); margin-right: 7px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--faction, #9aa6af) 16%, transparent); }
.badge-stack { display: flex; flex-wrap: wrap; gap: 4px; }
.table-filter { width: min(300px, 100%); }

.filter-bar { display: grid; grid-template-columns: 1.2fr 1.4fr 1fr .8fr auto; gap: 12px; align-items: end; padding: 16px; margin-bottom: 15px; }
.bulk-layout { display: grid; gap: 15px; }
.bulk-panel { padding: 20px; }
.bulk-panel h2 { margin-top: 4px; }
.bulk-panel p { margin-bottom: 14px; }
.bulk-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); }
.player-table td:nth-child(2) { min-width: 190px; }
.pagination { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 15px; }
.pagination a { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: white; }
.pagination a.active { background: var(--blue); color: white; border-color: var(--blue); }
.event-picker { width: min(440px, 100%); margin-bottom: 15px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .65fr); gap: 18px; align-items: start; }
.settings-side { display: grid; gap: 18px; }
.section-divider { border-top: 1px solid var(--line); margin: 8px 0; }
.detail-list { display: grid; margin: 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid #edf1f4; }
.detail-list div:first-child { border-top: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 700; text-align: right; }

.install-page { background: radial-gradient(circle at 15% 10%, rgba(197,154,66,.15), transparent 30%), var(--navy); }
.install-wrap { width: min(900px, calc(100% - 28px)); margin: 35px auto; }
.install-card { background: white; border-radius: 22px; padding: clamp(22px, 5vw, 48px); box-shadow: 0 28px 70px rgba(0,0,0,.28); }
.install-brand { color: var(--navy); margin-bottom: 25px; }
.install-brand:hover { color: var(--navy); }
.install-brand small { color: var(--muted); }
.install-card .lead { font-size: 16px; max-width: 680px; }
.install-card fieldset { border: 1px solid var(--line); border-radius: 13px; padding: 18px; display: grid; gap: 13px; }
.install-card legend { padding: 0 8px; color: var(--navy); font-weight: 800; }

@media (max-width: 1100px) {
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .account-card { grid-column: span 2; }
    .bank-grid { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar .btn { align-self: end; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .topbar { min-height: 66px; padding: 10px 15px; }
    .brand strong { font-size: 15px; }
    .brand small { display: none; }
    .brand-mark { width: 38px; height: 38px; }
    .top-link { padding: 7px 8px; font-size: 13px; }
    .admin-nav { padding: 0 8px; }
    .admin-nav a { padding-inline: 10px; }
    .page-wrap { width: min(100% - 20px, var(--max)); padding-top: 18px; }
    .site-footer { width: calc(100% - 24px); flex-direction: column; gap: 5px; }
    .login-layout { grid-template-columns: 1fr; padding: 15px 0 30px; min-height: auto; }
    .login-copy { padding: 12px 5px; }
    .login-copy > p { font-size: 15px; }
    .feature-strip { grid-template-columns: 1fr; }
    .login-card { padding: 22px; }
    .account-hero { padding: 22px; flex-direction: column; }
    .identity-line { display: grid; gap: 6px; }
    .summary-grid { grid-template-columns: 1fr; }
    .account-card { grid-column: auto; }
    .summary-grid .card { min-height: 128px; }
    .transfer-card, .statement-card, .admin-section { padding: 16px; }
    .transaction-row { grid-template-columns: 34px minmax(0, 1fr); }
    .tx-amount { grid-column: 2; }
    .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .metric-grid { grid-template-columns: 1fr; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .filter-bar { grid-template-columns: 1fr; }
    .bulk-footer { align-items: stretch; flex-direction: column; }
    .bulk-footer .btn { width: 100%; }
    .section-heading { flex-direction: column; }
    .table-filter { width: 100%; }
    .actions-cell { flex-direction: column; align-items: stretch; }
    .announcement { align-items: flex-start; flex-direction: column; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Bank admin data tools and account drill-down */
.admin-split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.rank-list, .activity-list { display: grid; }
.rank-row, .activity-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid #edf1f4; color: var(--ink); }
.rank-row:first-child, .activity-row:first-child { border-top: 0; }
.rank-row:hover { color: var(--blue-dark); }
.rank-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #eef4f8; color: var(--blue-dark); font-size: 12px; font-weight: 850; }
.rank-person, .activity-row > span { min-width: 0; }
.rank-person strong, .rank-person small, .activity-row strong, .activity-row small { display: block; }
.rank-person small, .activity-row small { color: var(--muted); margin-top: 2px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-row { grid-template-columns: minmax(0, 1fr) auto; }
.text-link, .back-link { font-weight: 750; font-size: 13px; }
.back-link { display: inline-block; margin-bottom: 8px; }
.empty-state.compact { padding: 24px 12px; }
.table-heading { align-items: center; }
.table-actions { display: flex; align-items: end; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.compact-control { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.compact-control select { min-height: 34px; padding: 6px 30px 6px 9px; width: auto; min-width: 150px; }
.filter-bar-compact { grid-template-columns: 1.3fr 1fr .8fr auto; }
.account-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.account-admin-grid { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
.money-positive { color: var(--success); }
.money-negative { color: var(--danger); }
.player-table .actions-cell { min-width: 78px; }
.dataTables_wrapper .table-scroll { overflow-x: auto; }
.dataTables_wrapper input[type="search"], .dataTables_wrapper select { min-height: 36px; padding-top: 7px; padding-bottom: 7px; }
.dataTables_wrapper .data-table { margin-top: 0 !important; margin-bottom: 0 !important; }
.dataTables_wrapper .data-table td { background-clip: padding-box; }

@media (max-width: 1100px) {
    .account-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .admin-split-grid, .account-admin-grid { grid-template-columns: 1fr; }
    .account-metrics { grid-template-columns: 1fr; }
    .filter-bar-compact { grid-template-columns: 1fr; }
    .table-heading { align-items: stretch; }
    .table-actions { justify-content: stretch; align-items: stretch; flex-direction: column; width: 100%; }
    .table-actions .btn, .compact-control, .compact-control select { width: 100%; }
    .rank-row { grid-template-columns: auto minmax(0, 1fr); }
    .rank-row > strong { grid-column: 2; }
}
