/*
|--------------------------------------------------------------------------
| BizPilot AI — Responsive Design System
|--------------------------------------------------------------------------
| Deep forest-ink + warm brass
| Sora headings / Inter body
|--------------------------------------------------------------------------
*/

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');


/* ==========================================================================
   DESIGN TOKENS
   ========================================================================== */

:root {
    --font-display: 'Sora', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    --bg: #F6F7F5;
    --bg-elevated: #FFFFFF;
    --bg-sunken: #EEF1EC;

    --border: #DDE3DD;

    --text: #16211D;
    --text-muted: #57685F;

    --brand: #1B4B43;
    --brand-strong: #123832;
    --brand-tint: #E4EEEB;

    --accent: #C68A3B;
    --accent-strong: #A9722A;

    --danger: #B3422F;
    --success: #2F7A4F;

    --shadow:
        0 1px 2px rgba(15, 30, 25, 0.06),
        0 4px 12px rgba(15, 30, 25, 0.05);

    --shadow-lg:
        0 8px 30px rgba(15, 30, 25, 0.12);

    --radius: 10px;

    --sidebar-width: 240px;
    --topbar-height: 64px;
}


/* ==========================================================================
   DARK THEME
   ========================================================================== */

:root[data-theme="dark"] {
    --bg: #101714;
    --bg-elevated: #17211D;
    --bg-sunken: #0C1210;

    --border: #263129;

    --text: #EAF0EC;
    --text-muted: #93A69B;

    --brand: #4C9C87;
    --brand-strong: #6FB8A3;
    --brand-tint: #17302A;

    --accent: #E0A959;
    --accent-strong: #F0BE76;

    --danger: #E28270;
    --success: #6FC393;

    --shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        0 6px 16px rgba(0, 0, 0, 0.35);

    --shadow-lg:
        0 12px 35px rgba(0, 0, 0, 0.45);
}


@media (prefers-color-scheme: dark) {

    :root:not([data-theme="light"]) {
        --bg: #101714;
        --bg-elevated: #17211D;
        --bg-sunken: #0C1210;

        --border: #263129;

        --text: #EAF0EC;
        --text-muted: #93A69B;

        --brand: #4C9C87;
        --brand-strong: #6FB8A3;
        --brand-tint: #17302A;

        --accent: #E0A959;
        --accent-strong: #F0BE76;

        --danger: #E28270;
        --success: #6FC393;

        --shadow:
            0 1px 2px rgba(0, 0, 0, 0.3),
            0 6px 16px rgba(0, 0, 0, 0.35);
    }
}


/* ==========================================================================
   RESET
   ========================================================================== */

* {
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;

    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;

    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;

    margin: 0;
    padding: 0;

    background: var(--bg);
    color: var(--text);

    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;

    overflow-x: hidden;

    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}


img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}


button,
input,
select,
textarea {
    font: inherit;
}


button {
    cursor: pointer;
}


a {
    color: var(--brand);
}


:root[data-theme="dark"] a {
    color: var(--brand-strong);
}


/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

h1,
h2,
h3,
h4,
h5,
h6,
.brand-mark {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text);

    margin-top: 0;
    margin-bottom: 0.5em;

    line-height: 1.25;
}

h1 {
    font-size: 30px;
}

h2 {
    font-size: 24px;
}

h3 {
    font-size: 19px;
}

h4 {
    font-size: 16px;
}


/* ==========================================================================
   MAIN APPLICATION LAYOUT
   ========================================================================== */

.layout {
    display: flex;

    width: 100%;
    min-height: 100vh;

    position: relative;
}


/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
    width: var(--sidebar-width);

    min-width: var(--sidebar-width);
    flex-shrink: 0;

    background: var(--bg-elevated);

    border-right: 1px solid var(--border);

    padding: 20px 14px;

    position: sticky;
    top: 0;

    height: 100vh;

    overflow-y: auto;
    overflow-x: hidden;

    z-index: 1000;

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}


.sidebar .brand-mark {
    font-size: 18px;
    padding: 0 8px 20px;

    white-space: nowrap;
}


.sidebar nav {
    width: 100%;
}


.sidebar nav a {
    display: flex;
    align-items: center;

    min-height: 42px;

    padding: 10px 12px;

    border-radius: var(--radius);

    color: var(--text-muted);

    text-decoration: none;

    font-size: 14px;

    margin-bottom: 3px;

    transition:
        background 0.15s ease,
        color 0.15s ease;
}


.sidebar nav a:hover {
    background: var(--bg-sunken);
    color: var(--text);
}


.sidebar nav a.active {
    background: var(--brand-tint);
    color: var(--brand);
    font-weight: 600;
}


