/* ============================================================
   PBM Fluent 2 — Enterprise design system
   Inspired by Microsoft Fluent 2 (microsoft.com/design)
   Loaded AFTER Bootstrap & admin-style.css to override.
   ============================================================ */

:root {
    /* ── Color tokens (Fluent 2 neutrals) ── */
    --ft-neutral-0:    #ffffff;
    --ft-neutral-2:    #fafafa;
    --ft-neutral-4:    #f5f5f5;
    --ft-neutral-6:    #f0f0f0;
    --ft-neutral-10:   #e1e1e1;
    --ft-neutral-20:   #c7c7c7;
    --ft-neutral-30:   #a3a3a3;
    --ft-neutral-40:   #757575;
    --ft-neutral-50:   #5a5a5a;
    --ft-neutral-60:   #424242;
    --ft-neutral-80:   #242424;
    --ft-neutral-100:  #000000;

    /* ── Brand (Fluent Communication Blue) ── */
    --ft-brand-10:     #e0eaf6;
    --ft-brand-20:     #b4d0f5;
    --ft-brand-40:     #4f8de2;
    --ft-brand-60:     #0078d4;   /* primary */
    --ft-brand-70:     #005a9e;   /* hover */
    --ft-brand-80:     #004578;

    /* ── Semantic ── */
    --ft-success-10:   #dff6dd;
    --ft-success-60:   #107c10;
    --ft-warning-10:   #fff4ce;
    --ft-warning-60:   #b89500;
    --ft-danger-10:    #fde7e9;
    --ft-danger-60:    #c50f1f;
    --ft-info-10:      #e5f2ff;
    --ft-info-60:      #0078d4;

    /* ── Typography ── */
    --ft-font-family: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    --ft-font-mono:   "Cascadia Code", "Consolas", "SF Mono", Menlo, monospace;
    --ft-fs-100:      11px;   /* caption */
    --ft-fs-200:      12px;   /* small */
    --ft-fs-300:      14px;   /* body */
    --ft-fs-400:      16px;   /* subhead */
    --ft-fs-500:      20px;   /* title 3 */
    --ft-fs-600:      24px;   /* title 2 */
    --ft-fs-700:      28px;   /* title 1 */
    --ft-fs-800:      32px;   /* hero */
    --ft-fw-regular:  400;
    --ft-fw-semibold: 600;
    --ft-fw-bold:     700;
    --ft-lh-tight:    1.2;
    --ft-lh-base:     1.45;

    /* ── Spacing (4-point grid) ── */
    --ft-space-1: 4px;
    --ft-space-2: 8px;
    --ft-space-3: 12px;
    --ft-space-4: 16px;
    --ft-space-5: 20px;
    --ft-space-6: 24px;
    --ft-space-8: 32px;
    --ft-space-10: 40px;
    --ft-space-12: 48px;

    /* ── Radius ── */
    --ft-radius-sm: 2px;
    --ft-radius:    4px;
    --ft-radius-md: 6px;
    --ft-radius-lg: 8px;

    /* ── Elevation ── */
    --ft-shadow-2:  0 1px 2px rgba(0,0,0,.08), 0 0 2px rgba(0,0,0,.06);
    --ft-shadow-4:  0 2px 4px rgba(0,0,0,.10), 0 0 2px rgba(0,0,0,.06);
    --ft-shadow-8:  0 4px 8px rgba(0,0,0,.10), 0 0 2px rgba(0,0,0,.08);
    --ft-shadow-16: 0 8px 16px rgba(0,0,0,.10), 0 0 2px rgba(0,0,0,.08);

    /* ── Motion ── */
    --ft-duration-fast: 100ms;
    --ft-duration:      200ms;
    --ft-ease:          cubic-bezier(0.33, 0, 0.67, 1);

    /* ── App shell sizing ── */
    --ft-topbar-h:   48px;
    --ft-sidebar-w:  210px;
    --ft-sidebar-w-collapsed: 44px;

    /* ── Focus ring ── */
    --ft-focus-ring: 0 0 0 2px var(--ft-neutral-0), 0 0 0 4px var(--ft-brand-60);
}

/* ============================================================
   Base
   ============================================================ */
