/*
 * IHPIS theme. Tokens follow the Dreams Core light scheme (green primary, dark sidebar, 5px radius),
 * with Geist as the typeface. Layered over Bootstrap 5.
 */
:root {
    /* Primary (green) */
    --p-50: #effaf6; --p-100: #d7f2e7; --p-200: #b0e4d0; --p-300: #7ed0b4; --p-400: #48b594;
    --p-500: #24997c; --p-600: #187f65; --p-700: #146553; --p-800: #135144; --p-900: #114339;
    /* Neutrals */
    --n-0: #fff; --n-50: #f7f8f7; --n-100: #eff1f0; --n-150: #e4e7e5; --n-200: #d8dcd9; --n-300: #c0c6c2;
    --n-400: #98a29b; --n-500: #757f79; --n-600: #5a625c; --n-700: #454b46; --n-800: #2e3230; --n-900: #1e211f;
    /* Status */
    --success-50: #ecfaf3; --success-500: #1e9e6b; --success-600: #16814d; --success-700: #106a3f;
    --warning-50: #fdf6e9; --warning-500: #dc9a2c; --warning-600: #b87c1c; --warning-700: #93630f;
    --danger-50: #fceeee; --danger-500: #d0504c; --danger-600: #b33d3a; --danger-700: #8f2e2c;
    --info-50: #eef4fa; --info-500: #3e7ead; --info-600: #2e6690; --info-700: #235071;
    --accent-50: #fff8ec; --accent-500: #e8830f; --accent-700: #a15220;
    /* Surfaces & text */
    --surface-canvas: var(--n-50); --surface-raised: var(--n-0); --surface-sunken: var(--n-100);
    --border-subtle: var(--n-150); --border-default: var(--n-200); --border-strong: var(--n-300);
    --text-primary: var(--n-900); --text-secondary: var(--n-600); --text-tertiary: var(--n-500);
    --sidebar-bg: #14201c; --sidebar-border: #ffffff0f; --sidebar-text: #ffffff9e; --sidebar-text-active: #fff;
    --radius: 5px;
    --shadow-xs: 0 1px 2px 0 #1e211f0a;
    --shadow-sm: 0 1px 3px 0 #1e211f0f, 0 1px 2px -1px #1e211f0d;
    --shadow-md: 0 4px 10px -2px #1e211f12, 0 2px 6px -3px #1e211f0f;
    --shadow-lg: 0 12px 24px -6px #1e211f17, 0 4px 10px -4px #1e211f0f;
    --shadow-glow-primary: 0 8px 24px -6px #187f6559;
    --app-sidebar-w: 250px;
    --app-topbar-h: 64px;

    /* Bootstrap mapping */
    --bs-font-sans-serif: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-font-monospace: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --bs-body-font-size: 0.8125rem;
    --bs-body-color: var(--text-primary);
    --bs-body-bg: var(--surface-canvas);
    --bs-secondary-color: var(--text-tertiary);
    --bs-emphasis-color: var(--text-primary);
    --bs-heading-color: var(--text-primary);
    --bs-border-color: var(--border-subtle);
    --bs-border-radius: 5px; --bs-border-radius-sm: 5px; --bs-border-radius-lg: 5px;
    --bs-primary: #187f65; --bs-primary-rgb: 24, 127, 101;
    --bs-success: #16814d; --bs-success-rgb: 22, 129, 77;
    --bs-danger: #b33d3a; --bs-danger-rgb: 179, 61, 58;
    --bs-warning: #b87c1c; --bs-warning-rgb: 184, 124, 28;
    --bs-info: #2e6690; --bs-info-rgb: 46, 102, 144;
    --bs-link-color: #187f65; --bs-link-color-rgb: 24, 127, 101;
    --bs-link-hover-color: #146553; --bs-link-hover-color-rgb: 20, 101, 83;
}

body { -webkit-font-smoothing: antialiased; color: var(--text-primary); }
a { text-decoration: none; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 700; letter-spacing: -0.015em; color: var(--text-primary); }
.text-secondary { color: var(--text-tertiary) !important; }
.text-body-emphasis { color: var(--text-primary) !important; }
.min-w-0 { min-width: 0; }

