/*
 * Motion for the whole panel - one layer, loaded after mtik.css by the app layout.
 *
 * The aim is the feel of iOS: nothing jumps, things settle. Two curves do almost all of it -
 * --m-spring for things arriving (fast start, long soft landing, the curve of an iOS sheet)
 * and --m-ease for state changes (hover, focus, colour). Durations stay short; an operator
 * clicking through forty routers should feel the app is quick, not that it is performing.
 *
 * Rules this file keeps, because breaking them breaks real pages:
 *   - only opacity and transform are animated (cheap on a phone's GPU, never reflows a table);
 *   - an entrance animation never LEAVES a transform behind (fill-mode backwards), because a
 *     transformed ancestor becomes the containing block for position:fixed children - a modal
 *     or dropdown inside a card would be pinned to the card instead of the screen;
 *   - everything is switched off for prefers-reduced-motion.
 * Delete the <link> in the layout and the panel is exactly as it was before.
 */
:root {
    --m-spring: cubic-bezier(.32, .72, 0, 1);
    --m-ease: cubic-bezier(.25, .1, .25, 1);
    --m-fast: .18s;
    --m-base: .32s;
    --m-slow: .5s;
}

@media (prefers-reduced-motion: no-preference) {
    /* ── Between pages ───────────────────────────────────────────────────────────────────
       Same-origin navigations cross-fade instead of blanking to white (Chrome/Edge 126+,
       Safari 18.2+; other browsers simply navigate as before). The header and sidebar are
       named so they hold still while only the content changes. */
    @view-transition {
        navigation: auto;
    }

    ::view-transition-old(root) {
        animation: m-page-out .2s var(--m-ease) both;
    }

    ::view-transition-new(root) {
        animation: m-page-in .38s var(--m-spring) both;
    }

    .app-header {
        view-transition-name: m-header;
    }

    .app-sidebar {
        view-transition-name: m-sidebar;
    }

    html {
        scroll-behavior: smooth;
    }

    /* ── Page content settles in ─────────────────────────────────────────────────────────
       The content block, then each card in turn, a few hundredths apart. Backwards fill
       only: once landed, no transform is left on the element (see the header note). */
    .app-content-header {
        animation: m-rise var(--m-slow) var(--m-spring) backwards;
    }

    .app-content > .container-fluid > .row > [class*="col"],
    .app-content > .container-fluid > .card,
    .app-content > .container-fluid > .alert {
        animation: m-rise var(--m-slow) var(--m-spring) backwards;
    }

    .app-content > .container-fluid > :nth-child(2),
    .app-content > .container-fluid > .row > :nth-child(2) { animation-delay: .04s; }
    .app-content > .container-fluid > :nth-child(3),
    .app-content > .container-fluid > .row > :nth-child(3) { animation-delay: .08s; }
    .app-content > .container-fluid > :nth-child(4),
    .app-content > .container-fluid > .row > :nth-child(4) { animation-delay: .12s; }
    .app-content > .container-fluid > :nth-child(5),
    .app-content > .container-fluid > .row > :nth-child(5) { animation-delay: .16s; }
    .app-content > .container-fluid > :nth-child(n+6),
    .app-content > .container-fluid > .row > :nth-child(n+6) { animation-delay: .2s; }

    /* ── Buttons: a soft press, like a key under a finger ──────────────────────────────── */
    .btn,
    .nav-link,
    .page-link,
    .dropdown-item,
    .list-group-item-action {
        transition:
            color var(--m-fast) var(--m-ease),
            background-color var(--m-fast) var(--m-ease),
            border-color var(--m-fast) var(--m-ease),
            box-shadow var(--m-base) var(--m-ease),
            transform var(--m-fast) var(--m-spring);
    }

    .btn:not(:disabled):not(.disabled):active {
        transform: scale(.96);
    }

    .page-link:active,
    .list-group-item-action:active {
        transform: scale(.98);
    }

    /* ── Cards that are tiles lift a touch under a mouse (never on touch screens) ──────── */
    @media (hover: hover) {
        .stat-card,
        a.card {
            transition: transform var(--m-base) var(--m-spring), box-shadow var(--m-base) var(--m-ease);
        }

        .stat-card:hover,
        a.card:hover {
            transform: translateY(-2px);
            box-shadow: 0 .6rem 1.4rem rgba(0, 0, 0, .12);
        }
    }

    /* ── Fields: the focus ring fades in rather than snapping on ───────────────────────── */
    .form-control,
    .form-select,
    .form-check-input {
        transition:
            border-color var(--m-fast) var(--m-ease),
            box-shadow var(--m-base) var(--m-ease),
            background-color var(--m-fast) var(--m-ease),
            background-position var(--m-base) var(--m-spring);
    }

    /* ── Table rows: hover tint glides ─────────────────────────────────────────────────── */
    .table > tbody > tr > * {
        transition: background-color var(--m-fast) var(--m-ease), box-shadow var(--m-fast) var(--m-ease);
    }

    /* ── Menus open like an iOS context menu: a quick scale from where they hang ───────── */
    .dropdown-menu.show {
        animation: m-pop .22s var(--m-spring) backwards;
        transform-origin: top center;
    }

    /* ── Dialogs rise as a sheet over a frosted page ───────────────────────────────────── */
    .modal.fade .modal-dialog {
        transform: translateY(24px) scale(.97);
        transition: transform var(--m-slow) var(--m-spring);
    }

    .modal.show .modal-dialog {
        transform: none;
    }

    .modal.fade {
        transition: opacity var(--m-base) var(--m-ease);
    }

    .modal-backdrop.show {
        -webkit-backdrop-filter: blur(6px) saturate(140%);
        backdrop-filter: blur(6px) saturate(140%);
    }

    .modal-content {
        border-radius: 1rem;
    }

    /* ── Collapses (filters, details, nested lists) open on the same curve ─────────────── */
    .collapsing {
        transition: height var(--m-base) var(--m-spring);
    }

    details > summary ~ * {
        animation: m-rise .28s var(--m-spring) backwards;
    }

    /* ── Messages slide in; tabs fade their content ────────────────────────────────────── */
    .alert {
        animation: m-rise .4s var(--m-spring) backwards;
    }

    .tab-pane.fade {
        transition: opacity var(--m-base) var(--m-ease);
    }

    .progress-bar {
        transition: width var(--m-slow) var(--m-spring);
    }

    .badge,
    .chip {
        transition: background-color var(--m-base) var(--m-ease), color var(--m-base) var(--m-ease);
    }
}

