/* ============================================================
   DocDairy theme — approved compact surfaces, light + dark variants
   ============================================================ */

:root {
  /* Brand colours and gradients are theme-agnostic */
  --brand-violet: #9482bd;
  --brand-indigo: #6366f1;
  --brand-blue: #4a8fc2;
  --brand-cyan: #087f75;
  --brand-teal: #087f75;
  --brand-pink: #ca708d;
  --brand-orange: #d99b30;
  /* Interaction shades of the brand teal (were literals in app.css): hover on light surfaces,
     hover on dark surfaces, and the focus ring of form controls. */
  --brand-teal-hover: #06675f;
  --brand-teal-hover-dark: #3fb3a1;
  --focus-ring: #2e9e7f;
  /* Behind the sign-in photo while it loads (and if it fails): a deep slate, same in both themes. */
  --auth-backdrop: #112233;
  /* Support-session banner (an operator signed in as a farm user): one unmistakable colour in both
     themes, white ink 9.6:1. fragments/support-banner.html repeats them as var() fallbacks for the
     barn phone, which has its own palette and no theme.css. */
  --support-banner-bg: #5b2a86;
  --support-banner-ink: #ffffff;
  /* The logo roundel is dark ink: it always sits on a white disc, in both themes (offline page). */
  --logo-disc: #ffffff;

  --gradient-primary: linear-gradient(#087f75, #087f75);
  --gradient-pink: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  --gradient-teal: linear-gradient(#087f75, #087f75);
  --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ec4899 100%);
}

[data-bs-theme="dark"] {
  --bg-deep: #15202e;
  --bg-base: #15202e;
  --bg-elevated: #1d2938;
  --sidebar-top: #1d2938;
  --sidebar-bottom: #1d2938;
  --navbar-bg: #1d2938;
  --surface: #1d2938;
  --surface-strong: #263447;
  --surface-border: #334052;
  --surface-border-strong: #46556b;
  --text-primary: #e8eef5;
  --text-secondary: #afbdd0;
  --text-muted: #96a6bb;
  --bs-body-bg: #15202e;
  --bs-body-color: #e8eef5;
  --bs-secondary-color: #afbdd0;
  --bs-tertiary-bg: #263447;
  --bs-border-color: #334052;
  --bs-link-color: #50c5b3;
  --bs-link-hover-color: #81d7cb;
  --brand-teal: #50c5b3;
  --brand-cyan: #50c5b3;
  --brand-blue: #79b4df;
  --brand-orange: #e1b15a;
  --soft-primary: #25443f;
  --soft-warning: #3a3325;
  --soft-danger: #412b35;
  --soft-info: #253a4c;
  /* Ink = text/icon colour on the matching soft tint (and on surfaces); --on-brand = text on a
     solid --brand-teal fill. Every pair clears WCAG AA 4.5:1 on its tint and on --surface. */
  --on-brand: #153129;        /* on #50c5b3 6.6:1 */
  --ink-primary: #50c5b3;     /* on --soft-primary 5.1:1 */
  --ink-warning: #e1b15a;     /* on --soft-warning 6.3:1 */
  --ink-danger: #f09aa8;      /* on --soft-danger 6.1:1 (was #c65b6c, 3.2:1) */
  --ink-info: #79b4df;        /* on --soft-info 5.3:1 */
  --control-bg: #2b3b50;
  --control-border: transparent;   /* dark inputs read by their lighter fill alone */
  --bs-primary-rgb: 80, 197, 179;
  --bs-success-rgb: 80, 197, 179;
  --bs-info-rgb: 121, 180, 223;
  --bs-warning-rgb: 225, 177, 90;
  --gradient-primary: linear-gradient(#50c5b3, #50c5b3);
  --bs-body-secondary-bg: var(--bg-deep);
  --bs-link-color-rgb: 80, 197, 179;
  --bs-link-hover-color-rgb: 129, 215, 203;
}

[data-bs-theme="light"] {
  /* Light surfaces follow the common light-admin convention: a clearly grey page, solid white
     cards, hairline slate borders that are actually visible, and ink-dark text. The previous
     values (page #f5f7fa, borders #e4e9ef, muted #7d8ba1) left white cards floating on a
     near-white page with nothing to separate them, and the calendar unreadable. Every value
     here clears WCAG AA against the surface it sits on.
     v0.9.229: the page grey was softened (#edf0f4 -> #f4f6f9; cards keep their border + shadow) and
     inputs became white with a visible slate border: grey fields with no border on a grey page were
     hard to find (Saeed: "hard for eyes to see the input sections"). */
  --bg-deep: #e9edf2;
  --bg-base: #f4f6f9;
  --bg-elevated: #ffffff;
  --sidebar-top: #ffffff;
  --sidebar-bottom: #ffffff;
  --navbar-bg: #ffffff;
  --surface: #ffffff;
  --surface-strong: #e9edf2;
  --surface-border: #d6dde6;
  --surface-border-strong: #bfc9d6;
  --text-primary: #172234;
  --text-secondary: #46566b;
  --text-muted: #5b6a7f;
  --bs-body-bg: #f4f6f9;
  --bs-body-color: #172234;
  --bs-secondary-color: #46566b;
  --bs-tertiary-bg: #e9edf2;
  --bs-border-color: #d6dde6;
  --bs-link-color: #066b62;         /* = --ink-primary: 5.9:1 on the page, 6.4:1 on white */
  --bs-link-hover-color: #055a52;
  --soft-primary: #d3ebe6;
  --soft-warning: #f8e8c6;
  --soft-danger: #f7dade;
  --soft-info: #d9e7f4;
  /* The brand teal/orange/blue read well as fills but sit at 2–3.9:1 as TEXT on the soft tints,
     so text on a tint takes the darker ink of the same hue. --on-brand is text on a solid teal. */
  --on-brand: #ffffff;        /* on #087f75 4.9:1 */
  --ink-primary: #066b62;     /* on --soft-primary 5.1:1, on white 6.4:1 */
  --ink-warning: #8a5a00;     /* on --soft-warning 4.9:1, on white 5.9:1 */
  --ink-danger: #a3233a;      /* on --soft-danger 5.6:1, on white 7.4:1 */
  --ink-info: #27679a;        /* on --soft-info 4.8:1, on white 6.0:1 */
  --brand-orange: #b7791f;    /* fills/icons only: 3.6:1 on white (was #d99b30, 2.4:1) */
  --control-bg: #ffffff;
  --control-border: #8592a3;  /* input outline: 3.2:1 on white (WCAG 1.4.11 non-text contrast) */
  --chart-grid: #d6dde6;
  --bs-primary: #087f75;
  --bs-primary-rgb: 8, 127, 117;
  --bs-success-rgb: 8, 127, 117;
  --bs-info-rgb: 39, 103, 154;      /* .text-info: #27679a 6.0:1 on white (was #4a8fc2, 3.5:1) */
  --bs-warning-rgb: 138, 90, 0;     /* .text-warning: #8a5a00 5.9:1 on white (was #d99b30, 2.4:1) */
  --bs-body-secondary-bg: var(--bg-deep);
  --bs-link-color-rgb: 6, 107, 98;
  --bs-link-hover-color-rgb: 5, 90, 82;
}
/* Sign-in pages (login, forgot/reset password, 2FA, farm chooser and the account notices) keep the
   light fields they had before v0.9.229: a soft grey fill and no outline, so the icon, the field and
   the password eye read as one seamless pill (Saeed, 2026-11-03: the login inputs "was good as it
   was"). Inside the app the fields stay white with the slate outline. */
[data-bs-theme="light"] .auth-card {
  --control-bg: #f1f4f7;
  --control-border: transparent;
}

/* Fallback when no data-bs-theme attribute exists yet */
:root { color-scheme: dark; }
:root[data-bs-theme="light"] { color-scheme: light; }

/* AdminLTE's screen-reader live region sits at left:-10000px, which is fine in
   LTR but adds 10000px of horizontal scroll width under dir="rtl". Hide it with
   a fixed-position clip technique that never expands the scrollable area. */
.live-region {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

html, body {
    background: var(--bg-base);
    color: var(--text-primary);
    max-width: 100%;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Display",
                 "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
}

.app-wrapper, .login-box { position: relative; z-index: 1; }

/* ---------- Header / navbar ---------- */
.app-header.navbar {
    background: var(--navbar-bg) !important;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--surface-border);
}
.app-header .nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
}
.app-header .nav-link:hover { color: var(--text-primary) !important; }

/* ---------- Sidebar ---------- */
.app-sidebar {
    background: linear-gradient(180deg, var(--sidebar-top) 0%, var(--sidebar-bottom) 100%) !important;
    border-inline-end: 1px solid var(--surface-border);   /* the inner edge: right in LTR, left in RTL */
}
.sidebar-brand {
    border-bottom: 1px solid var(--surface-border);
    padding: 1rem 1.25rem;
}
.brand-link {
    color: var(--text-primary) !important;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.brand-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
}

.sidebar-menu .nav-link {
    color: var(--text-secondary) !important;
    border-radius: 12px;
    margin: 2px 8px;
    padding: 10px 14px;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.sidebar-menu .nav-link:hover {
    background: var(--surface);
    color: var(--text-primary) !important;
    transform: translateX(2px);
}
.sidebar-menu .nav-link.active {
    background: var(--gradient-primary);
    color: #fff !important;
    box-shadow: 0 8px 22px -10px rgba(139, 92, 246, 0.7);
}
.sidebar-menu .nav-link.active .nav-icon { color: #fff !important; }
.sidebar-menu .nav-icon {
    color: var(--text-muted);
    transition: color 0.18s ease;
}
.sidebar-menu .nav-link:hover .nav-icon { color: var(--brand-cyan); }
.nav-header {
    color: var(--text-muted) !important;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 1rem 1.25rem 0.4rem;
}

/* ---------- Content layout ---------- */
.app-main { padding: 0; }
.app-content-header {
    background: transparent;
    padding-top: 1.75rem;
    padding-bottom: 0.5rem;
}
.app-content-header h3 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    font-size: 1.4rem;
}
.app-content { padding: 0.5rem 0 2.5rem; }
.app-content > .container-fluid { padding-left: 1.75rem; padding-right: 1.75rem; }
.app-content-header > .container-fluid { padding-left: 1.75rem; padding-right: 1.75rem; }

/* Page greeting block */
.eyebrow {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.display-title {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.page-greeting { padding-top: 0.25rem; }

/* ---------- Cards (glass) ---------- */
.card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    color: var(--text-primary);
    box-shadow: 0 20px 60px -30px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: var(--surface-border-strong); }
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--surface-border);
    padding: 1.1rem 1.5rem;
}
.card-title { color: var(--text-primary); font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em; }
.card-body { color: var(--text-primary); padding: 1.5rem; }

/* ---------- Stat cards (Zerion-style) ---------- */
.stat-card {
    position: relative;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 20px 60px -30px rgba(0, 0, 0, 0.7);
    transition: border-color 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}
.stat-card:hover {
    border-color: var(--surface-border-strong);
    transform: translateY(-2px);
}
.stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.04) 0%,
        transparent 60%);
    pointer-events: none;
}
.stat-card > * { position: relative; z-index: 1; }
.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin: 0 0 0.6rem;
}
.stat-card .stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.1;
    margin: 0 0 0.4rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.stat-card .stat-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0;
}
.stat-card .stat-icon {
    position: absolute;
    top: 1.1rem;
    inset-inline-end: 1.3rem;   /* the end corner, away from the start-aligned label */
    font-size: 1.5rem;
    color: var(--text-muted);
    opacity: 0.5;
    z-index: 1;
}

