/* ============ Design tokens (single source of truth for brand colours) ==== */
:root {
    --brand-wine: #7f3852;
    --brand-rose: #a44b6c;
    --brand-aubergine: #623c5f;
    --brand-indigo: #524c78;
    --brand-slate: #6b70a0;

    --success: #3a7d5d;
    --success-dark: #24513c;
    --error: #b03a4a;
    --warning: #b07d3a;
    --whatsapp: #25d366;

    --surface: #ffffff;
    --canvas: #fbf8fc;
    --canvas-secondary: #f4f2f8;

    --border-soft: #ece8f2;
    --border-medium: #e7e2ee;
    --border-strong: #d9d2e4;

    --text-primary: #342a35;
    --text-secondary: #3b3446;
    --text-muted: #766d7d;
    --text-caption: #857b8a;

    /* Derived pastel tints - the colour "almost disappears" into white. */
    --tint-wine-bg: rgba(164, 75, 108, .05);
    --tint-wine-border: rgba(164, 75, 108, .15);
    --tint-indigo-bg: rgba(82, 76, 120, .045);
    --tint-indigo-border: rgba(82, 76, 120, .14);
    --tint-green-bg: rgba(58, 125, 93, .05);
    --tint-green-border: rgba(58, 125, 93, .15);
    --tint-error-bg: rgba(176, 58, 74, .05);
    --tint-error-border: rgba(176, 58, 74, .14);
    --tint-warning-bg: rgba(176, 125, 58, .055);
    --tint-warning-border: rgba(176, 125, 58, .16);
    --tint-slate-bg: rgba(107, 112, 160, .05);
    --tint-slate-border: rgba(107, 112, 160, .15);
    --tint-aubergine-bg: rgba(98, 60, 95, .05);
    --tint-aubergine-border: rgba(98, 60, 95, .15);

    --shadow-card: 0 2px 10px rgba(52, 42, 53, .025);
    --shadow-card-hover: 0 5px 15px rgba(52, 42, 53, .055);
}

/* ============ Static-SSR app shell (appbar + drawer + user menu) ============
   The layout never runs interactively (render modes propagate DOWNWARD from
   pages only), so the drawer is toggled by js/app.js and the user menu is a
   <details> popover — no Blazor circuit needed. */