/* ==========================================================================
   MOBILE SIDEBAR OVERLAY
   ========================================================================== */

.sidebar-overlay {
    display: none;

    position: fixed;

    inset: 0;

    background: rgba(0, 0, 0, 0.45);

    z-index: 999;

    backdrop-filter: blur(2px);
}


/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */

.main {
    flex: 1;

    min-width: 0;

    width: calc(100% - var(--sidebar-width));

    position: relative;
}


/* ==========================================================================
   TOPBAR
   ========================================================================== */

.topbar {
    min-height: var(--topbar-height);

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 16px;

    padding: 14px 24px;

    border-bottom: 1px solid var(--border);

    background: var(--bg-elevated);

    position: sticky;
    top: 0;

    z-index: 900;
}


.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;

    min-width: 0;
}


.topbar-title {
    min-width: 0;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ==========================================================================
   MOBILE MENU BUTTON
   ========================================================================== */

.mobile-menu-btn {
    display: none;

    width: 42px;
    height: 42px;

    flex-shrink: 0;

    align-items: center;
    justify-content: center;

    border: 1px solid var(--border);

    border-radius: 9px;

    background: var(--bg-elevated);

    color: var(--text);

    font-size: 20px;
}


/* ==========================================================================
   PAGE CONTENT
   ========================================================================== */

.content {
    width: 100%;

    max-width: 1100px;

    padding: 24px;

    margin: 0 auto;
}


/* ==========================================================================
   CARDS
   ========================================================================== */

.card {
    width: 100%;

    background: var(--bg-elevated);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    padding: 20px;

    box-shadow: var(--shadow);

    min-width: 0;
}


.card-header {
    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    margin-bottom: 16px;
}


.card-body {
    min-width: 0;
}


/* ==========================================================================
   GRIDS
   ========================================================================== */

.grid {
    display: grid;

    gap: 16px;

    width: 100%;
}


.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}


.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}


.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}


/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    gap: 8px;

    min-height: 42px;

    padding: 10px 18px;

    border-radius: var(--radius);

    border: 1px solid transparent;

    font-family: var(--font-body);

    font-weight: 500;

    font-size: 14px;

    cursor: pointer;

    text-decoration: none;

    white-space: nowrap;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.1s ease;
}


.btn:active {
    transform: translateY(1px);
}


.btn-primary {
    background: var(--brand);
    color: #fff;
}


.btn-primary:hover {
    background: var(--brand-strong);
}


.btn-accent {
    background: var(--accent);
    color: #201405;
}


.btn-accent:hover {
    background: var(--accent-strong);
}


.btn-ghost {
    background: transparent;

    border-color: var(--border);

    color: var(--text);
}


.btn-ghost:hover {
    background: var(--bg-sunken);
}


/* ==========================================================================
   FORMS
   ========================================================================== */

.field {
    margin-bottom: 16px;

    min-width: 0;
}


.field label {
    display: block;

    font-size: 13px;

    color: var(--text-muted);

    margin-bottom: 6px;
}


.field input,
.field select,
.field textarea {
    width: 100%;

    max-width: 100%;

    padding: 10px 12px;

    border: 1px solid var(--border);

    border-radius: 8px;

    background: var(--bg);

    color: var(--text);

    font-family: var(--font-body);

    font-size: 14px;
}


.field textarea {
    min-height: 110px;

    resize: vertical;
}


.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid var(--brand);

    outline-offset: 1px;
}


/* ==========================================================================
   AUTH
   ========================================================================== */

.auth-shell {
    min-height: 100vh;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 24px;
}


.auth-card {
    width: 100%;

    max-width: 380px;
}


/* ==========================================================================
   ERROR
   ========================================================================== */

.error-list {
    color: var(--danger);

    font-size: 13px;

    margin: 0 0 12px;

    padding-left: 18px;
}


/* ==========================================================================
   BUSINESS TILES
   ========================================================================== */