/* Type renders the way Apple renders it, and taps do not flash grey on iOS. */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a,
button,
.btn,
[role="button"] {
    -webkit-tap-highlight-color: transparent;
}

@keyframes m-rise {
    from {
        opacity: 0;
        translate: 0 10px;
    }
}

/* scale/translate, not transform: Popper positions every dropdown with an inline transform,
   and animating that property would throw the menu to the corner for the length of the pop. */
@keyframes m-pop {
    from {
        opacity: 0;
        scale: .95;
        translate: 0 -4px;
    }
}

@keyframes m-page-out {
    to {
        opacity: 0;
    }
}

@keyframes m-page-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* ── Live search (live-search.js) ─────────────────────────────────────────────────────
   Once a list has been swapped in place, its cards do not replay the page-entry rise on every
   keystroke; the results just cross-fade in. The search icon turns while a request runs. */
.live-search-swapped .app-content * {
    animation: none !important;
}

@media (prefers-reduced-motion: no-preference) {
    .live-search-swapped .app-content .table > tbody {
        animation: m-fade .2s var(--m-ease) both !important;
    }

    .list-search-form.is-searching .input-group-text .bi-arrow-repeat {
        display: inline-block;
        animation: m-spin .8s linear infinite;
    }
}

@keyframes m-fade {
    from {
        opacity: 0;
    }
}

@keyframes m-spin {
    to {
        rotate: 360deg;
    }
}

/* ── Opening a page: a thin line across the top (mtik-loader.js) ──────────────────────
   Instead of the veil, for plain navigation. Slides on the spring curve, glows faintly,
   and the page underneath stays visible so the cross-fade into the next one reads. */
.mtik-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2100;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s var(--m-ease);
}

.mtik-progress.is-active {
    opacity: 1;
    transition-duration: .12s;
}

