/* Pack 1 MVC admin styles */
:root {
    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255,255,255,0.08);
    --accent: #dc2626;
    --accent-dark: #b91c1c;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --body-bg: #eef2f7;
    --text: #0f172a;
    --muted: #64748b;
    --radius-xl: 1.25rem;
    --app-font-sans: "Montserrat Z", "Montserrat", "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--app-font-sans);
    color: var(--text);
    background: var(--body-bg);
}

button,
input,
optgroup,
select,
textarea {
    font: inherit;
}

.guest-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(220,38,38,0.12), transparent 30%),
        radial-gradient(circle at bottom right, rgba(15,23,42,0.12), transparent 30%),
        linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

.guest-wrapper {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 520px;
    border-radius: 1.5rem;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.login-logo {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 1rem;
    background: rgba(220,38,38,0.1);
    color: var(--accent);
    font-size: 1.5rem;
}

.login-help {
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    background: #f8fafc;
    font-size: 0.92rem;
}

.admin-body {
    min-height: 100vh;
}

.admin-app {
    display: flex;
    min-height: 100vh;
    padding-left: 290px;
}

.admin-sidebar {
    width: 290px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: #fff;
    border-right: 1px solid var(--sidebar-border);
    padding: 1.5rem 1rem;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 1050;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.5rem 0.75rem 1.5rem;
}

.sidebar-logo {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 1rem;
    background: rgba(220,38,38,0.16);
    color: #fca5a5;
    font-size: 1.25rem;
}

.sidebar-title {
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-subtitle {
    color: #94a3b8;
    font-size: 0.85rem;
}

.sidebar-user {
    border: 1px solid var(--sidebar-border);
    background: rgba(255,255,255,0.04);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    transition: 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: #fff;
    color: var(--sidebar-bg);
}

.admin-main {
    flex: 1 1 auto;
    width: 100%;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem 1.5rem 0;
}

.page-title {
    font-size: 1.65rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-user {
    font-weight: 600;
}

.admin-content {
    flex: 1;
    padding: 1.5rem;
}

.admin-footer {
    padding: 0 1.5rem 1.5rem;
}

.admin-topbar,
.admin-content,
.admin-footer {
    min-width: 0;
}

.hero-card {
    background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%);
    color: #fff;
    border-radius: 1.5rem;
    padding: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 18px 40px rgba(127,29,29,0.18);
}

.hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.76rem;
    opacity: 0.82;
}

.hero-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.4rem 0 0.2rem;
}

