/* Apni Society: base styles and components. Self-contained, with no CDN and no framework. The class names follow
   the common grid-and-utility convention (row, col-md-6, btn, form-control and so on), so the templates read
   familiarly, but every rule here is our own. app.css adds the application layout on top. */

:root {
    --navy: #16233a;
    --navy-2: #22344f;
    --navy-3: #2f4566;
    --teal: #0f766e;
    --teal-dark: #0b5d57;
    --teal-soft: #e3f4f1;
    --ink: #1c2533;
    --ink-2: #3a4657;
    --muted: #5e6b7b;
    --line: #e1e6ee;
    --line-strong: #c9d2de;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --page: #f2f5f9;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --warning: #9a4a07;
    --warning-soft: #fff4e0;
    --success: #12704a;
    --success-soft: #e4f5ec;
    --info: #1d5f8f;
    --info-soft: #e5f1fa;
    --focus: 0 0 0 3px rgba(15, 118, 110, 0.28);
    --radius: 0.65rem;
    --radius-sm: 0.45rem;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 0.6rem 1.6rem rgba(16, 24, 40, 0.12);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ----- Reset and type ---------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    margin: 0 0 0.5rem;
    color: var(--navy);
    font-weight: 650;
    line-height: 1.25;
}

h1, .h1 { font-size: 1.75rem; }
h2, .h2 { font-size: 1.45rem; }
h3, .h3 { font-size: 1.25rem; }
h4, .h4 { font-size: 1.3rem; letter-spacing: -0.01em; }
h5, .h5 { font-size: 1.1rem; }
h6, .h6 { font-size: 0.975rem; }

p {
    margin: 0 0 1rem;
}

ul, ol, dl {
    margin: 0 0 1rem;
}

dt {
    font-weight: 600;
}

dd {
    margin: 0 0 0.5rem;
}

a {
    color: var(--teal);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--teal-dark);
}

small, .small {
    font-size: 0.85em;
}

strong, b {
    font-weight: 650;
}

hr {
    margin: 1rem 0;
    border: 0;
    border-top: 1px solid var(--line);
}

code, pre {
    font-family: var(--mono);
    font-size: 0.875em;
}

img, svg {
    vertical-align: middle;
}

table {
    border-collapse: collapse;
}

th {
    text-align: inherit;
}

label {
    display: inline-block;
}

button, input, select, textarea {
    margin: 0;
    font: inherit;
    color: inherit;
}

button, select {
    text-transform: none;
}

button, [type="button"], [type="submit"], [type="reset"] {
    -webkit-appearance: button;
    appearance: button;
}

button:not(:disabled), [type="submit"]:not(:disabled), summary {
    cursor: pointer;
}

:focus-visible {
    outline: 0;
    box-shadow: var(--focus);
}

[hidden] {
    display: none !important;
}

/* ----- Layout: container and grid ----------------------------------------------- */

.container {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding-right: 1rem;
    padding-left: 1rem;
}

.row {
    --gx: 1.5rem;
    --gy: 0;
    display: flex;
    flex-wrap: wrap;
    margin-top: calc(-1 * var(--gy));
    margin-right: calc(-0.5 * var(--gx));
    margin-left: calc(-0.5 * var(--gx));
}

.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    margin-top: var(--gy);
    padding-right: calc(0.5 * var(--gx));
    padding-left: calc(0.5 * var(--gx));
}

.g-2 { --gx: 0.75rem; --gy: 0.75rem; }
.g-3 { --gx: 1rem; --gy: 1rem; }

.col { flex: 1 0 0; }
.col-3 { flex: 0 0 auto; width: 25%; }
.col-4 { flex: 0 0 auto; width: 33.3333%; }
.col-5 { flex: 0 0 auto; width: 41.6667%; }
.col-6 { flex: 0 0 auto; width: 50%; }
.col-7 { flex: 0 0 auto; width: 58.3333%; }
.col-8 { flex: 0 0 auto; width: 66.6667%; }
.col-9 { flex: 0 0 auto; width: 75%; }
.col-12 { flex: 0 0 auto; width: 100%; }