.mtik-progress > span {
    display: block;
    height: 100%;
    transform-origin: left center;
    transform: scaleX(0);
    border-radius: 0 3px 3px 0;
    background: linear-gradient(90deg, rgba(var(--bs-primary-rgb), .55), var(--bs-primary) 70%, #7cc4ff);
    box-shadow: 0 0 10px rgba(var(--bs-primary-rgb), .6);
    transition: transform 1.1s var(--m-spring);
}

/* ── The veil, kept for changes (Apply, Save, Delete, router writes) ──────────────────
   Same safety, iPhone manners: deeper frosted glass that fades in, and the card rises as a
   sheet on the spring instead of a plain ease. */
@media (prefers-reduced-motion: no-preference) {
    .mtik-loader.is-active {
        -webkit-backdrop-filter: blur(18px) saturate(160%);
        backdrop-filter: blur(18px) saturate(160%);
        transition: opacity .28s var(--m-ease), visibility 0s linear 0s;
    }

    .mtik-loader {
        transition: opacity .3s var(--m-ease), visibility 0s linear .3s;
    }

    .mtik-loader-inner {
        transform: translateY(18px) scale(.92);
        opacity: 0;
        transition: transform .55s var(--m-spring), opacity .3s var(--m-ease);
    }

    .mtik-loader.is-active .mtik-loader-inner {
        transform: none;
        opacity: 1;
    }
}

/* Rows that do not match what is typed so far, while the server answers (live-search.js). */
.table > tbody > tr.ls-dim > * {
    opacity: .28;
    transition: opacity .12s var(--m-ease);
}

/* ── Dropdowns: menus and selection boxes ─────────────────────────────────────────────
   One look for both, the iOS one: a rounded sheet of frosted glass on a soft deep shadow,
   rows that are rounded pills with a gentle tint under the finger, and a pop on the spring
   curve when it opens.

   Menus (.dropdown-menu - account, bell, tick-box lists) are ours to draw everywhere.
   Selection boxes (<select>) open a list the BROWSER draws; Chrome/Edge 135+ (desktop and
   Android, and the Android app's WebView) let a page style it with appearance: base-select,
   and it stays a real <select> - same value, same form post, same change events, so no page
   script notices. Older browsers and iPhone Safari keep their native list (the iOS wheel is
   already the iOS look). Multi-selects and list boxes are left native. */
:root {
    --m-menu-bg: rgba(var(--bs-body-bg-rgb), .86);
    --m-menu-border: rgba(var(--bs-emphasis-color-rgb), .08);
    --m-menu-shadow: 0 12px 32px -8px rgba(15, 23, 42, .28), 0 4px 10px -4px rgba(15, 23, 42, .12);
    --m-menu-hover: rgba(var(--bs-primary-rgb), .1);
    --m-menu-radius: 14px;
}

[data-bs-theme="dark"] {
    --m-menu-shadow: 0 16px 40px -8px rgba(0, 0, 0, .65), 0 4px 12px -4px rgba(0, 0, 0, .4);
}

/* Menus. :where() keeps these at zero weight, so a menu with a design of its own (the
   account menu's gilt card, the bell's list) keeps it and only borrows what it lacks. */
:where(.dropdown-menu) {
    --bs-dropdown-border-radius: var(--m-menu-radius);
    --bs-dropdown-inner-border-radius: calc(var(--m-menu-radius) - 1px);
    --bs-dropdown-link-active-bg: var(--bs-primary);
    padding: 6px;
    border: 1px solid var(--m-menu-border);
    border-radius: var(--m-menu-radius);
    background-color: var(--m-menu-bg);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow: var(--m-menu-shadow);
    max-height: min(70dvh, 30rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Bootstrap's .shadow utility is !important; the soft layered one replaces it on menus. */
.dropdown-menu.shadow {
    box-shadow: var(--m-menu-shadow) !important;
}

:where(.dropdown-menu) .dropdown-item {
    border-radius: 9px;
    padding: .5rem .75rem;
}

:where(.dropdown-menu) .dropdown-item:hover,
:where(.dropdown-menu) .dropdown-item:focus {
    background-color: var(--m-menu-hover);
}

:where(.dropdown-menu) .dropdown-divider {
    margin: 6px 4px;
    opacity: .6;
}

:where(.dropdown-menu) .dropdown-header {
    padding: .45rem .75rem .25rem;
    font-size: .72rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

@media (prefers-reduced-motion: no-preference) {
    .dropdown-menu.show {
        animation: m-pop .32s var(--m-spring) backwards;
    }

    .dropdown-menu.show .dropdown-item {
        animation: m-fade .3s var(--m-ease) backwards;
    }
}

/* Selection boxes, where the browser allows it. */
@supports (appearance: base-select) {
    select.form-select:not([multiple]):not([size]),
    select.form-select:not([multiple]):not([size])::picker(select) {
        appearance: base-select;
    }

    /* The closed box keeps the panel's own field look; Bootstrap's chevron stays the only
       arrow. */
    select.form-select:not([multiple]):not([size])::picker-icon {
        display: none;
    }

    select.form-select:not([multiple]):not([size])::picker(select) {
        margin-block: 6px;
        padding: 6px;
        min-width: anchor-size(width);
        max-height: min(22rem, 60vh);
        overflow-y: auto;
        border: 1px solid var(--m-menu-border);
        border-radius: var(--m-menu-radius);
        background-color: var(--m-menu-bg);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        backdrop-filter: blur(20px) saturate(180%);
        box-shadow: var(--m-menu-shadow);
        color: var(--bs-body-color);
    }

    select.form-select:not([multiple]):not([size]) option {
        display: flex;
        align-items: center;
        gap: .5rem;
        padding: .55rem .75rem;
        border-radius: 9px;
        font-size: .95rem;
        cursor: pointer;
    }

    select.form-select:not([multiple]):not([size]) option:hover,
    select.form-select:not([multiple]):not([size]) option:focus-visible {
        background-color: var(--m-menu-hover);
        outline: none;
    }

    select.form-select:not([multiple]):not([size]) option:checked {
        font-weight: 600;
        color: var(--bs-primary);
    }

    select.form-select:not([multiple]):not([size]) option::checkmark {
        order: 1;
        margin-left: auto;
        color: var(--bs-primary);
    }

    select.form-select:not([multiple]):not([size]) option:disabled {
        opacity: .45;
        cursor: default;
    }

    select.form-select:not([multiple]):not([size]) optgroup {
        padding-top: .35rem;
        font-size: .72rem;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--bs-secondary-color);
    }

    @media (prefers-reduced-motion: no-preference) {
        /* Opens with the same pop as the menus, and closes with a quick fade. */
        select.form-select:not([multiple]):not([size])::picker(select) {
            opacity: 0;
            scale: .95;
            translate: 0 -6px;
            transition:
                opacity .2s var(--m-ease),
                scale .32s var(--m-spring),
                translate .32s var(--m-spring),
                display .32s allow-discrete,
                overlay .32s allow-discrete;
        }

        select.form-select:not([multiple]):not([size]):open::picker(select) {
            opacity: 1;
            scale: 1;
            translate: 0 0;
        }

        @starting-style {
            select.form-select:not([multiple]):not([size]):open::picker(select) {
                opacity: 0;
                scale: .95;
                translate: 0 -6px;
            }
        }
    }
}

/* ── Scrolling inside dropdowns on a phone ────────────────────────────────────────────
   Three things made a long list feel broken under a thumb: the list hung below the box and
   ran off the bottom of the screen; reaching its end handed the swipe to the page behind;
   and a blurred, scrolling layer stutters on phone GPUs. So on a phone: lists keep their
   own swipe (overscroll contain), menus drop the blur for a solid sheet, and a selection
   box opens as an iOS bottom sheet - always fully on screen, thumb-sized rows. */
/* Menus and lists only. NOT .table-responsive: mtik.css gives tables
   overscroll-behavior-x: contain on purpose - a sideways swipe stays in the table while an
   up/down swipe must pass through to the page. Containing both axes there (as this rule did
   briefly on 2026-10-01) made every list page impossible to scroll with a thumb on a table. */
.notification-menu__list,
.mtk-check-dropdown .dropdown-menu,
.dropdown-menu {
    overscroll-behavior: contain;
}

@media (max-width: 767.98px) {
    .dropdown-menu {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    :where(.dropdown-menu) {
        background-color: var(--bs-body-bg);
    }

    :where(.dropdown-menu) .dropdown-item {
        padding: .7rem .85rem;
    }

    @supports (appearance: base-select) {
        select.form-select:not([multiple]):not([size])::picker(select) {
            position: fixed;
            inset: auto 0 0 0;
            position-area: none;
            position-try-fallbacks: none;
            margin: 0;
            width: 100%;
            min-width: 100%;
            max-width: 100%;
            max-height: 70dvh;
            padding: 22px 10px calc(12px + env(safe-area-inset-bottom));
            border: 0;
            border-radius: 22px 22px 0 0;
            background-color: var(--bs-body-bg);
            -webkit-backdrop-filter: none;
            backdrop-filter: none;
            box-shadow: 0 -12px 40px rgba(0, 0, 0, .28);
            overscroll-behavior: contain;
            touch-action: pan-y;
            /* The grabber, drawn as a background so it costs no element. */
            background-image: linear-gradient(rgba(var(--bs-emphasis-color-rgb), .22), rgba(var(--bs-emphasis-color-rgb), .22));
            background-size: 38px 5px;
            background-position: center 8px;
            background-repeat: no-repeat;
        }

        select.form-select:not([multiple]):not([size]) option {
            min-height: 3rem;
            padding: .75rem 1rem;
            font-size: 1.02rem;
            border-radius: 12px;
        }

        @media (prefers-reduced-motion: no-preference) {
            select.form-select:not([multiple]):not([size])::picker(select) {
                opacity: 1;
                scale: 1;
                translate: 0 100%;
                transition:
                    translate .42s var(--m-spring),
                    display .42s allow-discrete,
                    overlay .42s allow-discrete;
            }

            select.form-select:not([multiple]):not([size]):open::picker(select) {
                translate: 0 0;
            }

            @starting-style {
                select.form-select:not([multiple]):not([size]):open::picker(select) {
                    translate: 0 100%;
                }
            }
        }
    }
}

/* ════════════════════════════════════════════════════════════════════════════════════
   iPhone finish - on top of the gilt shell in mtik.css, not instead of it.
   Softer, rounder, lighter edges; system type; frosted chrome; iOS controls.
   ════════════════════════════════════════════════════════════════════════════════════ */
:root {
    --m-radius-card: 1.15rem;
    --m-radius-field: .8rem;
    --m-radius-btn: .75rem;
    --m-hairline: color-mix(in srgb, var(--mtik-gilt, #b89b6a) 22%, var(--bs-border-color));
    --m-card-shadow: 0 1px 2px rgba(28, 24, 18, .04), 0 8px 24px -6px rgba(28, 24, 18, .10);
}

[data-bs-theme="dark"] {
    --m-card-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -6px rgba(0, 0, 0, .55);
}

/* Type: Apple's own face where it exists, the closest system face elsewhere. */
body.mtik-app {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -.003em;
}

.mtik-app h1, .mtik-app h2, .mtik-app h3, .mtik-app .h1, .mtik-app .h2, .mtik-app .h3,
.mtik-app .card-title, .mtik-app .app-content-header h3 {
    letter-spacing: -.015em;
}

::selection {
    background: color-mix(in srgb, var(--mtik-gilt, #b89b6a) 35%, transparent);
}

/* Frosted top bar: the page slides under it, softened, like an iOS navigation bar. Computer
   screens only - a phone re-blurs the whole strip on every scroll frame, which is exactly the
   kind of work that makes scrolling stutter; there the bar stays solid. */
@media (min-width: 768px) {
    .mtik-app .app-header {
        background: color-mix(in srgb, var(--bs-body-bg) 78%, transparent);
        -webkit-backdrop-filter: blur(18px) saturate(180%);
        backdrop-filter: blur(18px) saturate(180%);
    }
}

/* Cards: rounder, lighter edge, layered soft shadow. */
.mtik-app .card {
    border-radius: var(--m-radius-card);
    border-color: var(--m-hairline);
    box-shadow: var(--m-card-shadow);
}

.mtik-app .card > .card-header {
    background: transparent;
    border-bottom-color: var(--m-hairline);
}

.mtik-app .card > .card-footer {
    background: transparent;
    border-top-color: var(--m-hairline);
}

/* Fields: the iOS grouped look - a soft fill that brightens and rings on focus. */
.mtik-app .form-control,
.mtik-app .form-select {
    border-radius: var(--m-radius-field);
    border-color: color-mix(in srgb, var(--bs-border-color) 70%, transparent);
    background-color: color-mix(in srgb, var(--bs-body-bg) 70%, var(--bs-tertiary-bg));
}

.mtik-app .form-control:focus,
.mtik-app .form-select:focus {
    background-color: var(--bs-body-bg);
    border-color: rgba(var(--bs-primary-rgb), .55);
    box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), .14);
}

/* Joined fields (a search box and its button) keep Bootstrap's own corner handling - it knows
   about validation messages - and only take the rounder outer radius from the field rule. */

/* Buttons: rounded, a touch bolder; the filled ones carry a faint top light. */
.mtik-app .btn {
    border-radius: var(--m-radius-btn);
    font-weight: 500;
}

.mtik-app .btn-sm {
    border-radius: calc(var(--m-radius-btn) - .15rem);
}

.mtik-app .btn-primary,
.mtik-app .btn-success,
.mtik-app .btn-danger {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0));
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 4px 12px -5px rgba(0, 0, 0, .3);
}

/* iOS switches: rounder track, the system green when on. */
.mtik-app .form-switch .form-check-input {
    width: 2.6em;
    height: 1.5em;
    margin-top: -.1em;
    border: 0;
    background-color: rgba(var(--bs-emphasis-color-rgb), .16);
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.4' fill='%23fff'/%3e%3c/svg%3e");
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
}

.mtik-app .form-switch .form-check-input:checked {
    background-color: #34c759;
}

.mtik-app .form-switch .form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(52, 199, 89, .25);
}

/* Tables: iOS section-header captions and hairline rows. */
.mtik-app .table > thead > tr > th {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    border-bottom-color: var(--m-hairline);
}

.mtik-app .table > tbody > tr > td {
    border-bottom-color: color-mix(in srgb, var(--m-hairline) 70%, transparent);
}

/* Pills and chips, alerts, pagination. */
.mtik-app .badge {
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: .01em;
}

/* Notices: drawn in mtik.css ("Errors and notices") - rounded, tinted, with their own glyph. */

.mtik-app .pagination {
    gap: .3rem;
}

.mtik-app .page-link {
    border-radius: .65rem !important;
    border-color: transparent;
    min-width: 2.25rem;
    text-align: center;
}

.mtik-app .page-item.active .page-link {
    box-shadow: 0 4px 12px -4px rgba(var(--bs-primary-rgb), .55);
}

.mtik-app .nav-pills .nav-link {
    border-radius: 999px;
}

/* Dialogs: rounded sheets; on a phone they rise from the bottom with a grabber. */
.mtik-app .modal-content {
    border: 0;
    border-radius: 1.35rem;
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .35);
}

@media (max-width: 575.98px) {
    .mtik-app .modal-dialog:not(.modal-fullscreen):not(.modal-dialog-scrollable) {
        display: flex;
        align-items: flex-end;
        min-height: 100%;
        margin: 0;
    }

    .mtik-app .modal-dialog:not(.modal-fullscreen):not(.modal-dialog-scrollable) .modal-content {
        border-radius: 1.4rem 1.4rem 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mtik-app .modal-dialog:not(.modal-fullscreen):not(.modal-dialog-scrollable) .modal-content::before {
        content: "";
        display: block;
        width: 38px;
        height: 5px;
        margin: 8px auto 0;
        border-radius: 3px;
        background: rgba(var(--bs-emphasis-color-rgb), .2);
    }

    @media (prefers-reduced-motion: no-preference) {
        .mtik-app .modal.fade .modal-dialog:not(.modal-fullscreen):not(.modal-dialog-scrollable) {
            transform: translateY(100%);
            transition: transform .45s var(--m-spring);
        }

        .mtik-app .modal.show .modal-dialog:not(.modal-fullscreen):not(.modal-dialog-scrollable) {
            transform: none;
        }
    }
}

/* Scrollbars: thin and rounded, out of the way until needed. */
.mtik-app * {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--bs-emphasis-color-rgb), .22) transparent;
}

.mtik-app ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.mtik-app ::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 8px;
    background-clip: padding-box;
    background-color: rgba(var(--bs-emphasis-color-rgb), .22);
}