html, body {
    font-family: var(--ft-font-family);
    font-size: var(--ft-fs-300);
    line-height: var(--ft-lh-base);
    color: var(--ft-neutral-80);
    background: var(--ft-neutral-4);
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

*:focus-visible {
    outline: none;
    box-shadow: var(--ft-focus-ring);
    border-radius: var(--ft-radius);
}

/* Skip link for a11y */
.ft-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--ft-brand-60);
    color: #fff;
    padding: 8px 16px;
    z-index: 9999;
    border-radius: 0 0 var(--ft-radius) 0;
    font-weight: var(--ft-fw-semibold);
}
.ft-skip-link:focus { left: 0; }

/* ============================================================
   App shell
   ============================================================ */
.ft-shell {
    display: grid;
    grid-template-rows: var(--ft-topbar-h) 1fr;
    grid-template-columns: auto 1fr;
    grid-template-areas: "topbar topbar" "sidebar main";
    min-height: 100vh;
}

/* ── Top bar ── */
.ft-topbar {
    grid-area: topbar;
    background: var(--ft-neutral-0);
    border-bottom: 1px solid var(--ft-neutral-10);
    display: flex;
    align-items: center;
    padding: 0 var(--ft-space-3);
    gap: var(--ft-space-2);
    z-index: 100;
    position: sticky;
    top: 0;
    min-width: 0;           /* allow flex children to shrink */
}
@media (min-width: 576px) {
    .ft-topbar { padding: 0 var(--ft-space-4); gap: var(--ft-space-3); }
}
.ft-topbar__brand {
    display: flex;
    align-items: center;
    gap: var(--ft-space-2);
    font-weight: var(--ft-fw-semibold);
    color: var(--ft-neutral-80);
    text-decoration: none;
    font-size: var(--ft-fs-300);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    max-width: 200px;
}
.ft-topbar__brand:hover { color: var(--ft-brand-60); text-decoration: none; }
.ft-topbar__logo {
    width: 28px; height: 28px;
    background: var(--ft-brand-60);
    color: #fff;
    border-radius: var(--ft-radius);
    display: flex; align-items: center; justify-content: center;
    font-weight: var(--ft-fw-bold);
    font-size: 11px;
    letter-spacing: 0.3px;
}
.ft-topbar__search {
    flex: 1;
    max-width: 480px;
    position: relative;
    /* hide on very small screens */
    display: flex;
    align-items: center;
}
@media (max-width: 576px) {
    .ft-topbar__search { display: none; }
}
.ft-topbar__search input {
    width: 100%;
    height: 34px;
    padding: 0 var(--ft-space-3) 0 36px;
    background: var(--ft-neutral-4);
    border: 1px solid transparent;
    border-radius: var(--ft-radius-md);
    font-size: var(--ft-fs-300);
    font-family: var(--ft-font-family);
    transition: border-color var(--ft-duration-fast), background var(--ft-duration-fast), box-shadow var(--ft-duration-fast);
}
.ft-topbar__search input:hover  { border-color: var(--ft-neutral-20); }
.ft-topbar__search input:focus  { background: #fff; border-color: var(--ft-brand-60); box-shadow: 0 0 0 2px rgba(0,120,212,.15); outline: none; }
.ft-topbar__search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    line-height: 1;
    opacity: .45;
    pointer-events: none;
    color: var(--ft-neutral-50);
    /* Force Material Symbols font */
    font-family: 'Material Symbols Rounded', sans-serif;
    font-weight: normal;
    font-style: normal;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.ft-topbar__actions {
    display: flex;
    align-items: center;
    gap: var(--ft-space-2);
    margin-left: auto;
}
/* ── Force Material Symbols font everywhere it's used ── */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded', sans-serif !important;
    font-weight: normal;
    font-style: normal;
    font-size: inherit;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
    transition: font-variation-settings 160ms ease;
}

.ft-topbar__iconbtn {
    width: 36px; height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--ft-radius-md);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--ft-neutral-50);
    transition: background var(--ft-duration-fast), color var(--ft-duration-fast);
    text-decoration: none;
    flex-shrink: 0;
}
.ft-topbar__iconbtn .material-symbols-rounded {
    font-size: 22px;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}