@media (min-width: 768px) {
    .col-md-1 { flex: 0 0 auto; width: 8.3333%; }
    .col-md-2 { flex: 0 0 auto; width: 16.6667%; }
    .col-md-3 { flex: 0 0 auto; width: 25%; }
    .col-md-4 { flex: 0 0 auto; width: 33.3333%; }
    .col-md-5 { flex: 0 0 auto; width: 41.6667%; }
    .col-md-6 { flex: 0 0 auto; width: 50%; }
    .col-md-8 { flex: 0 0 auto; width: 66.6667%; }
    .col-md-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 992px) {
    .col-lg-4 { flex: 0 0 auto; width: 33.3333%; }
    .col-lg-5 { flex: 0 0 auto; width: 41.6667%; }
    .col-lg-6 { flex: 0 0 auto; width: 50%; }
    .col-lg-7 { flex: 0 0 auto; width: 58.3333%; }
    .col-lg-8 { flex: 0 0 auto; width: 66.6667%; }
}

@media (min-width: 1200px) {
    .col-xl-4 { flex: 0 0 auto; width: 33.3333%; }
}

/* ----- Buttons ------------------------------------------------------------------ */

.btn {
    --btn-color: var(--ink);
    --btn-bg: var(--surface);
    --btn-border: var(--line-strong);
    --btn-hover-color: var(--ink);
    --btn-hover-bg: var(--surface-2);
    --btn-hover-border: var(--line-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-height: 2.375rem;
    padding: 0.4rem 0.95rem;
    border: 1px solid var(--btn-border);
    border-radius: var(--radius-sm);
    background: var(--btn-bg);
    color: var(--btn-color);
    font-size: 0.9rem;
    font-weight: 550;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
    border-color: var(--btn-hover-border);
    background: var(--btn-hover-bg);
    color: var(--btn-hover-color);
}

.btn.active {
    border-color: var(--teal);
    background: var(--teal-soft);
    color: var(--teal-dark);
    position: relative;
    z-index: 1;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    pointer-events: none;
}

.btn-primary {
    --btn-color: #fff;
    --btn-bg: var(--teal);
    --btn-border: var(--teal);
    --btn-hover-color: #fff;
    --btn-hover-bg: var(--teal-dark);
    --btn-hover-border: var(--teal-dark);
    box-shadow: 0 1px 2px rgba(15, 118, 110, 0.25);
}

.btn-danger {
    --btn-color: #fff;
    --btn-bg: var(--danger);
    --btn-border: var(--danger);
    --btn-hover-color: #fff;
    --btn-hover-bg: #912018;
    --btn-hover-border: #912018;
}

.btn-outline-primary {
    --btn-color: var(--teal);
    --btn-bg: var(--surface);
    --btn-border: #9fd3cb;
    --btn-hover-color: var(--teal-dark);
    --btn-hover-bg: var(--teal-soft);
    --btn-hover-border: var(--teal);
}

.btn-outline-secondary {
    --btn-color: var(--ink-2);
    --btn-bg: var(--surface);
    --btn-border: var(--line-strong);
    --btn-hover-color: var(--ink);
    --btn-hover-bg: var(--surface-2);
    --btn-hover-border: #aab6c5;
}

.btn-outline-danger {
    --btn-color: var(--danger);
    --btn-bg: var(--surface);
    --btn-border: #f0b4ae;
    --btn-hover-color: #fff;
    --btn-hover-bg: var(--danger);
    --btn-hover-border: var(--danger);
}

.btn-outline-light {
    --btn-color: #e8eef6;
    --btn-bg: transparent;
    --btn-border: rgba(255, 255, 255, 0.35);
    --btn-hover-color: #fff;
    --btn-hover-bg: rgba(255, 255, 255, 0.12);
    --btn-hover-border: rgba(255, 255, 255, 0.6);
}

.btn-sm,
.btn-group-sm > .btn {
    min-height: 1.95rem;
    padding: 0.25rem 0.7rem;
    font-size: 0.825rem;
    border-radius: 0.4rem;
}

.btn-group {
    display: inline-flex;
    vertical-align: middle;
}

.btn-group > .btn:not(:first-child) {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-group > .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-close {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    color: currentColor;
    opacity: 0.6;
}

.btn-close::before {
    content: "\00d7";
    font-size: 1.35rem;
    line-height: 1;
}

.btn-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

/* ----- Forms -------------------------------------------------------------------- */

.form-label {
    margin-bottom: 0.3rem;
    color: var(--ink-2);
    font-size: 0.85rem;
    font-weight: 550;
}

.form-label.small {
    font-size: 0.8rem;
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    min-height: 2.375rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.4;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-control::placeholder {
    color: #8a97a8;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--teal);
    outline: 0;
    box-shadow: var(--focus);
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: var(--surface-2);
    color: var(--muted);
}

textarea.form-control {
    min-height: 5rem;
    resize: vertical;
}

input[type="file"].form-control {
    padding: 0.3rem 0.4rem;
}

input[type="file"].form-control::file-selector-button {
    margin-right: 0.6rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.35rem;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}

.form-select {
    padding-right: 2rem;
    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='%235e6b7b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m3 6 5 5 5-5'/%3e%3c/svg%3e");
    background-position: right 0.6rem center;
    background-repeat: no-repeat;
    background-size: 0.8rem;
}

.form-control-sm,
.form-select-sm {
    min-height: 1.95rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    font-size: 0.825rem;
    border-radius: 0.4rem;
}

.form-control-sm {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
}

.form-select-sm {
    padding-left: 0.55rem;
}

.form-text {
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    min-height: 1.5rem;
}

.form-check-input {
    flex: 0 0 auto;
    width: 1.05rem;
    height: 1.05rem;
    margin-top: 0.2rem;
    accent-color: var(--teal);
}

.form-check-label {
    color: var(--ink-2);
}

.is-invalid,
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger);
}

.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.2);
}