.mtik-app ::-webkit-scrollbar-track {
    background: transparent;
}

/* ── No pull-to-refresh while a sheet is open (browsers; the app: sheet-guard.js) ────────
   Chrome's pull-to-refresh belongs to the root scroller. While a selection list, a dialog or
   a menu is open, the root does not take over-scroll, so swiping a sheet back up past its
   top just stops - it no longer reloads the page. */
html:has(select:open) {
    overscroll-behavior-y: none;
}

html:has(body.modal-open),
html:has(.dropdown-menu.show) {
    overscroll-behavior-y: none;
}

/* ── The selection list: rows you can tell apart at a glance ───────────────────────────
   Every row carries a round marker; the chosen one fills in as a blue tick and the row is
   tinted. Rows are divided by hairlines and every other one is faintly shaded, so a long
   list of routers or plans reads like an iOS settings list. */
@supports (appearance: base-select) {
    select.form-select:not([multiple]):not([size]) option::before {
        content: "\f28a";
        font-family: "bootstrap-icons";
        font-size: 1.05rem;
        line-height: 1;
        color: rgba(var(--bs-emphasis-color-rgb), .28);
        transition: color .2s var(--m-ease), scale .3s var(--m-spring);
    }

    select.form-select:not([multiple]):not([size]) option:checked::before {
        content: "\f26a";
        color: var(--bs-primary);
    }

    @media (prefers-reduced-motion: no-preference) {
        select.form-select:not([multiple]):not([size]) option:active::before {
            scale: .85;
        }
    }

    /* The tick is the marker now; the browser's own checkmark would be a second one. */
    select.form-select:not([multiple]):not([size]) option::checkmark {
        display: none;
    }

    select.form-select:not([multiple]):not([size]) option:checked {
        background-color: rgba(var(--bs-primary-rgb), .1);
        color: var(--bs-primary);
    }

    /* "Choose…" and other empty placeholders read as a prompt, not a choice. */
    select.form-select:not([multiple]):not([size]) option[value=""] {
        color: var(--bs-secondary-color);
        font-style: italic;
    }

    select.form-select:not([multiple]):not([size]) option[value=""]::before {
        content: "\f2e6";
        color: rgba(var(--bs-emphasis-color-rgb), .22);
    }

    select.form-select:not([multiple]):not([size]) option:nth-of-type(even):not(:checked) {
        background-color: rgba(var(--bs-emphasis-color-rgb), .025);
    }

    select.form-select:not([multiple]):not([size]) option + option {
        box-shadow: inset 0 1px 0 rgba(var(--bs-emphasis-color-rgb), .07);
    }

    select.form-select:not([multiple]):not([size]) option:checked,
    select.form-select:not([multiple]):not([size]) option:checked + option {
        box-shadow: none;
    }

    @media (max-width: 767.98px) {
        select.form-select:not([multiple]):not([size]) option {
            gap: .85rem;
        }

        select.form-select:not([multiple]):not([size]) option::before {
            font-size: 1.25rem;
        }
    }
}