.ft-topbar__iconbtn:hover {
    background: var(--ft-neutral-6);
    color: var(--ft-brand-60);
    text-decoration: none;
}
.ft-topbar__iconbtn:hover .material-symbols-rounded {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.ft-topbar__user {
    width: 32px; height: 32px;
    background: var(--ft-brand-60);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: var(--ft-fw-semibold);
    cursor: pointer;
}

/* ── Sidebar ── */
.ft-sidebar {
    grid-area: sidebar;
    background: var(--ft-neutral-0);
    border-right: 1px solid var(--ft-neutral-10);
    width: var(--ft-sidebar-w);
    overflow-y: auto;
    padding: var(--ft-space-3) 0;
    transition: width var(--ft-duration) var(--ft-ease);
}
.ft-shell.is-collapsed .ft-sidebar { width: var(--ft-sidebar-w-collapsed); }
.ft-shell.is-collapsed .ft-nav__label,
.ft-shell.is-collapsed .ft-nav__section { display: none; }

.ft-nav__section {
    font-size: 10px;
    font-weight: var(--ft-fw-semibold);
    color: var(--ft-neutral-40);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px var(--ft-space-3) 4px;
}
.ft-nav__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px var(--ft-space-3);
    color: var(--ft-neutral-80);
    text-decoration: none;
    font-size: var(--ft-fs-200);
    border-left: 3px solid transparent;
    transition: background var(--ft-duration-fast);
    position: relative;
}
.ft-nav__item:hover { background: var(--ft-neutral-4); }
.ft-nav__item.is-active {
    background: var(--ft-brand-10);
    color: var(--ft-brand-70);
    border-left-color: var(--ft-brand-60);
    font-weight: var(--ft-fw-semibold);
}
.ft-nav__icon {
    width: 18px;
    height: 18px;
    font-size: 17px;
    flex-shrink: 0;
    /* Explicit font-family so Bootstrap resets can't strip it */
    font-family: 'Material Symbols Rounded', sans-serif !important;
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
    transition: font-variation-settings 160ms ease, color 160ms ease;
}
.ft-nav__item.is-active .ft-nav__icon {
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
    color: var(--ft-brand-60);
}
.ft-nav__item:hover .ft-nav__icon {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.ft-sidebar__footer {
    padding: 6px var(--ft-space-3);
    border-top: 1px solid var(--ft-neutral-10);
    font-size: var(--ft-fs-100);
    color: var(--ft-neutral-40);
    line-height: 1.4;
}

/* ── Main content ── */
.ft-main {
    grid-area: main;
    padding: var(--ft-space-6);
    overflow-x: hidden;
}

/* ── Page header ── */
.ft-page-header {
    margin-bottom: var(--ft-space-5);
}
.ft-breadcrumb {
    font-size: var(--ft-fs-200);
    color: var(--ft-neutral-40);
    margin-bottom: var(--ft-space-2);
    display: flex;
    align-items: center;
    gap: var(--ft-space-2);
}
.ft-breadcrumb a {
    color: var(--ft-neutral-40);
    text-decoration: none;
}
.ft-breadcrumb a:hover { color: var(--ft-brand-60); text-decoration: underline; }
.ft-breadcrumb__sep { color: var(--ft-neutral-20); }
.ft-page-header__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ft-space-4);
    flex-wrap: wrap;
}
.ft-page-header__title {
    font-size: var(--ft-fs-600);
    font-weight: var(--ft-fw-semibold);
    margin: 0;
    color: var(--ft-neutral-80);
    line-height: var(--ft-lh-tight);
}
.ft-page-header__subtitle {
    font-size: var(--ft-fs-300);
    color: var(--ft-neutral-40);
    margin-top: var(--ft-space-1);
}
.ft-page-header__actions { display: flex; gap: var(--ft-space-2); align-items: center; }

/* ============================================================
   Buttons
   ============================================================ */
