:root {
    --bg: #eef1fb;
    --card: #ffffff;
    --ink: #181d2e;
    --muted: #6b7385;
    --line: #e7eaf3;

    /* Vibrant brand identity */
    --brand: #5b5bf0;
    --brand-2: #2b8bff;
    --brand-3: #9b4dff;
    --brand-ink: #ffffff;
    --brand-grad: linear-gradient(135deg, #7b4dff 0%, #5b5bf0 45%, #2b8bff 100%);
    --brand-soft: rgba(91, 91, 240, .12);

    /* Status colours */
    --ok: #0a9d5a;
    --ok-bg: #d8f7e6;
    --ok-grad: linear-gradient(135deg, #10b981, #06b6a4);
    --due: #e0344b;
    --due-bg: #ffe2e6;
    --due-grad: linear-gradient(135deg, #fb5a6f, #e0344b);
    --pending: #c47f12;
    --pending-bg: #fdf0d6;
    --pending-grad: linear-gradient(135deg, #fbbf24, #f59e0b);

    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 2px 6px rgba(30, 35, 80, .05), 0 12px 32px rgba(40, 50, 110, .08);
    --shadow-lift: 0 10px 24px rgba(40, 50, 110, .12), 0 24px 60px rgba(40, 50, 110, .14);
    --shadow-brand: 0 8px 22px rgba(91, 91, 240, .38);
    font-synthesis: none;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    background-color: var(--bg);
    background-image:
        radial-gradient(40rem 40rem at 110% -10%, rgba(155, 77, 255, .18), transparent 60%),
        radial-gradient(36rem 36rem at -10% 0%, rgba(43, 139, 255, .16), transparent 55%),
        radial-gradient(44rem 44rem at 50% 120%, rgba(16, 185, 129, .10), transparent 60%);
    background-attachment: fixed;
    min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--brand-3); text-decoration: none; }

.container { max-width: 980px; margin: 0 auto; padding: 28px 20px; }
.container.narrow { max-width: 560px; }

/* Top bar — frosted glass */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid rgba(231, 234, 243, .9);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; max-width: 980px; margin: 0 auto; padding: 14px 20px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.brand > span:last-child {
    background: var(--brand-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    background: var(--brand-grad); color: var(--brand-ink);
    border-radius: 11px; font-size: 14px; font-weight: 800;
    box-shadow: var(--shadow-brand);
}
.topbar-tag { color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-search input { width: 180px; max-width: 42vw; padding: 7px 14px; border-radius: 999px;
    border: 1.5px solid var(--line); font-size: 14px; background: #fff; }
.topbar-user { color: var(--ink); font-size: 14px; font-weight: 600; }
.topbar-link { font-size: 14px; font-weight: 600; }
.logout-form { margin: 0; }

/* Role pill + selects + checkboxes */
.pill-role { background: var(--brand-soft); color: var(--brand); }
select {
    padding: 11px 13px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    font-size: 15px; width: 100%; background: #fff; color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.check input { width: auto; accent-color: var(--brand); }
/* Radio option: input and label text start at the same horizontal point across stacked options. */
.radio { display: flex; align-items: flex-start; gap: 7px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.radio input[type=radio] { flex-shrink: 0; margin-top: 3px; width: auto; accent-color: var(--brand); }
.radio-group { display: flex; flex-direction: column; gap: 4px; }

/* Stacked admin cards + danger zone */
.form + .form { margin-top: 20px; }
.danger-zone { border: 1.5px solid var(--due-bg); }
.danger-zone h2 { margin-top: 0; color: var(--due); }
.btn-danger { background: var(--due-grad); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(224, 52, 75, .32); }
.btn-danger:hover { filter: brightness(1.05); }

/* Login page — gradient hero */
.login-body {
    /* Calm blue-to-teal, matching the iBus app instead of the harsh purple glow. */
    background: linear-gradient(135deg, #0078d7 0%, #00b294 100%);
    background-attachment: fixed;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 390px;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    box-shadow: 0 24px 70px rgba(0, 60, 90, .28);
}
.login-brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 19px; margin-bottom: 20px; }
.login-brand > span:last-child {
    background: linear-gradient(135deg, #0078d7 0%, #00b294 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.login-card h1 { margin-bottom: 18px; }
.login-card .field { margin-bottom: 16px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
/* Keep the login screen on the calm blue-teal accent (scoped so the rest of the app is unchanged). */
.login-card .brand-mark { background: linear-gradient(135deg, #0078d7, #00b294); box-shadow: 0 8px 22px rgba(0, 120, 215, .32); }
.login-card .btn-primary { background: linear-gradient(135deg, #0078d7, #00b294); box-shadow: 0 8px 22px rgba(0, 120, 215, .32); }
.login-card .btn-primary:hover { box-shadow: 0 12px 28px rgba(0, 120, 215, .42); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* Headings */
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 30px 0 12px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.back {
    display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px;
    color: var(--muted); font-size: 14px; font-weight: 600;
}
.back:hover { color: var(--brand); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.account-actions form { margin: 0; }

/* Per-school staff accounts: stacked rows that wrap within the card (no horizontal overflow). */
.account-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.account-row:last-of-type { border-bottom: none; }
.account-info { display: flex; flex-direction: column; gap: 4px; }
.account-info > div:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.account-controls form { margin: 0; display: flex; gap: 6px; align-items: center; }
.account-controls input { width: 150px; max-width: 45vw; padding: 7px 10px; }

/* Keep any wide table contained within its card instead of spilling out. */
.table-scroll { overflow-x: auto; }

/* Search */
.search { display: flex; gap: 8px; }
.search input { width: 280px; max-width: 60vw; }

/* Table */
.table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--card); border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); margin-top: 16px;
}
.table th, .table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.table th {
    font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
    background: linear-gradient(180deg, #f7f8fe, #f1f3fb);
}
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: var(--brand-soft); }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }

/* Cards */
.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px; border: 1px solid rgba(255, 255, 255, .6);
}
.student-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.center-card { text-align: center; }

/* Error pages */
.error-card { padding: 36px 28px 30px; }
.error-code {
    font-size: 76px; font-weight: 800; line-height: 1; letter-spacing: -.04em; margin-bottom: 8px;
    background: var(--brand-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.error-card h1 { margin-bottom: 8px; }
.error-card .btn { margin-top: 8px; }

/* Stat tiles — each gets its own accent */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.stat {
    position: relative; overflow: hidden;
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 18px 18px 20px; display: flex; flex-direction: column; gap: 5px;
    transition: transform .18s ease, box-shadow .18s ease;
}
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.stat:nth-child(1)::before { background: var(--brand-grad); }
.stat:nth-child(2)::before { background: var(--ok-grad); }
.stat:nth-child(3)::before { background: var(--due-grad); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat-value.ok { color: var(--ok); }
.stat-value.due { color: var(--due); }
/* Any positive amount owed on a balance sheet is shown in red. */
.owed-red { color: var(--due); font-weight: 700; }

/* Pills */
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .01em; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-due { background: var(--due-bg); color: var(--due); }
.pill-fail { background: var(--due-bg); color: var(--due); }
.pill-pending { background: var(--pending-bg); color: var(--pending); }

/* Import progress bar */
.progress { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 16px 0; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .25s ease; }

/* Buttons */
.btn {
    display: inline-block; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--line);
    background: var(--card); color: var(--ink); font-weight: 700; cursor: pointer; font-size: 14px;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; border-color: #cdd5e6; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand-grad); border-color: transparent; color: var(--brand-ink); box-shadow: var(--shadow-brand); }
.btn-primary:hover { color: var(--brand-ink); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(91, 91, 240, .48); }
.btn-lg { padding: 13px 26px; font-size: 15px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Forms */
input[type=text], input[type=tel], input[type=number], input[type=password], .search input {
    padding: 11px 13px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    font-size: 15px; width: 100%; background: #fff; color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
button { font-family: inherit; }

/* File picker (e.g. the class-list upload): make the chooser large and legible, not the tiny default. */
input[type=file] {
    display: block; width: 100%; box-sizing: border-box; cursor: pointer;
    padding: 14px; border: 2px dashed var(--line); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink); font-size: 15px;
}
input[type=file]::file-selector-button {
    margin-right: 16px; padding: 12px 24px; font-size: 15px; font-weight: 700;
    border: none; border-radius: 999px; cursor: pointer;
    background: var(--brand-grad); color: var(--brand-ink); box-shadow: var(--shadow-brand);
}
input[type=file]::-webkit-file-upload-button {
    margin-right: 16px; padding: 12px 24px; font-size: 15px; font-weight: 700;
    border: none; border-radius: 999px; cursor: pointer;
    background: var(--brand-grad); color: var(--brand-ink); box-shadow: var(--shadow-brand);
}
input[type=file]::file-selector-button:hover { filter: brightness(1.05); }
input[type=file]:hover { border-color: var(--brand); }
.form .field { border: none; padding: 0; margin: 0 0 22px; }
.form legend { font-weight: 700; font-size: 14px; padding: 0; margin-bottom: 9px; }
.hint { display: block; color: var(--muted); font-size: 12.5px; margin-top: 7px; }

/* Provider chooser */
.providers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.provider {
    position: relative; display: flex; flex-direction: column; gap: 2px;
    border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 15px; cursor: pointer;
    background: #fff; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.provider:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.provider input { position: absolute; opacity: 0; }
.provider-name { font-weight: 700; }
.provider-selected { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.provider-disabled { opacity: .5; cursor: not-allowed; }
.provider-disabled:hover { transform: none; box-shadow: none; }
.provider-soon { font-size: 11px; color: var(--pending); font-weight: 700; }

/* Alerts */
.alert { padding: 13px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.alert-error { background: var(--due-bg); color: var(--due); }

.empty {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 32px; text-align: center; color: var(--muted); margin-top: 16px;
}

/* Status card */
.status-card { text-align: center; }
.status-icon { display: grid; place-items: center; margin: 6px 0 16px; min-height: 64px; }
.spinner {
    width: 48px; height: 48px; border: 4px solid var(--brand-soft);
    border-top-color: var(--brand); border-right-color: var(--brand-3);
    border-radius: 50%; animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.badge {
    width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
    font-size: 28px; color: #fff;
}
.badge-ok { background: var(--ok-grad); box-shadow: 0 10px 26px rgba(16, 185, 129, .42); }
.badge-fail { background: var(--due-grad); box-shadow: 0 10px 26px rgba(224, 52, 75, .42); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; text-align: left; margin: 20px 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-size: 14px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }

/* Pay screen fee breakdown */
.quote-box {
    margin: 4px 0 18px; padding: 14px 16px; border: 1px solid var(--brand-soft);
    border-radius: 12px; background: var(--brand-soft);
}
.quote-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; color: var(--muted); }
.quote-total { margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(0, 0, 0, .08); font-weight: 700; font-size: 16px; color: var(--ink, inherit); }

.footer { text-align: center; color: var(--muted); padding: 28px 0 44px; }

@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    .providers { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation-duration: .001ms !important; }
}

/* Printable receipts / balance sheets */
@media print {
    .topbar, .footer, .no-print { display: none !important; }
    body { background: #fff !important; }
    body::before, body::after { display: none !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd; }
}
.doc-actions { display: flex; gap: 10px; margin: 16px 0; justify-content: flex-end; flex-wrap: wrap; }
.idbox { text-align: center; border: 1px dashed var(--brand); border-radius: 12px; padding: 14px;
    background: var(--brand-soft); margin: 16px 0; }
.idbox-label { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.idbox-value { display: block; font-size: 24px; font-weight: 800; letter-spacing: .04em; color: var(--brand); margin-top: 4px; }
.payout-form { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.payout-form input { width: 150px; max-width: 45vw; padding: 7px 10px; }
.payout-dest { width: auto; padding: 7px 10px; }
.sortable-col { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-col.sort-asc::after { content: ' \25B2'; font-size: 9px; opacity: .8; }
.sortable-col.sort-desc::after { content: ' \25BC'; font-size: 9px; opacity: .8; }
.doc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.doc-head-center { text-align: center; margin-bottom: 18px; }
.doc-head-center h1 { margin: 0 0 6px 0; }
.doc-head-center .doc-meta { margin: 2px 0; }
.doc-meta { color: var(--muted); font-size: 13px; }

/* Parent browse: tappable school/class cards */
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 8px; }
.link-card { display: flex; flex-direction: column; gap: 4px; padding: 18px; transition: transform .12s ease, box-shadow .12s ease; }
.link-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.link-card-title { font-weight: 700; font-size: 17px; color: var(--ink); }
