/* Apni Society: application layout. ui.css (loaded first) supplies the base styles and components; this file
   adds the header, sidebar, page furniture, dashboard, reports, sign-in, the bill sheet and the print rules. */

:root {
    --header-h: 3.5rem;
    --sidebar-w: 15.5rem;
}

.skip-link {
    position: absolute;
    top: -3rem;
    left: 0.75rem;
    z-index: 2000;
    padding: 0.5rem 0.9rem;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: #fff;
    color: var(--navy);
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
}

/* ----- Header -------------------------------------------------------------------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--header-h);
    padding: 0 1rem;
    background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 8px rgba(16, 24, 40, 0.18);
}

.header-start {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
}

.nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    background: transparent;
    color: #fff;
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
    display: block;
    width: 1.05rem;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.nav-toggle-bars {
    position: relative;
}

.nav-toggle-bars::before,
.nav-toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: #fff;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-decoration: none;
}

.brand-link:hover {
    color: #fff;
}

.brand-logo {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.55rem;
    background: linear-gradient(145deg, #14a294 0%, var(--teal) 100%);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.02em;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.brand-name {
    white-space: nowrap;
}

.header-society {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.society-name {
    overflow: hidden;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.society-name:hover {
    color: #fff;
    text-decoration: underline;
}

.role-chip {
    flex: 0 0 auto;
    padding: 0.1rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    color: #cfe0f0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.fy-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.fy-label {
    color: #b9c8da;
    font-size: 0.78rem;
    white-space: nowrap;
}

.header-fy .form-select {
    min-width: 10.5rem;
    border-color: rgba(255, 255, 255, 0.22);
    background-color: rgba(255, 255, 255, 0.08);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cfe0f0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m3 6 5 5 5-5'/%3e%3c/svg%3e");
    color: #fff;
}

.header-fy .form-select option {
    color: var(--ink);
    background: #fff;
}

.header-user {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.header-user form {
    margin: 0;
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.user-name {
    max-width: 14rem;
    overflow: hidden;
    color: #e3ebf5;
    font-size: 0.875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----- Shell and sidebar ----------------------------------------------------------- */

.app-shell {
    display: flex;
    min-height: calc(100vh - var(--header-h));
}

/* The sidebar column keeps its white background and border on long pages too. */
@media (min-width: 992px) {
    .app-shell:has(.app-sidebar) {
        background: linear-gradient(to right, var(--surface) calc(var(--sidebar-w) - 1px), var(--line) calc(var(--sidebar-w) - 1px), var(--line) var(--sidebar-w), transparent var(--sidebar-w));
    }
}

.app-sidebar {
    position: sticky;
    top: var(--header-h);
    display: flex;
    flex: 0 0 var(--sidebar-w);
    flex-direction: column;
    width: var(--sidebar-w);
    height: calc(100vh - var(--header-h));
    padding: 0.75rem 0.6rem;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.nav-group + .nav-group {
    margin-top: 0.45rem;
}

.nav-group-label {
    padding: 0.3rem 0.75rem 0.2rem;
    color: #8592a3;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-sidebar .nav-link {
    position: relative;
    padding: 0.32rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 0.9rem;
}

.app-sidebar .nav-link:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.app-sidebar .nav-link.active {
    background: var(--teal-soft);
    color: var(--teal-dark);
    font-weight: 600;
}

.app-sidebar .nav-link.active::before {
    content: "";
    position: absolute;
    top: 0.45rem;
    bottom: 0.45rem;
    left: -0.6rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--teal);
}

.sidebar-fy {
    margin: 0 0.25rem 0.75rem;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.sidebar-fy .fy-switch {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
}

.sidebar-fy .fy-label {
    color: var(--muted);
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid var(--line);
}

.app-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: 92rem;
    min-width: 0;
    padding: 1.5rem 1.75rem 3rem;
}

.nav-backdrop {
    display: none;
}

/* Small screens: the sidebar slides in from the left when the menu button is pressed. */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: var(--header-h);
        bottom: 0;
        left: 0;
        z-index: 1025;
        height: auto;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-lg);
    }

    .app-sidebar.is-open {
        transform: none;
    }

    .nav-backdrop:not([hidden]) {
        position: fixed;
        inset: var(--header-h) 0 0 0;
        z-index: 1020;
        display: block;
        background: rgba(16, 24, 40, 0.35);
    }

    .app-main {
        padding: 1.1rem 1rem 2.5rem;
    }

    .user-name {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .app-header {
        gap: 0.6rem;
        padding: 0 0.75rem;
    }

    .brand-name,
    .role-chip,
    .avatar {
        display: none;
    }

    .header-society {
        padding-left: 0.6rem;
    }
}

