/* ==========================================================================
   Admin panel layout
   Built on the shared design system in ui.css (colours, type, buttons,
   fields, badges, app bar, bottom bar, "More" menu), so the admin panel and
   the guard / resident app look and behave like one product.

   Computers: a white sidebar and top bar around white cards.
   Phones:    every admin page becomes an app screen - app bar with a back
              arrow, bottom bar, tables shown as flat lists, dialogs as bottom
              sheets and thumb-sized fields - without changing the pages.
   ========================================================================== */

:root {
    --sidebar-width: 264px;
    --co-primary: var(--co-brand);
    --co-primary-600: var(--co-brand-600);
    --co-primary-rgb: var(--co-brand-rgb);
    --co-card-shadow: var(--co-shadow);
    --co-card-shadow-lg: var(--co-shadow-lg);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--co-brand) !important; border-color: var(--co-brand) !important; color: #fff !important; }

body { font-size: .9375rem; }

@media (hover: hover) and (pointer: fine) {
    a:hover { color: var(--bs-link-hover-color); }
    .sidebar-nav .nav-link:hover { background: var(--co-soft); color: var(--co-ink); }
    .sidebar-nav .nav-link.active:hover { background: var(--co-brand-soft); color: var(--co-brand-ink); }
    .stat-card:hover { transform: translateY(-2px); box-shadow: var(--co-card-shadow-lg); }
    .settings-nav-link:hover { background: var(--co-soft); color: inherit; }
    .table-hover > tbody > tr:hover > * { background: var(--co-soft); }
}

/* ---- Layout ------------------------------------------------------------- */
.app-wrapper { display: flex; min-height: 100vh; min-height: 100dvh; }
.app-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.app-content { flex: 1 1 auto; }

/* ---- Sidebar (computers) ----------------------------------------------- */
.app-sidebar {
    width: var(--sidebar-width); flex: 0 0 var(--sidebar-width);
    background: var(--co-card); border-right: 1px solid var(--co-line);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--co-line); border-radius: 3px; }

.sidebar-brand { color: var(--co-ink); min-height: 64px; border-bottom: 1px solid var(--co-line); }
.sidebar-brand span { letter-spacing: -.02em; }
.sidebar-society { background: var(--co-soft); border-radius: 14px; }

.sidebar-nav { padding-bottom: 2rem; }
.sidebar-nav .nav-link {
    color: var(--co-muted); border-radius: 12px; margin: .125rem .75rem; padding: .6rem .85rem;
    display: flex; align-items: center; font-weight: 500; transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 1.5rem; }
.sidebar-nav .nav-link.active { background: var(--co-brand-soft); color: var(--co-brand-ink); font-weight: 600; }
.nav-section { color: var(--co-muted) !important; letter-spacing: .06em; font-size: .6875rem; font-weight: 600; margin-top: 1.25rem !important; padding-left: 1.6rem !important; }

/* ---- Top bar (computers) ------------------------------------------------ */
.app-navbar {
    position: sticky; top: 0; z-index: 1020; height: 64px;
    background: var(--co-card) !important; border-bottom: 1px solid var(--co-line);
}
.app-navbar .dropdown-toggle::after { display: none; }

/* ---- Page heading ------------------------------------------------------- */
.page-title { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; color: var(--co-ink); }
.breadcrumb { --bs-breadcrumb-item-active-color: var(--co-muted); --bs-breadcrumb-divider-color: var(--co-faint); }
.app-footer { background: transparent; }

/* ---- Cards ------------------------------------------------------------- */
.card {
    --bs-card-border-radius: var(--co-radius);
    --bs-card-inner-border-radius: calc(var(--co-radius) - 1px);
    --bs-card-border-color: var(--co-line);
    --bs-card-bg: var(--co-card);
    --bs-card-cap-bg: transparent;
    box-shadow: var(--co-shadow);
}
.card .card-body { padding: 1.25rem; }
.card-header { font-weight: 600; padding: .9rem 1.25rem; }
.card-header, .card-footer { border-color: var(--co-line); }
.shadow-sm { box-shadow: var(--co-shadow) !important; }

