/*
 * Ultra Biochem CRM — design system & app shell
 * ------------------------------------------------------------------
 * Built on Bootstrap 5.3 (its components follow the tokens below).
 * Light/dark via <html data-bs-theme="light|dark">, set before first
 * paint by the inline script in layouts/partials/head.php.
 */

/* 1. Tokens ------------------------------------------------------- */
:root,
[data-bs-theme="light"] {
    --ub-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --ub-brand-50: #eef2fc;
    --ub-brand-100: #dde5f8;
    --ub-brand-500: #3a63d1;
    --ub-brand-600: #2347a8;
    --ub-brand-700: #1b3a8c;

    --ub-bg: #f4f6f9;
    --ub-surface: #ffffff;
    --ub-surface-2: #f8fafc;
    --ub-surface-hover: #f2f5f9;
    --ub-border: #e3e8ef;
    --ub-border-strong: #cdd5df;

    --ub-text: #0f172a;
    --ub-text-2: #475569;
    --ub-muted: #64748b;

    --ub-accent: var(--ub-brand-600);
    --ub-accent-hover: var(--ub-brand-700);
    --ub-accent-soft: var(--ub-brand-50);
    --ub-accent-ink: #1b3a8c;
    --ub-on-accent: #ffffff;

    --ub-success: #067647;  --ub-success-soft: #e7f8ef;
    --ub-warning: #b54708;  --ub-warning-soft: #fff6e5;
    --ub-danger:  #b42318;  --ub-danger-soft:  #fdeeec;
    --ub-info:    #1d5fb8;  --ub-info-soft:    #eaf2fd;

    --ub-radius-sm: 6px;
    --ub-radius: 10px;
    --ub-radius-lg: 14px;
    --ub-shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --ub-shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
    --ub-shadow-lg: 0 18px 48px -12px rgba(15, 23, 42, .28);
    --ub-ring: 0 0 0 3px rgba(35, 71, 168, .22);

    --ub-sidebar-w: 260px;
    --ub-sidebar-w-collapsed: 72px;
    --ub-topbar-h: 64px;

    /* Charts (validated: dataviz validate_palette.js, light on #ffffff) */
    --ub-chart-surface: var(--ub-surface);
    --ub-series-1: #2a78d6;
    --ub-series-2: #eb6834;
    --ub-series-3: #1baf7a;
    --ub-series-4: #eda100;
    --ub-series-5: #e87ba4;
    --ub-series-6: #008300;
    --ub-grid: #e8ecf1;
    --ub-axis: #cbd2da;
    --ub-ink-muted: #7b8594;
    --ub-delta-up: #067647;
    --ub-delta-down: #b42318;

    color-scheme: light;
}

[data-bs-theme="dark"] {
    --ub-bg: #0b1018;
    --ub-surface: #131a25;
    --ub-surface-2: #172030;
    --ub-surface-hover: #1b2535;
    --ub-border: #243044;
    --ub-border-strong: #33415a;

    --ub-text: #e7ebf2;
    --ub-text-2: #aeb8c8;
    --ub-muted: #8592a6;

    --ub-accent: #5b86ee;
    --ub-accent-hover: #7398f2;
    --ub-accent-soft: rgba(91, 134, 238, .14);
    --ub-accent-ink: #a9c0fa;
    --ub-on-accent: #0b1018;

    --ub-success: #3ccb7f;  --ub-success-soft: rgba(60, 203, 127, .13);
    --ub-warning: #f5b544;  --ub-warning-soft: rgba(245, 181, 68, .13);
    --ub-danger:  #f17166;  --ub-danger-soft:  rgba(241, 113, 102, .13);
    --ub-info:    #7aa7f5;  --ub-info-soft:    rgba(122, 167, 245, .13);

    --ub-shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --ub-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --ub-shadow-lg: 0 18px 48px -12px rgba(0, 0, 0, .65);
    --ub-ring: 0 0 0 3px rgba(91, 134, 238, .35);

    /* Charts (validated: dark on #131a25-class surface) */
    --ub-series-1: #3987e5;
    --ub-series-2: #d95926;
    --ub-series-3: #199e70;
    --ub-series-4: #c98500;
    --ub-series-5: #d55181;
    --ub-series-6: #008300;
    --ub-grid: #1f2a3b;
    --ub-axis: #33415a;
    --ub-ink-muted: #8592a6;
    --ub-delta-up: #3ccb7f;
    --ub-delta-down: #f17166;

    color-scheme: dark;
}

/* Bootstrap follows the tokens */
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
    --bs-body-font-family: var(--ub-font);
    --bs-body-bg: var(--ub-bg);
    --bs-body-color: var(--ub-text);
    --bs-secondary-color: var(--ub-text-2);
    --bs-tertiary-color: var(--ub-muted);
    --bs-border-color: var(--ub-border);
    --bs-border-radius: var(--ub-radius-sm);
    --bs-border-radius-lg: var(--ub-radius);
    --bs-primary: var(--ub-accent);
    --bs-link-color: var(--ub-accent);
    --bs-link-hover-color: var(--ub-accent-hover);
    --bs-focus-ring-color: rgba(35, 71, 168, .25);
}
/* Bootstrap paints fields with --bs-body-bg, which is the grey page background
   above, so editable fields looked readonly. Put them on the card surface instead.
   .form-floating too: its floated-label backdrop on textareas uses the same variable. */