/* ---------- Today widget + period selector (dashboard) ---------- */
.today-badge {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    background: var(--gradient-primary);
    color: var(--on-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: 0 12px 26px -12px rgba(139, 92, 246, 0.6);
}
.period-group .btn {
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 8px;
}
.period-group .btn.active {
    background: var(--gradient-primary);
    color: var(--on-brand);
    border-color: transparent;
}

/* ---------- Pill tabs (Wave 5 sub-navs, requirements, medicines) ----------
   Bootstrap's default active pill is its own blue under link-coloured text (1.6:1): the active pill takes the brand
   fill and the on-brand text of the theme instead (4.9:1 light, 6.6:1 dark). The .app-content form outranks app.css's
   ".app-content a:not(.btn):not(.card)" link colour (0,3,1). */
.nav-pills .nav-link.active,
.nav-pills .show > .nav-link,
.app-content .nav-pills .nav-link.active,
.app-content .nav-pills .show > .nav-link {
    background-color: var(--brand-teal);
    color: var(--on-brand);
}

/* ---------- Theme toggle button ---------- */
.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    width: 38px; height: 38px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
    font-size: 1.05rem;
    padding: 0;
}
.theme-toggle:hover {
    background: var(--surface-strong);
    border-color: var(--surface-border-strong);
    color: var(--text-primary);
    transform: translateY(-1px);
}
.theme-toggle:focus-visible {
    outline: 2px solid var(--brand-violet);
    outline-offset: 2px;
}
.auth-theme-toggle {
    position: absolute;
    top: 1rem;
    inset-inline-end: 1rem;     /* opposite corners from the language switch, in both directions */
    z-index: 5;
}
.auth-lang-switch {
    position: absolute;
    top: 1rem;
    inset-inline-start: 1rem;
    z-index: 5;
}
.login-page { position: relative; }