.business-tile {
    display: block;

    width: 100%;

    padding: 18px;

    border-radius: var(--radius);

    border: 1px solid var(--border);

    background: var(--bg-elevated);

    text-decoration: none;

    color: var(--text);

    cursor: pointer;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


.business-tile:hover {
    border-color: var(--brand);

    box-shadow: var(--shadow);
}


.business-tile .role {
    font-size: 12px;

    color: var(--text-muted);
}


/* ==========================================================================
   TABLES
   ========================================================================== */

.table-wrapper {
    width: 100%;

    max-width: 100%;

    overflow-x: auto;

    -webkit-overflow-scrolling: touch;

    border-radius: var(--radius);
}


table {
    width: 100%;

    border-collapse: collapse;

    min-width: 600px;
}


th,
td {
    padding: 11px 12px;

    text-align: left;

    border-bottom: 1px solid var(--border);

    white-space: nowrap;
}


th {
    font-family: var(--font-display);

    font-size: 12px;

    color: var(--text-muted);

    font-weight: 600;
}


td {
    font-size: 14px;
}


/* ==========================================================================
   THEME TOGGLE
   ========================================================================== */

.theme-toggle {
    position: relative;

    width: 46px;
    height: 26px;

    flex-shrink: 0;

    border-radius: 999px;

    border: 1px solid var(--border);

    background: var(--bg-sunken);

    cursor: pointer;

    padding: 0;
}


.theme-toggle .knob {
    position: absolute;

    top: 2px;
    left: 2px;

    width: 20px;
    height: 20px;

    border-radius: 50%;

    background: var(--brand);

    transition: transform 0.15s ease;
}


:root[data-theme="dark"] .theme-toggle .knob {
    transform: translateX(20px);

    background: var(--accent);
}


/* ==========================================================================
   UTILITY
   ========================================================================== */

.w-full {
    width: 100%;
}


.text-center {
    text-align: center;
}


.text-right {
    text-align: right;
}


.flex {
    display: flex;
}


.flex-wrap {
    flex-wrap: wrap;
}


.items-center {
    align-items: center;
}


.justify-between {
    justify-content: space-between;
}


.gap-1 {
    gap: 8px;
}


.gap-2 {
    gap: 12px;
}


.gap-3 {
    gap: 16px;
}


/* ==========================================================================
   TABLET
   ========================================================================== */

@media (max-width: 1000px) {

    .content {
        padding: 20px;
    }

    .topbar {
        padding: 12px 20px;
    }

    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* ==========================================================================
   MOBILE — 768px
   ========================================================================== */

@media (max-width: 768px) {

    body {
        font-size: 14px;
    }


    /* --------------------------------------------------------------
       Layout
       -------------------------------------------------------------- */

    .layout {
        display: block;

        width: 100%;

        min-height: 100vh;
    }


    .main {
        width: 100%;

        min-width: 0;

        margin-left: 0;
    }


    /* --------------------------------------------------------------
       Sidebar becomes a drawer
       -------------------------------------------------------------- */

    .sidebar {
        position: fixed;

        top: 0;
        left: 0;
        bottom: 0;

        width: 280px;

        min-width: 280px;

        height: 100vh;

        transform: translateX(-105%);

        box-shadow: var(--shadow-lg);

        z-index: 1100;
    }


    .sidebar.open {
        transform: translateX(0);
    }


    .sidebar-overlay {
        display: block;

        opacity: 0;

        pointer-events: none;

        transition: opacity 0.25s ease;

        z-index: 1050;
    }


    .sidebar-overlay.active {
        opacity: 1;

        pointer-events: auto;
    }


    /* --------------------------------------------------------------
       Mobile menu
       -------------------------------------------------------------- */

    .mobile-menu-btn {
        display: inline-flex;
    }


    /* --------------------------------------------------------------
       Topbar
       -------------------------------------------------------------- */

    .topbar {
        min-height: 58px;

        padding: 9px 14px;

        gap: 8px;
    }


    .topbar-left,
    .topbar-right {
        gap: 8px;
    }


    .topbar-title {
        font-size: 15px;
    }


    /* --------------------------------------------------------------
       Content
       -------------------------------------------------------------- */

    .content {
        width: 100%;

        max-width: none;

        padding: 16px;
    }


    /* --------------------------------------------------------------
       Headings
       -------------------------------------------------------------- */

    h1 {
        font-size: 24px;
    }


    h2 {
        font-size: 20px;
    }


    h3 {
        font-size: 17px;
    }


    /* --------------------------------------------------------------
       Grids
       -------------------------------------------------------------- */

    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }


    .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }


    .grid-2 {
        grid-template-columns: 1fr;
    }


    /* --------------------------------------------------------------
       Cards
       -------------------------------------------------------------- */

    .card {
        padding: 16px;

        border-radius: 9px;
    }


    .card-header {
        align-items: flex-start;

        flex-wrap: wrap;
    }


    /* --------------------------------------------------------------
       Buttons
       -------------------------------------------------------------- */

    .btn {
        min-height: 44px;

        padding: 10px 14px;
    }


    /* --------------------------------------------------------------
       Forms
       -------------------------------------------------------------- */

    .field input,
    .field select,
    .field textarea {
        font-size: 16px;
    }


    /* --------------------------------------------------------------
       Tables
       -------------------------------------------------------------- */

    .table-wrapper {
        margin-left: 0;

        margin-right: 0;

        width: 100%;
    }


    /* --------------------------------------------------------------
       Auth
       -------------------------------------------------------------- */

    .auth-shell {
        padding: 16px;
    }


    .auth-card {
        max-width: 100%;
    }
}