/* ---------- Buttons ---------- */
.btn {
    --bs-btn-padding-y: .55rem; --bs-btn-padding-x: 1rem; --bs-btn-font-size: .8125rem; --bs-btn-font-weight: 600;
    --bs-btn-border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap;
    transition: background .15s, box-shadow .15s, transform .1s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { --bs-btn-padding-y: .35rem; --bs-btn-padding-x: .7rem; --bs-btn-font-size: .75rem; }
.btn-primary {
    --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-disabled-color: #fff;
    --bs-btn-border-color: transparent; --bs-btn-hover-border-color: transparent; --bs-btn-active-border-color: transparent; --bs-btn-disabled-border-color: transparent;
    background: linear-gradient(180deg, var(--p-500), var(--p-700)); box-shadow: var(--shadow-glow-primary);
}
.btn-primary:hover, .btn-primary:focus-visible { background: linear-gradient(180deg, var(--p-400), var(--p-600)); }
.btn-primary:active { background: linear-gradient(180deg, var(--p-600), var(--p-800)) !important; }
.btn-light, .btn-outline {
    --bs-btn-color: var(--text-primary); --bs-btn-bg: var(--surface-raised); --bs-btn-border-color: var(--border-default);
    --bs-btn-hover-color: var(--text-primary); --bs-btn-hover-bg: var(--surface-sunken); --bs-btn-hover-border-color: var(--border-default);
    --bs-btn-active-bg: var(--surface-sunken); --bs-btn-active-border-color: var(--border-strong); --bs-btn-active-color: var(--text-primary);
}
.btn-outline-primary { --bs-btn-color: var(--p-700); --bs-btn-border-color: var(--p-300); --bs-btn-hover-bg: var(--p-50); --bs-btn-hover-color: var(--p-700); --bs-btn-hover-border-color: var(--p-400); --bs-btn-active-bg: var(--p-100); --bs-btn-active-color: var(--p-800); --bs-btn-active-border-color: var(--p-500); }
.btn-outline-danger { --bs-btn-color: var(--danger-600); --bs-btn-border-color: #f2afad; --bs-btn-hover-bg: var(--danger-50); --bs-btn-hover-color: var(--danger-700); --bs-btn-hover-border-color: var(--danger-500); --bs-btn-active-bg: var(--danger-50); --bs-btn-active-color: var(--danger-700); }
.btn-link { --bs-btn-color: var(--p-600); text-decoration: none; }
.header-icon-btn {
    width: 2.375rem; height: 2.375rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    border-radius: 5px; border: 0; background: transparent; color: var(--text-secondary); transition: background .15s, color .15s;
}
.header-icon-btn:hover { background: var(--surface-sunken); color: var(--text-primary); }
.header-icon-btn.bordered { border: 1px solid var(--border-subtle); background: var(--surface-raised); }

/* ---------- Forms ---------- */
.form-label { font-size: .71875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin-bottom: .4rem; }
.form-control, .form-select {
    font-size: .78125rem; padding: .5rem .65rem; border-radius: 5px; border: 1px solid var(--border-subtle);
    background-color: var(--surface-raised); color: var(--text-primary); transition: border-color .2s;
}
textarea.form-control { background: var(--surface-sunken); }
.form-control::placeholder { color: var(--n-400); }
.form-control:focus, .form-select:focus { border-color: var(--p-500); box-shadow: 0 0 0 3px rgba(36, 153, 124, .12); background-color: var(--surface-raised); }
.form-check-input { border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--p-600); border-color: var(--p-600); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(36, 153, 124, .15); border-color: var(--p-500); }
.form-check-label { font-size: .78125rem; font-weight: 500; }
fieldset legend { font-size: .71875rem !important; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin-bottom: .5rem; }
.invalid-feedback { font-size: .72rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding-top: .25rem; }
.filter-bar .form-label { font-size: .65rem; }
/* Option rows (checkbox/radio inside a sunken tile) */
.option-tile { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem .8rem; border-radius: 5px; background: var(--surface-sunken); cursor: pointer; font-size: .78125rem; font-weight: 500; margin: 0; }
.option-tile + .option-tile { margin-top: .5rem; }
.option-tile .form-check-input { margin: 0; flex-shrink: 0; }
.option-tile.is-on { background: var(--p-50); box-shadow: inset 0 0 0 1px var(--p-200); }
/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-default); transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.toggle input:checked + span { background: var(--p-600); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { box-shadow: 0 0 0 3px rgba(36, 153, 124, .25); }
/* Choice chips (multi-select) */
.chip-group { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .65rem; border-radius: 5px; font-size: .75rem; font-weight: 500; cursor: pointer;
    background: var(--surface-raised); border: 1px solid var(--border-subtle); color: var(--text-secondary); transition: background .15s, border-color .15s, color .15s; user-select: none; }
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip.is-on { background: var(--p-50); border-color: var(--p-600); color: var(--p-700); box-shadow: inset 0 0 0 .5px var(--p-600); }
.chip.is-on::before { content: "✓"; font-size: .7rem; }
.chip:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(36, 153, 124, .2); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); font-size: .75rem; color: var(--text-tertiary); pointer-events: none; }
.input-prefix > .form-control { padding-left: 2.6rem; }