.invalid-feedback {
    display: none;
    margin-top: 0.3rem;
    color: var(--danger);
    font-size: 0.8rem;
}

.invalid-feedback.d-block,
.is-invalid ~ .invalid-feedback {
    display: block;
}

/* ----- Cards -------------------------------------------------------------------- */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.card-body {
    flex: 1 1 auto;
    padding: 1.1rem 1.25rem;
    /* A wide table inside a card scrolls within the card on a phone, instead of widening the page. */
    overflow-x: auto;
}

a.card {
    text-decoration: none;
}

/* ----- Tables ------------------------------------------------------------------- */

.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--ink);
    vertical-align: top;
    font-variant-numeric: tabular-nums;
}

.table > :not(caption) > * > * {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--line);
    background-color: var(--cell-bg, transparent);
}

.table > thead > tr > th,
.table > thead > tr > td {
    background-color: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: bottom;
    border-bottom-color: var(--line-strong);
}

.table > tfoot > tr > th,
.table > tfoot > tr > td {
    border-top: 1px solid var(--line-strong);
    border-bottom: 0;
    font-weight: 650;
}

.table > tbody > tr:last-child > * {
    border-bottom-color: var(--line);
}

.card > .table > tbody > tr:last-child > *,
.card > .table-responsive > .table > tbody > tr:last-child > *,
.table-responsive.card > .table > tbody > tr:last-child > * {
    border-bottom: 0;
}

/* Links in tables are document numbers, flats and names: keep each on one line. */
.table td a {
    white-space: nowrap;
}

.table-sm > :not(caption) > * > * {
    padding: 0.35rem 0.55rem;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    --cell-bg: #fafbfd;
}

.table-hover > tbody > tr:hover > * {
    --cell-bg: #f3f7fb;
}

.table-secondary > *,
tr.table-secondary > * {
    --cell-bg: #f2f4f7;
    color: var(--muted);
}

.table-warning > *,
tr.table-warning > * {
    --cell-bg: var(--warning-soft);
}