/* ==========================================================================
   SMALL PHONES — 600px
   ========================================================================== */

@media (max-width: 600px) {

    .content {
        padding: 12px;
    }


    .topbar {
        padding: 8px 12px;
    }


    .grid-4,
    .grid-3 {
        grid-template-columns: 1fr;
    }


    .card {
        padding: 14px;
    }


    .card-header {
        display: flex;

        flex-direction: column;

        align-items: stretch;
    }


    .card-header .btn,
    .card-header button {
        width: 100%;
    }


    .btn {
        width: 100%;
    }


    .topbar-right .btn {
        width: auto;
    }


    .theme-toggle {
        width: 44px;
    }


    h1 {
        font-size: 22px;
    }


    h2 {
        font-size: 19px;
    }


    h3 {
        font-size: 16px;
    }
}


/* ==========================================================================
   VERY SMALL PHONES — 420px
   ========================================================================== */

@media (max-width: 420px) {

    .content {
        padding: 10px;
    }


    .topbar {
        min-height: 54px;

        padding: 7px 10px;
    }


    .mobile-menu-btn {
        width: 40px;
        height: 40px;
    }


    .topbar-title {
        font-size: 14px;
    }


    .card {
        padding: 12px;
    }


    .sidebar {
        width: 270px;

        min-width: 270px;
    }


    .btn {
        font-size: 13px;
    }


    table {
        min-width: 540px;
    }
}


/* ==========================================================================
   ACCESSIBILITY / REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;

        transition-duration: 0.01ms !important;

        animation-duration: 0.01ms !important;

        animation-iteration-count: 1 !important;
    }
}


/* ==========================================================================
   SIDEBAR DRAWER, USER FOOTER & LOGOUT
   (single source of truth — the old inline <style> in sidebar.php was removed)
   ========================================================================== */

.sidebar {
    display: flex;
    flex-direction: column;

    height: 100vh;
    height: 100dvh; /* real visible height on phones (address bar aware) */

    /* the nav list scrolls on its own; header and user/logout footer stay put */
    overflow: hidden;
    padding-bottom: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 44px;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;

    width: 100%;

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-close-btn {
    display: none;

    width: 38px;
    height: 38px;

    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 8px;

    background: var(--bg-sunken);
    color: var(--text);

    font-size: 28px;
    line-height: 1;
}

.mobile-menu-btn {
    flex-direction: column;
    gap: 5px;
    padding: 0;
}

.mobile-menu-btn span {
    display: block;

    width: 21px;
    height: 2px;

    border-radius: 999px;

    background: var(--text);
}

.sidebar-footer {
    flex-shrink: 0;

    /* cancel the sidebar's side padding so the divider spans edge to edge */
    margin: 8px -14px 0;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));

    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;

    min-width: 0;
    margin-bottom: 10px;
}

.sidebar-avatar {
    flex-shrink: 0;

    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: var(--brand-tint);
    color: var(--brand);

    font-family: var(--font-display);
    font-weight: 600;
}

.sidebar-user-text {
    display: flex;
    flex-direction: column;

    min-width: 0;
    line-height: 1.3;
}

.sidebar-user-text strong,
.sidebar-user-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-text strong {
    font-size: 13px;
}

.sidebar-user-text small {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-logout {
    width: 100%;
}

body.sidebar-open {
    overflow: hidden; /* no background scrolling behind the open drawer */
}


/* ==========================================================================
   AUTH — Google button, divider, notices
   ========================================================================== */

.btn-google {
    width: 100%;

    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text);
}

.btn-google:hover {
    background: var(--bg-sunken);
}