/* ---------- Cards ---------- */
.card {
    --bs-card-border-color: var(--border-subtle); --bs-card-border-radius: 5px; --bs-card-inner-border-radius: 4px; --bs-card-bg: var(--surface-raised);
    --bs-card-spacer-y: 1.25rem; --bs-card-spacer-x: 1.25rem; --bs-card-cap-bg: transparent;
    box-shadow: var(--shadow-sm); margin-bottom: 1rem; transition: box-shadow .25s;
}
.row > * > .card { margin-bottom: 0; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card-title { font-size: .875rem; font-weight: 700; margin: 0; color: var(--text-primary); }
.card-subtitle { font-size: .72rem; color: var(--text-tertiary); margin: .2rem 0 0; }
.card-footer { background: transparent; border-top: 1px solid var(--border-subtle); padding: .8rem 1.25rem; }
.card-body > .table-responsive:last-child, .card-body > .table:last-child { margin-bottom: 0; }
.section-card .card-body { padding: 1.25rem; }
.section-title { font-size: .875rem; font-weight: 700; margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem; }
.section-tag { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; background: var(--p-50); color: var(--p-700); font-weight: 700; font-size: .7rem; margin-right: .45rem; }
.callout { border-radius: 5px; padding: 1rem; background: var(--p-50); border: 1px solid var(--p-200); }
.callout-title { display: flex; align-items: center; gap: .45rem; font-size: .78125rem; font-weight: 600; color: var(--p-700); margin: 0; }
.callout p { font-size: .72rem; color: var(--text-secondary); margin: .4rem 0 0; }

/* ---------- Tables (data-table look) ---------- */
.table { --bs-table-bg: transparent; --bs-table-border-color: var(--border-subtle); --bs-table-hover-bg: var(--surface-sunken); --bs-table-color: var(--text-primary); margin-bottom: 0; }
.table > thead > tr > th {
    background: transparent; color: var(--text-tertiary); font-weight: 600; font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--border-subtle); white-space: nowrap; padding: .6rem .75rem;
}
.table > tbody > tr > td { padding: .7rem .75rem; font-size: .8125rem; vertical-align: middle; border-bottom-color: var(--border-subtle); }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--surface-sunken); }
.card-table > :not(caption) > * > *:first-child { padding-left: 1.25rem; }
.card-table > :not(caption) > * > *:last-child { padding-right: 1.25rem; }
.cell-sub { display: block; font-size: .65625rem; color: var(--text-tertiary); }
.cell-muted { color: var(--text-tertiary); }
.row-thumb { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 5px; background: var(--surface-sunken); color: var(--text-secondary); font-weight: 700; font-size: .72rem; flex-shrink: 0; }

/* ---------- Badges ---------- */
.badge { border-radius: 5px; font-weight: 700; font-size: .6875rem; padding: .25rem .55rem; display: inline-flex; align-items: center; gap: .3rem; }
.badge-soft-primary { background: var(--p-50); color: var(--p-700); }
.badge-soft-success { background: var(--success-50); color: var(--success-700); }
.badge-soft-warning { background: var(--warning-50); color: var(--warning-700); }
.badge-soft-danger { background: var(--danger-50); color: var(--danger-700); }
.badge-soft-info { background: var(--info-50); color: var(--info-700); }
.badge-soft-secondary { background: var(--n-100); color: var(--n-700); }

