/* ==========================================================================
   TBPANEL — Admin Shell layout
   --------------------------------------------------------------------------
   This file layers on top of webixa-theme.css.  Every colour, radius and
   shadow here pulls from a `--token` declared in webixa-theme.css so the
   White + Emerald + Gold brand carries through unchanged.

   Layout grid
   -----------
   .tbp-shell ─┬─ .tbp-sidebar      240 px, fixed, scrolls independently
               └─ .tbp-main ────────┬─ .tbp-topbar     56 px, sticky
                                     └─ .tbp-content   flex-grow, scrolls
   ========================================================================== */


/* ---------- shell ---------- */
.tbp-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
    background: var(--bg-soft);
}

/* ---------- sidebar ---------- */
.tbp-sidebar {
    background: linear-gradient(180deg, #FFFFFF 0%, #F0FDF4 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.tbp-brand {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.tbp-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--grad-hero);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-md);
}

.tbp-brand-text {
    line-height: 1.1;
}

.tbp-brand-text .name {
    font-weight: 700;
    color: var(--text);
    font-size: 15px;
}

.tbp-brand-text .sub {
    color: var(--text-mute);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tbp-nav {
    flex: 1;
    padding: 12px 8px 24px;
}

/* Direct (no submenu) links - e.g. Dashboard sits at the top, no toggle. */
.tbp-nav-direct {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 4px 4px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.tbp-nav-direct:hover {
    background: var(--primary-05);
    color: var(--primary-dk);
}

.tbp-nav-direct.active {
    background: var(--primary-10);
    color: var(--primary-dk);
    font-weight: 600;
}

/* Group container holds the toggle button + the collapsible panel. */
.tbp-nav-group {
    margin: 2px 0;
}

/* The clickable main-menu row. */
.tbp-nav-group-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 8px);
    margin: 2px 4px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.tbp-nav-group-btn:hover {
    background: var(--primary-05);
    color: var(--primary-dk);
}

.tbp-nav-group-btn.open {
    color: var(--primary-dk);
    background: var(--primary-05);
}

/* "Contains the active page" - persists even when the group is collapsed
   so the user can see which section they're in at a glance.  Applied by
   wx-sidebar.js when any descendant link has .active. */
.tbp-nav-group-btn.has-active {
    color: var(--primary-dk);
    font-weight: 700;
}

.tbp-nav-group-btn.has-active .tbp-nav-icon {
    color: var(--primary);
}

.tbp-nav-group-btn .label {
    flex: 1;
}

.tbp-nav-group-btn .chev {
    font-size: 10px;
    color: var(--text-faint);
    transition: transform 0.2s var(--ease);
    display: inline-block;
    width: 12px;
    text-align: center;
}

.tbp-nav-group-btn.open .chev {
    transform: rotate(90deg);
    color: var(--primary-dk);
}

/* The submenu panel itself.  max-height transition is driven by JS
   that sets explicit pixel heights so the animation is smooth no
   matter how many children the group has. */
.tbp-nav-group-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s var(--ease);
    margin-left: 8px;
    border-left: 1px dashed var(--border);
    padding-left: 8px;
}

.tbp-nav-group-panel.open {
    /* Actual pixel value injected by wx-sidebar.js to match content. */
}

/* Submenu links sit inside the panel.  Smaller, indented, with a left
   accent on the active item. */
.tbp-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 14px;
    margin: 1px 4px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 13px;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.tbp-nav a:hover {
    background: var(--primary-05);
    color: var(--primary-dk);
}

.tbp-nav a.active {
    background: var(--primary-10);
    color: var(--primary-dk);
    font-weight: 600;
}

.tbp-nav a.active::before {
    content: '';
    width: 3px;
    height: 18px;
    background: var(--primary);
    border-radius: 2px;
    margin-right: 2px;
    margin-left: -7px;
}

.tbp-nav-icon {
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    font-size: 14px;
    opacity: 0.85;
}

/* ---------- main pane ----------
   align-self: start prevents the grid row from stretching the main pane
   past its natural content height, which would otherwise leave a big
   gray gap below the form's Save / Cancel buttons when the sidebar
   (height: 100vh) is taller than the content. */
.tbp-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    align-self: start;
}

/* ---------- topbar ---------- */
.tbp-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 56px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tbp-breadcrumb {
    color: var(--text-mute);
    font-size: 13px;
}

.tbp-breadcrumb a {
    color: var(--text-mute);
}

.tbp-breadcrumb a:hover {
    color: var(--primary-dk);
}

.tbp-breadcrumb .sep {
    margin: 0 6px;
    color: var(--text-faint);
}

.tbp-breadcrumb .current {
    color: var(--text);
    font-weight: 600;
}

.tbp-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tbp-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-soft);
    transition: background 0.15s var(--ease);
    position: relative;
}