a.btn-google,
a.btn-google:hover {
    text-decoration: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;

    margin: 16px 0;

    color: var(--text-muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.notice {
    margin: 0 0 14px;
    padding: 10px 12px;

    border-radius: 8px;

    font-size: 13px;
}

.notice-success {
    background: var(--brand-tint);
    color: var(--brand);
}


/* ==========================================================================
   LAYOUT HELPERS
   ========================================================================== */

.grid-main-side {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.topbar > strong,
.topbar > div:first-child {
    min-width: 0;
}

.topbar > strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Buttons that sit beside an input/another control must never stretch full-width */
[style*="display:flex"] > .btn,
[style*="display: flex"] > .btn,
.topbar .btn,
table .btn {
    width: auto;
    flex-shrink: 0;
}


/* ==========================================================================
   NOTIFICATION BELL DROPDOWN
   ========================================================================== */

.notif-wrap {
    position: relative;
    display: inline-block;
}

.notif-dropdown {
    display: none;

    position: absolute;
    right: 0;
    top: 110%;

    width: 320px;
    max-width: calc(100vw - 20px);
    max-height: 360px;

    overflow-y: auto;

    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);

    z-index: 1200;

    padding: 8px;
}


/* ==========================================================================
   PAYMENT SHEET (bottom sheet on phones, centred dialog on desktop)
   ========================================================================== */

.sheet-backdrop {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 16px;

    background: rgba(0, 0, 0, 0.5);

    z-index: 2000;
}

.sheet {
    width: 100%;
    max-width: 440px;
    max-height: 92vh;
    max-height: 92dvh;

    overflow-y: auto;

    background: var(--bg-elevated);
    color: var(--text);

    border: 1px solid var(--border);
    border-radius: 14px;

    box-shadow: var(--shadow-lg);

    padding: 20px;
}

.sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;

    margin-bottom: 14px;
}

.sheet-head h3 {
    margin: 0;
}

.sheet-sub {
    color: var(--text-muted);
    font-size: 13px;
}

.sheet-close {
    flex-shrink: 0;

    width: 36px;
    height: 36px;

    border: 0;
    border-radius: 8px;

    background: var(--bg-sunken);
    color: var(--text);

    font-size: 24px;
    line-height: 1;
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;

    margin-bottom: 16px;
}

.method-btn {
    min-height: 56px;

    padding: 10px;

    border: 1.5px solid var(--border);
    border-radius: 10px;

    background: var(--bg);
    color: var(--text);

    font-weight: 500;
    font-size: 14px;
    text-align: center;
}

.method-btn small {
    display: block;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 11px;
}

.method-btn.active {
    border-color: var(--brand);
    background: var(--brand-tint);
    color: var(--brand);
}

.provider-row {
    display: flex;
    gap: 8px;

    margin-bottom: 16px;
}

.provider-row .method-btn {
    flex: 1;
    min-height: 44px;
}

.pay-state {
    padding: 18px 8px;

    text-align: center;
}

.pay-state .big {
    font-size: 40px;
    line-height: 1;
}

.pay-state p {
    margin: 10px 0 0;
    color: var(--text-muted);
}

.pay-spinner {
    width: 38px;
    height: 38px;

    margin: 0 auto;

    border: 4px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;

    animation: pay-spin 0.9s linear infinite;
}

@keyframes pay-spin {
    to { transform: rotate(360deg); }
}


/* ==========================================================================
   MOBILE FIXES (<= 768px) — loaded last so these win over earlier rules
   ========================================================================== */

@media (max-width: 768px) {

    .grid-main-side {
        grid-template-columns: 1fr;
    }

    /* Hamburger: pinned inside the topbar's left edge, hidden while the drawer is open */
    .mobile-menu-btn {
        position: fixed;
        top: 7px;
        left: 10px;

        display: flex;

        width: 44px;
        height: 44px;

        z-index: 950;

        box-shadow: var(--shadow);
    }

    body.sidebar-open .mobile-menu-btn {
        visibility: hidden;
    }

    /* leave room for the hamburger so it never covers the page title */
    .topbar {
        padding-left: 64px;
    }

    .sidebar {
        height: 100vh;
        height: 100dvh;

        width: min(290px, 85vw);
        min-width: 0;

        overflow: hidden;
        padding-bottom: 0;
    }

    .sidebar-close-btn {
        display: flex;
    }

    .sidebar nav a {
        min-height: 44px;
    }

    /* Wide tables scroll sideways INSIDE their card instead of being clipped
       by body { overflow-x: hidden } */
    table {
        display: block;

        width: 100%;
        max-width: 100%;
        min-width: 0;

        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 16px stops iOS Safari zooming the page when a field is focused */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px;
        max-width: 100%;
    }

    /* notifications: full-width panel under the topbar instead of a 320px box
       that can hang off the left edge of a small screen */
    .notif-dropdown {
        position: fixed;

        left: 10px;
        right: 10px;
        top: 62px;

        width: auto;
        max-width: none;
    }

    .sheet-backdrop {
        align-items: flex-end;

        padding: 0;
    }

    .sheet {
        max-width: none;

        border-radius: 16px 16px 0 0;
        border-bottom: 0;

        padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 420px) {

    .topbar {
        padding-left: 60px;
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .pay-spinner {
        animation-duration: 3s;
    }
}