.form-control, .form-select, .form-floating { --bs-body-bg: var(--ub-surface); }
/* Bootstrap's one-line floating label has no width cap, so a label longer than its
   field ran past the field's edge instead of ending in an ellipsis. */
.form-floating > label { max-width: 100%; }

/* 2. Base --------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
body.app-body {
    margin: 0;
    font-family: var(--ub-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ub-text);
    background: var(--ub-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.app-body :focus-visible { outline: none; box-shadow: var(--ub-ring); border-radius: var(--ub-radius-sm); }
.tabular { font-variant-numeric: tabular-nums; }
.text-2 { color: var(--ub-text-2) !important; }
.text-muted-ub { color: var(--ub-muted) !important; }
.visually-hidden-focusable:not(:focus):not(:focus-within) { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; }
[x-cloak] { display: none !important; }

.skip-link { position: absolute; left: 12px; top: -48px; z-index: 2000; background: var(--ub-accent); color: var(--ub-on-accent); padding: 8px 14px; border-radius: var(--ub-radius-sm); transition: top .15s; }
.skip-link:focus { top: 12px; }

/* Buttons — Bootstrap primary in brand colours */
.btn { font-weight: 500; border-radius: var(--ub-radius-sm); }
.btn-primary {
    --bs-btn-bg: var(--ub-accent); --bs-btn-border-color: var(--ub-accent);
    --bs-btn-hover-bg: var(--ub-accent-hover); --bs-btn-hover-border-color: var(--ub-accent-hover);
    --bs-btn-active-bg: var(--ub-accent-hover); --bs-btn-active-border-color: var(--ub-accent-hover);
    --bs-btn-color: var(--ub-on-accent); --bs-btn-hover-color: var(--ub-on-accent); --bs-btn-active-color: var(--ub-on-accent);
    --bs-btn-disabled-bg: var(--ub-accent); --bs-btn-disabled-border-color: var(--ub-accent);
}
.btn-ghost {
    --bs-btn-color: var(--ub-text-2); --bs-btn-bg: transparent; --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: var(--ub-surface-hover); --bs-btn-hover-color: var(--ub-text); --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: var(--ub-surface-hover); --bs-btn-active-border-color: transparent;
}
.btn-soft {
    --bs-btn-color: var(--ub-text); --bs-btn-bg: var(--ub-surface); --bs-btn-border-color: var(--ub-border);
    --bs-btn-hover-bg: var(--ub-surface-hover); --bs-btn-hover-color: var(--ub-text); --bs-btn-hover-border-color: var(--ub-border-strong);
    --bs-btn-active-bg: var(--ub-surface-hover); --bs-btn-active-border-color: var(--ub-border-strong);
    box-shadow: var(--ub-shadow-sm);
}
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; }
.btn-icon .bi { font-size: 18px; }

/* 3. App shell ---------------------------------------------------- */
.app-shell { min-height: 100vh; }

.app-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1045;
    width: var(--ub-sidebar-w);
    display: flex; flex-direction: column;
    background: var(--ub-surface);
    border-right: 1px solid var(--ub-border);
    transition: width .2s ease, transform .2s ease;
}
.sidebar-brand {
    height: var(--ub-topbar-h); flex: none;
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px 0 18px;
    border-bottom: 1px solid var(--ub-border);
}
.sidebar-brand-link { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--ub-text); }
.sidebar-logo { height: 40px; width: auto; flex: none; border-radius: 6px; }
[data-bs-theme="dark"] .sidebar-logo { background: #fff; padding: 2px 4px; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand-text strong { font-size: 13px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand-text span { font-size: 11px; color: var(--ub-muted); white-space: nowrap; }
.sidebar-collapse-btn { margin-left: auto; flex: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 16px; scrollbar-width: thin; scrollbar-color: var(--ub-border-strong) transparent; }
.nav-section + .nav-section { margin-top: 14px; }
.nav-section-label { padding: 6px 12px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ub-muted); white-space: nowrap; }
.nav-list, .nav-sublist { list-style: none; margin: 0; padding: 0 !important; }
.nav-item-link {
    display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: 38px; padding: 8px 12px; margin: 1px 0;
    border: 0; border-radius: 8px; background: none;
    color: var(--ub-text-2); font-size: 14px; font-weight: 500; text-align: left; text-decoration: none;
    white-space: nowrap; cursor: pointer;
    transition: background-color .12s, color .12s;
}
.nav-item-link .bi { font-size: 18px !important; flex: none; width: 20px; text-align: center; }
.nav-item-link:hover { background: var(--ub-surface-hover); color: var(--ub-text); }
.nav-item-link.is-active { background: var(--ub-accent-soft); color: var(--ub-accent-ink); }
.nav-item-link.is-active .bi { color: var(--ub-accent); }
.nav-item-link .nav-chevron { margin-left: auto; font-size: 12px !important; width: auto; transition: transform .15s; }
.nav-item-link[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-sublist { margin: 2px 0 6px 22px !important; padding-left: 10px !important; border-left: 1px solid var(--ub-border); }
.nav-sublink {
    display: block; padding: 7px 12px; border-radius: 6px;
    color: var(--ub-text-2); font-size: 13.5px; text-decoration: none; white-space: nowrap;
}
.nav-sublink:hover { background: var(--ub-surface-hover); color: var(--ub-text); }
.nav-sublink.is-active { color: var(--ub-accent-ink); font-weight: 600; background: var(--ub-accent-soft); }

.sidebar-footer { flex: none; border-top: 1px solid var(--ub-border); padding: 10px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; color: var(--ub-text); text-decoration: none; }
.sidebar-user:hover { background: var(--ub-surface-hover); color: var(--ub-text); }
.sidebar-user-meta { min-width: 0; line-height: 1.2; }
.sidebar-user-meta strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta span { font-size: 12px; color: var(--ub-muted); }

.avatar {
    width: 34px; height: 34px; flex: none; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--ub-accent-soft); color: var(--ub-accent-ink);
    font-size: 13px; font-weight: 600; letter-spacing: .02em;
}