.btn, .ft-btn {
    font-family: var(--ft-font-family);
    font-size: var(--ft-fs-300);
    font-weight: var(--ft-fw-semibold);
    border-radius: var(--ft-radius);
    padding: 5px 12px;
    border: 1px solid transparent;
    transition: background var(--ft-duration-fast), border-color var(--ft-duration-fast);
    line-height: 20px;
    min-height: 32px;
}
.btn-primary, .ft-btn--primary {
    background: var(--ft-brand-60) !important;
    border-color: var(--ft-brand-60) !important;
    color: #fff !important;
}
.btn-primary:hover, .ft-btn--primary:hover {
    background: var(--ft-brand-70) !important;
    border-color: var(--ft-brand-70) !important;
}
.btn-outline-primary, .btn-outline-secondary, .btn-outline-danger, .btn-outline-info, .btn-outline-success {
    background: var(--ft-neutral-0);
    border-color: var(--ft-neutral-20);
    color: var(--ft-neutral-80);
}
.btn-outline-primary:hover, .btn-outline-secondary:hover { background: var(--ft-neutral-4); color: var(--ft-neutral-80); }
.btn-outline-danger { color: var(--ft-danger-60); border-color: var(--ft-neutral-20); }
.btn-outline-danger:hover { background: var(--ft-danger-10); color: var(--ft-danger-60); border-color: var(--ft-danger-60); }
.btn-sm { padding: 3px 10px; min-height: 26px; font-size: var(--ft-fs-200); }
.btn-lg { padding: 7px 16px; min-height: 40px; font-size: var(--ft-fs-400); }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--ft-neutral-0);
    border: 1px solid var(--ft-neutral-10);
    border-radius: var(--ft-radius-lg);
    box-shadow: var(--ft-shadow-2);
    overflow: hidden;
}
.card-header {
    background: var(--ft-neutral-0);
    border-bottom: 1px solid var(--ft-neutral-10);
    padding: var(--ft-space-3) var(--ft-space-4);
    font-weight: var(--ft-fw-semibold);
}
.card-body { padding: var(--ft-space-4); }

/* ============================================================
   Forms
   ============================================================ */
.form-control, .form-select {
    font-family: var(--ft-font-family);
    font-size: var(--ft-fs-300);
    color: var(--ft-neutral-80);
    background: var(--ft-neutral-0);
    border: 1px solid var(--ft-neutral-20);
    border-radius: var(--ft-radius);
    padding: 5px 10px;
    min-height: 32px;
    transition: border-color var(--ft-duration-fast), box-shadow var(--ft-duration-fast);
}
.form-control:hover, .form-select:hover { border-color: var(--ft-neutral-40); }
.form-control:focus, .form-select:focus {
    border-color: var(--ft-brand-60);
    box-shadow: 0 0 0 1px var(--ft-brand-60);
    outline: none;
}
.form-label {
    font-size: var(--ft-fs-200);
    font-weight: var(--ft-fw-semibold);
    color: var(--ft-neutral-80);
    margin-bottom: var(--ft-space-1);
}

/* ============================================================
   Message bars (Fluent)
   ============================================================ */
.alert {
    border-radius: var(--ft-radius);
    padding: var(--ft-space-3) var(--ft-space-4);
    border: 1px solid;
    font-size: var(--ft-fs-300);
    display: flex;
    align-items: center;
    gap: var(--ft-space-3);
}
.alert-success { background: var(--ft-success-10); border-color: var(--ft-success-60); color: var(--ft-success-60); }
.alert-danger, .alert-error  { background: var(--ft-danger-10);  border-color: var(--ft-danger-60);  color: var(--ft-danger-60); }
.alert-warning { background: var(--ft-warning-10); border-color: var(--ft-warning-60); color: var(--ft-warning-60); }
.alert-info, .alert-primary { background: var(--ft-info-10); border-color: var(--ft-info-60); color: var(--ft-info-60); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    font-family: var(--ft-font-family);
    font-weight: var(--ft-fw-semibold);
    font-size: var(--ft-fs-100);
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.02em;
}

/* ============================================================
   Enterprise Data Table
   ============================================================ */