/* ----- Page furniture --------------------------------------------------------------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    margin-bottom: 0.15rem;
}

.page-head p {
    max-width: 52rem;
}

.section-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
    color: var(--navy);
    font-weight: 650;
}

h2.section-title {
    font-size: 1rem;
}

.empty-state {
    padding: 2rem 1rem;
    color: var(--muted);
    text-align: center;
}

form.card .row + .d-flex,
form.card .row + button,
form.card .row + .btn {
    margin-top: 1rem;
}

/* ----- Dashboard -------------------------------------------------------------------- */

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem 1.15rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.kpi::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--teal) 0%, #4fb3a8 100%);
}

.kpi-label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.kpi-value {
    color: var(--navy);
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.kpi-small {
    font-size: 1.05rem;
}

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

.kpi-grid .kpi-value {
    font-size: 1.35rem;
}

.kpi-link {
    color: inherit;
    text-decoration: none;
}

.kpi-link:hover,
.kpi-link:focus-visible {
    border-color: var(--teal);
}

.society-summary-logo,
.society-logo-preview {
    flex: 0 0 auto;
    max-width: 6.5rem;
    max-height: 6.5rem;
    object-fit: contain;
}

.society-logo-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 6.5rem;
    height: 6.5rem;
    padding: 0.5rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    text-align: center;
}

.qr-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.qr-figure {
    margin: 0;
    text-align: center;
}

.qr-figure svg,
.qr-image {
    width: 9rem;
    height: 9rem;
    object-fit: contain;
}

.min-w-0 {
    min-width: 0;
}

.fy-manage {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.8rem;
    white-space: nowrap;
}

.settings-tile {
    color: inherit;
    text-decoration: none;
}

.settings-tile:hover h2,
.settings-tile:focus-visible h2 {
    color: var(--teal);
}

.rich-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.3rem;
}

.rich-surface {
    height: auto;
    min-height: 7rem;
    white-space: normal;
}

.rich-surface ul,
.rich-surface ol {
    margin: 0.3rem 0;
    padding-left: 1.4rem;
}

.rich-surface p {
    margin: 0 0 0.35rem;
}

.bank-edit-row td {
    padding-top: 0;
    border-top: 0;
}

.kpi a {
    margin-top: auto;
    padding-top: 0.25rem;
    font-size: 0.825rem;
    text-decoration: none;
}

.kpi a:hover {
    text-decoration: underline;
}

.checklist li {
    gap: 0.75rem;
}

.check {
    display: inline-grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.4rem;
    border: 1.5px solid #e0a54d;
    border-radius: 50%;
    color: transparent;
    font-size: 0.7rem;
    font-weight: 700;
    vertical-align: -0.2em;
}

.check.done {
    border-color: var(--teal);
    background: var(--teal);
    color: #fff;
}

.society-card,
.report-card {
    height: 100%;
    color: inherit;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.society-card:hover,
.report-card:hover {
    border-color: #a9d8d1;
    color: inherit;
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

details > summary {
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

/* A plain summary reads as a link with a turning arrow; a summary styled as a button keeps the button look. */
details > summary:not(.btn) {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--teal);
    font-weight: 550;
}

details > summary:not(.btn)::before {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

details[open] > summary:not(.btn)::before {
    transform: rotate(45deg);
}

details.card > summary:not(.btn) {
    color: var(--navy);
    font-weight: 650;
}

details[open] > summary.btn {
    border-color: var(--btn-hover-border);
    background: var(--btn-hover-bg);
}

.details-panel {
    min-width: 18rem;
    max-width: 36rem;
    text-align: left;
}

/* ----- Reports and audit ------------------------------------------------------------ */

.report-sheet {
    padding: 1.1rem 1.25rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.report-sheet .table {
    margin-bottom: 0;
}

.report-note {
    margin-bottom: 0.75rem;
}

.print-page .report-sheet {
    max-width: 64rem;
    margin: 0.5rem auto 0;
    padding: 1.75rem 2rem;
    border-radius: 0.4rem;
    box-shadow: var(--shadow-lg);
}

.report-print-head {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--navy);
}

.report-society {
    color: var(--navy);
    font-size: 1.1rem;
    font-weight: 700;
}

.report-table th {
    white-space: nowrap;
}

.report-summary {
    max-width: 34rem;
}

.report-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--line);
}

.report-summary-row dt {
    margin: 0;
    color: var(--muted);
    font-weight: 400;
}

.report-summary-row dd {
    margin: 0;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.audit-table td {
    vertical-align: top;
}

.audit-json {
    max-height: 14rem;
    margin: 0;
    padding: 0.5rem 0.6rem;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ----- Sign-in and other guest pages ------------------------------------------------- */

.guest-body {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background:
        radial-gradient(60rem 30rem at 85% 110%, rgba(20, 162, 148, 0.35), transparent 60%),
        radial-gradient(40rem 24rem at 0% 0%, rgba(47, 69, 102, 0.9), transparent 70%),
        var(--navy);
}

.guest-card {
    width: 100%;
    max-width: 27rem;
    padding: 2rem 2rem 1.75rem;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.3);
}

.guest-card.guest-wide {
    max-width: 46rem;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--line);
}

.brand-mark .brand-logo {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    font-size: 0.95rem;
}

.brand-mark .brand-name {
    color: var(--navy);
    font-size: 1.15rem;
    font-weight: 700;
}

.brand-tagline {
    color: var(--muted);
    font-size: 0.82rem;
}

.guest-card h1 {
    margin-top: 0.25rem;
}

.guest-card .btn-primary {
    width: 100%;
    min-height: 2.6rem;
}

.guest-foot {
    margin-top: 1.25rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.78rem;
    text-align: center;
}

/* ----- Bill sheet (print layout) ----------------------------------------------------- */

.print-body {
    background: #e9edf2;
}

.print-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(233, 237, 242, 0.92);
    backdrop-filter: blur(4px);
}