/* Collapsed (desktop) */
@media (min-width: 992px) {
    .sb-collapsed .app-shell .app-sidebar { width: var(--ub-sidebar-w-collapsed); }
    .sb-collapsed .app-shell .sidebar-brand { padding: 0 12px; justify-content: center; }
    .sb-collapsed .app-shell .sidebar-brand-text,
    .sb-collapsed .app-shell .nav-section-label,
    .sb-collapsed .app-shell .nav-label,
    .sb-collapsed .app-shell .nav-chevron,
    .sb-collapsed .app-shell .nav-sublist,
    .sb-collapsed .app-shell .sidebar-user-meta { display: none !important; }
    .sb-collapsed .app-shell .sidebar-brand-link { display: none; }
    .sb-collapsed .app-shell .sidebar-collapse-btn { margin: 0; }
    .sb-collapsed .app-shell .nav-item-link { justify-content: center; padding: 8px; }
    .sb-collapsed .app-shell .nav-section + .nav-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ub-border); }
    .sb-collapsed .app-shell .sidebar-user { justify-content: center; }
    .sb-collapsed .app-shell .app-main { margin-left: var(--ub-sidebar-w-collapsed); }
}

.app-main { margin-left: var(--ub-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; min-width: 0; }

.app-topbar {
    position: sticky; top: 0; z-index: 1030;
    height: var(--ub-topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px;
    background: var(--ub-surface);
    background: color-mix(in srgb, var(--ub-surface) 88%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--ub-border);
}
/* Only the title gives up space on narrow screens; the controls keep their size. */
.app-topbar > :not(.topbar-title) { flex-shrink: 0; }
.topbar-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.topbar-title .crumb { font-size: 12px; color: var(--ub-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title h1 { margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search {
    margin-left: auto;
    display: flex; align-items: center; gap: 10px;
    width: min(380px, 40vw); height: 38px; padding: 0 10px 0 12px;
    border: 1px solid var(--ub-border); border-radius: 8px;
    background: var(--ub-surface-2); color: var(--ub-muted);
    font-size: 13.5px; text-align: left; cursor: pointer;
    transition: border-color .12s, background-color .12s;
}
.topbar-search:hover { border-color: var(--ub-border-strong); background: var(--ub-surface); }
.topbar-search .bi { font-size: 15px !important; }
.topbar-search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd.ub-kbd {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 1px 6px; border: 1px solid var(--ub-border); border-bottom-width: 2px; border-radius: 5px;
    background: var(--ub-surface); color: var(--ub-muted);
    font: 500 11px/1.4 var(--ub-font); box-shadow: none;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-user { display: flex; align-items: center; gap: 8px; padding: 3px 6px 3px 3px; border-radius: 999px; border: 1px solid transparent; background: none; color: var(--ub-text); }
.topbar-user:hover { background: var(--ub-surface-hover); }
.topbar-user .avatar { width: 32px; height: 32px; }

.app-content { flex: 1; padding: 24px; min-width: 0; }
.app-footer { padding: 16px 24px 20px; color: var(--ub-muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; align-items: center; }
.app-footer a { color: var(--ub-text-2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.app-footer img { height: 18px; width: auto; }

/* Dropdowns */
.dropdown-menu { --bs-dropdown-bg: var(--ub-surface); --bs-dropdown-border-color: var(--ub-border); --bs-dropdown-link-hover-bg: var(--ub-surface-hover); --bs-dropdown-link-color: var(--ub-text); --bs-dropdown-link-hover-color: var(--ub-text); --bs-dropdown-link-active-bg: var(--ub-accent-soft); --bs-dropdown-link-active-color: var(--ub-accent-ink); border-radius: var(--ub-radius); box-shadow: var(--ub-shadow-lg); padding: 6px; font-size: 14px; }
.dropdown-item { border-radius: 6px; padding: 7px 10px; display: flex; align-items: center; gap: 10px; }
.dropdown-item .bi { font-size: 16px !important; color: var(--ub-muted); }
.dropdown-header { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--ub-muted); }

/* Mobile */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--ub-shadow-lg); }
    .app-shell.is-mobile-open .app-sidebar { transform: none; }
    .app-shell.is-mobile-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(15, 23, 42, .45); }
    .app-main { margin-left: 0; }
    .app-topbar { padding: 0 16px; }
    .app-content { padding: 16px; }
    .app-footer { padding: 12px 16px 16px; }
    .topbar-search { width: 38px; padding: 0; justify-content: center; }
    .topbar-search span, .topbar-search kbd { display: none; }
    .sidebar-collapse-btn { display: none; }
}
@media (min-width: 992px) { .topbar-menu-btn { display: none !important; } }

/* 4. Components --------------------------------------------------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-header h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.page-header p { margin: 4px 0 0; color: var(--ub-text-2); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ub-card {
    background: var(--ub-surface);
    border: 1px solid var(--ub-border);
    border-radius: var(--ub-radius-lg);
    box-shadow: var(--ub-shadow-sm);
    min-width: 0;
}
.ub-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.ub-card-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.ub-card-header .sub { font-size: 12.5px; color: var(--ub-muted); margin-top: 2px; }
.ub-card-body { padding: 16px 18px 18px; }
.ub-card-link { font-size: 13px; font-weight: 500; color: var(--ub-accent); text-decoration: none; white-space: nowrap; }
.ub-card-link:hover { text-decoration: underline; }

.dash-grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; }
@media (min-width: 1200px) {
    .xl-span-4 { grid-column: span 4; } .xl-span-5 { grid-column: span 5; }
    .xl-span-7 { grid-column: span 7; } .xl-span-8 { grid-column: span 8; }
}
@media (min-width: 768px) and (max-width: 1199.98px) {
    .md-span-6 { grid-column: span 6; }
}

/* Hero figure — exactly one per view */
.hero-card { padding: 20px 22px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; position: relative; overflow: hidden; }
.hero-card::after { content: ""; position: absolute; inset: auto -60px -80px auto; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(closest-side, var(--ub-accent-soft), transparent); pointer-events: none; }
.hero-label { font-size: 13px; font-weight: 500; color: var(--ub-text-2); display: flex; align-items: center; gap: 8px; }
.hero-value { font-size: 44px; line-height: 1.05; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; }
@media (min-width: 1200px) { .hero-value { font-size: 52px; } }
.hero-sub { color: var(--ub-text-2); font-size: 13px; margin-top: 6px; }
.hero-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: relative; z-index: 1; }
.hero-split > div { padding: 12px 14px; border-radius: var(--ub-radius); background: var(--ub-surface-2); border: 1px solid var(--ub-border); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--ub-surface-2); border: 1px solid var(--ub-border); color: var(--ub-text-2); white-space: nowrap; }

/* Stat tiles */
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); height: 100%; }
@media (min-width: 576px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat-tile { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s, transform .12s; }
a.stat-tile:hover { border-color: var(--ub-border-strong); box-shadow: var(--ub-shadow); color: inherit; }
.stat-tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--ub-text-2); }
.stat-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--ub-accent-soft); color: var(--ub-accent); }
.stat-icon .bi { font-size: 15px !important; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.01em; line-height: 1.1; }
.stat-foot { font-size: 12px; color: var(--ub-muted); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12.5px; }
.delta.up { color: var(--ub-delta-up); }
.delta.down { color: var(--ub-delta-down); }
.delta.flat { color: var(--ub-muted); }