.tbp-icon-btn:hover {
    background: var(--primary-05);
    color: var(--primary-dk);
}

.tbp-icon-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--bg);
}

.tbp-user-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 14px 4px 4px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.15s var(--ease);
}

.tbp-user-pill:hover {
    border-color: var(--primary);
}

.tbp-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--grad-hero);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 12px;
}

.tbp-user-pill .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.tbp-user-pill .role {
    font-size: 11px;
    color: var(--text-mute);
    line-height: 1;
    margin-top: 2px;
}

/* ---------- content ----------
   No flex: 1 - we want the content area to size to its actual content
   and not stretch to fill the grid row.  The .tbp-shell background
   (var(--bg-soft)) provides the unified backdrop below.  Min-height
   keeps short pages (login etc) visually filled. */
.tbp-content {
    padding: 24px;
    min-height: calc(100vh - 56px);
    box-sizing: border-box;
}

.tbp-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
    flex-wrap: wrap;
}

.tbp-page-head h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.tbp-page-head .lede {
    color: var(--text-mute);
    font-size: 13.5px;
    margin: 4px 0 0;
}

.tbp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    background: var(--grad-hero);
    color: white;
    font-weight: 600;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s var(--ease-back), box-shadow 0.15s var(--ease);
    box-shadow: var(--shadow-md);
}

.tbp-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.tbp-btn-ghost {
    background: transparent;
    color: var(--text-soft);
    border: 1px solid var(--border);
    box-shadow: none;
}

.tbp-btn-ghost:hover {
    background: var(--primary-05);
    color: var(--primary-dk);
    border-color: var(--primary);
}

/* ---------- KPI tiles ---------- */
.tbp-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.tbp-kpi {
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease-back);
}

.tbp-kpi:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.tbp-kpi .label {
    color: var(--text-mute);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.tbp-kpi .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.tbp-kpi .sub {
    color: var(--text-faint);
    font-size: 12px;
    margin-top: 6px;
}

.tbp-kpi.accent {
    background: linear-gradient(135deg, var(--primary-05) 0%, var(--accent-lt) 100%);
}

.tbp-kpi.accent .value {
    background: var(--grad-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------- panels ---------- */
.tbp-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 18px;
}

.tbp-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.tbp-panel-head h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* ---------- login screen ---------- */
.tbp-auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--bg-green) 0%, var(--bg) 50%, var(--bg-gold) 100%);
    padding: 24px;
}

.tbp-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
}

.tbp-auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.tbp-auth-brand .mark {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--grad-hero);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
    box-shadow: var(--shadow-md);
}

.tbp-auth-brand .text .name {
    font-weight: 700;
    color: var(--text);
    font-size: 16px;
}

.tbp-auth-brand .text .sub {
    font-size: 11px;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tbp-auth-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
}

.tbp-auth-card .lede {
    color: var(--text-mute);
    font-size: 13.5px;
    margin: 0 0 22px;
}

.tbp-field {
    margin-bottom: 14px;
}

.tbp-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 6px;
}

/* All input types + select + textarea share the same look so every
   field renders consistently regardless of HTML5 type. */
.tbp-field input[type='text'],
.tbp-field input[type='password'],
.tbp-field input[type='email'],
.tbp-field input[type='tel'],
.tbp-field input[type='number'],
.tbp-field input[type='search'],
.tbp-field input[type='url'],
.tbp-field input[type='date'],
.tbp-field input[type='time'],
.tbp-field input[type='datetime-local'],
.tbp-field input[type='month'],
.tbp-field input[type='week'],
.tbp-field input:not([type]),
.tbp-field input[type='file'],
.tbp-field textarea,
.tbp-field select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.3;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

/* Native select needs a custom chevron because we just removed the
   default OS dropdown arrow with appearance:none above. */
.tbp-field select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='2,2 6,6 10,2'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}

/* Native date / time pickers get a green calendar / clock icon so the
   field carries the same brand colour as the rest of the form. */
.tbp-field input[type='date']::-webkit-calendar-picker-indicator,
.tbp-field input[type='time']::-webkit-calendar-picker-indicator,
.tbp-field input[type='datetime-local']::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(45%) sepia(85%) saturate(360%) hue-rotate(115deg) brightness(95%);
    opacity: 0.85;
}

.tbp-field textarea {
    min-height: 88px;
    resize: vertical;
}

.tbp-field input:focus,
.tbp-field textarea:focus,
.tbp-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-10);
}

.tbp-field input:disabled,
.tbp-field textarea:disabled,
.tbp-field select:disabled,
.tbp-field input[readonly] {
    background: var(--bg-mist);
    color: var(--text-mute);
    cursor: not-allowed;
}