/* ---------- Admin tile (clickable card) ---------- */
.admin-tile { color: var(--text-primary); transition: transform 0.18s ease, border-color 0.18s ease; }
.admin-tile:hover { transform: translateY(-2px); border-color: var(--surface-border-strong); }
.admin-tile-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--gradient-primary);
    color: var(--on-brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.admin-tile h5 { font-weight: 700; letter-spacing: -0.02em; }

/* ---------- PnL up/down accents ---------- */
.pnl-pos { color: #5EEAD4 !important; }
.pnl-neg { color: #FBA5C0 !important; }
.pnl-pos .bi, .pnl-neg .bi { font-size: 0.9em; vertical-align: -0.05em; }

/* ---------- Chart container ---------- */
.chart-wrap {
    position: relative;
    height: 320px;
    width: 100%;
}

/* ---------- Quick links (sidebar of dashboard) ---------- */
.quick-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.quick-link i.bi { font-size: 1.05rem; }
.quick-link i.bi:first-child { color: var(--brand-cyan); }
.quick-link i.bi.ms-auto { color: var(--text-muted); font-size: 0.85rem; }
.quick-link:hover {
    background: var(--surface);
    color: var(--text-primary);
    transform: translateX(2px);
}
.quick-link:hover i.bi.ms-auto { color: var(--text-primary); }

/* ---------- Small-boxes (dashboard tiles) ---------- */
.small-box {
    border-radius: 18px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--surface-border-strong);
    box-shadow: 0 20px 50px -25px rgba(0, 0, 0, 0.75);
    color: #fff;
}
.small-box .inner h3 {
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.02em;
}
.small-box .icon {
    opacity: 0.25;
    font-size: 5rem;
    top: 8px; inset-inline-end: 12px;
}
.small-box.text-bg-primary { background: var(--gradient-primary) !important; }
.small-box.text-bg-success { background: var(--gradient-teal) !important; }
.small-box.text-bg-warning { background: var(--gradient-warm) !important; }
.small-box.text-bg-danger  { background: var(--gradient-pink) !important; }
.small-box .small-box-footer {
    background: rgba(0, 0, 0, 0.18);
    color: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(4px);
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 0.55rem 1.1rem;
    letter-spacing: -0.01em;
    transition: transform 0.15s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary,
.btn-success {
    border: none;
    color: #fff;
    box-shadow: 0 12px 30px -15px rgba(139, 92, 246, 0.7);
}
.btn-primary { background: var(--gradient-primary); }
.btn-success { background: var(--gradient-teal); }
.btn-primary:hover, .btn-success:hover {
    filter: brightness(1.08);
    color: #fff;
}
.btn-outline-primary {
    color: #C4B5FD;
    border-color: rgba(139, 92, 246, 0.4);
    background: transparent;
}
.btn-outline-primary:hover {
    background: rgba(139, 92, 246, 0.15);
    color: #fff;
    border-color: var(--brand-violet);
}
.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--surface-border-strong);
    background: transparent;
}
.btn-outline-secondary:hover {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--surface-border-strong);
}
.btn-outline-success {
    color: #5EEAD4;
    border-color: rgba(20, 184, 166, 0.45);
    background: transparent;
}
.btn-outline-success:hover {
    background: rgba(20, 184, 166, 0.15);
    color: #fff;
    border-color: var(--brand-teal);
}
.btn-outline-danger {
    color: #FBA5C0;
    border-color: rgba(236, 72, 153, 0.45);
    background: transparent;
}
.btn-outline-danger:hover {
    background: rgba(236, 72, 153, 0.15);
    color: #fff;
    border-color: var(--brand-pink);
}