/* Status badges: always icon + label, never colour alone */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-badge .bi { font-size: 12px !important; }
.status-good    { background: var(--ub-success-soft); color: var(--ub-success); }
.status-warning { background: var(--ub-warning-soft); color: var(--ub-warning); }
.status-critical{ background: var(--ub-danger-soft);  color: var(--ub-danger); }
.status-info    { background: var(--ub-info-soft);    color: var(--ub-info); }
.status-neutral { background: var(--ub-surface-2); color: var(--ub-text-2); border: 1px solid var(--ub-border); }

/* Tables */
.ub-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.ub-table th { position: sticky; top: 0; background: var(--ub-surface-2); color: var(--ub-muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; border-bottom: 1px solid var(--ub-border); white-space: nowrap; text-align: left; }
.ub-table td { padding: 12px 14px; border-bottom: 1px solid var(--ub-border); vertical-align: middle; }
.ub-table tr:last-child td { border-bottom: 0; }
.ub-table tbody tr { transition: background-color .1s; }
.ub-table tbody tr:hover { background: var(--ub-surface-hover); }
.ub-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ub-table a { color: var(--ub-text); font-weight: 600; text-decoration: none; }
.ub-table a:hover { color: var(--ub-accent); }
.table-scroll { overflow-x: auto; }

/* Lists */
.task-list { list-style: none; margin: 0; padding: 0 !important; }
.task-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--ub-border); }
.task-row:last-child { border-bottom: 0; }
.task-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-meta { font-size: 12.5px; color: var(--ub-muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.task-meta a { color: var(--ub-text-2); text-decoration: none; }
.priority { display: inline-flex; flex-direction: column; align-items: center; width: 44px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ub-muted); }
.priority .bi { font-size: 16px !important; }
.priority-high .bi { color: var(--ub-danger); }
.priority-medium .bi { color: var(--ub-warning); }
.priority-low .bi { color: var(--ub-muted); }
.status-select { min-width: 132px; font-size: 13px; padding: 5px 30px 5px 10px; border-radius: 8px; border-color: var(--ub-border); background-color: var(--ub-surface); color: var(--ub-text); }
.status-select:disabled { opacity: .6; }

/* Empty / error / loading */
.empty-state { text-align: center; padding: 28px 16px; color: var(--ub-text-2); }
.empty-state .bi { font-size: 28px !important; color: var(--ub-muted); display: block; margin-bottom: 8px; }
.empty-state strong { display: block; color: var(--ub-text); margin-bottom: 2px; }
.skeleton { position: relative; overflow: hidden; background: var(--ub-surface-2); border-radius: 6px; color: transparent !important; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ub-surface) 70%, transparent), transparent); animation: ub-shimmer 1.3s infinite; }
@keyframes ub-shimmer { 100% { transform: translateX(100%); } }
.is-refreshing { opacity: .55; transition: opacity .15s; }
.spin { display: inline-block; animation: ub-spin .8s linear infinite; }
@keyframes ub-spin { to { transform: rotate(360deg); } }