.tbp-field input[type='checkbox'],
.tbp-field input[type='radio'] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ==========================================================================
   SIDEBAR FOOTER (logout button)
   ========================================================================== */

.tbp-nav-footer {
    margin-top: auto;
    padding: 10px 8px 14px;
    border-top: 1px solid var(--border);
}

.tbp-nav-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--danger);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.tbp-nav-logout:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
}

.tbp-nav-logout:focus-visible {
    outline: 2px solid var(--danger);
    outline-offset: 0;
}

/* ==========================================================================
   IDLE LOCK SCREEN
   --------------------------------------------------------------------------
   Hidden by default - revealed by wx-idle-lock.js with the .open class.
   z-index 99999 so it sits above sidebar, topbar, modals, toasts, etc.
   pointer-events on body when locked is still inert; the overlay itself
   intercepts every click.
   ========================================================================== */

.tbp-lock-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(17, 24, 39, 0.78);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    backdrop-filter:         blur(8px) saturate(120%);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.tbp-lock-overlay.open {
    display: flex;
    animation: tbp-lock-in 0.18s var(--ease);
}

@keyframes tbp-lock-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tbp-lock-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    text-align: center;
    box-shadow: 0 32px 96px rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border);
    animation: tbp-lock-pop 0.22s var(--ease-back);
}

@keyframes tbp-lock-pop {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.tbp-lock-icon {
    font-size: 44px;
    line-height: 1;
    margin-bottom: 12px;
}

.tbp-lock-card h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
}

.tbp-lock-card .lede {
    font-size: 13.5px;
    color: var(--text-mute);
    margin: 0 0 18px;
    line-height: 1.5;
}

.tbp-lock-card .tbp-field {
    margin-bottom: 12px;
}

.tbp-lock-card .tbp-alert {
    margin: 0 0 10px;
    text-align: left;
}

.tbp-lock-attempts {
    font-size: 12px;
    color: var(--accent-dk);
    margin-top: 10px;
}

/* While locked, prevent the page underneath from being scrolled by
   touchscreen/wheel gestures even though the overlay catches clicks. */
body.tbp-locked {
    overflow: hidden;
}

/* ==========================================================================
   REQUIRED-FIELD MARKERS + VALIDATION SUMMARY
   --------------------------------------------------------------------------
   Auto-applied by Braves.TagHelpers.RequiredLabelTagHelper on labels of
   model properties carrying [Required].  Pair this with the _FormNotices
   partial so every form renders a consistent "what's required" notice
   plus a prominent red list of any server-side validation errors at the
   top of the form.
   ========================================================================== */

.req {
    color: var(--danger);
    font-weight: 700;
    margin-left: 2px;
}

.tbp-required-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    margin-bottom: 14px;
    background: rgba(239, 68, 68, 0.06);
    color: var(--danger);
    border-left: 3px solid var(--danger);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
}

.tbp-required-notice .req {
    margin-left: 0;
}

/* The built-in <div asp-validation-summary="..."> outputs one of these
   two classes depending on ModelState.  We hide the "valid" variant
   entirely and style the "errors" variant as a red banner with bullets. */
.validation-summary-valid {
    display: none;
}

.validation-summary-errors {
    padding: 12px 16px;
    margin-bottom: 16px;
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.validation-summary-errors ul {
    margin: 6px 0 0;
    padding-left: 22px;
}

.validation-summary-errors li {
    margin: 3px 0;
    list-style: disc;
}

.validation-summary-errors::before {
    content: 'Please fix the following before saving:';
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--danger);
}

/* Per-field error message (already used by <span asp-validation-for>) -
   re-style here so it matches the validation summary's red tone. */
.tbp-field .err,
.tbp-field .field-validation-error {
    display: block;
    margin-top: 6px;
    color: var(--danger);
    font-size: 12px;
}

.tbp-field .err {
    display: block;
    margin-top: 6px;
    color: var(--danger);
    font-size: 12px;
}

.tbp-auth-submit {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--grad-hero);
    color: white;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.15s var(--ease-back), box-shadow 0.15s var(--ease);
    box-shadow: var(--shadow-md);
    margin-top: 8px;
}

.tbp-auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.tbp-auth-footer {
    margin-top: 22px;
    text-align: center;
    color: var(--text-faint);
    font-size: 12px;
}