.print-page {
    padding: 0 1rem 2rem;
}

.bill-sheet {
    max-width: 52rem;
    margin: 0.5rem auto 0;
    padding: 2rem 2.25rem;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    background: #fff;
    box-shadow: var(--shadow-lg);
}

.bill-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.9rem;
    border-bottom: 2px solid var(--navy);
}

.bill-society {
    margin: 0 0 0.2rem;
    color: var(--navy);
    font-size: 1.3rem;
    font-weight: 700;
}

.bill-title {
    text-align: right;
}

.bill-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.6rem 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 0.9rem;
}

.bill-meta .label {
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.bill-table {
    font-size: 0.9rem;
}

.bill-cancelled {
    display: inline-block;
    margin-bottom: 0.75rem;
    padding: 0.25rem 0.75rem;
    border: 2px solid var(--danger);
    color: var(--danger);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.bill-message {
    margin-top: 1rem;
    padding: 0.7rem 0.9rem;
    border-left: 3px solid var(--teal);
    border-radius: 0.3rem;
    background: var(--teal-soft);
    font-size: 0.9rem;
}

.bill-pay {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.bill-pay-details {
    display: grid;
    gap: 0.25rem;
}

.bill-logo {
    flex: 0 0 auto;
    max-width: 9rem;
    max-height: 4.5rem;
    object-fit: contain;
}

.bill-society-block {
    flex: 1 1 16rem;
    min-width: 0;
}

.bill-line-tax td {
    color: var(--muted);
}

.bill-qr-box {
    display: grid;
    justify-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    text-align: center;
}

.bill-qr-box svg,
.bill-qr-box .bill-qr {
    width: 8.5rem;
    height: 8.5rem;
}

@media (max-width: 575.98px) {
    .bill-sheet {
        padding: 1.25rem 1rem;
    }

    .bill-title {
        text-align: left;
    }
}

/* ----- Print ------------------------------------------------------------------------- */

@media print {
    @page {
        margin: 12mm;
    }

    .no-print,
    .print-toolbar,
    .app-header,
    .app-sidebar,
    .nav-backdrop,
    .skip-link,
    .alert-dismissible {
        display: none !important;
    }

    body,
    body.print-body {
        background: #fff;
        font-size: 10pt;
    }

    .app-main {
        max-width: none;
        padding: 0;
    }

    .card,
    .kpi {
        box-shadow: none;
    }

    .print-page {
        padding: 0;
    }

    .bill-sheet,
    .report-sheet,
    .print-page .report-sheet {
        max-width: none;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .bill-meta {
        background: none;
        padding: 0;
    }

    .table > thead > tr > th {
        background: none;
    }

    .report-table,
    .bill-table {
        font-size: 9.5pt;
    }

    a {
        color: inherit;
        text-decoration: none;
    }

    a[href]::after {
        content: none !important;
    }
}

/* ----- Journal entry lines --------------------------------------------------------------- */

.journal-lines {
    min-width: 40rem;
}

.journal-lines .col-account {
    width: 38%;
}

.journal-lines .col-amount {
    width: 14%;
}

@media (max-width: 575.98px) {
    .kpi-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .kpi {
        padding: 0.85rem 0.9rem;
    }

    .kpi-value {
        font-size: 1.25rem;
    }

    .kpi-small {
        font-size: 0.95rem;
    }
}