.appbar-shell {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border-radius: 0 !important;
    background: linear-gradient(90deg, #7f3852 0%, #623c5f 52%, #3f568f 100%);
    color: rgba(255,255,255,.92);
    box-shadow: 0 1px 6px rgba(40,18,32,.18);
}
.appbar-brand { font-weight: 700; font-size: .98rem; }
.appbar-sub { opacity: .7; font-weight: 500; }
.appbar-btn {
    display: inline-grid;
    place-items: center;
    width: 40px; height: 40px;
    border: none; border-radius: 10px;
    background: transparent;
    color: rgba(255,255,255,.92);
    cursor: pointer;
}
.appbar-btn:hover { background: rgba(255,255,255,.08); }

/* User menu: <details> popover, closes on outside click via JS helper */
.user-menu { position: relative; }
.user-menu summary {
    list-style: none;
    display: inline-grid;
    place-items: center;
    width: 40px; height: 40px;
    border-radius: 10px;
    cursor: pointer;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: rgba(255,255,255,.08); }
.user-menu-panel {
    position: absolute;
    right: 0; top: 46px;
    min-width: 190px;
    background: #fff;
    color: #2f2a3d;
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(40,18,32,.35);
    padding: 6px;
    z-index: 1300;
}
.user-menu-head { padding: 10px 12px 8px; border-bottom: 1px solid #e7e2ee; margin-bottom: 4px; font-weight: 600; }
.user-menu-role { font-size: .75rem; color: #6b70a0; font-weight: 500; }
.user-menu-panel a {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    color: #5e2b41;
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
}
.user-menu-panel a:hover { background: #f4f2f8; }

/* Admin notification bell: unread = rose bell icon + bold row,
   acknowledged = green check icon + quiet row. Panel shows today's alerts. */
.notif-bell-wrap { position: relative; display: inline-flex; }
.notif-bell { position: relative; z-index: 2; }
.notif-badge {
    position: absolute;
    top: 3px; right: 2px;
    min-width: 17px; height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #ffd0d8;
    color: #8a1330;
    font-size: .66rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.notif-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1;          /* under the bell/panel, over the page */
    background: transparent;
    cursor: default;
}
.notif-panel {
    position: fixed;
    right: 12px; top: 52px;
    width: min(400px, calc(100vw - 24px));
    max-height: min(70vh, 560px);
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #2f2a3d;
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(40,18,32,.35);
    z-index: 2;
    overflow: hidden;
}
.notif-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #e7e2ee;
    font-size: .9rem;
}
.notif-date { color: #6b70a0; font-size: .78rem; }
.notif-markall {
    margin-left: auto;
    border: none;
    background: transparent;
    color: #8f3f5c;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}
.notif-markall:hover { background: #f4f2f8; }
.notif-list { overflow-y: auto; padding: 6px; }
.notif-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 8px 8px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.notif-row:hover { background: #f4f2f8; }
.notif-icon { display: inline-grid; place-items: center; flex-shrink: 0; }
.notif-row.is-unread .notif-icon { color: #b03a4a; }   /* unread: rose bell */
.notif-row.is-read   .notif-icon { color: #3a7d5d; }   /* acknowledged: green check */
.notif-row.is-unread .notif-msg { font-weight: 600; }
.notif-row.is-read   .notif-msg { opacity: .62; font-weight: 400; }
.notif-msg { flex: 1; font-size: .84rem; line-height: 1.3; }
.notif-kind { margin-right: 2px; }
.notif-time { flex-shrink: 0; font-size: .72rem; color: #6b70a0; white-space: nowrap; }
.notif-empty { padding: 18px 12px; text-align: center; color: #6b70a0; font-size: .85rem; }

/* Drawer: off-canvas on mobile, pinned on desktop (>=1024px) */
.drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(40,18,32,.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    z-index: 1100;
}
html.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

.app-drawer {
    position: fixed;
    top: 56px; bottom: 0; left: 0;
    width: 248px;
    background: #fff;
    border-right: 1px solid var(--border-soft);
    z-index: 1150;
    transform: translateX(-100%);
    transition: transform .22s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(40,18,32,.08);
}
html.drawer-open .app-drawer { transform: translateX(0); }

@media (min-width: 1024px) {
    .app-drawer { transform: translateX(0); }
    .page-host { margin-left: 248px; }
    .drawer-backdrop { display: none; }
}

.drawer-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 18px 14px;
}
.drawer-title { font-weight: 700; color: #5e2b41; font-size: 1.02rem; }
.drawer-sub { font-size: .75rem; color: var(--brand-slate); }
.drawer-nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.drawer-section {
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .07em;
    color: var(--brand-slate);
    padding: 18px 12px 6px;
}
.drawer-link {
    display: flex; align-items: center; gap: 11px;
    height: 42px;
    padding: 0 13px;
    margin: 2px 0;
    border-radius: 9px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
}
.drawer-link:hover { background: var(--canvas-secondary); color: #5e2b41; }
.drawer-link.active { background: rgba(164,75,108,.10); color: var(--brand-wine); font-weight: 600; }
.drawer-icon { color: var(--brand-slate); width: 22px; height: 22px; flex: 0 0 auto; }
.drawer-link.active .drawer-icon { color: var(--brand-rose); }
.drawer-footer { border-top: 1px solid var(--border-soft); padding: 12px 16px; }
.drawer-who { font-size: .85rem; font-weight: 600; color: #5e2b41; }
.drawer-who-role { font-size: .74rem; color: var(--brand-slate); font-weight: 500; }

/* Page content host: offset for the fixed appbar. Main canvas is WHITE
   (client preference); colored surfaces come from the cards on top of it. */
.page-host {
    padding: 80px clamp(18px, 2.5vw, 32px) 48px;
    min-height: 100dvh;
    background:
        radial-gradient(900px 420px at 95% 0%, rgba(164, 75, 108, .045), transparent 65%),
        #ffffff;
    box-sizing: border-box;
}
.page-host > * { min-height: unset; }
.page-host h1 {
    margin-top: 4px;
    margin-bottom: 24px;
    letter-spacing: -.02em;
    color: #3c3757;
}
.page-host h2,
.page-host h3,
.page-host h4,
.page-host h5,
.page-host h6 { letter-spacing: -.01em; }
.page-host .section-card,
.page-host .mud-paper {
    border-radius: 16px;
}
.page-host .section-card {
    transition: box-shadow .18s ease, transform .18s ease;
}
.page-host .section-card:hover {
    box-shadow: 0 10px 26px rgba(40, 18, 32, .08);
}

/* Gold brand avatar used in the appbar, drawer and profile */
.appbar-avatar {
    background: linear-gradient(145deg, #a44b6c, #8f3f5c) !important;
    color: #fff;
}

/* MudBlazor components that must clear the fixed appbar inside pages */
.page-host .mud-main-content { margin-top: 0; }

/* The auth shell is the whole page on static SSR routes; keep the canvas
   navy so any overflow area blends with the gradient. */
html, body { min-height: 100%; background: #3a1c2b; }

/* FocusOnNavigate focuses the h1 after navigation; a focus ring on a
   non-interactive heading is visual noise on static pages. */
h1:focus { outline: none; }

/* Slim global layer: MudBlazor owns components now. This file only carries
   the few app-specific visuals MudBlazor doesn't cover. */

/* Gold brand avatar used in the appbar, drawer and profile */
.appbar-avatar {
    background: linear-gradient(145deg, #a44b6c, #8f3f5c) !important;
    color: #fff;
}

/* Nicer scrollbars in webkit browsers */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(107, 112, 160, .45); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* Login / Enroll / ChangePassword are static SSR and render outside the
   MudLayout — they get a centered brand card over the navy gradient.
   (Main content already carries the 56px appbar offset.) */
.auth-shell {
    min-height: calc(100dvh - 56px - 48px);
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 500px at 85% -10%, rgba(164, 75, 108, .18), transparent 60%),
        radial-gradient(900px 600px at -10% 110%, rgba(82, 76, 120, .22), transparent 55%),
        linear-gradient(160deg, #5e2b41 0%, #3a1c2b 100%);
}

.auth-card {
    width: min(430px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 32px 30px;
    box-shadow: 0 24px 70px rgba(40, 18, 32, .45);
}

.auth-card h1 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.35rem;
    color: #5e2b41;
    margin: 0 0 4px;
}

.auth-card .mud-typography-caption { color: #6b70a0; }

.auth-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #a44b6c, #8f3f5c);
    color: #fff;
    font-weight: 800;
    font-size: 1.3rem;
    box-shadow: 0 6px 16px rgba(164, 75, 108, .35);
}

/* Monospaced one-time credential / TOTP key display */
.code-key {
    display: block;
    font-family: 'Cascadia Mono', 'Consolas', monospace;
    font-size: 1.05rem;
    letter-spacing: 2px;
    background: #5e2b41;
    color: #f2c9da;
    border-radius: 10px;
    padding: 12px 14px;
    text-align: center;
    user-select: all;
    margin: 10px 0;
}

@media (max-width: 480px) {
    .auth-card { padding: 26px 20px; border-radius: 14px; }
}

/* Static-SSR form primitives — used on the auth pages and inside EditForms
   that must POST (MudBlazor inputs can't bind by name there). Styled to
   blend with the MudBlazor outlined inputs. */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label {
    font-size: .78rem;
    font-weight: 600;
    color: #524c78;
    letter-spacing: .2px;
}
.field input,
.field select,
.field textarea {
    font: inherit;
    font-size: .9rem;
    color: #2f2a3d;
    background: #fff;
    border: 1px solid #d3cddd;
    border-radius: 8px;
    padding: 9px 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
    box-sizing: border-box;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #5e2b41;
    box-shadow: 0 0 0 3px rgba(127, 56, 82, .15);
}

/* Buttons used on static-SSR pages outside MudBlazor reach */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 9px 16px;
    border: 1px solid #d3cddd;
    background: #fff;
    color: #5e2b41;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.97); }
.btn.primary {
    background: linear-gradient(145deg, #8a3e59, #5e2b41);
    border-color: #5e2b41;
    color: #fff;
}
.btn.link { border: none; background: none; color: #7f3852; padding: 4px 6px; }

/* Masked values keep the confidential look inside Mud tables */
.masked-name {
    letter-spacing: 1.5px;
    font-weight: 600;
    color: #6b70a0;
}

/* Phase 2: call-back due today — gold pulse beside the time */
.callback-pending {
    position: relative;
    padding-left: 14px;
    font-weight: 600;
}
.callback-pending::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c76e8e;
    animation: callback-pulse 1.6s ease-in-out infinite;
}
@keyframes callback-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(199, 110, 142, .45); }
    50% { opacity: .55; box-shadow: 0 0 0 5px rgba(199, 110, 142, 0); }
}

/* Inline alerts on static-SSR pages (no MudAlert there) */
.error-box {
    background: #fbf1f4;
    border: 1px solid #eed2da;
    border-left: 4px solid #b03a4a;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 12px 0;
}
.error-box p { margin: 0; color: #7c2433; font-size: .86rem; }
.ok-box {
    background: #f1f8f4;
    border: 1px solid #cfe6d9;
    border-left: 4px solid #3a7d5d;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 12px 0;
}
.ok-box p { margin: 0; color: #24513c; font-size: .86rem; }
.notice-box {
    background: #f4f2f9;
    border: 1px solid #d9d4e6;
    border-left: 4px solid #524c78;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 12px 0;
}
.notice-box p { margin: 0; color: #3c3757; font-size: .86rem; }
.qr-wrap { display: grid; place-items: center; padding: 12px 0; }
.qr-wrap img { border-radius: 12px; box-shadow: 0 8px 24px rgba(94,43,65,.18); }

/* Upload drop zone (Import page activator) */
.upload-zone {
    border: 2px dashed #c9c0d6;
    border-radius: 12px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: #a44b6c; background: rgba(164, 75, 108, .05); }

/* Wide report table horizontal scroll on mobile */
.table-scroll { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.report-table th {
    text-align: left;
    font-weight: 600;
    color: #524c78;
    background: #f4f2f8;
    padding: 8px 12px;
    white-space: nowrap;
}
.report-table td { padding: 7px 12px; border-top: 1px solid #e7e2ee; white-space: nowrap; }

/* Call-back dialog: native date/time fields side by side + quick chips */
.callback-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.callback-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--mud-palette-text-secondary);
}

.callback-field input {
  font: inherit;
  font-size: 0.95rem;
  padding: 9px 12px;
  border: 1px solid var(--mud-palette-grey-lighten, #b0b0b0);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  min-height: 42px;
}

.callback-field input:focus {
  outline: 2px solid var(--mud-palette-primary);
  outline-offset: -1px;
}

.callback-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

@media (max-width: 600px) {
  .callback-fields { grid-template-columns: 1fr; }
}

/* Audit log: rows outside the actor's working hours — hard to miss */
tr.ooh-row { background: #fbf1f4 !important; box-shadow: inset 4px 0 0 #b03a4a; }
tr.ooh-row > td { background: transparent !important; }
.ooh-user { color: #b03a4a; font-weight: 700; }

/* Dashboard: out-of-hours activity banner */
.ooh-banner {
    border-left: 5px solid #b03a4a;
    background: linear-gradient(180deg, #fff5f7, #ffffff);
}

/* ============ Dashboard: clear hierarchy with quiet, data-led surfaces ============ */
.dashboard-canvas {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* The greeting is the only strong visual anchor; everything below it is
   intentionally quieter so counters and work queues stay easy to scan. */
.dash-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-radius: 15px;
    padding: 20px 26px;
    background: linear-gradient(105deg, #8f3f5c 0%, #623c5f 48%, #405c96 100%);
    color: #fff;
    box-shadow: 0 8px 22px rgba(94, 43, 65, .16);
}
.dash-hero::before,
.dash-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
}
.dash-hero::before {
    right: 12%;
    top: -130px;
    width: 280px;
    height: 280px;
    border: 40px solid rgba(255, 255, 255, .05);
}
.dash-hero::after {
    left: 34%;
    bottom: -140px;
    width: 220px;
    height: 220px;
    border: 34px solid rgba(255, 255, 255, .035);
}
.dash-hero-copy,
.dash-hero-actions { position: relative; z-index: 1; }
.dash-hero-copy .mud-typography-h5 {
    font-size: clamp(27px, 2vw, 34px);
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.15;
}
.dash-hero .hero-sub {
    color: rgba(255, 255, 255, .85);
    font-size: 14.5px;
    font-weight: 400;
    line-height: 1.5;
}
.dash-hero-actions { display: flex; align-items: center; gap: 11px; flex: none; }
.dash-hero .mud-button-root {
    min-height: 41px;
    text-transform: none;
    font-weight: 600;
    border-radius: 9px;
}

/* Celebrations: conditional pastel banners, quieter than the hero. Both cards
   share one 50/50 grid when both appear; a single card takes the full row.
   Dark mode restrains the gradients to keep contrast WCAG-friendly. */
.celebration-grid {
    display: grid;
    gap: 14px;
}
@media (min-width: 761px) {
    .celebration-grid.two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.celebration-banner {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 102px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: 14px;
    padding: 18px 22px;
    color: var(--text-primary);
    box-shadow: var(--shadow-card);
}
.mud-theme-dark .celebration-banner.birthday {
    background: linear-gradient(110deg, #2e1a26 0%, #33202e 60%, #3a2334 100%);
    border-color: rgba(217,138,166,.22);
}
.mud-theme-dark .celebration-banner.birthday .cele-icon { background: rgba(217,138,166,.14); color: #d98aa6; }
.mud-theme-dark .celebration-banner.birthday .mud-typography-h6 { color: #d98aa6; }
.mud-theme-dark .celebration-banner.anniversary {
    background: linear-gradient(110deg, #1c2233 0%, #1e2d33 55%, #1e332c 100%);
    border-color: rgba(154,147,201,.22);
}
.mud-theme-dark .celebration-banner.anniversary .cele-icon { background: rgba(154,147,201,.14); color: #9a93c9; }
.mud-theme-dark .celebration-banner.anniversary .mud-typography-h6 { color: #9a93c9; }
.mud-theme-dark .celebration-banner .cele-sub { opacity: .75; }
.celebration-banner::after {
    content: "";
    position: absolute;
    z-index: -1;
    right: -46px;
    top: -58px;
    width: 170px;
    height: 170px;
    border-radius: 50%;
    pointer-events: none;
}
.celebration-banner .cele-icon {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex: none;
}
.celebration-banner .mud-typography-h6 {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.2;
}
.celebration-banner .cele-sub {
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.45;
    opacity: .8;
}
.celebration-banner.birthday {
    background: linear-gradient(110deg, #fff7fa 0%, #fce7ef 60%, #f8dce8 100%);
    border: 1px solid rgba(164,75,108,.12);
}
.celebration-banner.birthday::after { background: rgba(164,75,108,.06); }
.celebration-banner.birthday .cele-icon { background: rgba(164,75,108,.12); color: #8f2754; }
.celebration-banner.birthday .mud-typography-h6 { color: #8f2754; }
.celebration-banner.anniversary {
    background: linear-gradient(110deg, #e9f4ff 0%, #d9f2f0 55%, #dff3df 100%);
    border: 1px solid rgba(82,76,120,.12);
}
.celebration-banner.anniversary::after { background: rgba(82,76,120,.06); }
.celebration-banner.anniversary .cele-icon { background: rgba(82,76,120,.10); color: var(--brand-indigo); }
.celebration-banner.anniversary .mud-typography-h6 { color: #314a88; }

/* KPI tiles: ~90-95% white; only the icon box, border tint and chevron
   carry the stage colour. Four columns on desktop, two on tablet. */
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}
@media (max-width: 1280px) {
    .tiles-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .tiles-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .tiles-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .tiles-grid { grid-template-columns: 1fr; }
}
.tiles-grid .stat-tile { min-width: 0; }
.stat-tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 78px;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--tile-border, var(--border-soft));
    border-radius: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--tile-bg, var(--surface)), #fff 72%);
    box-shadow: var(--shadow-card);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.stat-tile:hover {
    transform: translateY(-1px);
    border-color: var(--tile-border-strong, var(--border-medium));
    box-shadow: var(--shadow-card-hover);
}
.stat-tile:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent, #a44b6c) 35%, transparent);
    outline-offset: 2px;
}
.stat-icon {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 12px;
    background: var(--accent, #7f3852);
    color: #fff;
}
.stat-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.stat-value {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    overflow: hidden;
    color: var(--brand-slate);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .02em;
    line-height: 1.2;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}
.stat-chevron {
    flex: none;
    color: var(--accent, #a44b6c);
    opacity: .55;
    align-self: center;
}

/* Staff details dialog: keep labels aligned and identity values readable
   without making the table look like a form. */
.staff-detail-label {
    width: 190px;
    color: var(--brand-indigo);
    font-weight: 700;
}
.staff-sensitive-value {
    color: var(--success-dark);
    font-weight: 700;
    letter-spacing: .3px;
}

/* Staff Accounts: give the operational forms and account table a little more
   breathing room while keeping the dense table usable on tablets. */
.page-host .staff-page-card {
    border: 1px solid #ece8f2;
    box-shadow: 0 3px 14px rgba(40, 18, 32, .05);
}
.page-host .staff-accounts-table {
    border: 1px solid #ece8f2;
}
.page-host .staff-accounts-table .mud-table-container {
    border-top: 1px solid #eeeaf2;
}
.page-host .staff-accounts-table .mud-table-cell {
    vertical-align: middle;
}
.page-host .staff-accounts-table .mud-table-row:hover {
    background: rgba(164, 75, 108, .035);
}
/* Operational cards: white, soft border, thin semantic left accent. */
.page-host .dashboard-canvas .section-card {
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--accent, var(--brand-rose));
    border-radius: 13px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    margin-bottom: 0 !important;
}
.page-host .dashboard-canvas .section-card:hover {
    transform: none;
    box-shadow: var(--shadow-card);
}
.page-host .dashboard-canvas .section-card .section-head {
    min-height: 34px;
    margin-bottom: 10px;
}
.page-host .dashboard-canvas .section-head h1,
.page-host .dashboard-canvas .section-head h2,
.page-host .dashboard-canvas .section-head h3,
.page-host .dashboard-canvas .section-head h4,
.page-host .dashboard-canvas .section-head h5,
.page-host .dashboard-canvas .section-head h6 {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -.01em;
}

/* Softer tables inside dashboard cards: subtle separators only. */
.page-host .dashboard-canvas .mud-table-root .mud-table-head .mud-table-cell {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
}
.page-host .dashboard-canvas .mud-table-root .mud-table-body td {
    font-size: 12.5px;
    border-bottom: 1px solid #f0edf3;
}

/* Dashboard split: reminders + today's queue keep ~70% of the width while the
   personal disbursement rows (same design as My Profile) sit alongside at
   ~30%; below 1200px the money card stacks under the queue instead. */
.dash-split {
    display: grid;
    grid-template-columns: minmax(0, 2.25fr) minmax(300px, .75fr);
    gap: 16px;
    align-items: start;
}
.dash-split-main,
.dash-split-side { min-width: 0; }
.dash-split-main .section-card + .section-card { margin-top: 14px !important; }
@media (max-width: 1200px) {
    .dash-split { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    .dash-hero { align-items: flex-start; flex-direction: column; padding: 20px; }
    .dash-hero-actions { width: 100%; }
    .dash-hero-actions .mud-button-root { flex: 1; }
    .dashboard-canvas .section-head { flex-wrap: wrap; }
    .page-host .dashboard-canvas .section-card { padding: 14px !important; }
    .stat-tile { min-height: 66px; gap: 10px; padding: 10px; }
    .stat-icon { width: 38px; height: 38px; flex-basis: 38px; }
    .stat-value { font-size: 21px; }
    .stat-label { font-size: 11px; }
    .celebration-banner { padding: 16px; }
}
@media (max-width: 420px) {
    .dash-hero-actions { flex-direction: column; align-items: stretch; }
    .stat-tile { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
    .stat-tile { transition: none; }
    .stat-tile:hover { transform: none; }
}

.staff-details-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #d9d2e4;
    border-radius: 9px;
    padding: 5px 9px;
    color: #524c78;
    background: #fff;
    font: inherit;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.staff-details-trigger:hover { background: #f6f2fa; border-color: #a44b6c; color: #7f3852; }
.staff-details-trigger:disabled { opacity: .6; cursor: wait; }
.staff-details-error { color: #b3261e; font-size: .78rem; margin-top: 4px; }
.staff-details-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(35, 18, 29, .58);
    backdrop-filter: blur(3px);
}
.staff-details-popup {
    width: min(760px, 100%);
    max-height: min(88vh, 900px);
    overflow: auto;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(24, 12, 22, .3);
}
.staff-details-popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 26px 18px;
    background: linear-gradient(135deg, #fbf8fc, #f5eff8);
    border-bottom: 1px solid #ece8f2;
}
.staff-details-popup-header h2 { margin: 2px 0; color: #3d2432; }
.staff-details-kicker { color: #a44b6c; font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.staff-details-subtitle { color: #766d7d; }
.staff-details-close { border: 0; background: transparent; color: #766d7d; font-size: 1.8rem; line-height: 1; cursor: pointer; }
.staff-details-popup-body { padding: 20px 26px 26px; }
.staff-details-notice { margin-bottom: 18px; padding: 10px 12px; border-radius: 10px; color: #6c4e1d; background: #fff8e7; font-size: .84rem; }
.staff-details-section { padding: 15px 0; border-top: 1px solid #eeeaf2; }
.staff-details-section h3 { margin: 0 0 9px; color: #524c78; font-size: .95rem; }
.staff-details-grid { display: grid; grid-template-columns: minmax(150px, 32%) 1fr; gap: 7px 16px; margin: 0; }
.staff-details-grid dt { color: #857b8a; font-size: .82rem; }
.staff-details-grid dd { margin: 0; color: #342a35; font-size: .86rem; overflow-wrap: anywhere; }
.staff-details-identity { padding: 15px 12px 2px; border: 1px solid #d8ecdf; border-radius: 12px; background: #f6fbf7; }
.staff-details-identity h3 { color: #24513c; }
/* Joining-date editor inside the Complete staff profile popup (admin only) */
.joining-edit { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.joining-input {
    border: 1px solid #d9d2e4;
    border-radius: 8px;
    padding: 5px 8px;
    font: inherit;
    font-size: .84rem;
    width: 132px;
    color: #342a35;
    background: #fff;
}
.joining-input:focus { outline: 2px solid #a44b6c; outline-offset: 1px; border-color: #a44b6c; }
.staff-details-save {
    border: 1px solid #7f3852;
    border-radius: 8px;
    padding: 5px 12px;
    background: #7f3852;
    color: #fff;
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
}
.staff-details-save:hover { background: #6b3146; }
.staff-details-save:disabled { opacity: .6; cursor: wait; }
.staff-details-feedback { margin-top: 5px; font-size: .78rem; font-weight: 600; }
.staff-details-feedback.is-ok { color: #3a7d5d; }
.staff-details-feedback.is-error { color: #b3261e; }
.staff-details-hint { margin-top: 4px; font-size: .72rem; color: #857b8a; }
.staff-details-identity .staff-sensitive-value { font-size: 1rem; letter-spacing: .08em; }
@media (max-width: 600px) {
    .staff-details-overlay { padding: 8px; }
    .staff-details-popup-header, .staff-details-popup-body { padding-left: 16px; padding-right: 16px; }
    .staff-details-grid { grid-template-columns: 1fr; gap: 2px 0; }
    .staff-details-grid dd { margin-bottom: 8px; }
}
@media (max-width: 700px) {
    .page-host .staff-page-card { padding: 16px !important; }
    .page-host .staff-accounts-table .pa-4 { padding: 16px !important; }
}

/* Customer row actions stay on one line; the admin-only assign action simply
   occupies the third slot, so the icons never wrap into a second line. */
.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    white-space: nowrap;
}

/* Outlined action buttons: white background in every state (MudBlazor's
   outlined hover tints the surface); tighter radius to match the card
   system, and a hairline border that keeps sibling actions distinct. */
.mud-button-root.mud-button-outlined.mud-button-outlined-primary,
.mud-button-root.mud-button-outlined.mud-button-outlined-secondary,
.mud-button-root.mud-button-outlined.mud-button-outlined-info,
.mud-button-root.mud-button-outlined.mud-button-outlined-success,
.mud-button-root.mud-button-outlined.mud-button-outlined-warning,
.mud-button-root.mud-button-outlined.mud-button-outlined-error {
    background-color: #fff;
    border-radius: 8px;
}
.mud-button-root.mud-button-outlined:hover {
    background-color: #faf7fb;
}
.mud-button-root.mud-button-outlined.mud-button-outlined-warning { border-color: rgba(176,125,58,.45); color: #8b612b; }
.mud-button-root.mud-button-outlined.mud-button-outlined-warning:hover { border-color: #b07d3a; }
.mud-button-root.mud-button-outlined.mud-button-outlined-secondary { border-color: rgba(164,75,108,.45); }
.mud-button-root.mud-button-outlined.mud-button-outlined-error { border-color: rgba(176,58,74,.45); }
.mud-button-root.mud-button-outlined.mud-button-outlined-success { border-color: rgba(58,125,93,.45); }
.mud-button-root.mud-button-outlined.mud-button-outlined-info { border-color: rgba(82,76,120,.45); }
/* Inherit/default-coloured outlined buttons (e.g. dialog Cancel) get the same
   white card treatment. */
.mud-button-root.mud-button-outlined.mud-button-outlined-inherit,
.mud-button-root.mud-button-outlined:not([class*='mud-button-outlined-']) {
    background-color: #fff;
    border-color: #d9d2e2;
    border-radius: 8px;
}

/* Global action-in-progress shield (dashboard): transparent full-page
   click-blocker shown while any action spinner is active. Sits over page
   content but under the appbar (1200), user menu (1300) and MudBlazor
   dialogs/snackbars, so those stay usable. */
.busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(250, 247, 251, .35);
    backdrop-filter: blur(1px);
    cursor: progress;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 72px;
}
.busy-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #ece8f2;
    border-radius: 999px;
    box-shadow: 0 6px 24px rgba(40, 18, 32, .16);
    padding: 8px 16px;
    font-size: .85rem;
    font-weight: 600;
    color: #623c5f;
}
.busy-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--brand-wine, #7f3852);
    animation: busy-pulse 1s ease-in-out infinite;
}
@keyframes busy-pulse {
    0%, 100% { opacity: .25; transform: scale(.8); }
    50% { opacity: 1; transform: scale(1.15); }
}
.mud-theme-dark .busy-overlay { background: rgba(20, 12, 20, .45); }
.mud-theme-dark .busy-pill { background: #2a2130; border-color: #453752; color: #d9c9e8; }

/* Section cards (today's calls, OOH banner, future panels) */
.section-card {
    border-radius: 16px;
    border: 1px solid #ece8f2;
    box-shadow: 0 3px 14px rgba(40, 18, 32, .05);
}
.section-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
}
.section-icon {
    display: inline-grid;
    place-items: center;
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--accent, #7f3852);
    color: #fff;
    flex: none;
}

/* Money rows beside today's calls: bold tabular figures left, quiet label
   right - mirrors the My Profile disbursement table exactly. */
.disbursement-rows td { white-space: nowrap; }
.disbursement-rows td b {
    color: #24513c;
    font-variant-numeric: tabular-nums;
}

/* Dark mode: MudBlazor swaps component palettes, but the dashboard's own
   token block above is light-scoped. When the provider renders dark
   (.mud-theme-dark on the root), re-map the neutrals so cards stay dark
   plum with lighter borders - tints become low-opacity overlays. */
.mud-theme-dark {
    --surface: #271b2e;
    --canvas: #1a1220;
    --canvas-secondary: #241a29;
    --border-soft: #3a2f42;
    --border-medium: #453a4e;
    --border-strong: #52465c;
    --text-primary: #f0e8f0;
    --text-secondary: #e2d8e4;
    --text-muted: #a89bb0;
    --text-caption: #978b9f;
    --shadow-card: 0 2px 10px rgba(0, 0, 0, .35);
    --shadow-card-hover: 0 5px 15px rgba(0, 0, 0, .45);
    --tint-wine-bg: rgba(217, 138, 166, .07);
    --tint-wine-border: rgba(217, 138, 166, .18);
    --tint-indigo-bg: rgba(154, 147, 201, .08);
    --tint-indigo-border: rgba(154, 147, 201, .20);
    --tint-green-bg: rgba(125, 201, 164, .07);
    --tint-green-border: rgba(125, 201, 164, .18);
    --tint-error-bg: rgba(224, 133, 149, .07);
    --tint-error-border: rgba(224, 133, 149, .18);
    --tint-warning-bg: rgba(217, 138, 166, .07);
    --tint-warning-border: rgba(217, 138, 166, .18);
    --tint-slate-bg: rgba(154, 147, 201, .07);
    --tint-slate-border: rgba(154, 147, 201, .18);
    --tint-aubergine-bg: rgba(217, 138, 166, .06);
    --tint-aubergine-border: rgba(217, 138, 166, .16);
}
.mud-theme-dark .page-host {
    background:
        radial-gradient(900px 420px at 95% 0%, rgba(217, 138, 166, .04), transparent 65%),
        var(--canvas);
}

/* Snackbar: rounded, floating, blur — all alerts surface through it */
.mud-snackbar {
    border-radius: 12px !important;
    box-shadow: 0 12px 34px rgba(40, 18, 32, .30) !important;
    font-weight: 500;
}
.mud-snackbar .mud-snackbar-content-message { font-size: .9rem; }

/* Audit detail cells: plain label/value text, bold labels, no JSON ever.
   Used by /audit, the dashboard out-of-hours banner, and mirrored in the
   Excel export via AuditDetailFormatter.Summarize. */
.audit-detail {
    display: flex;
    flex-wrap: wrap;
    column-gap: 12px;
    row-gap: 2px;
    font-size: .82rem;
    color: #3c3757;
    line-height: 1.45;
    min-width: 220px;
}
.audit-detail-item b {
    font-weight: 700;
    color: #524c78;
}
.audit-detail-more {
    font-size: .72rem;
    font-weight: 600;
    color: #6b70a0;
    background: #f4f2f8;
    border-radius: 6px;
    padding: 1px 7px;
}

/* Audit detail dialog: neat two-column label/value sheet */
.audit-detail-table .ad-label {
    font-weight: 700;
    color: #524c78;
    width: 180px;
    white-space: nowrap;
    vertical-align: top;
}
.audit-detail-table td {
    font-size: .88rem;
    padding: 7px 10px !important;
    border-bottom: 1px solid #f0edf5 !important;
}
.audit-detail-table tr:last-child td { border-bottom: none !important; }

/* Responsive loan-type cell: full product name on wide screens, compact
   code on narrow ones (the code carries a title tooltip either way). */
.loan-type-code { display: none; }
@media (max-width: 600px) {
    .loan-type-full { display: none; }
    .loan-type-code { display: inline; font-weight: 700; color: #524c78; }
}

/* Small "?" helper chip next to jargon form fields — hover for a plain-
   language explanation (also fine on touch: it opens on tap). */
.helper-chip {
    font-size: .72rem;
    font-weight: 700;
    color: #ffffff;
    background: #6b70a0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    margin-left: 4px;
    flex: none;
    user-select: none;
}

/* Defensive icon sizing: keeps MudBlazor SVGs sane even if their stylesheet
   fails to load (stale cache), instead of exploding into giant black glyphs. */
.appbar-btn-icon { width: 26px; height: 26px; }
.appbar-btn .mud-icon-size-medium { width: 22px; height: 22px; }
svg.mud-icon-size-small { width: 20px; height: 20px; }
svg.mud-icon-size-medium { width: 24px; height: 24px; }

/* Static-SSR form double-submit guard (class set by js/app.js on submit). */
form.form-busy { opacity: .65; pointer-events: none; transition: opacity .15s ease; }