/* ── Photo viewer (photo-viewer.js) ───────────────────────────────────────────────────
   A profile photo opened full size: it grows out of the spot it was tapped over a dimmed,
   blurred page, and shrinks back into it on close. */
.mtk-photo-button {
    padding: 0;
    border: 0;
    cursor: zoom-in;
    overflow: hidden;
    transition: transform .2s var(--m-spring), box-shadow .2s var(--m-ease);
}

.mtk-photo-button:hover {
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), .35);
}

.mtk-photo-button:active {
    transform: scale(.94);
}

.mtk-photo-button img,
img[data-photo-view] {
    cursor: zoom-in;
}

.mtk-photo-viewer {
    --viewer-dim: 1;
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(8, 10, 14, calc(.78 * var(--viewer-dim)));
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    opacity: 0;
    transition: opacity .3s var(--m-ease);
    cursor: zoom-out;
    touch-action: none;
}

.mtk-photo-viewer.is-open {
    opacity: 1;
}

.mtk-photo-viewer__stage {
    margin: 0;
    display: grid;
    justify-items: center;
    gap: .9rem;
}

.mtk-photo-viewer__stage img {
    width: min(88vw, 72vh, 640px);
    height: min(88vw, 72vh, 640px);
    object-fit: contain;
    border-radius: 1.25rem;
    transform-origin: top left;
    will-change: transform;
    filter: drop-shadow(0 24px 48px rgba(0, 0, 0, .45));
}