.table-danger > *,
tr.table-danger > * {
    --cell-bg: var(--danger-soft);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive.card {
    display: block;
    overflow-x: auto;
}

.table-responsive.card > .table > thead > tr:first-child > th:first-child {
    border-top-left-radius: var(--radius);
}

.table-responsive.card > .table > thead > tr:first-child > th:last-child {
    border-top-right-radius: var(--radius);
}

.align-middle,
.table.align-middle > :not(caption) > * > * {
    vertical-align: middle;
}

/* ----- Badges and alerts -------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: 0.01em;
    white-space: nowrap;
    vertical-align: 0.08em;
    box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.08);
}

.text-bg-primary { background-color: var(--teal-soft) !important; color: var(--teal-dark) !important; }
.text-bg-secondary { background-color: #e9edf2 !important; color: #4a5767 !important; }
.text-bg-success { background-color: var(--success-soft) !important; color: var(--success) !important; }
.text-bg-warning { background-color: var(--warning-soft) !important; color: var(--warning) !important; }
.text-bg-danger { background-color: var(--danger-soft) !important; color: var(--danger) !important; }
.text-bg-light { background-color: #eef2f6 !important; color: var(--ink-2) !important; }

.alert {
    position: relative;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.alert-dismissible {
    padding-right: 3rem;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0.45rem;
    right: 0.5rem;
}

.alert-success { border-color: #b7e2cb; border-left-color: var(--success); background: var(--success-soft); color: #0d5236; }
.alert-info { border-color: #bcd9ee; border-left-color: var(--info); background: var(--info-soft); color: #164a70; }
.alert-warning { border-color: #f6d6a4; border-left-color: #d97706; background: var(--warning-soft); color: #7a3a05; }
.alert-danger { border-color: #f4c1bb; border-left-color: var(--danger); background: var(--danger-soft); color: #8a1b12; }
.alert-secondary { border-color: var(--line); border-left-color: #8a97a8; background: var(--surface-2); color: var(--ink-2); }

.alert > :last-child {
    margin-bottom: 0;
}

/* ----- Navigation pieces ---------------------------------------------------------- */

.nav {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-link {
    display: block;
    padding: 0.5rem 0.9rem;
    color: var(--ink-2);
    text-decoration: none;
}

.nav-tabs {
    gap: 0.25rem;
    border-bottom: 1px solid var(--line-strong);
}

.nav-tabs .nav-link {
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-weight: 550;
}

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

.nav-tabs .nav-link.active {
    border-color: var(--line-strong) var(--line-strong) var(--surface);
    background: var(--surface);
    color: var(--teal);
    box-shadow: inset 0 2px 0 var(--teal);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    margin: 0 0 0.25rem;
    padding: 0;
    list-style: none;
    color: var(--muted);
    font-size: 0.78rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    padding: 0 0.45rem;
    color: #a3afbd;
}

.breadcrumb-item a {
    color: var(--muted);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--teal);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--ink-2);
}

/* ----- Utilities ------------------------------------------------------------------ */

.d-none { display: none !important; }
.d-inline { display: inline !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-inline { display: inline !important; }
    .d-md-block { display: block !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
}

.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.align-self-end { align-self: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }

.m-0 { margin: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-auto { margin-top: auto !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.p-2 { padding: 0.5rem !important; }
.py-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
.ps-3 { padding-left: 1rem !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.text-start { text-align: left !important; }
.text-end { text-align: right !important; }
.text-nowrap { white-space: nowrap !important; }
.text-muted { color: var(--muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-success { color: var(--success) !important; }
.text-decoration-none { text-decoration: none !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

.list-unstyled { padding-left: 0; list-style: none; }
.rounded { border-radius: var(--radius-sm) !important; }
.border { border: 1px solid var(--line) !important; }
.border-bottom { border-bottom: 1px solid var(--line) !important; }
.bg-light { background-color: var(--surface-2) !important; }

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* The "fade show" pair on dismissible alerts. */
.fade { transition: opacity 0.15s linear; }
.fade:not(.show) { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
    }
}