/* ---- Stat tiles -------------------------------------------------------- */
.stat-card { transition: transform .15s ease, box-shadow .15s ease; }
.stat-card .stat-icon {
    width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.stat-card .card-body { padding: 1rem 1.1rem; }
/* Icon above the figure: long amounts (Rs 1,038,240.00) keep the whole tile width. */
.stat-card .card-body { flex-direction: column !important; align-items: flex-start !important; gap: .65rem !important; }
.stat-card .card-body > * { max-width: 100%; }
.stat-card .stat-value { font-size: 1.375rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; color: var(--co-ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* a figure never splits between digits */
.stat-card .stat-label { color: var(--co-muted); font-size: .8125rem; font-weight: 500; }
.stat-card .badge { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; }

@media (min-width: 1200px) and (max-width: 1599.98px) {
    .stat-card .card-body { padding: .9rem .9rem; }
    .stat-card .stat-value { font-size: 1.2rem; }   /* six tiles share the row */
    .stat-card .stat-icon { width: 40px; height: 40px; flex-basis: auto; font-size: 1.1rem; }
}

/* tinted icon backgrounds */
.bg-soft-primary   { background: #e9edfc; color: #2748db; }
.bg-soft-success   { background: #e3f6ef; color: #13795b; }
.bg-soft-info      { background: #e4f1fd; color: #1f6fd1; }
.bg-soft-warning   { background: #fff4dc; color: #946200; }
.bg-soft-danger    { background: #fdecec; color: #c62828; }
.bg-soft-dark      { background: #ececee; color: #2c2e33; }
.bg-soft-secondary { background: #f2f2f3; color: #5b5e66; }

/* ---- Charts (fixed-height wrappers prevent the infinite-grow bug) ------ */
.chart-box { position: relative; width: 100%; }
.chart-box.h-sm { height: 230px; }
.chart-box.h-md { height: 300px; }
.chart-box.h-lg { height: 340px; }
.chart-box canvas { max-height: 100%; }
.chart-box:not(.chart-ready)::after {
    content: ""; position: absolute; top: 50%; left: 50%; width: 28px; height: 28px;
    margin: -14px 0 0 -14px; border: 3px solid var(--co-brand); border-right-color: transparent;
    border-radius: 50%; animation: co-spin .7s linear infinite;
}
@keyframes co-spin { to { transform: rotate(360deg); } }

/* ---- Settings sub-navigation -------------------------------------------- */
.settings-nav-link {
    display: flex; align-items: flex-start; gap: .7rem; padding: .65rem .8rem;
    border-radius: 12px; color: inherit; margin-bottom: .15rem; transition: background .15s ease;
}
.settings-nav-link i { font-size: 1.1rem; margin-top: .1rem; color: var(--co-brand-ink); }
.settings-nav-link.active { background: var(--co-brand-soft); }
.settings-nav-link.active i, .settings-nav-link.active .fw-semibold { color: var(--co-brand-ink); }
.settings-nav-group:not(:first-child) { margin-top: .5rem; }

/* segmented option buttons (billing type / cycle) */
.option-grid { display: grid; gap: .6rem; }
.option-tile input { position: absolute; opacity: 0; }
.option-tile label {
    display: block; cursor: pointer; padding: .8rem .95rem; border: 1.5px solid var(--co-field);
    border-radius: 14px; font-weight: 500; transition: all .12s ease;
}
.option-tile input:checked + label { border-color: var(--co-brand); background: var(--co-brand-soft); color: var(--co-brand-ink); }
.option-tile label .opt-sub { font-weight: 400; font-size: .8125rem; }

/* ---- Tables ------------------------------------------------------------ */
.table {
    --bs-table-color: var(--co-ink);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--co-line);
    --bs-table-striped-bg: rgba(18, 25, 39, .02);
    --bs-table-hover-bg: var(--co-soft);
}
.table thead th { white-space: nowrap; font-size: .75rem; font-weight: 600; letter-spacing: .01em; color: var(--co-muted); border-bottom-width: 1px; }
.table > :not(caption) > * > * { padding: .8rem .75rem; }
.table-light { --bs-table-bg: #f7f7f8; --bs-table-color: var(--co-ink); --bs-table-border-color: var(--co-line); }

/* List search: one rounded field with a magnifier. */
.dataTables_wrapper .dataTables_filter input {
    padding-left: 2.4rem !important;
    background: var(--co-card) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%239a9ca3'%3e%3cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3e%3c/svg%3e") no-repeat .9rem center / 15px;
}
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter input { background-color: var(--co-bg); }

/* ---- Sign-in pages ------------------------------------------------------
   Phone: the picture on top, then the form - all of it visible without scrolling
   on a usual phone. Computer: a split screen - the picture on a rounded blue
   panel (with what the app does) on the left, the form on the right. */
.auth-body {
    min-height: 100vh; min-height: 100svh;
    background: var(--co-bg);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.auth-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
.auth-art { padding: 1rem 1rem 0; }
.auth-art__img {
    display: block; margin: 0 auto;
    width: auto; max-width: 100%; height: min(30svh, 250px);
    object-fit: contain;
}
.auth-art__copy { display: none; }
.auth-main { flex: 1 0 auto; display: flex; justify-content: center; padding: .75rem 1.25rem 1.5rem; }
.auth-card { width: 100%; margin: 0 auto; }
.auth-brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.0625rem; letter-spacing: -.02em; color: var(--co-ink); }
.auth-brand .co-logo { width: 30px; height: 30px; }
.auth-title { font-size: 1.75rem; font-weight: 600; letter-spacing: -.02em; margin: .75rem 0 .3rem; }
.auth-sub { color: var(--co-muted); margin-bottom: 1.5rem; }
.auth-body .form-control, .auth-body .form-select { min-height: 52px; border-radius: 16px; }
.auth-body form .btn-primary { min-height: 52px; font-weight: 700; }

@media (min-width: 992px) {
    .auth-body { padding: 0; }
    .auth-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .auth-art { position: sticky; top: 0; height: 100vh; height: 100svh; padding: 1rem; }
    .auth-art__inner {
        position: relative; overflow: hidden; isolation: isolate;
        height: 100%; border-radius: 28px; padding: 3rem 2.5rem;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        background: var(--co-brand); color: #fff;
    }
    /* two soft circles for depth */
    .auth-art__inner::before, .auth-art__inner::after {
        content: ""; position: absolute; z-index: -1; border-radius: 50%; background: rgba(255, 255, 255, .07);
    }
    .auth-art__inner::before { width: 520px; height: 520px; top: -180px; right: -160px; }
    .auth-art__inner::after { width: 340px; height: 340px; bottom: -140px; left: -110px; }
    .auth-art__img { width: 100%; max-width: 540px; height: auto; max-height: 52vh; }
    .auth-art__copy { display: block; width: 100%; max-width: 460px; margin-top: 2rem; }
    .auth-art__title { color: #fff; font-size: 2rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 1.1rem; }
    .auth-art__points { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
    .auth-art__points li { display: flex; align-items: center; gap: .8rem; font-weight: 500; color: rgba(255, 255, 255, .92); }
    .auth-art__points .bi {
        flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%;
        display: inline-flex; align-items: center; justify-content: center;
        background: rgba(255, 255, 255, .14); color: #fff; font-size: 1rem;
    }
    .auth-main { align-items: center; padding: 3rem 2.5rem; }
    .auth-brand { font-size: 1.125rem; }
    .auth-brand .co-logo { width: 34px; height: 34px; }
    .auth-title { font-size: 2rem; margin-top: 1.25rem; }
    .auth-sub { margin-bottom: 2rem; }
}
/* Short phones (e.g. 320 x 568): a smaller picture keeps the Sign in button on the first screen. */
@media (max-width: 991.98px) and (max-height: 700px) {
    .auth-art__img { height: min(20svh, 140px); }
    .auth-title { font-size: 1.5rem; margin-top: .4rem; }
    .auth-sub { margin-bottom: 1rem; }
}
/* Dark theme: the picture sits on a deep blue panel (phones too), so its light backdrop does not glare. */
[data-bs-theme="dark"] .auth-art__inner { background: var(--co-brand-700); border-radius: 24px; padding: .75rem; }
@media (min-width: 992px) {
    [data-bs-theme="dark"] .auth-art__inner { border-radius: 28px; padding: 3rem 2.5rem; }
}

/* Show / hide password: the eye inside the field. */
.co-password { position: relative; }
.co-password > .form-control { padding-right: 3.25rem; }
.co-password > .form-control.is-invalid { padding-right: 5.5rem; background-position: right 3.25rem center; }
.co-password__toggle {
    position: absolute; top: 4px; right: 4px; width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 12px; background: transparent; color: var(--co-muted); font-size: 1.15rem;
}
.co-password__toggle:focus-visible { outline: 2px solid var(--co-brand-ink); outline-offset: 0; }
@media (hover: hover) and (pointer: fine) { .co-password__toggle:hover { color: var(--co-ink); } }

/* ==========================================================================
   Dark theme: Bootstrap themes its own components; these tune the rest.
   ========================================================================== */
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td {
    --bs-table-bg: #1b1e25; --bs-table-color: var(--co-ink); --bs-table-border-color: var(--co-line);
    background-color: #1b1e25; color: var(--co-ink);
}
[data-bs-theme="dark"] .table > :not(caption) > * > * { border-bottom-color: var(--co-line); }
[data-bs-theme="dark"] .border, [data-bs-theme="dark"] .border-bottom, [data-bs-theme="dark"] .border-top { border-color: var(--co-line) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--co-ink) !important; }
[data-bs-theme="dark"] .bg-soft-primary   { background: rgba(39, 72, 219, .24); color: #a9b9ff; }
[data-bs-theme="dark"] .bg-soft-success   { background: rgba(22, 163, 74, .18); color: #4ade80; }
[data-bs-theme="dark"] .bg-soft-info      { background: rgba(31, 111, 209, .22); color: #7cc0ff; }
[data-bs-theme="dark"] .bg-soft-warning   { background: rgba(202, 138, 4, .20); color: #fcd34d; }
[data-bs-theme="dark"] .bg-soft-danger    { background: rgba(220, 38, 38, .18); color: #f87171; }
[data-bs-theme="dark"] .bg-soft-dark      { background: rgba(160, 164, 173, .18); color: #d6d8dd; }
[data-bs-theme="dark"] .bg-soft-secondary { background: rgba(160, 164, 173, .14); color: #c9ccd3; }

/* ==========================================================================
   Phones and small tablets: the admin panel becomes the app
   ========================================================================== */
@media (max-width: 991.98px) {
    body.co-shell {
        font-size: 1rem;
        padding-bottom: calc(var(--co-tabs-h) + var(--co-safe-b) + 16px);
        -webkit-tap-highlight-color: transparent;
    }
    .app-sidebar, .app-navbar, .app-footer { display: none !important; }
    .app-content { padding: 1rem 1rem 0 !important; }

    /* The title is in the app bar and the back arrow replaces breadcrumbs:
       what stays at the top of the page is its buttons. */
    .co-pagehead { margin-bottom: 1rem !important; }
    .co-pagehead__title { display: none; }
    .co-pagehead:not(:has(.co-pagehead__actions)) { display: none !important; }
    .co-pagehead__actions { width: 100%; display: flex; flex-wrap: wrap; gap: .5rem; }
    .co-pagehead__actions > * { margin: 0 !important; }
    .co-pagehead__actions .btn { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }

    .card .card-body { padding: 1rem; }
    .chart-box.h-md { height: 240px; }
    .chart-box.h-sm, .chart-box.h-lg { height: 210px; }

    /* Thumb-sized controls; 16px text stops iPhones zooming into fields. */
    .form-control, .form-select { min-height: 52px; border-radius: 16px; }
    .form-control-sm, .form-select-sm { min-height: 44px; border-radius: 12px; }
    textarea.form-control { min-height: 112px; }
    .btn { min-height: 46px; }
    .btn-sm { min-height: 38px; }
    .btn-lg { min-height: 54px; }
    .input-group > .btn { min-height: 0; }

    /* Tab and pill bars scroll sideways instead of wrapping onto many lines. */
    .nav-tabs, .nav-pills { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
    .nav-tabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link, .nav-pills .nav-link { white-space: nowrap; }

    /* Settings menu: one row of chips on the page. */
    .settings-nav.card { border: 0; box-shadow: none; background: transparent; }
    .settings-nav .card-body { display: flex; gap: .5rem; overflow-x: auto; padding: 0 0 .25rem !important; scrollbar-width: none; }
    .settings-nav .card-body::-webkit-scrollbar { display: none; }
    .settings-nav-group { display: none; }
    .settings-nav-link { flex: 0 0 auto; margin: 0; align-items: center; white-space: nowrap; background: var(--co-soft); border-radius: 999px; padding: .5rem .95rem; }
    .settings-nav-link .opacity-75 { display: none !important; }
    .settings-nav-link i { margin-top: 0; }
    .settings-nav-link.active { background: var(--co-brand); }
    .settings-nav-link.active i, .settings-nav-link.active .fw-semibold { color: #fff; }

    /* Lists: one full-width search box and compact paging. */
    .dataTables_wrapper .dataTables_length { display: none; }
    .dataTables_wrapper > .row { --bs-gutter-x: 0; }
    .dataTables_wrapper .dataTables_filter { text-align: left !important; margin-bottom: .75rem; }
    .dataTables_wrapper .dataTables_filter label { width: 100%; }
    .dataTables_wrapper .dataTables_filter input { width: 100% !important; margin: 0 !important; min-height: 48px; border-radius: 14px; }
    .dataTables_wrapper .dataTables_info { text-align: center; font-size: .8125rem; color: var(--co-muted); }
    .dataTables_wrapper .dataTables_paginate { display: flex; justify-content: center !important; }
    .pagination { flex-wrap: wrap; justify-content: center; }

    .co-submitbar {
        position: sticky; bottom: calc(var(--co-tabs-h) + var(--co-safe-b) + 10px); z-index: 20;
        display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; padding: .6rem;
        background: var(--co-card); border: 1px solid var(--co-line); border-radius: 999px;
        box-shadow: var(--co-shadow-lg);
    }
    .co-submitbar > * { margin: 0 !important; }
    .co-submitbar .btn { flex: 1 1 auto; }

    /* Dialogs open as bottom sheets. */
    .app-content .modal-dialog { margin: 0; max-width: none; min-height: 100%; display: flex; align-items: flex-end; }
    .app-content .modal-content { border: 0; border-radius: 24px 24px 0 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding-bottom: var(--co-safe-b); }
    .app-content .modal.fade .modal-dialog { transform: translateY(40px); }
    .app-content .modal.show .modal-dialog { transform: none; }
}

/* Phones: every table row becomes a list row (cells are labelled by app.js). */
@media (max-width: 767.98px) {
    .stat-card .stat-value { font-size: 1.15rem; }

    /* A card that only frames a list steps aside: the rows sit on the page. */
    .card:has(table.co-cards) { border: 0; box-shadow: none !important; background: transparent; }
    .card:has(table.co-cards) > .card-body { padding: 0; }

    table.co-cards > thead { display: none; }
    table.co-cards, table.co-cards > tbody, table.co-cards > tfoot { display: block; width: 100% !important; }
    table.co-cards { border: 0; margin-bottom: .25rem; }

    /* Each row: a title across the top, then the facts in two columns. */
    table.co-cards > tbody > tr, table.co-cards > tfoot > tr {
        position: relative;
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1rem;
        padding: .9rem 0; border-bottom: 1px solid var(--co-line);
    }
    table.co-cards > tbody > tr:last-child, table.co-cards > tfoot > tr:last-child { border-bottom: 0; }
    table.co-cards > tbody > tr > *, table.co-cards > tfoot > tr > * {
        display: block; width: auto !important; min-width: 0;
        padding: .3rem 0 !important;
        border: 0 !important; background: transparent !important; box-shadow: none !important;
        text-align: left !important; white-space: normal !important; overflow-wrap: anywhere;
        font-weight: 500;
    }
    table.co-cards > tbody > tr > *::before, table.co-cards > tfoot > tr > *::before {
        content: attr(data-label);
        display: block; margin-bottom: .1rem;
        color: var(--co-muted); font-size: .75rem; font-weight: 500; line-height: 1.3;
    }
    /* first cell: the row's title, full width */
    table.co-cards > tbody > tr > :first-child { grid-column: 1 / -1; font-size: 1rem; font-weight: 600; letter-spacing: -.005em; padding-right: 1.5rem !important; }
    table.co-cards > tbody > tr > :first-child::before { display: none; }
    /* cells without a column heading (row actions): full width, at the end */
    table.co-cards > tbody > tr > [data-label=""], table.co-cards > tfoot > tr > [data-label=""] {
        grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .45rem;
    }
    table.co-cards > tbody > tr > [data-label=""] > *, table.co-cards > tbody > tr > [data-label=""] form { margin: 0 !important; }
    table.co-cards > tbody > tr > [data-label=""]::before, table.co-cards > tfoot > tr > [data-label=""]::before { display: none; }
    table.co-cards > tbody > tr > [data-label=""] .btn { min-height: 42px; min-width: 42px; display: inline-flex; align-items: center; justify-content: center; }
    /* the "nothing here yet" row */
    table.co-cards > tbody > tr > td[colspan] { grid-column: 1 / -1; padding: 1.25rem 0 !important; text-align: center !important; font-weight: 400; color: var(--co-muted); }
    table.co-cards > tbody > tr > td[colspan]::before { display: none; }

    /* A row with a details page opens it when tapped anywhere (app.js). */
    table.co-cards > tbody > tr.co-row-link { cursor: pointer; transition: opacity 120ms ease; }
    table.co-cards > tbody > tr.co-row-link::after {
        content: "\F285"; font-family: "bootstrap-icons"; position: absolute; top: 1.1rem; right: .1rem;
        color: var(--co-muted); font-size: .85rem;
    }
    table.co-cards > tbody > tr.co-row-link:active { opacity: .6; }

    .table-responsive:has(table.co-cards) { overflow: visible; }
}

@media (max-width: 575.98px) {
    .stat-card .stat-icon { width: 40px; height: 40px; flex-basis: auto; font-size: 1.1rem; }
}

/* Success messages: a toast that slides in and leaves on its own.
   Problems (errors, warnings) stay at the top of the page until read. */
body.co-shell .co-flash--success, body.co-shell .co-flash--info {
    --bs-alert-bg: #121212; --bs-alert-color: #fff; --bs-alert-link-color: #fff;
    position: fixed; z-index: 1085; left: 1rem; right: 1rem;
    bottom: calc(var(--co-tabs-h) + var(--co-safe-b) + 14px);
    max-width: 30rem; margin: 0 auto; padding-left: 2.9rem;
    border: 0; border-radius: 14px; box-shadow: 0 10px 30px rgba(18, 25, 39, .22);
    animation: co-toast-in .22s ease-out both, co-toast-out .3s ease-in 5s forwards;
}
body.co-shell .co-flash--success::before, body.co-shell .co-flash--info::before {
    content: "\F26A"; font-family: "bootstrap-icons"; position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
    font-size: 1.15rem; line-height: 1; color: #4ade80;
}
body.co-shell .co-flash--info::before { content: "\F430"; color: #8da2ff; }
body.co-shell .co-flash--success .btn-close, body.co-shell .co-flash--info .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
[data-bs-theme="dark"] body.co-shell .co-flash--success, [data-bs-theme="dark"] body.co-shell .co-flash--info { --bs-alert-bg: #2a2f39; }
@media (min-width: 992px) {
    body.co-shell .co-flash--success, body.co-shell .co-flash--info { left: auto; right: 1.5rem; bottom: 1.5rem; width: 26rem; margin: 0; }
}
@keyframes co-toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes co-toast-out { to { opacity: 0; transform: translateY(12px); visibility: hidden; pointer-events: none; } }

/* ---- Access control ------------------------------------------------------ */
.co-access-list { border: 1px solid var(--co-line); border-radius: 14px; overflow: hidden; background: var(--co-card); }
.co-access-row {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
    padding: .8rem .95rem; border-bottom: 1px solid var(--co-line);
}
.co-access-row:last-child { border-bottom: 0; }
.co-access-row__name { display: flex; gap: .7rem; align-items: flex-start; flex: 1 1 16rem; min-width: 0; }
.co-access-row__name > .bi {
    flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.05rem; color: var(--co-brand-ink); background: var(--co-soft);
}
.co-access-row__select { flex: 0 1 15rem; width: auto; }
@media (max-width: 575.98px) { .co-access-row__select { flex-basis: 100%; } }
.co-lvl { display: inline-block; padding: .25em .7em; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.co-lvl--off    { background: var(--co-idle-bg); color: var(--co-idle); }
.co-lvl--own    { background: var(--co-brand-soft); color: var(--co-brand-ink); }
.co-lvl--view   { background: #e4f1fd; color: #1f6fd1; }
.co-lvl--full   { background: var(--co-ok-bg); color: var(--co-ok); }
.co-lvl--custom { background: var(--co-warn-bg); color: var(--co-warn); }
[data-bs-theme="dark"] .co-lvl--view { background: rgba(31, 111, 209, .22); color: #7cc0ff; }
.co-access-matrix th { white-space: nowrap; }

/* ---- Society ledger ---------------------------------------------------- */
.co-amount-in  { color: var(--co-ok); font-weight: 600; white-space: nowrap; }
.co-amount-out { color: var(--co-ink); font-weight: 600; white-space: nowrap; }
.co-big-amount { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.co-bar { display: block; height: 8px; border-radius: 999px; background: var(--co-soft); overflow: hidden; }
.co-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--co-brand); }
.co-bar--in > span, .co-bar--done > span { background: #16ba9c; }
.co-cat { display: flex; align-items: center; gap: .8rem; padding: .65rem 0; border-bottom: 1px solid var(--co-line); color: var(--co-ink); text-decoration: none; }
.co-cat:last-child { border-bottom: 0; }
.co-cat__icon { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--co-soft); color: var(--co-brand-ink); font-size: 1.05rem; }
.co-cat__body { flex: 1 1 auto; min-width: 0; display: grid; gap: .35rem; }
.co-cat__label { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-cat__amount { flex: 0 0 auto; font-weight: 600; white-space: nowrap; }
.co-cat__share { flex: 0 0 2.75rem; text-align: right; color: var(--co-muted); font-size: .8125rem; font-weight: 600; }
.co-month { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr) auto; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--co-line); }
.co-month:last-child { border-bottom: 0; }
.co-month__label { font-weight: 600; font-size: .875rem; }
.co-month__bars { display: grid; gap: .3rem; }
.co-month__nums { display: grid; text-align: right; font-size: .8125rem; line-height: 1.35; }
.co-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8125rem; color: var(--co-muted); }
.co-legend i { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .35rem; vertical-align: -.05rem; }
.co-row-void > * { color: var(--co-muted) !important; }
.co-strike { text-decoration: line-through; }
.co-proof { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; font-size: .8125rem; white-space: nowrap; }
.co-bill-preview { display: block; max-width: 100%; max-height: 440px; border-radius: 14px; border: 1px solid var(--co-line); object-fit: contain; background: var(--co-soft); }
.co-trail { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.co-trail li { display: flex; gap: .75rem; align-items: flex-start; }
.co-trail li > .bi { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--co-soft); color: var(--co-brand-ink); }
.co-facts { display: grid; grid-template-columns: minmax(7rem, 35%) minmax(0, 1fr); gap: .55rem 1rem; margin: 0; }
.co-facts dt { color: var(--co-muted); font-weight: 500; font-size: .875rem; }
.co-facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---- Meetings & votes ---------------------------------------------------- */
.co-date { flex: 0 0 auto; width: 56px; border-radius: 14px; overflow: hidden; text-align: center; background: var(--co-card); border: 1px solid var(--co-line); }
.co-date__month { display: block; background: var(--co-brand); color: #fff; font-size: .6875rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .15rem 0; }
.co-date__day { display: block; font-size: 1.375rem; font-weight: 700; line-height: 1.6; color: var(--co-ink); }
.co-date--muted .co-date__month { background: var(--co-idle); }
.co-meeting { display: flex; gap: .9rem; align-items: flex-start; padding: .9rem 0; border-bottom: 1px solid var(--co-line); color: var(--co-ink); text-decoration: none; }
.co-meeting:last-child { border-bottom: 0; }
.co-meeting__body { flex: 1 1 auto; min-width: 0; }
.co-meeting__title { font-weight: 600; }
.co-meeting__meta { font-size: .8125rem; color: var(--co-muted); }
.co-agenda { list-style: none; counter-reset: agenda; padding: 0; margin: 0; }
.co-agenda > li { counter-increment: agenda; position: relative; padding: .85rem 0 .85rem 2.75rem; border-bottom: 1px solid var(--co-line); }
.co-agenda > li:last-child { border-bottom: 0; }
.co-agenda > li::before {
    content: counter(agenda); position: absolute; left: 0; top: .8rem; width: 1.9rem; height: 1.9rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; background: var(--co-brand-soft); color: var(--co-brand-ink); font-weight: 700; font-size: .875rem;
}
.co-decision { margin-top: .55rem; padding: .6rem .8rem; border-radius: 12px; background: var(--co-ok-bg); }
.co-decision strong { color: var(--co-ok); }
.co-action { padding: .9rem 0; border-bottom: 1px solid var(--co-line); }
.co-action:last-child { border-bottom: 0; }
.co-action__head { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.co-action__title { font-weight: 600; }
.co-action__meta { font-size: .8125rem; color: var(--co-muted); }
.co-progress-line { display: flex; align-items: center; gap: .6rem; margin-top: .45rem; }
.co-progress-line .co-bar { flex: 1 1 auto; }
.co-progress-line__pct { flex: 0 0 auto; min-width: 2.6rem; text-align: right; font-size: .8125rem; font-weight: 700; }
.co-vote-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--co-soft); }
.co-vote-bar > span { display: block; height: 100%; }
.co-vote-bar .is-for, .co-legend .is-for { background: #16ba9c; }
.co-vote-bar .is-against, .co-legend .is-against { background: #e74141; }
.co-vote-bar .is-abstain, .co-legend .is-abstain { background: #b1b4bb; }
.co-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.co-choices .btn { min-height: 48px; padding-left: .5rem; padding-right: .5rem; white-space: nowrap; }
.co-outcome { display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; border-radius: 14px; font-weight: 600; }
.co-outcome .bi { font-size: 1.6rem; }
.co-outcome--passed { background: var(--co-ok-bg); color: var(--co-ok); }
.co-outcome--rejected { background: var(--co-bad-bg); color: var(--co-bad); }
.co-outcome--no_quorum { background: var(--co-warn-bg); color: var(--co-warn); }
.co-rules { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.co-rules .bi { color: var(--co-brand-ink); margin-right: .45rem; }
.co-agenda-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; gap: .5rem; align-items: start; padding: .75rem 0; border-bottom: 1px solid var(--co-line); }
.co-agenda-row__n { width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--co-brand-soft); color: var(--co-brand-ink); font-weight: 700; font-size: .875rem; margin-top: .4rem; }
.co-agenda-row__fields { display: grid; gap: .5rem; }
@media (min-width: 768px) { .co-agenda-row__fields { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .co-agenda-row__fields .co-span-2 { grid-column: 1 / -1; } }

/* Printing (invoices, receipts, reports): only the page itself. */
@media print {
    .co-top, .co-tabs, .co-sheet, .co-install, .app-sidebar, .app-navbar, .app-footer { display: none !important; }
    body.co-shell { padding: 0 !important; background: #fff !important; }
}