.mtk-photo-viewer__stage figcaption {
    color: rgba(255, 255, 255, .88);
    font-weight: 600;
    letter-spacing: -.01em;
    opacity: 0;
    translate: 0 6px;
    transition: opacity .3s var(--m-ease) .12s, translate .4s var(--m-spring) .12s;
}

.mtk-photo-viewer.is-open figcaption {
    opacity: 1;
    translate: 0 0;
}

.mtk-photo-viewer__close {
    position: absolute;
    top: calc(.9rem + env(safe-area-inset-top));
    right: .9rem;
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, .16);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-size: 1.1rem;
    transition: background-color .2s var(--m-ease), transform .2s var(--m-spring);
}

.mtk-photo-viewer__close:active {
    transform: scale(.9);
}

@media (prefers-reduced-motion: reduce) {
    .mtk-photo-viewer,
    .mtk-photo-viewer figcaption {
        transition: none;
    }
}


/* ════════════════════════════════════════════════════════════════════════════════════
   iOS type & controls (2026-10-24) - the whole panel, every page.
   SF where Apple ships it, Inter (its closest open cousin, loaded in the layout) everywhere
   else, so an Android phone or a Windows desk sees the same face an iPhone does. Then the
   iOS type ramp: bold large titles, semibold headlines, quiet secondary text.
   ════════════════════════════════════════════════════════════════════════════════════ */