/* ---------- Forms ---------- */
.form-control { background: rgba(255, 255, 255, 0.03); }
/* Colour only: the shorthand would drop Bootstrap's select arrow (a background image). */
.form-select { background-color: rgba(255, 255, 255, 0.03); }
.form-control,
.form-select {
    border: 1px solid var(--surface-border-strong);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.form-control:focus { background: rgba(255, 255, 255, 0.06); }
.form-select:focus { background-color: rgba(255, 255, 255, 0.06); }
.form-control:focus,
.form-select:focus {
    border-color: var(--brand-violet);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
    color: var(--text-primary);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: rgba(255, 255, 255, 0.02); color: var(--text-muted); }
.form-label { color: var(--text-secondary); font-weight: 500; font-size: 0.9rem; }
.input-group .input-group-text {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--surface-border-strong);
    border-inline-start: 0;
    color: var(--text-secondary);
    border-radius: 12px;
}

/* ---------- Tables ---------- */
/* Links inside tables (payee names, etc.) read cleaner without a permanent
   underline; the underline appears on hover as an affordance. */
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }

.table {
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.025);
    --bs-table-striped-color: var(--text-primary);
    --bs-table-border-color: var(--surface-border);
}
.table thead th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--surface-border-strong);
    padding: 0.9rem 1rem;
}
.table tbody td { padding: 0.9rem 1rem; vertical-align: middle; border-color: var(--surface-border); }

