/* ==========================================================
   Unnati Society – admin & member theme (on Bootstrap 5.3)
   Brand colours come from the society logo: yellow, red, black.
   ========================================================== */
:root {
    --brand-red: #b91c1c;
    --brand-red-hover: #991b1b;
    --brand-red-soft: #fef2f2;
    --brand-yellow: #facc15;
    --brand-yellow-soft: #fefce8;
    --ink: #1c1917;
    --ink-2: #44403c;
    --muted: #78716c;
    --line: #e7e5e4;
    --page: #f6f5f2;
    --card: #ffffff;
    --sidebar: #1c1917;
    --sidebar-text: #d6d3d1;
    --sidebar-muted: #8a837e;
    --sidebar-hover: #292524;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(28, 25, 23, .04), 0 1px 3px rgba(28, 25, 23, .06);

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-bg: var(--page);
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-primary: var(--brand-red);
    --bs-primary-rgb: 185, 28, 28;
    --bs-link-color: var(--brand-red);
    --bs-link-color-rgb: 185, 28, 28;
    --bs-link-hover-color: var(--brand-red-hover);
    --bs-link-hover-color-rgb: 153, 27, 27;
    --bs-border-radius: 8px;
    --bs-secondary-color: var(--muted);
}

body { background: var(--page); font-size: .925rem; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6 { color: var(--ink); letter-spacing: -.01em; }
.text-muted { color: var(--muted) !important; }
.tabular, .table td.num, .table th.num, .stat-value { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: 8px; }
.btn-primary {
    --bs-btn-bg: var(--brand-red); --bs-btn-border-color: var(--brand-red);
    --bs-btn-hover-bg: var(--brand-red-hover); --bs-btn-hover-border-color: var(--brand-red-hover);
    --bs-btn-active-bg: #7f1d1d; --bs-btn-active-border-color: #7f1d1d;
    --bs-btn-disabled-bg: var(--brand-red); --bs-btn-disabled-border-color: var(--brand-red);
    --bs-btn-focus-shadow-rgb: 185, 28, 28;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-red); --bs-btn-border-color: #e9b4b4;
    --bs-btn-hover-bg: var(--brand-red); --bs-btn-hover-border-color: var(--brand-red); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brand-red-hover); --bs-btn-active-border-color: var(--brand-red-hover);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--line); --bs-btn-hover-bg: #f5f5f4; --bs-btn-hover-border-color: #d6d3d1; }
.btn-icon { border: 0; background: transparent; padding: .25rem .5rem; color: var(--ink); }
.btn-icon:hover { background: #f0efed; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #e29a9a; box-shadow: 0 0 0 .2rem rgba(185, 28, 28, .12);
}
.form-check-input:checked { background-color: var(--brand-red); border-color: var(--brand-red); }
.form-label { font-weight: 500; color: var(--ink-2); margin-bottom: .3rem; font-size: .85rem; }
.form-text { color: var(--muted); }

