:root {
    --primary: #7a1f1f;
    --primary-dark: #551414;
    --accent: #d98c1d;
    --bg: #f3f5f8;
    --surface: #ffffff;
    --text: #20242a;
    --muted: #667085;
    --border: #d9dee7;
    --success: #147a45;
    --danger: #b42318;
    --warning: #9a6700;
    --info: #175cd3;
    --secondary: #475467;
    --shadow: 0 5px 20px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar, .public-topbar {
    background: linear-gradient(110deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 14px clamp(16px, 4vw, 52px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 4px solid var(--accent);
}
.brand-wrap { display: flex; align-items: center; gap: 13px; }
.emblem {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #fff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 25px;
    box-shadow: inset 0 0 0 2px rgba(122,31,31,.18);
}
.brand-title { font-weight: 760; font-size: clamp(17px, 2.1vw, 24px); letter-spacing: .1px; }
.brand-subtitle { font-size: 13px; opacity: .9; }
.user-box { text-align: right; display: flex; flex-direction: column; }
.user-box span { font-weight: 700; }
.user-box small { opacity: .85; }

.main-nav {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 clamp(14px, 4vw, 52px);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: 0 2px 8px rgba(16,24,40,.04);
}
.main-nav a {
    display: block;
    padding: 12px 13px;
    color: #344054;
    font-size: 14px;
    font-weight: 650;
}
.main-nav a:hover { background: #f7f3ef; text-decoration: none; color: var(--primary); }
.main-nav .nav-right { margin-left: auto; }

.container, .public-container {
    width: min(1440px, calc(100% - 28px));
    margin: 24px auto 42px;
}
.public-container { width: min(980px, calc(100% - 28px)); }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 18px;
}
.page-header h1, .page-header h2 { margin: 0 0 4px; line-height: 1.2; }
.page-header p { margin: 0; color: var(--muted); }
h1 { font-size: 27px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.card-title { margin: 0 0 15px; font-size: 18px; }
.card-subtle { background: #fbfcfd; box-shadow: none; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2; }
.col-span-full { grid-column: 1 / -1; }

.kpi {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 5px solid var(--primary);
    border-radius: 10px;
    padding: 17px;
    box-shadow: 0 3px 12px rgba(16,24,40,.05);
}
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.kpi-value { font-size: 30px; line-height: 1.1; font-weight: 800; margin-top: 6px; }
.kpi-note { color: var(--muted); font-size: 12px; margin-top: 5px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 13px; font-weight: 700; color: #344054; }
.required::after { content: " *"; color: var(--danger); }
input, select, textarea {
    width: 100%;
    border: 1px solid #bfc7d4;
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 9px 10px;
    min-height: 40px;
    font: inherit;
}
textarea { min-height: 86px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(122,31,31,.12);
}
.help { color: var(--muted); font-size: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }
.inline-form { display: inline; }

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 9px 14px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
    min-height: 38px;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { color: #fff; background: var(--primary); }
.btn-secondary { color: #fff; background: var(--secondary); }
.btn-success { color: #fff; background: var(--success); }
.btn-danger { color: #fff; background: var(--danger); }
.btn-light { color: #344054; background: #fff; border-color: var(--border); }
.btn-outline { color: var(--primary); background: transparent; border-color: var(--primary); }
.btn-sm { padding: 6px 10px; min-height: 31px; font-size: 12px; }

.alert { border-radius: 8px; padding: 11px 14px; margin-bottom: 15px; border: 1px solid transparent; }
.alert-success { background: #ecfdf3; color: #05603a; border-color: #abefc6; }
.alert-danger { background: #fef3f2; color: #912018; border-color: #fecdca; }
.alert-warning { background: #fffaeb; color: #7a2e0e; border-color: #fedf89; }
.alert-info { background: #eff8ff; color: #1849a9; border-color: #b2ddff; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 9px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
th, td { padding: 10px 11px; border-bottom: 1px solid #e7eaf0; text-align: left; vertical-align: top; }
th { background: #f8f9fb; color: #344054; font-weight: 750; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fffaf4; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    line-height: 1.25;
    font-weight: 800;
    white-space: nowrap;
}
.badge-success { background: #dcfae6; color: #05603a; }
.badge-danger { background: #fee4e2; color: #912018; }
.badge-warning { background: #fef0c7; color: #7a2e0e; }
.badge-info { background: #d1e9ff; color: #1849a9; }
.badge-secondary { background: #eaecf0; color: #344054; }

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 13px; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

.detail-list { display: grid; grid-template-columns: 190px 1fr; gap: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.detail-list dt, .detail-list dd { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.detail-list dt { background: #f8f9fb; font-weight: 750; color: #475467; }
.detail-list dd { background: #fff; }
.detail-list dt:last-of-type, .detail-list dd:last-of-type { border-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 10px; top: 6px; bottom: 6px; width: 2px; background: #d0d5dd; }
.timeline li { position: relative; padding: 0 0 20px 34px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: 3px; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--primary); }
.timeline-title { font-weight: 780; }
.timeline-meta { color: var(--muted); font-size: 12px; margin: 2px 0 4px; }

.status-result {
    border-top: 5px solid var(--primary);
    padding: 24px;
}
.status-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 18px;
}
.status-hero h2 { margin: 0 0 5px; }
.status-message { background: #f9fafb; border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 4px; }
.public-page { background: linear-gradient(180deg, #f7eee6 0, var(--bg) 260px); }
.search-card { max-width: 760px; margin: 34px auto; }
.search-card h1 { margin: 0 0 6px; }

.checkbox-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 14px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.checkbox-label input { width: auto; min-height: 0; }

.bar-list { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(130px, 240px) 1fr 50px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { height: 10px; background: #eaecf0; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: inherit; }

.login-shell { min-height: calc(100vh - 170px); display: grid; place-items: center; }
.login-card { width: min(440px, 100%); }
.login-card h1 { margin-top: 0; }

.footer {
    padding: 18px clamp(16px, 4vw, 52px);
    background: #fff;
    color: var(--muted);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 15px;
    font-size: 12px;
}

hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f2f4f7; border-radius: 4px; padding: 2px 5px; }

@media (max-width: 1000px) {
    .grid-5, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .checkbox-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .topbar, .public-topbar { align-items: flex-start; }
    .user-box { display: none; }
    .main-nav { padding: 0 8px; }
    .main-nav a { padding: 10px 8px; font-size: 12px; }
    .main-nav .nav-right { margin-left: 0; }
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: auto; }
    .page-header, .status-hero, .footer { flex-direction: column; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list dt { border-bottom: 0; padding-bottom: 2px; }
    .detail-list dd { padding-top: 2px; }
    .checkbox-grid { grid-template-columns: 1fr; }
    .bar-row { grid-template-columns: 110px 1fr 38px; }
}

@media print {
    .topbar, .main-nav, .footer, .no-print, .alert, .btn { display: none !important; }
    body { background: #fff; font-size: 11px; }
    .container { width: 100%; margin: 0; }
    .card { box-shadow: none; border: 0; padding: 0; }
    table { font-size: 10px; }
    th, td { padding: 5px 6px; }
    @page { size: landscape; margin: 10mm; }
}

/* Role-specific Vasundhara work dashboard */
.work-grid { align-items: stretch; }
.work-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 165px;
}
.work-card-title { font-size: 16px; font-weight: 800; color: var(--primary); }
.work-card p { color: var(--muted); font-size: 13px; flex: 1; margin: 8px 0 15px; }
.work-card .btn { align-self: flex-start; }

/* Office-linked beneficiary status and executive reporting */
.office-search-card { max-width: 900px; }
.fixed-office-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 15px;
    margin: 14px 0;
    border: 1px solid #b2ddff;
    border-radius: 9px;
    background: #eff8ff;
}
.fixed-office-banner strong { display: block; margin-top: 3px; color: #1849a9; }
.report-builder { border-top: 4px solid var(--primary); }
.report-section-title { font-size: 16px; font-weight: 800; color: var(--primary); margin-bottom: 12px; }
.report-checkbox { min-height: 40px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.compact-header { margin-bottom: 12px; }
.report-output { border-top: 5px solid var(--primary); }
.report-masthead { text-align: center; margin-bottom: 18px; }
.report-masthead h2 { margin: 5px 0; font-size: 23px; }
.report-office-name { font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.report-subtitle { font-size: 14px; color: #475467; }
.report-generated { margin-top: 7px; font-size: 11px; color: var(--muted); }
.report-kpis { margin: 16px 0 20px; }
.mini-kpi { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: #f8f9fb; }
.mini-kpi span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.mini-kpi strong { display: block; margin-top: 4px; font-size: 20px; color: var(--primary); }
.report-table-wrap, .abstract-table-wrap { max-height: none; }
.report-table-wrap table, .abstract-table-wrap table { min-width: 760px; }
.abstract-metric-note { margin: 0 0 10px; padding: 9px 12px; border-radius: 7px; background: #f8f9fb; color: #475467; }
.matrix-table th:first-child { position: sticky; left: 0; z-index: 2; background: #f8f9fb; }
.matrix-table tfoot th { background: #f2f4f7; }
tfoot th, tfoot td { border-top: 2px solid #98a2b3; font-weight: 800; }
.signature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
    margin-top: 55px;
    text-align: center;
}
.signature-grid > div { border-top: 1px solid #344054; padding-top: 7px; min-height: 42px; }
.signature-grid span { display: block; font-size: 12px; color: var(--muted); }
.signature-grid strong { display: block; margin-top: 3px; }

@media (max-width: 720px) {
    .fixed-office-banner, .signature-grid { grid-template-columns: 1fr; flex-direction: column; align-items: flex-start; }
    .signature-grid { display: grid; gap: 45px; }
}

@media print {
    .report-masthead { margin-top: 0; }
    .report-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 6px; }
    .mini-kpi { padding: 6px; }
    .mini-kpi strong { font-size: 14px; }
    .signature-grid { page-break-inside: avoid; }
    .report-table-wrap, .abstract-table-wrap { overflow: visible; border: 0; }
}

/* Institutional Lease portal additions */
.btn-warning { color:#7a2e0e; background:#fef0c7; border-color:#fedf89; }
.detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1px; background:var(--border); border:1px solid var(--border); border-radius:9px; overflow:hidden; }
.detail-grid > div { background:#fff; padding:11px 12px; min-height:65px; }
.detail-grid span { display:block; color:var(--muted); font-size:12px; margin-bottom:4px; }
.detail-grid strong { display:block; font-weight:750; word-break:break-word; }
.note-box { background:#f8f9fb; border-left:4px solid var(--secondary); padding:12px 14px; border-radius:5px; line-height:1.55; }
.note-box.warning { background:#fffaeb; border-left-color:#f79009; }
.timeline article { position:relative; padding:0 0 20px 34px; }
.timeline article:last-child { padding-bottom:0; }
.tabs { display:flex; gap:8px; flex-wrap:wrap; margin:0 0 18px; }
.tabs a { background:#fff; color:#344054; border:1px solid var(--border); border-radius:7px; padding:9px 13px; font-weight:700; }
.tabs a.active { color:#fff; background:var(--primary); border-color:var(--primary); }
.check { display:flex; align-items:center; gap:8px; font-weight:600; }
.check input { width:auto; min-height:0; }
.check-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px 14px; }
code { white-space:pre-wrap; word-break:break-word; font-size:11px; }
@media (max-width:780px){.detail-grid{grid-template-columns:1fr}.check-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:520px){.check-grid{grid-template-columns:1fr}}