.tbp-alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.tbp-alert.danger {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.tbp-alert.warning {
    background: rgba(245, 158, 11, 0.08);
    color: var(--accent-dk);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.tbp-alert.success {
    background: rgba(34, 197, 94, 0.08);
    color: var(--primary-dk);
    border: 1px solid var(--primary-20);
}

/* ---------- wx-password-toggle (eye icon) ----------
   Auto-applied by wwwroot/js/wx-password-toggle.js to every
   <input type="password"> on the page.  The JS wraps the input in
   .wx-pw-wrap and inserts an absolutely-positioned eye button on
   the right edge.  Click toggles input.type between password / text. */
.wx-pw-wrap {
    position: relative;
    display: block;
    width: 100%;
}

.wx-pw-wrap input[type="password"],
.wx-pw-wrap input[type="text"] {
    padding-right: 42px !important;   /* leave room for the eye */
}

.wx-pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    color: var(--text-mute);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.wx-pw-toggle:hover {
    color: var(--primary-dk);
    background: var(--primary-05);
}

.wx-pw-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 0;
    color: var(--primary-dk);
}

.wx-pw-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

/* ---------- wx-submit spinner ----------
   Used inside disabled buttons while a CRUD post is in flight.  Sits next
   to the "Please wait..." text rendered by wwwroot/js/wx-submit.js. */
.wx-spin {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: wx-spin 0.7s linear infinite;
}

/* Spinner used inside ghost / outline buttons where the background is light. */
.tbp-btn-ghost .wx-spin {
    border: 2px solid rgba(16, 185, 129, 0.20);
    border-top-color: var(--primary-dk);
}

@keyframes wx-spin {
    to { transform: rotate(360deg); }
}

/* While a form is locked, the primary button shows muted styling so the
   "Please wait..." state reads as deliberate and not as a broken click. */
button[type="submit"][aria-busy="true"] {
    cursor: progress !important;
}

/* ==========================================================================
   MOBILE / TABLET RESPONSIVE
   --------------------------------------------------------------------------
   Two breakpoints:
        900px - sidebar collapses behind a hamburger toggle
        640px - inline-grid form layouts stack to a single column,
                page-head wraps, padding shrinks
   ========================================================================== */

/* Hamburger menu toggle - sits on the left of the topbar; hidden by
   default and only shown below the 900px sidebar-collapse breakpoint. */
.tbp-menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    padding: 6px 12px;
    color: var(--text-soft);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 18px;
    line-height: 1;
    align-items: center;
    justify-content: center;
}

.tbp-menu-toggle:hover {
    background: var(--primary-05);
    color: var(--primary-dk);
    border-color: var(--primary);
}

/* Backdrop dims the page behind the slide-out sidebar on mobile.
   Click-anywhere-to-close is wired by wx-sidebar.js. */
.tbp-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.tbp-sidebar-backdrop.open {
    display: block;
}

/* ----- 900px : sidebar slides ----- */
@media (max-width: 900px) {
    .tbp-shell {
        grid-template-columns: 1fr;
    }

    .tbp-sidebar {
        position: fixed;
        z-index: 100;
        width: 270px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.22s var(--ease);
        box-shadow: var(--shadow-lg);
    }

    .tbp-sidebar.open {
        transform: translateX(0);
    }

    .tbp-menu-toggle {
        display: inline-flex;
    }

    .tbp-topbar {
        padding: 0 14px;
        gap: 10px;
    }

    .tbp-breadcrumb {
        font-size: 12px;
    }

    /* User pill compacts: just the avatar, hide name + role text. */
    .tbp-user-pill > div:not(.tbp-avatar) {
        display: none;
    }

    .tbp-user-pill {
        padding: 4px;
    }

    .tbp-content {
        padding: 16px 14px;
    }
}

/* ----- 640px : form grids stack, headings tighten ----- */
@media (max-width: 640px) {

    /* Inline grid layouts inside panels collapse to a single column.
       This targets the inline `style="display: grid; grid-template-columns: 1fr 1fr"`
       (and variations) that the form views use, without needing to
       touch every Razor file. */
    .tbp-panel [style*="display: grid"],
    .tbp-panel [style*="display:grid"] {
        grid-template-columns: 1fr !important;
    }

    /* KPI tiles + page-level grids inside .tbp-content auto-collapse
       (they already use repeat(auto-fit, minmax(...))) but we shrink
       the minimum size so two columns no longer fight for space. */
    .tbp-content > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .tbp-page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .tbp-page-head > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .tbp-page-head h1 {
        font-size: 18px;
    }

    .tbp-page-head .lede {
        font-size: 12.5px;
    }

    .tbp-panel {
        padding: 16px;
    }

    .tbp-panel-head h3 {
        font-size: 14px;
    }

    .tbp-kpi {
        padding: 14px;
    }

    .tbp-kpi .value {
        font-size: 20px;
    }

    /* Submit buttons stretch full-width so they're easy to tap. */
    .tbp-btn {
        padding: 12px 18px;
        font-size: 14px;
    }

    /* Tables in panels keep horizontal scroll but tighten cell padding. */
    .tbp-panel table th,
    .tbp-panel table td {
        padding: 8px 10px !important;
        font-size: 12.5px;
    }
}