.ft-table-wrap {
    background: var(--ft-neutral-0);
    border: 1px solid var(--ft-neutral-10);
    border-radius: var(--ft-radius-lg);
    box-shadow: var(--ft-shadow-2);
    overflow: hidden;
}
.ft-table-toolbar {
    display: flex;
    align-items: center;
    gap: var(--ft-space-2);
    padding: var(--ft-space-3) var(--ft-space-4);
    border-bottom: 1px solid var(--ft-neutral-10);
    background: var(--ft-neutral-0);
    flex-wrap: wrap;
}
.ft-table-toolbar__search {
    height: 30px;
    padding: 0 var(--ft-space-3);
    width: 280px;
    background: var(--ft-neutral-4);
    border: 1px solid transparent;
    border-radius: var(--ft-radius);
    font-size: var(--ft-fs-300);
}
.ft-table-toolbar__search:focus { background: #fff; border-color: var(--ft-brand-60); outline: none; }
.ft-table-toolbar__spacer { flex: 1; }
.ft-table-toolbar__count {
    font-size: var(--ft-fs-200);
    color: var(--ft-neutral-40);
}
.ft-table-toolbar__btn {
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--ft-neutral-20);
    background: var(--ft-neutral-0);
    border-radius: var(--ft-radius);
    color: var(--ft-neutral-80);
    font-size: var(--ft-fs-200);
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
.ft-table-toolbar__btn:hover { background: var(--ft-neutral-4); }
.ft-table-toolbar__menu {
    position: absolute;
    z-index: 50;
    background: var(--ft-neutral-0);
    border: 1px solid var(--ft-neutral-10);
    border-radius: var(--ft-radius);
    box-shadow: var(--ft-shadow-8);
    padding: var(--ft-space-2);
    min-width: 220px;
    max-height: 360px;
    overflow-y: auto;
}
.ft-table-toolbar__menu label {
    display: flex; align-items: center; gap: var(--ft-space-2);
    padding: 6px 10px; border-radius: var(--ft-radius);
    cursor: pointer; font-size: var(--ft-fs-200);
}
.ft-table-toolbar__menu label:hover { background: var(--ft-neutral-4); }

.ft-table-scroll {
    max-height: calc(100vh - 280px);
    overflow: auto;
    position: relative;
}

table.ft-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--ft-fs-300);
    background: var(--ft-neutral-0);
    margin: 0;
}
table.ft-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--ft-neutral-2);
    border-bottom: 1px solid var(--ft-neutral-10);
    color: var(--ft-neutral-60);
    font-weight: var(--ft-fw-semibold);
    font-size: var(--ft-fs-200);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
table.ft-table thead th[data-not-sortable] { cursor: default; }
table.ft-table thead th:hover { background: var(--ft-neutral-4); }
table.ft-table thead th .ft-sort {
    display: inline-block; margin-left: 4px; opacity: .3;
    font-size: 9px; transition: opacity var(--ft-duration-fast);
}
table.ft-table thead th[aria-sort="ascending"] .ft-sort,
table.ft-table thead th[aria-sort="descending"] .ft-sort { opacity: 1; color: var(--ft-brand-60); }
table.ft-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--ft-neutral-6);
    vertical-align: middle;
}
table.ft-table tbody tr:hover { background: var(--ft-brand-10); }
table.ft-table tbody tr:last-child td { border-bottom: none; }
table.ft-table tfoot td {
    padding: 10px 12px;
    background: var(--ft-neutral-2);
    border-top: 1px solid var(--ft-neutral-10);
    font-weight: var(--ft-fw-semibold);
}

/* Density variants */
.ft-table-wrap[data-density="compact"] table.ft-table thead th,
.ft-table-wrap[data-density="compact"] table.ft-table tbody td { padding: 4px 10px; font-size: var(--ft-fs-200); }
.ft-table-wrap[data-density="comfortable"] table.ft-table thead th,
.ft-table-wrap[data-density="comfortable"] table.ft-table tbody td { padding: 14px 16px; }

/* Alignment helpers preserved */
table.ft-table .text-end { text-align: right; }
table.ft-table .text-center { text-align: center; }

/* ============================================================
   Empty state
   ============================================================ */
.ft-empty {
    text-align: center;
    padding: var(--ft-space-12) var(--ft-space-6);
    color: var(--ft-neutral-40);
}
.ft-empty__icon { font-size: 48px; opacity: .4; margin-bottom: var(--ft-space-3); }
.ft-empty__title { font-size: var(--ft-fs-400); font-weight: var(--ft-fw-semibold); color: var(--ft-neutral-60); }
.ft-empty__desc  { font-size: var(--ft-fs-300); margin-top: var(--ft-space-1); }

/* ============================================================
   Responsive
   ============================================================ */

/* ── Mobile sidebar overlay (< 900px) ── */
@media (max-width: 900px) {
    .ft-shell {
        grid-template-columns: 1fr;
        grid-template-areas: "topbar" "main";
    }
    .ft-sidebar {
        position: fixed;
        top: var(--ft-topbar-h);
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform 240ms cubic-bezier(0.33, 0, 0.67, 1), box-shadow 240ms;
        z-index: 200;
        box-shadow: none;
        width: 280px;
    }
    .ft-shell.is-mobile-open .ft-sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.16), 0 0 0 100vw rgba(0,0,0,.28);
    }
    /* Collapse sidebar toggle should show on mobile too */
    #ft-collapse-btn { display: none !important; }
}