body.mtik-app {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter Variable", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "cv11", "ss03";
}

/* Large Title: the page heading. */
.mtik-app .app-content-header h1 {
    font-weight: 700;
    letter-spacing: -.022em;
}

@media (max-width: 575.98px) {
    .mtik-app .app-content-header h1 {
        font-size: 1.65rem !important;
        line-height: 1.15;
    }
}

/* Headline: card titles and section headings. */
.mtik-app .card-header,
.mtik-app .card-title,
.mtik-app h2, .mtik-app h3, .mtik-app h4, .mtik-app h5,
.mtik-app .h2, .mtik-app .h3, .mtik-app .h4, .mtik-app .h5 {
    font-weight: 600;
    letter-spacing: -.012em;
}

.mtik-app .card-header .card-title {
    font-size: 1.0625rem;
}

/* Subheadline / footnote. */
.mtik-app .small,
.mtik-app small {
    letter-spacing: -.003em;
}

.mtik-app .form-label {
    font-weight: 500;
    font-size: .9rem;
}

.mtik-app .form-text {
    font-size: .8rem;
}

/* Buttons: semibold labels, and on a phone the 44pt touch height Apple asks for. */
.mtik-app .btn {
    font-weight: 600;
    letter-spacing: -.008em;
}

@media (max-width: 767.98px) {
    .mtik-app .btn:not(.btn-sm):not(.btn-link):not(.btn-close):not(.rowact-toggle) {
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mtik-app .btn-sm:not(.btn-link):not(.rowact-toggle) {
        min-height: 2.25rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mtik-app .btn-group > .btn,
    .mtik-app .input-group > .btn {
        display: inline-flex;
    }
}

/* Links read as iOS tint, not as underlined web links. Prose that wants an underline
   (a sentence with a link in it) keeps it via .text-decoration-underline. */
.mtik-app a:not(.btn):not(.nav-link):not(.dropdown-item):not(.page-link) {
    text-decoration: none;
}

.mtik-app p a:not(.btn) {
    text-decoration: underline;
    text-decoration-thickness: from-font;
    text-underline-offset: .15em;
}

/* Codes, usernames, MACs: SF Mono in a quiet ink rather than Bootstrap's pink. */
.mtik-app code {
    font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: .86em;
    color: color-mix(in srgb, var(--bs-body-color) 72%, var(--bs-primary));
}

/* Detail lists (dt/dd pairs in a card) as iOS grouped rows: label, value, hairline. */
.mtik-app .card-body > dl.row {
    --m-dl-line: color-mix(in srgb, var(--m-hairline) 75%, transparent);
    row-gap: 0;
}

.mtik-app .card-body > dl.row > dt {
    font-weight: 500;
    color: var(--bs-secondary-color);
    padding-top: .6rem;
    padding-bottom: .6rem;
    margin: 0;
    border-bottom: 1px solid var(--m-dl-line);
}

.mtik-app .card-body > dl.row > dd {
    padding-top: .6rem;
    padding-bottom: .6rem;
    margin: 0;
    border-bottom: 1px solid var(--m-dl-line);
    overflow-wrap: anywhere;
}

.mtik-app .card-body > dl.row > dt:nth-last-child(2),
.mtik-app .card-body > dl.row > dd:last-child {
    border-bottom: 0;
}

/* Stacked on a phone: the label becomes a small caption over its value, one hairline per pair. */
@media (max-width: 575.98px) {
    /* Only lists that actually stack (col-sm-*); a col-5/col-7 list stays side by side. */
    .mtik-app .card-body > dl.row > dt[class*="col-sm-"] {
        padding-bottom: .1rem;
        border-bottom: 0;
        font-size: .78rem;
    }

    .mtik-app .card-body > dl.row > dt[class*="col-sm-"] + dd {
        padding-top: 0;
    }
}

/* Tab switchers (a record's Overview / Live session / ...) slide sideways on a phone like an
   iOS segmented strip, instead of stacking into three ragged rows. */
@media (max-width: 767.98px) {
    .mtik-app .page-switch {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }

    .mtik-app .page-switch::-webkit-scrollbar {
        display: none;
    }

    .mtik-app .page-switch .nav-link {
        white-space: nowrap;
    }
}

/* "More tabs this way" on a sliding tab row (public/js/page-switch-scroll.js): the edge with
   more to see fades out like an iOS scroll view, and a small frosted chevron sits over it.
   Phone widths only - wider screens wrap the row, so there is never anything hidden. */
.page-switch-wrap {
    position: relative;
    min-width: 0; /* lets it shrink inside a flex toolbar, so the row scrolls instead of overflowing */
    margin-bottom: .85rem;
}

.page-switch-wrap > .page-switch {
    margin-bottom: 0;
}

.page-switch-more {
    display: none;
}

@media (max-width: 767.98px) {
    .mtik-app .page-switch-wrap.can-right > .page-switch {
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 3rem), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 3rem), transparent);
    }

    .mtik-app .page-switch-wrap.can-left > .page-switch {
        -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 3rem), transparent);
        mask-image: linear-gradient(to left, #000 calc(100% - 3rem), transparent);
    }

    .mtik-app .page-switch-wrap.can-left.can-right > .page-switch {
        -webkit-mask-image: linear-gradient(to right, transparent, #000 3rem, #000 calc(100% - 3rem), transparent);
        mask-image: linear-gradient(to right, transparent, #000 3rem, #000 calc(100% - 3rem), transparent);
    }

    .mtik-app .page-switch-more {
        position: absolute;
        top: 50%;
        z-index: 2;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.6rem;
        height: 1.6rem;
        padding: 0;
        border: .5px solid color-mix(in srgb, var(--bs-emphasis-color) 12%, transparent);
        border-radius: 50%;
        background: color-mix(in srgb, var(--bs-body-bg) 72%, transparent);
        -webkit-backdrop-filter: saturate(180%) blur(12px);
        backdrop-filter: saturate(180%) blur(12px);
        box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
        color: var(--bs-emphasis-color);
        font-size: .7rem;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-50%) scale(.85);
        transition: opacity .25s ease, transform .3s cubic-bezier(.32, .72, 0, 1);
    }

    .mtik-app .page-switch-more--right { right: 0; }
    .mtik-app .page-switch-more--left { left: 0; }

    .mtik-app .page-switch-wrap.can-right > .page-switch-more--right,
    .mtik-app .page-switch-wrap.can-left > .page-switch-more--left {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(-50%) scale(1);
    }

    .mtik-app .page-switch-more:active {
        transform: translateY(-50%) scale(.9);
    }

    /* One gentle nudge when the page opens, so the hint is noticed without shouting. */
    @media (prefers-reduced-motion: no-preference) {
        .mtik-app .page-switch-wrap.can-right > .page-switch-more--right {
            animation: page-switch-nudge 1.4s cubic-bezier(.32, .72, 0, 1) .6s 1;
        }
    }
}

@keyframes page-switch-nudge {
    0%, 100% { transform: translateY(-50%) translateX(0) scale(1); }
    40% { transform: translateY(-50%) translateX(3px) scale(1); }
    70% { transform: translateY(-50%) translateX(-1px) scale(1); }
}