/* ---------- App shell ---------- */
.app-sidebar {
    background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .app-sidebar {
        position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 1030;
        visibility: visible !important; transform: none !important;
        background-color: var(--sidebar) !important;
    }
    .app-body { margin-left: 252px; }
}
@media (max-width: 991.98px) {
    .app-sidebar { --bs-offcanvas-width: 272px; --bs-offcanvas-bg: var(--sidebar); }
}
.sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid #2f2a27;
}
.sidebar-brand img { border-radius: 8px; background: var(--brand-yellow); object-fit: contain; }
.brand-title { color: #fff; font-weight: 700; font-size: 1rem; line-height: 1.15; }
.brand-sub { color: var(--brand-yellow); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.sidebar-nav { padding: .5rem .65rem 1rem; overflow-y: auto; flex: 1; }
.nav-section {
    color: var(--sidebar-muted); font-size: .68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .09em; padding: 1rem .65rem .35rem;
}
.nav-item-link {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; margin: 1px 0;
    color: var(--sidebar-text); text-decoration: none; border-radius: 8px; font-weight: 500; position: relative;
}
.nav-item-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; color: var(--sidebar-muted); }
.nav-item-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item-link:hover i { color: #fff; }
.nav-item-link.active { background: #2b2522; color: #fff; }
.nav-item-link.active::before {
    content: ""; position: absolute; left: -.65rem; top: .45rem; bottom: .45rem; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--brand-yellow);
}
.nav-item-link.active i { color: var(--brand-yellow); }
.nav-badge {
    margin-left: auto; background: var(--brand-red); color: #fff; font-size: .7rem; font-weight: 700;
    min-width: 1.35rem; height: 1.35rem; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 .35rem;
}
button.nav-item-link { font: inherit; cursor: pointer; }
.sidebar-foot { padding: .6rem .65rem 1rem; border-top: 1px solid #2f2a27; }

.app-body { min-height: 100vh; display: flex; flex-direction: column; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.5rem; background: rgba(246, 245, 242, .92); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 1.25rem; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 0; color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line); background: #fff; padding: .25rem .6rem .25rem .3rem; border-radius: 999px; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--brand-yellow); color: var(--ink);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.app-main { padding: 1.5rem; flex: 1; width: 100%; max-width: 1440px; }
.app-footer {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
    padding: 1rem 1.5rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line);
}
.app-footer a { color: var(--brand-red); font-weight: 600; text-decoration: none; }
@media (max-width: 575.98px) {
    .app-main { padding: 1rem; }
    .app-topbar { padding: .7rem 1rem; }
    .topbar-actions .btn-label { display: none; }
}

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
.card-header {
    background: transparent; border-bottom: 1px solid var(--line); padding: .9rem 1.1rem;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
}
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-title { font-size: .98rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-title i { color: var(--brand-red); }
.card-body { padding: 1.1rem; }
.card-footer { background: #fafaf9; border-top: 1px solid var(--line); }
.section-gap { margin-bottom: 1.25rem; }

/* ---------- Stat tiles ---------- */
.stat-tile {
    display: flex; gap: .9rem; align-items: flex-start; height: 100%;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1rem 1.1rem; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s;
}
a.stat-tile:hover { border-color: #d6d3d1; transform: translateY(-1px); color: inherit; }
.stat-icon {
    width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
    background: #f5f5f4; color: var(--ink-2);
}
.tone-primary .stat-icon { background: var(--brand-red-soft); color: var(--brand-red); }
.tone-success .stat-icon { background: #ecfdf5; color: #047857; }
.tone-danger  .stat-icon { background: #fef2f2; color: #b91c1c; }
.tone-warning .stat-icon { background: var(--brand-yellow-soft); color: #a16207; }
.tone-info    .stat-icon { background: #eff6ff; color: #1d4ed8; }
.stat-body { min-width: 0; }
.stat-label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.25; color: var(--ink); }
.stat-sub { font-size: .8rem; color: var(--muted); margin-top: .1rem; }

@media (max-width: 575.98px) {
    .stat-tile { flex-direction: column; gap: .5rem; padding: .85rem; }
    .stat-icon { width: 34px; height: 34px; font-size: 1rem; }
    .stat-value { font-size: 1.15rem; overflow-wrap: anywhere; }
    .stat-label { font-size: .68rem; }
}

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .65rem .8rem; border-bottom-color: #efedeb; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
    font-weight: 600; background: #fafaf9; white-space: nowrap; border-bottom: 1px solid var(--line);
}
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #fafaf9; }
.table tfoot td { font-weight: 700; background: #fafaf9; }
.table .row-active > * { background: var(--brand-yellow-soft) !important; }
.table-card { overflow: hidden; }
.cell-sub { font-size: .78rem; color: var(--muted); }
.unit-chip {
    display: inline-block; font-weight: 600; background: #f5f5f4; border: 1px solid var(--line);
    border-radius: 6px; padding: .05rem .45rem; font-size: .82rem; white-space: nowrap;
}

/* ---------- Badges ---------- */
.badge { font-weight: 600; border-radius: 6px; padding: .35em .6em; }
.badge-soft-success   { background: #ecfdf5; color: #047857; }
.badge-soft-danger    { background: #fef2f2; color: #b91c1c; }
.badge-soft-warning   { background: #fefce8; color: #a16207; }
.badge-soft-orange    { background: #fff7ed; color: #c2410c; }
.badge-soft-info      { background: #eff6ff; color: #1d4ed8; }
.badge-soft-secondary { background: #f5f5f4; color: #57534e; }

/* ---------- Filters bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filter-bar > div { min-width: 140px; flex: 1 1 140px; }
.filter-bar > .filter-actions { flex: 0 0 auto; min-width: 0; display: flex; gap: .4rem; }
.filter-bar .form-label { font-size: .75rem; margin-bottom: .2rem; }

/* ---------- Notice / misc ---------- */
.notice-card { border-left: 4px solid var(--brand-yellow); background: var(--brand-yellow-soft); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); }
.empty-state i { font-size: 2rem; color: #c8c3be; display: block; margin-bottom: .5rem; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: .45rem .75rem; font-size: .9rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.mini-stat { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; background: #fafaf9; }
.mini-stat .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.mini-stat .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.pagination { --bs-pagination-active-bg: var(--brand-red); --bs-pagination-active-border-color: var(--brand-red); --bs-pagination-color: var(--ink-2); }
.nav-tabs .nav-link.active { color: var(--brand-red); font-weight: 600; }
.nav-tabs .nav-link { color: var(--ink-2); }
.progress { --bs-progress-bar-bg: #047857; background: #efedeb; height: 8px; }

/* ---------- Bar chart (CSS only) ---------- */
.bar-chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .75rem; align-items: end; height: 190px; padding-top: .5rem; }
.bar-group { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: .35rem; min-width: 0; }
.bar-pair { display: flex; align-items: flex-end; gap: 2px; height: 100%; width: 100%; justify-content: center; }
.bar { width: min(22px, 40%); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.in  { background: #047857; }
.bar.out { background: #e7a23b; }
.bar-label { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--ink-2); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }

/* ---------- Ticket conversation ---------- */
.chat { display: flex; flex-direction: column; gap: .75rem; }
.bubble { max-width: 85%; padding: .65rem .85rem; border-radius: 12px; font-size: .9rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.bubble-meta { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.from-admin { align-self: flex-end; text-align: left; }
.from-admin .bubble { background: #fff3f3; border: 1px solid #f6d5d5; border-bottom-right-radius: 4px; }
.from-member { align-self: flex-start; }
.from-member .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.from-admin .bubble-meta { text-align: right; }

/* ---------- Auth pages ---------- */
.auth-page {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(250, 204, 21, .25), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(185, 28, 28, .14), transparent 60%),
        var(--page);
}
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(28, 25, 23, .08); padding: 2rem; }
.auth-logo { width: 72px; height: 72px; border-radius: 14px; background: var(--brand-yellow); object-fit: contain; display: block; margin: 0 auto 1rem; }
.auth-card h1 { font-size: 1.35rem; font-weight: 700; text-align: center; margin-bottom: .25rem; }
.auth-card .lead-sub { text-align: center; color: var(--muted); font-size: .88rem; margin-bottom: 1.5rem; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > .form-control { padding-left: 2.3rem; }
.input-icon > .toggle-pass { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); }
.input-icon > .form-control.has-toggle { padding-right: 2.6rem; }
.role-switch .btn-check:checked + .btn { background: var(--ink); border-color: var(--ink); color: #fff; }
.role-switch .btn { border-color: var(--line); background: #fff; color: var(--ink-2); }

/* ---------- Member portal ---------- */
.member-nav { background: #fff; border-bottom: 1px solid var(--line); }
.member-nav .navbar-brand img { width: 34px; height: 34px; border-radius: 8px; background: var(--brand-yellow); object-fit: contain; }
.member-nav .nav-link { color: var(--ink-2); font-weight: 500; border-radius: 8px; padding: .45rem .8rem !important; }
.member-nav .nav-link.active, .member-nav .nav-link:hover { color: var(--brand-red); background: var(--brand-red-soft); }
.member-main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.hero-due { border-radius: 16px; padding: 1.4rem; color: #fff; background: linear-gradient(135deg, #1c1917, #3a2f2a); position: relative; overflow: hidden; }
.hero-due::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(250, 204, 21, .18); }
.hero-due .amt { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-due .lbl { color: #d6d3d1; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.hero-due.is-clear { background: linear-gradient(135deg, #065f46, #047857); }
.quick-link { display: flex; align-items: center; gap: .85rem; padding: 1rem; height: 100%; text-decoration: none; color: inherit; }
.quick-link:hover { color: inherit; }
.quick-link .qi { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }

@media print {
    .app-sidebar, .app-topbar .topbar-actions, .app-footer, .no-print, .member-nav { display: none !important; }
    .app-body { margin: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}