.hero-subtitle {
    opacity: 0.9;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.metric-card {
    border-radius: 1.25rem;
}

.metric-label {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
}

.metric-meta {
    color: var(--muted);
    font-size: 0.92rem;
    margin-top: 0.4rem;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.workflow-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

.workflow-step {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1rem;
    background: #f8fafc;
}

.workflow-number {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 0.85rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    font-weight: 700;
    margin-bottom: 0.8rem;
}

.workflow-title {
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.workflow-text {
    color: var(--muted);
    font-size: 0.93rem;
}

.placeholder-note {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    padding: 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.placeholder-state {
    border: 1px dashed #cbd5e1;
    border-radius: 1.25rem;
    padding: 2rem;
    background: #f8fafc;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 1rem;
    background: rgba(220,38,38,0.1);
    color: var(--accent);
    font-size: 1.6rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .workflow-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .admin-app {
        padding-left: 0;
    }

    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        pointer-events: none;
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
        pointer-events: auto;
        box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
    }

    .admin-main {
        width: 100%;
    }

    .admin-topbar {
        padding-top: 1rem;
    }

    .hero-card {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* Pack 2 CRUD styles */
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-card,
.form-card,
.filter-card {
    border-radius: 1.25rem;
}

.table-shell {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    overflow: hidden;
}

.table-shell table {
    margin-bottom: 0;
}

.table-shell thead th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    border-bottom-color: #e2e8f0;
    white-space: nowrap;
}

.table-shell tbody td {
    vertical-align: middle;
}

.form-label.required::after {
    content: " *";
    color: var(--accent);
}

.card-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.empty-state {
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    background: #f8fafc;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.inline-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.form-help {
    color: var(--muted);
    font-size: 0.9rem;
}

.badge-soft {
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
}

.badge-soft-secondary { background: #eef2ff; color: #475569; }
.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-info { background: #dbeafe; color: #1d4ed8; }
.badge-soft-dark { background: #e2e8f0; color: #0f172a; }
.badge-soft-primary { background: #fee2e2; color: #b91c1c; }

.definition-list {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

.definition-item {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 1rem;
}

.definition-item .label {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.definition-item .value {
    font-weight: 700;
}

@media (min-width: 768px) {
    .definition-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* Pack 3 expenses + readings */
.readings-table input,
.readings-table select {
    min-width: 120px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1rem;
}

.summary-card {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 1rem;
}

.summary-card .label {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.summary-card .value {
    font-size: 1.4rem;
    font-weight: 700;
}

@media (min-width: 768px) {
    .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}


.table-card {
    border-radius: 1.25rem;
}

.card-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-actions,
.inline-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.table-shell {
    overflow-x: auto;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
}

.metric-inline-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1rem 1.1rem;
}

.metric-inline-label {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.metric-inline-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.15;
}

.summary-stack {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    overflow: hidden;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.summary-row:last-child {
    border-bottom: 0;
}

.summary-row.total {
    background: #fff;
    font-size: 1.02rem;
}


/* Pack 4-5 invoice/payment refinements */
.metric-inline-card {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 1rem;
    height: 100%;
}

.metric-inline-label {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 0.35rem;
}

.metric-inline-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.15;
}

.metric-inline-value-small {
    font-size: 1.05rem;
}

.summary-stack {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #f8fafc;
    overflow: hidden;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.summary-row:last-child {
    border-bottom: 0;
}

.summary-row.total {
    background: #fff;
    font-weight: 700;
}


/* UI hotfixes - light theme cleanup */
.sidebar-user {
    background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.04));
}

.sidebar-user-label {
    color: #94a3b8;
    font-size: 0.82rem;
    margin-bottom: 0.3rem;
}

.sidebar-user-name {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.25;
}

.sidebar-user-email {
    color: #cbd5e1;
    font-size: 0.9rem;
    margin-top: 0.25rem;
    word-break: break-word;
}

.admin-content .card {
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04) !important;
}

.table-shell {
    background: #ffffff;
    border-color: #dbe3ee;
}

.table-shell table {
    background: #ffffff;
}

.table-shell thead th {
    background: #f8fafc;
    color: #334155;
}

.table-shell tbody tr:nth-child(even) {
    background: #fbfdff;
}

.table-shell tbody tr:hover {
    background: #f8fafc;
}

.table-shell code,
.code-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #dbe3ee;
    color: #334155;
    font-size: 0.84rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.metric-inline-card,
.summary-card,
.summary-stack,
.placeholder-note,
.empty-state {
    background: #f8fafc;
}

.badge-soft-secondary {
    background: #e2e8f0;
    color: #334155;
}

.card-toolbar form {
    margin: 0;
}

@media (max-width: 767.98px) {
    .card-toolbar {
        align-items: stretch;
    }

    .card-toolbar > div,
    .card-toolbar > form,
    .page-actions,
    .page-actions form {
        width: 100%;
    }

    .page-actions {
        justify-content: flex-start;
    }

    .page-actions form .form-select-sm,
    .page-actions form .btn,
    .card-toolbar form .form-select-sm {
        width: 100%;
    }
}


/* Pack 9 funds */
.fund-amount-positive { color: #166534; }
.fund-amount-negative { color: #b91c1c; }
.fund-amount-neutral { color: #0f172a; }
.fund-balance-card {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 1rem;
    height: 100%;
}
.fund-balance-card .fund-name {
    font-weight: 700;
    margin-bottom: 0.35rem;
}
.fund-balance-card .fund-meta {
    color: var(--muted);
    font-size: 0.9rem;
}
.fund-balance-card .fund-balance {
    font-size: 1.45rem;
    font-weight: 700;
    margin-top: 0.65rem;
}

/* Pack 13C virtual tank */
.virtual-tank-card {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
    padding: 1rem;
}

.virtual-tank-card.is-over-capacity {
    border-color: #f59e0b;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.18);
}

.virtual-tank-visual-wrap {
    display: flex;
    justify-content: center;
}

.virtual-tank-shell {
    position: relative;
    width: 110px;
    height: 250px;
    border: 4px solid #cbd5e1;
    border-radius: 2rem 2rem 1.2rem 1.2rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(226,232,240,0.65));
    overflow: hidden;
    box-shadow: inset 0 12px 20px rgba(255,255,255,0.75);
}

.virtual-tank-cap {
    position: absolute;
    top: 10px;
    left: 50%;
    width: 44px;
    height: 10px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: #94a3b8;
    z-index: 3;
}

.virtual-tank-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 0;
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.95) 0%, rgba(245, 158, 11, 0.98) 52%, rgba(217, 119, 6, 1) 100%);
    transition: height 0.3s ease;
}

.virtual-tank-fill::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: rgba(255,255,255,0.18);
}

.virtual-tank-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    z-index: 2;
    text-align: center;
    padding: 1rem;
}

.virtual-tank-percent {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f172a;
}

.virtual-tank-caption {
    font-size: 0.88rem;
    color: #475569;
}

.virtual-tank-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.virtual-tank-metric {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #ffffff;
    padding: 0.9rem 1rem;
    min-height: 94px;
}

.virtual-tank-metric-label {
    color: var(--muted);
    font-size: 0.86rem;
    margin-bottom: 0.35rem;
}

.virtual-tank-metric-value {
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.2;
}

.virtual-tank-note {
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 0.9rem 1rem;
    color: #475569;
    font-size: 0.92rem;
}

@media (max-width: 991.98px) {
    .virtual-tank-card {
        grid-template-columns: 1fr;
    }

    .virtual-tank-metrics {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 575.98px) {
    .virtual-tank-metrics {
        grid-template-columns: 1fr;
    }
}


/* Pack 12 UI fixes: login flash, submenu, and safe clickability */
html,
body {
    min-height: 100%;
}

body {
    overflow-x: hidden;
}

/*
 * Layout safeguard:
 * the sidebar is fixed, so the content area must be offset via container padding,
 * not via margin on .admin-main. Otherwise the main pane overflows horizontally
 * and interactive controls appear to be offset or blocked.
 */

.guest-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.guest-stack {
    width: 100%;
    max-width: 520px;
    display: grid;
    gap: 1rem;
}

.guest-wrapper {
    min-height: auto;
    display: block;
    padding: 0;
}

.login-card {
    width: 100%;
    max-width: none;
    margin: 0;
}

.app-flash {
    position: relative;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 1rem;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.app-flash__inner {
    display: flex;
    align-items: center;
    min-height: 2rem;
    gap: 0.85rem;
    padding: 1rem 1rem;
}

.app-flash__icon {
    width: 2rem;
    height: 2rem;
    flex: 0 0 2rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    font-size: 1rem;
}

.app-flash__body {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    line-height: 1.4;
    display: flex;
    align-items: center;
    min-height: 2rem;
}

.app-flash__close {
    position: static;
    transform: none;
    margin-left: auto;
    flex: 0 0 auto;
    opacity: 0.72;
}

.app-flash__close:hover {
    opacity: 1;
}

.alert-success.app-flash {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.alert-success .app-flash__icon {
    background: #d1fae5;
    color: #047857;
}

.alert-warning.app-flash {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.alert-warning .app-flash__icon {
    background: #fef3c7;
    color: #b45309;
}

.alert-danger.app-flash {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-danger .app-flash__icon {
    background: #fee2e2;
    color: #b91c1c;
}

.alert-info.app-flash {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.alert-info .app-flash__icon {
    background: #dbeafe;
    color: #2563eb;
}


.admin-content .app-flash {
    margin-bottom: 1.25rem;
}

.sidebar-item-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-link-row {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.sidebar-link {
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar-link span,
.sidebar-sublink span {
    min-width: 0;
}

.sidebar-toggle {
    width: 48px;
    flex: 0 0 48px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 1rem;
    background: transparent;
    color: #94a3b8;
    transition: 0.2s ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus,
.sidebar-item-group.is-open .sidebar-toggle {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}

.sidebar-caret {
    transition: transform 0.2s ease;
}

.sidebar-item-group.is-open .sidebar-caret {
    transform: rotate(180deg);
}

.sidebar-subnav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0 0 0.25rem 3.15rem;
}

.sidebar-subnav[hidden] {
    display: none !important;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.72rem 0.9rem;
    border-radius: 0.9rem;
    font-size: 0.95rem;
    transition: 0.2s ease;
}

.sidebar-sublink:hover,
.sidebar-sublink.active {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}

.hero-actions .btn,
.d-grid .btn,
.topbar-actions .btn {
    min-height: 46px;
    font-weight: 700;
    border-radius: 1rem;
}

.hero-actions .btn-light {
    color: #0f172a;
    border-color: rgba(255,255,255,0.92);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
}

.hero-actions .btn:hover,
.hero-actions .btn:focus,
.d-grid .btn:hover,
.d-grid .btn:focus,
.topbar-actions .btn:hover,
.topbar-actions .btn:focus {
    transform: translateY(-1px);
}

@media (max-width: 991.98px) {
    .guest-shell {
        padding: 1.25rem;
    }

    .sidebar-subnav {
        padding-left: 1rem;
    }
}


/* Pack 12.1 refinement: button typography + alert close centering */
.hero-actions .btn,
.d-grid .btn,
.topbar-actions .btn,
.page-actions .btn,
.inline-actions .btn,
form .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    text-align: center;
    line-height: 1.2;
    letter-spacing: 0;
    vertical-align: middle;
}

.hero-actions .btn,
.topbar-actions .btn,
.page-actions .btn,
.inline-actions .btn {
    padding-top: 0.78rem;
    padding-bottom: 0.78rem;
}

.topbar-actions .btn,
.hero-actions .btn {
    min-width: 112px;
}

.topbar-actions .btn.btn-outline-danger,
.topbar-actions .btn.btn-outline-light,
.hero-actions .btn.btn-light,
.hero-actions .btn.btn-outline-light {
    box-shadow: none;
}

.d-grid .btn {
    width: 100%;
    min-height: 54px;
    font-size: 1.05rem;
}

.app-flash__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    padding: 0;
    border-radius: 999px;
    background-position: center;
    background-size: 1.15rem;
}

.app-flash__close:hover,
.app-flash__close:focus {
    background-color: rgba(15, 23, 42, 0.06);
    opacity: 1;
}


/* Pack 12.2 flash close realignment fix */
.app-flash.app-flash--dismissible {
    padding: 0;
}

.app-flash .app-flash__inner {
    min-height: 4.25rem;
}

.app-flash .app-flash__body {
    margin: 0;
}

.app-flash .app-flash__close,
.app-flash.alert-dismissible .app-flash__close,
.alert.app-flash .app-flash__close {
    position: static !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    z-index: auto !important;
    display: grid !important;
    place-items: center;
    align-self: center;
    flex: 0 0 2.5rem;
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0 !important;
    margin: 0 0 0 0.25rem !important;
    border: 0;
    border-radius: 999px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 1.1rem;
    background-color: transparent;
    box-shadow: none;
    transform: none !important;
    opacity: 0.72;
}

.app-flash .app-flash__close:hover,
.app-flash .app-flash__close:focus {
    background-color: rgba(15, 23, 42, 0.06);
    opacity: 1;
}


.portal-body {
    min-height: 100vh;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    font-family: var(--app-font-sans);
}

.portal-shell {
    min-height: 100vh;
}

.portal-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255,255,255,0.94);
    border-bottom: 1px solid rgba(15,23,42,0.08);
    backdrop-filter: blur(12px);
}

.portal-header-inner {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.portal-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
}

.portal-brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%);
    color: #fff;
    box-shadow: 0 12px 28px rgba(127,29,29,0.22);
}

.portal-brand-title {
    font-weight: 700;
    color: #0f172a;
}

.portal-brand-subtitle {
    font-size: 0.84rem;
    color: #64748b;
}

.portal-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.portal-user {
    text-align: right;
}

.portal-user-name {
    font-weight: 600;
    color: #0f172a;
}

.portal-user-email {
    font-size: 0.84rem;
    color: #64748b;
}

.portal-main {
    padding: 1.5rem 0 2.25rem;
}

.portal-nav {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0 0 1.1rem;
}

.portal-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: #475569;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.65rem 1rem;
    font-weight: 600;
    transition: 0.2s ease;
}

.portal-nav-link:hover,
.portal-nav-link.active {
    color: #991b1b;
    border-color: #fecaca;
    background: #fff5f5;
}

.portal-filter-note {
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 0.9rem 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.metric-value-sm {
    font-size: 1.35rem;
}

.portal-highlight-card {
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 1.25rem;
}

.portal-highlight-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.portal-highlight-kicker {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 0.25rem;
}

.portal-highlight-title {
    font-size: 1.15rem;
    font-weight: 700;
}

@media (max-width: 767.98px) {
    .portal-nav {
        padding-top: 0.25rem;
    }

    .portal-nav-link {
        padding: 0.55rem 0.85rem;
        font-size: 0.92rem;
    }

    .portal-highlight-head {
        flex-direction: column;
    }
}


/* Montserrat Z readability tweaks for portal and guest views */
.portal-brand-subtitle,
.portal-user-email,
.portal-filter-note,
.portal-highlight-kicker,
.portal-body .text-muted,
.portal-body .card-subtitle,
.portal-body .small,
.portal-body small,
.guest-body .text-muted,
.guest-body .form-text {
    font-weight: 500;
    color: #475569 !important;
}

.portal-body table td,
.portal-body table th,
.portal-body .form-label,
.portal-body .form-select,
.portal-body .form-control,
.portal-body .btn,
.portal-body .badge,
.portal-body .alert {
    letter-spacing: 0;
}

.portal-body,
.guest-body,
.admin-body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}


/* Montserrat Z typography tuning */
html {
    font-size: 16px;
}

body {
    font-size: 0.975rem;
    line-height: 1.45;
    letter-spacing: 0.002em;
    font-kerning: normal;
    font-feature-settings: "kern" 1;
}

.admin-body .page-title,
.admin-body .hero-card h1,
.admin-body .hero-card h2,
.admin-body .hero-card h3,
.portal-brand-title,
.portal-highlight-title,
.portal-body h1,
.portal-body h2,
.portal-body h3,
.portal-body h4,
.portal-body h5,
.guest-body h1,
.guest-body h2,
.guest-body h3 {
    letter-spacing: -0.018em;
}

.admin-body .page-title,
.portal-highlight-title,
.portal-body .card-title,
.portal-body .metric-value,
.portal-body .metric-value-sm,
.admin-body .metric-value,
.admin-body .metric-value-sm {
    font-weight: 700;
}

.page-subtitle,
.sidebar-subtitle,
.portal-brand-subtitle,
.portal-user-email,
.portal-filter-note,
.portal-highlight-kicker,
.portal-body .text-muted,
.portal-body .card-subtitle,
.portal-body .small,
.portal-body small,
.guest-body .text-muted,
.guest-body .form-text,
.admin-body .text-muted,
.admin-body .small,
.admin-body small {
    font-weight: 500;
    color: #475569 !important;
}

.sidebar-title,
.portal-brand-title,
.portal-user-name,
.topbar-user,
.card-title,
.box-title,
.section-title {
    font-weight: 700;
}

.table-shell thead th,
.portal-body table thead th,
.admin-body table thead th {
    font-size: 0.79rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.table-shell tbody td,
.portal-body table td,
.admin-body table td {
    line-height: 1.48;
}

.form-label,
.portal-body .form-label,
.admin-body .form-label {
    font-size: 0.89rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.45rem;
}

.form-control,
.form-select,
.portal-body .form-control,
.portal-body .form-select,
.admin-body .form-control,
.admin-body .form-select {
    font-weight: 500;
}

.btn,
.portal-body .btn,
.admin-body .btn,
.guest-body .btn {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.badge,
.badge-soft,
.portal-body .badge,
.admin-body .badge {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.portal-nav-link {
    font-weight: 650;
}

.portal-brand-title {
    font-size: 1.06rem;
}

.portal-header-inner {
    min-height: 84px;
}

.portal-body .card,
.portal-highlight-card,
.admin-content .card,
.login-card {
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.05);
}

.portal-highlight-kicker,
.hero-eyebrow {
    letter-spacing: 0.12em;
}

.portal-body .table-responsive,
.admin-body .table-responsive,
.table-shell {
    border-radius: 1rem;
}

.portal-announcement-card {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    padding: 1.1rem 1.15rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.portal-announcement-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}

.portal-announcement-period {
    font-weight: 700;
    color: #111827;
}

.portal-announcement-meta {
    font-size: .9rem;
    color: #64748b;
}

.portal-announcement-body {
    color: #334155;
    line-height: 1.65;
    white-space: normal;
}

.profile-info-card {
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1rem;
    padding: 1rem 1.05rem;
    min-height: 100%;
}

.profile-info-label {
    font-size: .82rem;
    letter-spacing: .02em;
    color: #64748b;
    margin-bottom: .35rem;
}

.profile-info-value {
    font-weight: 600;
    color: #111827;
    word-break: break-word;
}

.portal-nav {
    flex-wrap: wrap;
}

@media (max-width: 767.98px) {
    .portal-header-actions {
        align-items: flex-start;
        gap: .75rem;
    }

    .portal-announcement-head {
        flex-direction: column;
    }
}


/* Admin detail action bars: keep Montserrat Z baseline, only refine buttons */
.admin-detail-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .5rem;
}

.admin-detail-actions .admin-action-btn,
.page-actions .admin-action-btn {
    min-height: 42px;
    padding: .625rem .95rem;
    border-radius: .8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    white-space: nowrap;
    line-height: 1.1;
}

.admin-detail-actions .admin-action-btn i,
.page-actions .admin-action-btn i,
.admin-body .btn i,
.admin-body .btn .bi {
    flex: 0 0 auto;
    line-height: 1;
}

.admin-detail-actions .admin-action-btn span,
.page-actions .admin-action-btn span {
    display: inline-block;
}

/* Consistent icon spacing in admin buttons */
.admin-body .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
}

.admin-body .btn.btn-icon-only {
    gap: 0;
}

/* Compact clear buttons inside search/filter bars */
.admin-search-clear,
.filter-clear-btn {
    min-width: 42px;
    padding-inline: .75rem;
}

/* Public root landing page */
.guest-stack--wide {
    max-width: 1120px;
}

.public-home {
    width: 100%;
}

.public-home__hero,
.public-home__feature {
    border-radius: 1.5rem;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.public-home__hero {
    background:
        radial-gradient(circle at top right, rgba(220, 38, 38, 0.16), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f8fafc 55%, #eef2ff 100%);
}

.public-home__eyebrow,
.public-home__panel-kicker {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.public-home__title {
    max-width: 780px;
    font-size: clamp(2rem, 4vw, 3.65rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.public-home__lead {
    max-width: 720px;
    color: #475569;
    font-size: 1.06rem;
    line-height: 1.75;
}

.public-home__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.public-home__panel {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1.4rem;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(10px);
}

.public-home__panel-icon,
.public-home__feature-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 1rem;
    background: rgba(220, 38, 38, 0.1);
    color: var(--accent);
    font-size: 1.45rem;
    flex: 0 0 auto;
}

.public-home__panel-title {
    margin-top: 0.25rem;
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
}

.public-home__panel-text {
    margin-top: 0.35rem;
    color: #64748b;
    line-height: 1.6;
}

.public-home__feature h2 {
    font-weight: 750;
}

@media (max-width: 575.98px) {
    .public-home__actions .btn {
        width: 100%;
    }

    .public-home__panel {
        flex-direction: column;
    }
}