/* ---------- Alerts ---------- */
.alert { border: 1px solid transparent; border-radius: 5px; font-size: .8125rem; padding: .75rem 1rem; }
.alert-success { background: var(--success-50); color: var(--success-700); border-color: #a4e5c3; }
.alert-danger { background: var(--danger-50); color: var(--danger-700); border-color: #f2afad; }
.alert-warning { background: var(--warning-50); color: var(--warning-700); border-color: #f6d48f; }
.alert-info { background: var(--info-50); color: var(--info-700); border-color: #a5c8e5; }

/* ---------- Pagination ---------- */
.pagination { --bs-pagination-color: var(--text-secondary); --bs-pagination-border-color: var(--border-subtle); --bs-pagination-hover-bg: var(--surface-sunken); --bs-pagination-hover-color: var(--text-primary);
    --bs-pagination-active-bg: var(--p-600); --bs-pagination-active-border-color: var(--p-600); --bs-pagination-font-size: .75rem; --bs-pagination-border-radius: 5px; gap: .25rem; }
.pagination .page-link { border-radius: 5px !important; min-width: 30px; text-align: center; }

/* ---------- App shell ---------- */
.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--app-sidebar-w); z-index: 1040; display: flex; flex-direction: column;
    background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); transition: transform .25s;
    background-image: radial-gradient(120% 60% at 0% 0%, rgba(36, 153, 124, .18), transparent 60%);
}
.app-brand { height: var(--app-topbar-h); display: flex; align-items: center; gap: .65rem; padding: 0 1.25rem; color: #fff; flex-shrink: 0; border-bottom: 1px solid var(--sidebar-border); }
.app-brand:hover { color: #fff; }
.app-brand-mark { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; background: linear-gradient(180deg, var(--p-400), var(--p-700)); color: #fff; font-weight: 700; font-size: .8rem; box-shadow: var(--shadow-glow-primary); }
.app-brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; line-height: 1; }
.app-brand-sub { display: block; font-size: .65rem; color: var(--sidebar-text); font-weight: 500; margin-top: 3px; }
.app-menu { overflow-y: auto; padding: .5rem .75rem 1.5rem; flex: 1; scrollbar-width: thin; scrollbar-color: #ffffff1f transparent; }
.app-menu-title { font-size: .65625rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: rgba(255, 255, 255, .4); padding: 1.1rem .75rem .45rem; }
.app-menu-link {
    position: relative; display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; margin-bottom: 2px; border-radius: 5px;
    color: var(--sidebar-text); font-weight: 500; font-size: .8125rem; transition: background .15s, color .15s, padding-left .15s;
}
.app-menu-link svg { flex-shrink: 0; opacity: .9; }
.app-menu-link:hover { color: var(--sidebar-text-active); background: #ffffff0d; padding-left: .9rem; }
.app-menu-link.active { color: var(--sidebar-text-active); background: linear-gradient(90deg, rgba(36, 153, 124, .28), transparent); }
.app-menu-link.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--p-400); }
.app-menu-link.active svg { color: var(--p-300); opacity: 1; }
.app-sidebar-foot { padding: .9rem 1rem; border-top: 1px solid var(--sidebar-border); }
.app-sidebar-card { border-radius: 5px; padding: .8rem; background: #ffffff0a; border: 1px solid var(--sidebar-border); color: var(--sidebar-text); font-size: .72rem; }
.app-sidebar-card b { color: #fff; display: block; font-size: .78rem; margin-bottom: .15rem; }

.app-topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--app-topbar-h); margin-left: var(--app-sidebar-w);
    background: color-mix(in oklab, #fff 88%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem;
}
.app-topbar-toggle { display: none; }
.app-user { display: flex; align-items: center; gap: .6rem; padding: .3rem .45rem; border-radius: 5px; border: 0; background: none; text-align: left; }
.app-user:hover { background: var(--surface-sunken); }
.app-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--p-50); color: var(--p-700); font-weight: 700; font-size: .72rem; box-shadow: inset 0 0 0 1px var(--p-100); }
.app-user-name { font-weight: 600; color: var(--text-primary); font-size: .8125rem; line-height: 1.2; }
.app-user-role { font-size: .6875rem; color: var(--text-tertiary); line-height: 1.2; }
.app-dropdown { min-width: 14rem; border: 1px solid var(--border-subtle); box-shadow: var(--shadow-lg); border-radius: 5px; padding: .375rem; font-size: .78125rem; }
.app-dropdown .dropdown-item { border-radius: 5px; padding: .4rem .6rem; color: var(--text-primary); font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.app-dropdown .dropdown-item:hover { background: var(--surface-sunken); }
.app-dropdown .dropdown-item.text-danger:hover { color: var(--danger-600) !important; }

.app-main { margin-left: var(--app-sidebar-w); padding: 1.5rem; min-height: calc(100vh - var(--app-topbar-h)); display: flex; flex-direction: column; }
.app-content { flex: 1; }
.app-footer { color: var(--text-tertiary); font-size: .72rem; padding-top: 1.25rem; }
.app-backdrop { display: none; }
.sticky-actions {
    position: sticky; bottom: 0; z-index: 20; margin: 1.25rem -1.5rem -1.5rem; padding: .9rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
    background: color-mix(in oklab, #fff 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border-subtle);
}
.sticky-actions ~ .app-footer { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    body.sidebar-open .app-sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.sidebar-open .app-backdrop { display: block; position: fixed; inset: 0; background: rgba(30, 33, 31, .45); z-index: 1035; }
    .app-topbar, .app-main { margin-left: 0; }
    .app-topbar-toggle { display: inline-flex; }
    .app-main { padding: 1rem; }
    .sticky-actions { margin: 1rem -1rem -1rem; padding: .75rem 1rem; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head-main { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.page-title { font-size: 1.3125rem; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.page-subtitle { font-size: .78125rem; color: var(--text-tertiary); margin: .25rem 0 0; }
.page-crumb { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 0 0 .3rem; font-size: .72rem; color: var(--text-tertiary); }
.page-crumb li + li::before { content: '/'; margin-right: .4rem; color: var(--n-300); }
.page-crumb a { color: var(--text-tertiary); }
.page-crumb a:hover { color: var(--p-600); }
.page-crumb [aria-current] { color: var(--text-secondary); font-weight: 500; }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; font-size: .72rem; color: var(--text-tertiary); margin-top: .35rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Stats strip ---------- */
.stats-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0; overflow: hidden; }
.stat { position: relative; padding: 1.1rem 1.25rem; border-right: 1px solid var(--border-subtle); }
.stat:last-child { border-right: 0; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; transform: scaleY(0); transition: transform .25s; background: var(--tone); }
.stat:hover::before { transform: scaleY(1); }
.stat-icon { position: relative; width: 42px; height: 42px; display: grid; place-items: center; color: #fff; }
.stat-icon::before, .stat-icon::after { content: ""; position: absolute; inset: 0; border-radius: 14px; background: var(--tone); }
.stat-icon::before { transform: rotate(6deg); }
.stat-icon::after { opacity: .15; transform: rotate(-6deg); }
.stat-icon svg { position: relative; z-index: 1; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1; margin-top: .9rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .72rem; color: var(--text-tertiary); margin-top: .35rem; }
.stat-bar { height: 4px; border-radius: 999px; background: var(--surface-sunken); margin-top: .75rem; overflow: hidden; }
.stat-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--tone); }
.stat-delta { font-size: .6875rem; font-weight: 600; color: var(--tone-text, var(--success-600)); }
.tone-primary { --tone: var(--p-600); --tone-text: var(--p-600); }
.tone-success { --tone: var(--success-500); --tone-text: var(--success-600); }
.tone-warning { --tone: var(--warning-500); --tone-text: var(--warning-600); }
.tone-danger { --tone: var(--danger-500); --tone-text: var(--danger-600); }
.tone-info { --tone: var(--info-500); --tone-text: var(--info-600); }
@media (max-width: 991.98px) { .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat:nth-child(2n) { border-right: 0; } .stat:nth-child(-n+2) { border-bottom: 1px solid var(--border-subtle); } }
@media (max-width: 575.98px) { .stats-strip { grid-template-columns: 1fr; } .stat { border-right: 0; border-bottom: 1px solid var(--border-subtle); } }

/* ---------- Toolbar ---------- */
.toolbar { padding: .75rem; }
.toolbar .form-control, .toolbar .form-select { background-color: var(--surface-sunken); }
.toolbar-search { position: relative; }
.toolbar-search svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.toolbar-search .form-control { padding-left: 2.1rem; }

/* ---------- Toasts (success messages) ---------- */
.toast-stack { position: fixed; top: 1rem; right: 1rem; z-index: 1100; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
.app-toast {
    pointer-events: auto; display: flex; align-items: flex-start; gap: .7rem; padding: .85rem .8rem .85rem 1rem; border-radius: 6px;
    background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--border-subtle); border-left: 4px solid var(--p-500);
    box-shadow: var(--shadow-lg); font-size: .8125rem;
}
.app-toast-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--p-50); color: var(--p-600); }
.app-toast-text { flex: 1; min-width: 0; padding-top: .05rem; }
.app-toast-text strong { display: block; font-weight: 700; font-size: .8125rem; color: var(--text-primary); }
.app-toast-text span { display: block; color: var(--text-secondary); margin-top: .1rem; }
.app-toast-list { margin: .2rem 0 0; padding-left: 1rem; color: var(--text-secondary); }
.app-toast-list li + li { margin-top: .1rem; }
.app-toast-error { border-left-color: var(--danger-500); }
.app-toast-error .app-toast-icon { background: var(--danger-50); color: var(--danger-600); }
.app-toast-close { border: 0; background: transparent; color: var(--text-tertiary); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.app-toast-close:hover { background: var(--surface-sunken); color: var(--text-primary); }
.toast-enter-active { transition: transform .3s cubic-bezier(.22, 1, .36, 1), opacity .3s; }
.toast-leave-active { transition: transform .2s ease-in, opacity .2s; }
.toast-enter-from { transform: translateX(110%); opacity: 0; }
.toast-leave-to { transform: translateX(40%); opacity: 0; }
@media (prefers-reduced-motion: reduce) { .toast-enter-from, .toast-leave-to { transform: none; } }

/* ---------- Round icon action buttons (table rows) ---------- */
.icon-actions { display: inline-flex; align-items: center; gap: .35rem; }
.icon-btn {
    width: 32px; height: 32px; border-radius: 50%; border: 0; display: inline-grid; place-items: center; flex-shrink: 0;
    background: var(--t-bg); color: var(--t-fg); transition: background .15s, color .15s, transform .1s, box-shadow .15s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--t-solid); color: #fff; box-shadow: 0 4px 10px -3px var(--t-solid); }
.icon-btn:focus-visible { outline: 2px solid var(--t-solid); outline-offset: 2px; }
.icon-btn:active { transform: scale(.92); }
.icon-btn-primary { --t-bg: var(--p-50); --t-fg: var(--p-700); --t-solid: var(--p-600); }
.icon-btn-info { --t-bg: var(--info-50); --t-fg: var(--info-600); --t-solid: var(--info-500); }
.icon-btn-warning { --t-bg: var(--warning-50); --t-fg: var(--warning-700); --t-solid: var(--warning-500); }
.icon-btn-violet { --t-bg: #f3efff; --t-fg: #6d28d9; --t-solid: #7c3aed; }
.icon-btn-neutral { --t-bg: var(--n-100); --t-fg: var(--n-700); --t-solid: var(--n-600); }
.icon-btn-danger { --t-bg: var(--danger-50); --t-fg: var(--danger-600); --t-solid: var(--danger-500); }

/* ---------- Row action menu ---------- */
.row-menu { position: relative; display: inline-block; }
.row-menu .dropdown-menu { right: 0; left: auto; top: 100%; margin-top: .25rem; min-width: 11rem; }

/* ---------- KPI / dashboard ---------- */
.kpi { position: relative; overflow: hidden; height: 100%; }
.kpi .card-body { padding: 1.1rem 1.25rem; }
.kpi-label { font-size: .72rem; color: var(--text-tertiary); font-weight: 500; margin-bottom: .45rem; }
.kpi-value { font-size: 1.45rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .6875rem; color: var(--text-tertiary); margin-top: .55rem; }
.kpi-icon { position: absolute; top: 1rem; right: 1rem; width: 38px; height: 38px; border-radius: 5px; display: grid; place-items: center; background: var(--p-50); color: var(--p-700); }
.metric-xl { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.04em; color: var(--text-primary); line-height: 1; font-variant-numeric: tabular-nums; }
.metric-lg { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; color: var(--text-primary); line-height: 1.1; font-variant-numeric: tabular-nums; }
.eyebrow { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); }
.live-dot { display: inline-flex; align-items: center; gap: .4rem; color: var(--success-600); font-weight: 600; }
.live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success-500); box-shadow: 0 0 0 3px rgba(30, 158, 107, .2); }
.delta { display: inline-flex; align-items: center; gap: .2rem; font-size: .6875rem; font-weight: 700; padding: .12rem .45rem; border-radius: 5px; }
.delta-up { background: var(--success-50); color: var(--success-700); }
.delta-down { background: var(--danger-50); color: var(--danger-700); }
.delta-flat { background: var(--n-100); color: var(--n-600); }
.scale { position: relative; height: 8px; border-radius: 999px; background: var(--surface-sunken); margin: 1.25rem 0 .4rem; }
.scale > span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, var(--p-400), var(--p-600)); }
.scale-target { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--n-900); border-radius: 2px; }
.scale-labels { position: relative; display: flex; justify-content: space-between; font-size: .65rem; color: var(--text-tertiary); }
.scale-labels .t { position: absolute; transform: translateX(-50%); color: var(--text-primary); font-weight: 600; }
.submetric { padding-top: .75rem; }
.submetric + .submetric { border-left: 1px solid var(--border-subtle); padding-left: 1rem; }
.insight-card { background: linear-gradient(180deg, var(--p-50) 0%, #fff 45%); }
.insight-list { list-style: none; padding: 0; margin: 0; }
.insight-list li { position: relative; padding: .55rem 0 .55rem 1.4rem; border-top: 1px dashed var(--border-subtle); font-size: .8125rem; }
.insight-list li:first-child { border-top: 0; }
.insight-list li::before { content: ""; position: absolute; left: 1px; top: .95rem; width: 7px; height: 7px; border-radius: 2px; background: var(--p-600); transform: rotate(45deg); }
.insight-list strong { color: var(--text-primary); font-weight: 700; }
.score { border: 1px solid var(--border-subtle); border-radius: 5px; padding: .7rem .85rem; background: #fff; }
.rank-row { padding: .7rem 0; border-bottom: 1px solid var(--n-100); }
.rank-row:first-child { padding-top: 0; }
.rank-row:last-child { border-bottom: 0; padding-bottom: 0; }
.rank-name { font-weight: 600; color: var(--text-primary); }
.rank-meta { font-size: .6875rem; color: var(--text-tertiary); }
.rank-value { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.rank-badge { width: 32px; height: 32px; border-radius: 5px; display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-secondary); font-weight: 700; font-size: .75rem; flex-shrink: 0; }
.meter { height: 6px; background: var(--surface-sunken); border-radius: 999px; overflow: hidden; margin-top: .45rem; }
.meter > span { display: block; height: 100%; background: var(--p-500); border-radius: 999px; }
.meter.done > span { background: var(--success-500); }
.funnel-step { display: grid; grid-template-columns: 28px 1fr auto; gap: .75rem; align-items: center; padding: .6rem 0; }
.funnel-step + .funnel-step { border-top: 1px solid var(--n-100); }
.funnel-num { width: 28px; height: 28px; border-radius: 5px; background: var(--p-50); color: var(--p-700); font-weight: 700; font-size: .72rem; display: grid; place-items: center; }
.funnel-bar { height: 6px; border-radius: 999px; background: var(--surface-sunken); margin-top: .4rem; overflow: hidden; }
.funnel-bar > span { display: block; height: 100%; background: var(--p-500); border-radius: 999px; }
.funnel-drop { font-size: .6875rem; color: var(--danger-600); }
.alert-row { display: flex; gap: .75rem; padding: .75rem 0; }
.alert-row + .alert-row { border-top: 1px solid var(--n-100); }
.alert-icon { width: 32px; height: 32px; border-radius: 5px; display: grid; place-items: center; flex-shrink: 0; }
.alert-icon.warning { background: var(--warning-50); color: var(--warning-600); }
.alert-icon.info { background: var(--info-50); color: var(--info-600); }
.alert-icon.danger { background: var(--danger-50); color: var(--danger-600); }
.counter { border-radius: 5px; background: var(--surface-sunken); padding: .6rem .75rem; }
.progress-cell { display: flex; align-items: center; gap: .5rem; min-width: 120px; }
.progress-cell .meter { flex: 1; margin: 0; }
.empty-state { text-align: center; color: var(--text-tertiary); padding: 2.25rem 1rem; font-size: .8125rem; }
.list-tile { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; border: 1px solid var(--border-subtle); border-radius: 5px; color: var(--text-primary); height: 100%; background: #fff; transition: border-color .15s, box-shadow .15s; }
.list-tile:hover { border-color: var(--p-300); box-shadow: var(--shadow-md); color: var(--p-700); }
.list-tile .kpi-icon { position: static; width: 36px; height: 36px; }
.detail-list { display: grid; grid-template-columns: minmax(9rem, 13rem) 1fr; gap: .6rem 1rem; margin: 0; }
.detail-list dt { font-weight: 600; color: var(--text-tertiary); font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; padding-top: .1rem; }
.detail-list dd { margin: 0; color: var(--text-primary); }

/* Bar chart (single series) */
.bar-chart { display: grid; grid-template-columns: 2.25rem 1fr; gap: 0 .5rem; }
.bar-axis { position: relative; height: 240px; font-size: .65rem; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.bar-axis span { position: absolute; right: 0; transform: translateY(50%); }
.bar-plot { position: relative; height: 240px; display: flex; align-items: flex-end; gap: 2px; }
.bar-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border-subtle); pointer-events: none; }
.bar-grid.base { border-top: 1px solid var(--border-default); }
.bar-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar-col:hover { background: rgba(36, 153, 124, .06); border-radius: 4px 4px 0 0; }
.bar { width: min(26px, 62%); background: linear-gradient(180deg, var(--p-400), var(--p-600)); border-radius: 4px 4px 0 0; }
.bar-col:hover .bar { background: var(--p-700); }
.bar-tip { position: absolute; bottom: calc(var(--h) + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap; z-index: 2; background: var(--n-900); color: #fff; font-size: .6875rem; padding: .35rem .55rem; border-radius: 5px; opacity: 0; pointer-events: none; transition: opacity .12s; }
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { opacity: 1; }
.bar-labels { grid-column: 2; display: flex; gap: 2px; margin-top: .5rem; }
.bar-labels span { flex: 1; text-align: center; font-size: .65rem; color: var(--text-tertiary); }

/* ---------- Auth (login: form beside the provincial seal) ---------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: #fff; }
.auth-logo-side { margin: .75rem; border-radius: 12px; background: var(--n-50); border: 1px solid var(--n-150); display: grid; place-items: center; padding: clamp(2rem, 5vw, 4rem); }
.auth-logo { width: 100%; max-width: 420px; height: auto; }
@media (max-width: 991.98px) { .auth-split { grid-template-columns: minmax(0, 1fr); } .auth-logo-side { display: none; } }
.auth-form-side { display: flex; flex-direction: column; padding: 2rem clamp(1.5rem, 5vw, 4rem); }
.auth-form-side .app-brand-name { color: var(--text-primary); }
.auth-form-wrap { width: 100%; max-width: 400px; margin: auto; }
.auth-form-wrap h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; margin: 0 0 .35rem; }
.auth-form-wrap .form-control { height: 42px; }
.auth-form-wrap .btn-primary { height: 42px; width: 100%; }
.auth-input { position: relative; }
.auth-input > svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--n-400); pointer-events: none; }
.auth-input .form-control { padding-left: 2.4rem; }
.auth-reveal { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-tertiary); font-size: .72rem; font-weight: 600; padding: .35rem .5rem; }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 1060; background: rgba(30, 33, 31, .45); }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 1065; width: min(560px, 100vw); display: flex; flex-direction: column;
    background: var(--surface-raised); border-left: 1px solid var(--border-subtle); box-shadow: var(--shadow-lg);
}
.drawer.drawer-half { width: max(50vw, min(560px, 100vw)); }
@media (max-width: 991.98px) { .drawer.drawer-half { width: 100vw; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border-subtle); }
.drawer-title { font-size: 1rem; font-weight: 700; margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.25rem; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding: .9rem 1.25rem; border-top: 1px solid var(--border-subtle); background: var(--n-50); }
.drawer-group + .drawer-group { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px dashed var(--border-subtle); }
.drawer-group-title { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin: 0 0 .75rem; }
body.drawer-open { overflow: hidden; }
/* Open/close: the panel slides in from the right edge while the backdrop fades. */
.drawer-slide-enter-active { transition: transform .35s cubic-bezier(.22, 1, .36, 1); }
.drawer-slide-leave-active { transition: transform .25s cubic-bezier(.4, 0, 1, 1); }
.drawer-slide-enter-from, .drawer-slide-leave-to { transform: translateX(100%); }
.drawer-fade-enter-active { transition: opacity .3s ease; }
.drawer-fade-leave-active { transition: opacity .25s ease; }
.drawer-fade-enter-from, .drawer-fade-leave-to { opacity: 0; }
/* Reduced motion (an OS setting): no sliding, just a quick fade. */
@media (prefers-reduced-motion: reduce) {
    .drawer-slide-enter-active, .drawer-slide-leave-active { transition: opacity .15s ease; }
    .drawer-slide-enter-from, .drawer-slide-leave-to { transform: none; opacity: 0; }
}

/* ---------- Intake stepper (horizontal: dot, label, connector line) ---------- */
.stepper-card { padding: .9rem 1.1rem; }
.stepper { display: flex; flex-direction: row; align-items: center; list-style: none; margin: 0; padding: 0; gap: .25rem; }
.stepper-item { flex: 1 1 0; display: flex; align-items: center; min-width: 0; }
.stepper-item:last-child { flex: 0 0 auto; }
.stepper-item:not(:last-child)::after { content: ""; flex: 1 1 auto; height: 2px; border-radius: 2px; background: var(--border-subtle); margin: 0 .6rem; min-width: 16px; }
.stepper-item.done:not(:last-child)::after { background: var(--p-400); }
.stepper-link { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; color: inherit; border-radius: 5px; padding: .2rem .35rem .2rem .2rem; }
a.stepper-link:hover { background: var(--surface-sunken); color: inherit; }
.stepper-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-weight: 700; font-size: .75rem;
    background: var(--surface-raised); color: var(--text-tertiary); border: 1.5px solid var(--border-default); }
.stepper-item.done .stepper-dot { background: var(--p-600); border-color: var(--p-600); color: #fff; }
.stepper-item.current .stepper-dot { background: var(--p-50); border-color: var(--p-600); color: var(--p-700); box-shadow: 0 0 0 4px rgba(36, 153, 124, .14); }
.stepper-text { line-height: 1.2; }
.stepper-label { display: block; font-size: .78125rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.stepper-item.todo .stepper-label { color: var(--text-secondary); }
.stepper-sum { display: block; font-size: .65625rem; color: var(--text-tertiary); white-space: nowrap; }
.stepper-item.done .stepper-sum { color: var(--p-700); }
/* Narrow screens: keep the row, show text only for the current step. */
@media (max-width: 1199.98px) {
    .stepper-item:not(.current) .stepper-text { display: none; }
}
.member-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 .4rem; border-radius: 999px; background: var(--p-50); color: var(--p-700); font-size: .6875rem; font-weight: 700; }