/* ---------- Badges ---------- */
.badge {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.4em 0.7em;
    letter-spacing: 0.02em;
}
.text-bg-success { background: rgba(20, 184, 166, 0.18) !important; color: #5EEAD4 !important; }
.text-bg-warning { background: rgba(245, 158, 11, 0.18) !important; color: #FCD34D !important; }
.text-bg-secondary { background: rgba(255, 255, 255, 0.06) !important; color: var(--text-secondary) !important; }
.text-bg-danger { background: rgba(236, 72, 153, 0.18) !important; color: #FBA5C0 !important; }

/* ---------- Alerts ---------- */
.alert {
    border-radius: 14px;
    border: 1px solid;
    backdrop-filter: blur(12px);
}
.alert-success {
    background: rgba(20, 184, 166, 0.12);
    border-color: rgba(20, 184, 166, 0.35);
    color: #99F6E4;
}
.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.35);
    color: #FCD34D;
}
.alert-danger {
    background: rgba(236, 72, 153, 0.12);
    border-color: rgba(236, 72, 153, 0.35);
    color: #FBA5C0;
}

/* ---------- Login / auth layout ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
}
.login-box {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}
.login-logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: var(--gradient-primary);
    color: var(--on-brand);
    font-size: 1.7rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 16px 34px -14px rgba(139, 92, 246, 0.75);
}
.login-logo-badge .bi { color: var(--on-brand); }

/* ---------- Upload progress bar ---------- */
.upload-progress { margin-top: 0.6rem; }
.upload-progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-strong);
    overflow: hidden;
    border: 1px solid var(--surface-border);
}
.upload-progress-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: var(--gradient-primary);
    transition: width 0.15s ease;
}
.upload-progress-label {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.upload-progress.is-done .upload-progress-fill { background: var(--gradient-teal); }
.upload-progress.is-done .upload-progress-label { color: #5EEAD4; }
[data-bs-theme="light"] .upload-progress.is-done .upload-progress-label { color: #15803d; }
.login-logo a {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
}
.login-card-body { padding: 2rem; }
.login-box-msg {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

/* ---------- Footer ---------- */
.app-footer {
    background: transparent;
    border-top: 1px solid var(--surface-border);
    color: var(--text-muted);
    padding: 1rem 1.5rem;
}

/* ---------- Misc text helpers ---------- */
.text-body-secondary { color: var(--text-secondary) !important; }
.text-success { color: #5EEAD4 !important; }
.text-danger  { color: #FBA5C0 !important; }
code {
    background: rgba(139, 92, 246, 0.12);
    color: #DDD6FE;
    padding: 0.15em 0.4em;
    border-radius: 6px;
    font-size: 0.88em;
}

/* ---------- Table pagination ---------- */
.table-pagination {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--surface-border);
    direction: ltr;            /* keep prev/numbers/next in the familiar order */
}
.tp-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 0.5rem;
    border-radius: 9px;
    border: 1px solid var(--surface-border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-variant-numeric: normal;
    transition: background 0.15s ease, color 0.15s ease;
}
.tp-btn:hover:not(:disabled) { color: var(--text-primary); background: var(--surface-strong); }
.tp-btn:disabled { opacity: 0.4; cursor: default; }
.tp-num.active { background: var(--gradient-primary); color: var(--on-brand); border-color: transparent; }
.tp-info { margin-inline-start: auto; color: var(--text-muted); font-size: 0.8rem; }

/* ---------- Notification bell ---------- */
.navbar .bi-bell { font-size: 1.15rem; }
.notif-badge-count {
    position: absolute;
    top: 3px;
    inset-inline-end: 3px;               /* top-right in LTR, top-left in RTL */
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    background: #ef4444 !important;      /* solid red — override the muted .text-bg-danger tint */
    color: #fff !important;
    border: 2px solid var(--surface);    /* ring lifts it off the header bar */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    pointer-events: none;                /* clicks fall through to the bell */
}
.tp-size { display: flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-size: 0.8rem; margin-inline-end: 0.35rem; }
.tp-size-select {
    height: 34px;
    padding: 0 0.5rem;
    border-radius: 9px;
    border: 1px solid var(--surface-border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
}
[data-bs-theme="light"] .tp-size-select { background: var(--surface); }

/* ---------- Error page ---------- */
.error-code {
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    margin-bottom: 0.5rem;
}

/* Brand gradient text utility */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Status hero card on dashboard */
.status-hero {
    background: linear-gradient(135deg,
        rgba(139, 92, 246, 0.15) 0%,
        rgba(34, 211, 238, 0.10) 100%);
    border: 1px solid var(--surface-border-strong);
}

/* ---------- OAuth divider + Google button ---------- */
.oauth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.oauth-divider::before,
.oauth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--surface-border-strong);
}

.btn-oauth-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 0.65rem 1rem;
    font-weight: 600;
    box-shadow: 0 8px 20px -12px rgba(0, 0, 0, 0.55);
}
.btn-oauth-google:hover {
    background: #f7f7fa;
    color: #1f2937;
    transform: translateY(-1px);
}

/* ---------- Password show/hide toggle ---------- */
.input-group .pwd-toggle {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
}
.input-group .pwd-toggle:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.07);
}
.pwd-wrap { position: relative; }
.pwd-wrap > .pwd-toggle-btn {
    position: absolute;
    inset-inline-end: 0.7rem;   /* logical: right in LTR, left in RTL */
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem 0.4rem;
    line-height: 1;
    border-radius: 8px;
    transition: color 0.15s ease, background 0.15s ease;
}
.pwd-wrap > .pwd-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.07);
}
.pwd-wrap > input { padding-inline-end: 2.6rem !important; }   /* leave room for the eye, RTL-aware */