/* Charts */
.chart-box { position: relative; width: 100%; }
.chart-box svg { display: block; width: 100%; overflow: visible; }
.chart-box .tick { fill: var(--ub-ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-box .gridline { stroke: var(--ub-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-box .baseline { stroke: var(--ub-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-box .bar { fill: var(--ub-series-1); transition: opacity .12s; }
.chart-box .bar.is-dim { opacity: .45; }
.chart-box .bar-label { fill: var(--ub-text-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-box .hit { fill: transparent; cursor: default; outline: none; }
.chart-box .hit:focus-visible { fill: var(--ub-accent-soft); }
.chart-tooltip {
    position: absolute; z-index: 5; pointer-events: none;
    min-width: 150px; padding: 8px 10px;
    background: var(--ub-surface); border: 1px solid var(--ub-border); border-radius: 8px;
    box-shadow: var(--ub-shadow-lg); font-size: 12.5px; line-height: 1.35;
    transform: translate(-50%, calc(-100% - 10px));
}
.chart-tooltip .tt-title { color: var(--ub-muted); font-size: 11.5px; margin-bottom: 3px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.chart-tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.chart-tooltip .tt-value { font-weight: 700; color: var(--ub-text); font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-note { color: var(--ub-text-2); }
.chart-foot { font-size: 12px; color: var(--ub-muted); margin-top: 8px; }

.seg-toggle { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--ub-surface-2); border: 1px solid var(--ub-border); }
.seg-toggle button { border: 0; background: none; padding: 3px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--ub-text-2); }
.seg-toggle button[aria-pressed="true"] { background: var(--ub-surface); color: var(--ub-text); box-shadow: var(--ub-shadow-sm); }

/* Tall segmented bar (part-to-whole) */
.segbar { display: flex; gap: 2px; height: 28px; width: 100%; }
.segbar-part { position: relative; height: 100%; border-radius: 4px; min-width: 2px; display: flex; align-items: center; padding-left: 8px; color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: visible; outline: none; }
.segbar-part.ink-dark,
[data-bs-theme="light"] .segbar-part[data-slot="4"] { color: #0b0b0b; } /* near-black on yellow (palette rule) */
.segbar-part:focus-visible { box-shadow: 0 0 0 2px var(--ub-surface), 0 0 0 4px var(--ub-accent); }
.legend-table { width: 100%; margin-top: 14px; font-size: 13px; border-collapse: collapse; }
.legend-table td { padding: 6px 0; border-bottom: 1px solid var(--ub-border); }
.legend-table tr:last-child td { border-bottom: 0; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }

/* Horizontal bars (ranked) */
.hbar-list { list-style: none; margin: 0; padding: 0 !important; display: grid; gap: 14px; }
.hbar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 6px; }
.hbar-head a { color: var(--ub-text); font-weight: 500; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-head a:hover { color: var(--ub-accent); }
.hbar-head .v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-track { height: 10px; }
.hbar-fill { height: 100%; background: var(--ub-series-1); border-radius: 0 4px 4px 0; min-width: 2px; }

/* Toasts */
.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 2100; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.ub-toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--ub-radius); background: var(--ub-surface); border: 1px solid var(--ub-border); box-shadow: var(--ub-shadow-lg); font-size: 13.5px; }
.ub-toast .bi { font-size: 18px !important; flex: none; margin-top: -1px; }
.ub-toast.success .bi { color: var(--ub-success); }
.ub-toast.error .bi { color: var(--ub-danger); }
.ub-toast.info .bi { color: var(--ub-info); }

/* Command palette */
.palette-backdrop { position: fixed; inset: 0; z-index: 2050; background: rgba(15, 23, 42, .45); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette { width: min(640px, 100%); max-height: 70vh; display: flex; flex-direction: column; background: var(--ub-surface); border: 1px solid var(--ub-border); border-radius: var(--ub-radius-lg); box-shadow: var(--ub-shadow-lg); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--ub-border); }
.palette-input .bi { color: var(--ub-muted); font-size: 18px !important; }
.palette-input input { flex: 1; height: 54px; border: 0; outline: none; background: none; color: var(--ub-text); font-size: 15px; }
.app-body .palette-input input:focus-visible { box-shadow: none; } /* the whole palette is the focus context; no inner ring box */
.palette-results { overflow-y: auto; padding: 6px; }
.palette-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ub-muted); }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--ub-text); text-decoration: none; cursor: pointer; }
.palette-item .bi { font-size: 16px !important; color: var(--ub-muted); width: 18px; text-align: center; }
.palette-item.is-active { background: var(--ub-accent-soft); }
.palette-item.is-active .bi { color: var(--ub-accent); }
.palette-item-text { min-width: 0; flex: 1; }
.palette-item-text strong { display: block; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item-text span { display: block; font-size: 12px; color: var(--ub-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--ub-border); font-size: 12px; color: var(--ub-muted); }
.palette-empty { padding: 28px 16px; text-align: center; color: var(--ub-text-2); }

/* 5. Legacy pages inside the new shell ----------------------------
 * Modernises the shared legacy classes without changing their markup.
 */
.legacy-page { color: var(--ub-text); }
.legacy-page .container-fluid { background: transparent; }
.legacy-page .main-heading { font-size: 20px; font-weight: 650; letter-spacing: -.01em; color: var(--ub-text); }
.legacy-page .main-heading-1 { font-size: 16px; font-weight: 600; color: var(--ub-text); }
.legacy-page .flex-form-style,
.legacy-page .scd_table,
.legacy-page .outer-bs-div { background: var(--ub-surface); border: 1px solid var(--ub-border); border-radius: var(--ub-radius-lg) !important; box-shadow: var(--ub-shadow-sm); }
.legacy-page .theme-color-bg th,
.legacy-page thead.theme-color-bg th { background: var(--ub-surface-2) !important; color: var(--ub-muted) !important; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--ub-border) !important; }
.legacy-page .table { --bs-table-bg: var(--ub-surface); --bs-table-hover-bg: var(--ub-surface-hover); --bs-table-border-color: var(--ub-border); font-size: 13.5px; }
.legacy-page .table > :not(caption) > * > * { padding: .65rem .75rem; }
.legacy-page .table .btn-sm .bi { font-size: 16px; } /* row actions: keeps table rows compact */

/* AJAX list screens (assets/app/js/list-table.js) */
.ub-list { scroll-margin-top: calc(var(--ub-topbar-h) + 12px); }
.ub-list tbody { transition: opacity .15s; }
.ub-list.is-loading tbody { opacity: .5; }
.ub-list td { vertical-align: top; }
.ub-list .ub-list-msg td { text-align: center !important; color: var(--ub-muted); padding: 32px 12px; }
.ub-list .ub-list-msg .btn { margin-left: 10px; }
.ub-list .ub-nowrap { white-space: nowrap; }
.ub-list .ub-line { display: block; }
.ub-list .ub-sub { display: block; color: var(--ub-muted); font-size: 12.5px; }
.ub-list .ub-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; white-space: pre-line; overflow-wrap: anywhere; min-width: 140px; max-width: 360px; }
.ub-list mark { padding: 0 1px; border-radius: 2px; background: #ffe58f; color: #0f172a; }
[data-bs-theme="dark"] .ub-list mark { background: rgba(245, 181, 68, .32); color: var(--ub-text); }
.ub-list .action-btn { cursor: pointer; border-radius: 4px; }
.ub-list .action-btn:focus-visible, .ub-list a:focus-visible { outline: none; box-shadow: var(--ub-ring); }
.ub-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; text-transform: capitalize; background: var(--ub-surface-2); color: var(--ub-text-2); }
.ub-pill-success { background: var(--ub-success-soft); color: var(--ub-success); }
.ub-pill-danger  { background: var(--ub-danger-soft);  color: var(--ub-danger); }
.ub-pill-warning { background: var(--ub-warning-soft); color: var(--ub-warning); }
.ub-pill-info    { background: var(--ub-info-soft);    color: var(--ub-info); }
.ub-pill-accent  { background: var(--ub-accent-soft);  color: var(--ub-accent-ink); }

.ub-list-pager { display: flex; justify-content: space-between; align-items: center; gap: 10px 20px; flex-wrap: wrap; padding-top: 12px; }
.ub-list-summary { margin: 0; font-size: 13px; color: var(--ub-text-2); font-variant-numeric: tabular-nums; }
.ub-list-controls { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; }
.ub-list-size { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--ub-text-2); white-space: nowrap; }
.ub-list-size .form-select { width: auto; min-height: 32px !important; padding-top: 3px; padding-bottom: 3px; }
.ub-list-pager .pagination { padding-left: 0; }
.ub-list-pager .page-link { min-width: 34px; text-align: center; color: var(--ub-text); background: var(--ub-surface); border-color: var(--ub-border); font-variant-numeric: tabular-nums; }
.ub-list-pager .page-link:hover { background: var(--ub-surface-hover); }
.ub-list-pager .page-link:focus-visible { box-shadow: var(--ub-ring); }
.ub-list-pager .active > .page-link { background: var(--ub-accent); border-color: var(--ub-accent); color: var(--ub-on-accent); }
.ub-list-pager .disabled > .page-link { color: var(--ub-muted); background: var(--ub-surface-2); }
.legacy-page .ub-list-pager .bi { font-size: 12px; }
/* Search box on list screens: fills the rest of the filter row */
.legacy-page .ub-list-search { flex: 1 1 260px; }
@media (max-width: 575.98px) {
    .ub-list-pager { flex-direction: column; align-items: stretch; }
    .ub-list-controls { justify-content: space-between; }
    .ub-list-pager .ub-pg-num:not(.active), .ub-list-pager .ub-pg-gap { display: none; } /* phones: Prev · current · Next */
}

/* Spacing system for legacy pages
 * One rhythm on every page: 24px page gutter (16px on phones, from .app-content),
 * 24px inside cards, 24px between form fields, 16px between field rows.
 * The old wrapper (container-fluid mt-3 mb-3 > row > col-sm-12 pt-3 pb-3) added its
 * own gutter on top of the shell's, so content sat ~48px in and missed the top-bar
 * title's edge; nested filter "cards" then indented it again.
 */
.legacy-page > .container-fluid,
.legacy-page > section > .container-fluid { padding-left: 0; padding-right: 0; margin-top: 0 !important; margin-bottom: 0 !important; }
.legacy-page > .container-fluid ~ .container-fluid { margin-top: 24px !important; }
.legacy-page > .container-fluid > .row,
.legacy-page > section > .container-fluid > .row { row-gap: 24px; }
.legacy-page > .container-fluid > .row > [class*="col"],
.legacy-page > section > .container-fluid > .row > [class*="col"] { padding-top: 0 !important; padding-bottom: 0 !important; }

/* Pages whose white wrapper is itself the card (masters, profile) */
.legacy-page > .container-fluid.bg-white { background: var(--ub-surface) !important; border: 1px solid var(--ub-border); border-radius: var(--ub-radius-lg); box-shadow: var(--ub-shadow-sm); padding: 20px 24px; }
.legacy-page > .container-fluid.theme-bg { background: transparent !important; }

/* Cards: 16px + the 8px/12px on each field cell = 24px inset */
.legacy-page .scd_table { padding: 16px 12px; }
.legacy-page .scd_table + .scd_table { margin-top: 24px !important; }
.legacy-page .flex-form-style { padding: 16px 12px; }
/* A form inside a card is part of that card, not a second card */
.legacy-page :is(.scd_table, .outer-bs-div, .flex-form-style, .modal-body) .flex-form-style { padding: 0; background: transparent; border: 0; border-radius: 0 !important; box-shadow: none; }
/* Filter bar above a results table */
.legacy-page .scd_table form.flex-form-style[method="get" i]:not(:last-child) { border-bottom: 1px solid var(--ub-border); padding-bottom: 8px; margin-bottom: 8px; }

/* Field grid */
.legacy-page :is(.w_10, .w_15, .w_16, .w_20, .w_25, .w_33, .w_34, .w_40, .w_45, .w_50, .w_60, .w_67, .w_75, .w_100) { padding: 8px 12px; }
.legacy-page .flex-form-style .form-floating.mb-3:last-child { margin-bottom: 0 !important; }

/* Filter actions: sit level with the 58px floating fields, with a real gap */
.theme-submit-btn-lg, .theme-clear-btn-lg { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.legacy-page form.flex-form-style[method="get" i] > div:has(> :is(.theme-submit-btn-lg, .theme-clear-btn-lg)) { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.legacy-page form.flex-form-style[method="get" i] :is(.theme-submit-btn-lg, .theme-clear-btn-lg) { min-height: 58px !important; }

@media (max-width: 767.98px) {
    .legacy-page .w_25 { padding: 8px 12px !important; }
    .legacy-page > .container-fluid.bg-white { padding: 16px 12px; }
    .legacy-page .scd_table, .legacy-page .flex-form-style { padding: 8px 4px; }
}

.theme-submit-btn, .theme-submit-btn-lg,
.theme-clear-btn, .theme-clear-btn-lg,
.theme-success-btn, .theme-outer-warning-btn, .theme-outer-success-btn {
    border-radius: var(--ub-radius-sm) !important; font-weight: 600; letter-spacing: .01em;
    transition: background-color .12s, box-shadow .12s, color .12s;
}
.theme-submit-btn, .theme-submit-btn-lg { background: var(--ub-accent) !important; color: var(--ub-on-accent) !important; box-shadow: var(--ub-shadow-sm); }
.theme-submit-btn:hover, .theme-submit-btn-lg:hover { background: var(--ub-accent-hover) !important; }
.theme-submit-btn-lg, .theme-clear-btn-lg { min-height: 44px !important; padding: 10px 22px !important; font-size: 14.5px !important; }
.theme-clear-btn, .theme-clear-btn-lg { background: var(--ub-surface) !important; color: var(--ub-text) !important; border: 1px solid var(--ub-border) !important; }
.theme-clear-btn:hover, .theme-clear-btn-lg:hover { background: var(--ub-surface-hover) !important; color: var(--ub-text) !important; }
.theme-success-btn, .theme-outer-success-btn { background: var(--ub-success) !important; color: #fff !important; }
.theme-outer-warning-btn { background: #f5b544 !important; color: #3b2600 !important; }

.legacy-page .form-control, .legacy-page .form-select { border-color: var(--ub-border-strong); border-radius: var(--ub-radius-sm); }
.legacy-page .form-control:focus, .legacy-page .form-select:focus { border-color: var(--ub-accent); box-shadow: var(--ub-ring); }
.legacy-page .modal-content { border: 1px solid var(--ub-border); border-radius: var(--ub-radius-lg); box-shadow: var(--ub-shadow-lg); }
.legacy-page .modal-header { border-bottom-color: var(--ub-border); }

/* DataTables 2 */
.dt-container { font-size: 13.5px; }
.dt-container .dt-input { border: 1px solid var(--ub-border-strong) !important; border-radius: var(--ub-radius-sm) !important; padding: 5px 10px !important; background: var(--ub-surface) !important; }
.dt-container .dt-paging .dt-paging-button { border-radius: 6px !important; }
.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover { background: var(--ub-accent-soft) !important; border-color: transparent !important; color: var(--ub-accent-ink) !important; }

/* 6. Sign-in page ------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--ub-bg); }
@media (min-width: 992px) { .auth-page { grid-template-columns: minmax(420px, 1.05fr) 1fr; } }
.auth-aside {
    display: none; position: relative; overflow: hidden; color: #fff; padding: 48px 56px;
    background:
        radial-gradient(1200px 600px at -10% 110%, rgba(56, 189, 248, .35), transparent 60%),
        radial-gradient(900px 500px at 110% -10%, rgba(99, 102, 241, .45), transparent 60%),
        linear-gradient(160deg, #1a2f7a 0%, #2347a8 55%, #1e6fd0 100%);
}
@media (min-width: 992px) { .auth-aside { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-aside::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); pointer-events: none; }
.auth-aside > * { position: relative; }
.auth-aside h2 { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; max-width: 520px; margin: 0 0 14px; }
.auth-aside p { color: rgba(255, 255, 255, .82); font-size: 15px; max-width: 480px; }
.auth-points { list-style: none; padding: 0 !important; margin: 28px 0 0; display: grid; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: rgba(255, 255, 255, .92); }
.auth-points .bi { font-size: 16px !important; width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: rgba(255, 255, 255, .14); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: .02em; }
.auth-brand img { height: 44px; background: #fff; border-radius: 10px; padding: 4px 6px; }
.auth-aside-foot { font-size: 12.5px; color: rgba(255, 255, 255, .65); }

.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 20px; }
.auth-card { width: min(400px, 100%); }
.auth-card .auth-logo { height: 64px; width: auto; margin-bottom: 20px; }
@media (min-width: 992px) { .auth-card .auth-logo { display: none; } }
[data-bs-theme="dark"] .auth-card .auth-logo { background: #fff; border-radius: 10px; padding: 4px 8px; }
.auth-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-card .lead-sm { color: var(--ub-text-2); margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ub-text); }
.input-wrap { position: relative; }
.input-wrap > .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 16px !important; color: var(--ub-muted); pointer-events: none; }
.ub-input { width: 100%; height: 44px; padding: 0 44px 0 38px; border: 1px solid var(--ub-border-strong); border-radius: 8px; background: var(--ub-surface); color: var(--ub-text); font-size: 14.5px; transition: border-color .12s, box-shadow .12s; }
.ub-input::placeholder { color: var(--ub-muted); }
.ub-input:focus { outline: none; border-color: var(--ub-accent); box-shadow: var(--ub-ring); }
.ub-input[aria-invalid="true"] { border-color: var(--ub-danger); }
.input-action { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; border-radius: 6px; color: var(--ub-muted); display: grid; place-items: center; }
.input-action:hover { color: var(--ub-text); background: var(--ub-surface-hover); }
.input-action .bi { font-size: 17px !important; }
.btn-auth { width: 100%; height: 46px; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.form-alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.form-alert.error { background: var(--ub-danger-soft); color: var(--ub-danger); }
.form-alert.info { background: var(--ub-info-soft); color: var(--ub-info); }
.auth-foot { margin-top: 28px; font-size: 12.5px; color: var(--ub-muted); text-align: center; }
.auth-foot a { color: var(--ub-text-2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.auth-foot img { height: 16px; }
.auth-theme { position: absolute; top: 16px; right: 16px; }

/* 7. Motion & print ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
    .app-sidebar, .app-topbar, .app-footer, .toast-stack { display: none !important; }
    .app-main { margin: 0 !important; }
    .app-content { padding: 0 !important; }
}

/* 8. Touch screens ------------------------------------------------
 * iOS Safari zooms the whole page when a focused field's text is under 16px.
 * Kept last so it wins over the component sizes above.
 */
@media (pointer: coarse) {
    .ub-input, .palette-input input, .status-select, .form-control-1,
    .form-control-sm, .form-select-sm, div.dt-container .dt-input,
    .select2-container .select2-search__field { font-size: 16px; }
}