/* ── Tablet sidebar collapsed by default ── */
@media (max-width: 1100px) and (min-width: 901px) {
    .ft-shell:not(.is-collapsed) { --ft-sidebar-w: 210px; }
}

/* ── Hide topbar brand text on xs ── */
@media (max-width: 400px) {
    .ft-topbar__brand span { display: none !important; }
    .ft-topbar__actions { gap: 2px; }
}

/* ── Main content padding on mobile ── */
@media (max-width: 576px) {
    .ft-main { padding: var(--ft-space-4) var(--ft-space-3); }
    .ft-page-header__row { flex-direction: column; align-items: flex-start; }
    .ft-page-header__actions { flex-wrap: wrap; }
    .ft-page-header__title { font-size: var(--ft-fs-500); }
}

/* ============================================================
   Mobile — comprehensive responsive polish (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {

    /* ── Tables: horizontal scroll in every card / section ── */
    .card-body,
    .ft-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Keep ft-table-scroll height but allow full horizontal scroll */
    .ft-table-scroll { max-height: none; }

    /* Ensure tables don't shrink below readable width */
    table.ft-table,
    .card-body > table,
    .card-body .table { min-width: 480px; }

    /* Reduce table font on narrow screens */
    table.ft-table tbody td,
    .card-body table td,
    .card-body table th { font-size: 12px; padding: 6px 8px; }

    /* ── Page header ── */
    .ft-page-header { padding-bottom: var(--ft-space-3); }
    .ft-page-header__actions { gap: 6px; margin-top: 8px; }
    .pbm-page-header { flex-wrap: wrap; gap: 8px; align-items: center; }
    .pbm-page-header h1 { font-size: 20px; margin: 0; }

    /* ── Filter forms: stack all columns ── */
    .row.g-3 > .col-md-2,
    .row.g-3 > .col-md-3,
    .row.g-3 > .col-md-4 { flex: 0 0 100%; max-width: 100%; }

    /* Inline forms: switch to block layout */
    .d-inline-flex.align-items-center { flex-wrap: wrap; width: 100%; }
    form.d-inline-flex { width: 100%; }
    form.d-inline-flex input[type="text"],
    form.d-inline-flex input[type="search"] { width: 100% !important; max-width: 100% !important; }

    /* ── Cards ── */
    .card { border-radius: 8px; }
    .card-header { padding: 10px 14px; }
    .card-body { padding: 12px 14px; }

    /* ── Modals: near-fullscreen on mobile ── */
    .modal-dialog { margin: 8px auto; max-width: calc(100vw - 16px) !important; }
    .modal-xl,
    .modal-lg { max-width: calc(100vw - 16px) !important; }
    .modal-body { padding: 12px; }

    /* ── Pagination ── */
    .ft-pagination { flex-wrap: wrap; gap: 4px; justify-content: center; }

    /* ── Badges in tables ── */
    .badge { font-size: 10px; padding: 3px 6px; }

    /* ── Ledger: stat summary cards ── */
    .row.g-3 .col-md-3 .card-body.py-2 { padding: 8px 10px !important; }
}

/* ============================================================
   Mobile — small phone polish (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {

    /* ── Dashboard KPI cards: 2 per row, tighter ── */
    .col-6 .card-body { padding: 10px 12px !important; }
    .col-6 .card-body [style*="font-size:24px"] { font-size: 17px !important; }
    .col-6 .card-body [style*="font-size:11px"] { font-size: 10px !important; }

    /* ── Tables: even tighter ── */
    table.ft-table tbody td,
    .card-body table td,
    .card-body table th { font-size: 11px; padding: 5px 6px; }

    /* ── Topbar brand ── */
    .ft-topbar__brand { max-width: 130px; }

    /* ── Buttons ── */
    .btn-sm { font-size: 12px; padding: 4px 8px; }

    /* ── Page title ── */
    .ft-page-header__title { font-size: 18px; }
    .pbm-page-header h1 { font-size: 18px; }

    /* ── Single Feed Entry form labels ── */
    .form-label { font-size: 12px; margin-bottom: 2px; }
    .form-control, .form-select { font-size: 13px; }

    /* ── Card headers ── */
    .card-header strong { font-size: 13px; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