/* ============================================================
   Light-theme readability overrides
   The accents above are tuned for a dark background; on the light
   theme they wash out (pale teal/pink amounts, pale lavender code).
   These swap in darker, conventional, WCAG-AA-readable colours.
   ============================================================ */
[data-bs-theme="light"] .pnl-pos,
[data-bs-theme="light"] .text-success { color: #15803d !important; }   /* green-700  ~5:1  */
[data-bs-theme="light"] .pnl-neg,
[data-bs-theme="light"] .text-danger  { color: #b91c1c !important; }   /* red-700    ~6:1  */

/* Addresses / inline code */
[data-bs-theme="light"] code {
    background: rgba(109, 40, 217, 0.10);
    color: #6d28d9;                                                    /* violet-700 ~7:1  */
}

/* Status badges — the --ink-* tokens (top of this file) on the soft tints, all ≥4.5:1.
   Specificity (0,3,0) beats the refresh block in app.css, which paints the same pairs. */
[data-bs-theme="light"] .text-bg-success   { background: rgba(21, 128, 61, 0.14) !important;  color: #15803d !important; }
[data-bs-theme="light"] .text-bg-warning   { background: rgba(180, 83, 9, 0.15) !important;   color: #b45309 !important; }
[data-bs-theme="light"] .text-bg-danger    { background: rgba(185, 28, 28, 0.13) !important;  color: #b91c1c !important; }
[data-bs-theme="light"] .text-bg-secondary { background: rgba(15, 23, 42, 0.08) !important;   color: var(--text-secondary) !important; }
[data-bs-theme="light"] .badge.text-bg-success,
[data-bs-theme="light"] .badge.bg-success      { background: var(--soft-primary) !important; color: var(--ink-primary) !important; }
[data-bs-theme="light"] .badge.text-bg-warning { background: var(--soft-warning) !important; color: var(--ink-warning) !important; }
[data-bs-theme="light"] .badge.text-bg-info    { background: var(--soft-info) !important;    color: var(--ink-info) !important; }
[data-bs-theme="light"] .badge.text-bg-danger  { background: var(--soft-danger) !important;  color: var(--ink-danger) !important; }
[data-bs-theme="light"] .badge.text-bg-secondary,
[data-bs-theme="light"] .badge.text-bg-light   { background: var(--bg-deep) !important;      color: var(--text-secondary) !important; }
[data-bs-theme="light"] .badge.text-bg-primary { color: var(--on-brand) !important; }

/* Alerts */
[data-bs-theme="light"] .alert-success { background: rgba(21, 128, 61, 0.10); border-color: rgba(21, 128, 61, 0.30); color: #14532d; }
[data-bs-theme="light"] .alert-warning { background: rgba(180, 83, 9, 0.10);  border-color: rgba(180, 83, 9, 0.30);  color: #7c2d12; }
[data-bs-theme="light"] .alert-danger  { background: rgba(185, 28, 28, 0.10); border-color: rgba(185, 28, 28, 0.30); color: #7f1d1d; }

/* Table headers were near-invisible muted grey on white */
[data-bs-theme="light"] .table thead th { color: var(--text-secondary); }

/* Sortable column-header links */
.table thead th a.th-sort { color: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
.table thead th a.th-sort:hover { color: var(--text-primary); }
.table thead th a.th-sort .bi { font-size: 0.85em; }

/* ============================================================
   Light theme — surface & elevation tuned to common light-admin
   conventions: solid white cards, hairline slate borders, soft
   (not heavy/dark) shadows, and opaque inputs. The base styles use a
   translucent "glass" treatment that only reads well on a dark bg.
   Every token is defined ONCE, in the [data-bs-theme="light"] block at the top of this file;
   this section only consumes them.
   ============================================================ */
[data-bs-theme="light"] .card,
[data-bs-theme="light"] .stat-card {
    background: var(--bg-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--surface-border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px -16px rgba(15, 23, 42, 0.18);
}
[data-bs-theme="light"] .stat-card::after { display: none; }      /* drop the dark sheen */
[data-bs-theme="light"] .card-header { border-bottom-color: var(--surface-border); }

[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
    background-color: #ffffff;
    border-color: var(--surface-border-strong);
}
[data-bs-theme="light"] .form-control { background-image: none; }
[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
    background-color: #ffffff;
    border-color: var(--brand-violet);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}
[data-bs-theme="light"] .input-group .input-group-text {
    background: #F1F5F9;
    border-color: var(--surface-border-strong);
    color: var(--text-secondary);
}
[data-bs-theme="light"] .table {
    --bs-table-striped-bg: rgba(15, 23, 42, 0.025);
    --bs-table-border-color: var(--surface-border);
}
[data-bs-theme="light"] .table tbody td { border-color: var(--surface-border); }
[data-bs-theme="light"] .table thead th { border-bottom-color: var(--surface-border-strong); }

/* Outline buttons: give them a visible slate border on white */
[data-bs-theme="light"] .btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--surface-border-strong);
}
[data-bs-theme="light"] .btn-outline-secondary:hover {
    background: #F1F5F9;
    color: var(--text-primary);
}
[data-bs-theme="light"] .theme-toggle,
[data-bs-theme="light"] .tp-btn {
    background: #ffffff;
    border-color: var(--surface-border-strong);
}
[data-bs-theme="light"] .tp-btn:hover:not(:disabled) { background: #F1F5F9; }

/* Pagination/table separators */
[data-bs-theme="light"] .table-pagination { border-top-color: var(--surface-border); }
