:root {
    --green: #0B7A53;
    --green-dark: #075C40;
    --mint: #EAF8F1;
    --bg: #F7FAF8;
    --solar: #F4B942;
    --text: #10231B;
    --muted: #6B7C74;
    --border: #E2EAE5;
    --white: #fff;
    --shadow: 0 10px 28px rgba(16, 35, 27, 0.07);
    --radius: 18px;
    --font: "Noto Sans Devanagari", "Noto Sans", sans-serif;
    --sidebar: 260px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
}
img { max-width: 100%; display: block; }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
h1, h2, h3, p, ul, ol, dl { margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
:focus-visible { outline: 3px solid var(--solar); outline-offset: 2px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0,0,0,0);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 0.65rem 1.15rem; border-radius: 999px;
    border: 1.5px solid transparent; font: inherit; font-weight: 600; cursor: pointer;
}
.btn-sm { min-height: 38px; padding: 0.4rem 0.9rem; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); color: #fff; }
.btn-outline { background: #fff; color: var(--green-dark); border-color: var(--green); }
.btn[disabled] { opacity: 0.7; pointer-events: none; }

.alert { padding: 0.85rem 1rem; border-radius: 12px; margin-bottom: 1rem; }
.alert-success { background: var(--mint); color: var(--green-dark); }
.alert-error { background: #fde8e8; color: #8a1f1f; }
.alert-warning { background: #fff6dd; color: #7a5a00; }
.field-error { color: #8a1f1f; display: block; margin-top: 0.3rem; }
label.has-error input, .upload-field.has-error { border-color: #d46a6a; }
.upload-field.is-ready { border-color: var(--green); background: #f3fbf6; }
.upload-field.has-error { background: #fff7f7; }
.file-name.is-ready { color: var(--green-dark); font-weight: 600; }
.muted { color: var(--muted); }
.debug-mail { background: #fff8e1; padding: 0.8rem; border-radius: 10px; word-break: break-all; }

.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 90% 0, rgba(244,185,66,.18), transparent 28%),
        linear-gradient(#fff, var(--bg));
    display: grid; place-items: center; padding: 1.5rem;
}
.auth-wrap { width: min(440px, 100%); }
.auth-logo { display: flex; justify-content: center; margin-bottom: 1.2rem; }
.auth-logo img { height: 62px; width: auto; max-width: min(280px, 86vw); object-fit: contain; }
.auth-card {
    background: #fff; border: 1px solid var(--border); border-radius: 24px;
    padding: 1.6rem; box-shadow: var(--shadow);
}
.auth-card h1 { margin-bottom: 0.4rem; }
.auth-card form, .stack-form { display: grid; gap: 0.9rem; margin-top: 1rem; }
.verify-actions {
    display: grid;
    gap: 0.85rem;
    margin-top: 1.25rem;
}
.verify-actions form { margin-top: 0; }
.verify-actions .btn-primary { width: 100%; }
.verify-logout {
    justify-self: center;
    min-width: 128px;
    padding-inline: 1.35rem;
}
.auth-card label, .stack-form label, .form-grid label, .upload-field {
    display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.92rem;
}
input, select, textarea {
    width: 100%; border: 1px solid var(--border); border-radius: 12px;
    padding: 0.7rem 0.8rem; font: inherit; background: #fff;
}
.form-row { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.phone-field { display: grid; gap: 0.35rem; }
.phone-field-label { font-weight: 600; font-size: 0.92rem; }
.phone-row {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    min-width: 0;
}
.phone-row select {
    width: auto;
    min-width: 9.2rem;
    max-width: 46%;
    flex: 0 1 11rem;
}
.phone-row input[data-phone-national] {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
}
.auth-card label.check,
.stack-form label.check,
.form-grid label.check,
label.check {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    width: auto;
    max-width: 100%;
    margin: 0;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.2;
}
.form-row label.check { flex-wrap: nowrap; white-space: nowrap; }
label.check span { font-weight: 500; }
.auth-card label.check input[type="checkbox"],
.stack-form label.check input[type="checkbox"],
.form-grid label.check input[type="checkbox"],
label.check input[type="checkbox"] {
    appearance: auto;
    -webkit-appearance: checkbox;
    width: 1.05rem;
    height: 1.05rem;
    min-width: 1.05rem;
    max-width: 1.05rem;
    margin: 0;
    padding: 0;
    border-radius: 3px;
    flex-shrink: 0;
    accent-color: var(--green);
    background: none;
    box-shadow: none;
    cursor: pointer;
}
label.check:hover { color: var(--green-dark); }
label.check input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--solar);
    outline-offset: 2px;
}
.auth-links { text-align: center; margin-top: 1rem; color: var(--muted); }

.portal-body { min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
    background: #fff; border-right: 1px solid var(--border);
    padding: 1.2rem; display: flex; flex-direction: column; z-index: 40;
}
.sidebar-logo img { height: 44px; width: auto; margin-bottom: 1.4rem; }
.sidebar nav ul { list-style: none; padding: 0; display: grid; gap: 0.25rem; }
.sidebar nav a {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.7rem 0.85rem; border-radius: 12px; color: var(--text); font-weight: 600;
}
.nav-ico {
    width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.28; flex-shrink: 0;
}
.sidebar nav a.is-active .nav-ico { opacity: 1; background: var(--green); }
.sidebar nav a.is-active, .sidebar nav a:hover { background: var(--mint); color: var(--green-dark); }
.sidebar-logout { margin-top: auto; color: #8a1f1f; font-weight: 600; padding: 0.7rem; }

.portal-main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 30; background: rgba(247,250,248,.94);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem 1.4rem;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 0.7rem; }
.lang-switch a { color: var(--muted); font-weight: 600; }
.lang-switch a.is-active { color: var(--green-dark); }
.icon-btn { border: 0; background: none; color: var(--muted); }
.user-menu { position: relative; }
.user-chip {
    display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--border);
    background: #fff; border-radius: 999px; padding: 0.2rem 0.7rem 0.2rem 0.2rem; cursor: pointer; font: inherit;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--green);
    color: #fff; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700;
}
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 6px); background: #fff;
    border: 1px solid var(--border); border-radius: 12px; min-width: 160px;
    box-shadow: var(--shadow); padding: 0.4rem;
}
.user-dropdown a { display: block; padding: 0.55rem 0.7rem; border-radius: 8px; color: var(--text); }
.menu-toggle {
    display: none; width: 42px; height: 42px; border: 1px solid var(--border);
    background: #fff; border-radius: 10px; flex-direction: column; justify-content: center; gap: 5px; padding: 9px;
}
.menu-toggle span { display: block; height: 2px; background: var(--text); }
.nav-overlay { position: fixed; inset: 0; background: rgba(16,35,27,.35); z-index: 35; }

.portal-content { padding: 1.4rem; width: min(1120px, 100%); overflow-x: hidden; }
.page-toolbar { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.welcome { font-size: 1.25rem; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.stat-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem; min-height: 110px; display: flex; flex-direction: column; justify-content: space-between;
    box-shadow: var(--shadow);
}
.stat-card span { color: var(--muted); font-weight: 600; }
.stat-card strong { font-size: 1.8rem; }
.accent-green { border-top: 4px solid var(--green); }
.accent-teal { border-top: 4px solid #1a9a86; }
.accent-amber { border-top: 4px solid #d99012; }
.accent-solar { border-top: 4px solid var(--solar); }

.brand-banner {
    background: linear-gradient(135deg, var(--green-dark), var(--green));
    color: #fff; border-radius: 20px; padding: 1.3rem 1.5rem; margin-bottom: 1.2rem;
}
.brand-banner p { color: #d9f3e6; margin-top: 0.35rem; }

.panel {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.2rem; margin-bottom: 1.2rem; box-shadow: 0 6px 18px rgba(16,35,27,.04);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.data-table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.data-table th, .data-table td { text-align: left; padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.mobile-cards { display: none; }
.ref-card { border: 1px solid var(--border); border-radius: 14px; padding: 0.9rem; margin-bottom: 0.7rem; }
.ref-card-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.empty-state { text-align: center; padding: 2rem 1rem; display: grid; gap: 0.6rem; justify-items: center; }

.status-badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge-amber { background: #fff4d6; color: #8a5a00; }
.badge-blue { background: #e6f1ff; color: #1d4f91; }
.badge-green { background: var(--mint); color: var(--green-dark); }
.badge-purple { background: #f1e8ff; color: #5b2d91; }
.badge-teal { background: #e5f7f4; color: #0f6b62; }
.badge-solid-green { background: var(--green); color: #fff; }
.badge-muted { background: #eef1ef; color: var(--muted); }
.status-xl .status-badge { font-size: 1rem; padding: 0.4rem 0.9rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.filters input, .filters select { max-width: 280px; }
.pager { display: flex; gap: 0.35rem; margin-top: 1rem; }
.pager a { padding: 0.35rem 0.7rem; border-radius: 8px; border: 1px solid var(--border); color: var(--text); }
.pager a.is-active { background: var(--green); color: #fff; border-color: var(--green); }

.form-grid, .upload-grid, .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.upload-field { border: 1px dashed var(--border); border-radius: 14px; padding: 0.9rem; background: var(--bg); }
.meta-list { display: grid; gap: 0.7rem; margin-top: 0.8rem; }
.meta-list div { display: grid; gap: 0.15rem; }
.meta-list dt { color: var(--muted); font-size: 0.85rem; }
.status-timeline { list-style: none; padding: 0; display: grid; gap: 0.7rem; margin-top: 0.8rem; }
.status-timeline li { padding-left: 1.2rem; border-left: 3px solid var(--border); }
.status-timeline .is-done { border-color: var(--green); }
.status-timeline .is-current { border-color: var(--solar); }
.status-timeline span { color: var(--muted); font-size: 0.85rem; display: block; }
.doc-list { list-style: none; padding: 0; display: grid; gap: 0.6rem; }
.doc-list li { display: flex; gap: 0.7rem; align-items: center; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 0.55rem; }
.pill { background: var(--mint); color: var(--green-dark); border-radius: 999px; padding: 0.15rem 0.55rem; font-size: 0.78rem; font-weight: 700; }
.profile-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; margin-top: 0.4rem; }

body.nav-open { overflow: hidden; }

@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .form-grid, .upload-grid, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-110%); transition: transform .2s ease; }
    .sidebar.is-open { transform: none; }
    .portal-main { margin-left: 0; }
    .menu-toggle { display: flex; }
    .user-name { display: none; }
    .toolbar-cta { width: 100%; }
    .page-toolbar { flex-direction: column; }
    .desktop-table { display: none; }
    .mobile-cards { display: block; }
}

@media (max-width: 414px) {
    .stat-grid { grid-template-columns: 1fr; }
    .portal-content { padding: 1rem; }
    .filters input, .filters select { max-width: none; width: 100%; }
    .btn { width: 100%; }
    .topbar .btn { width: auto; }
    .verify-logout { width: auto; }
    .phone-row select { min-width: 7.25rem; max-width: 44%; flex-basis: 7.5rem; }
    .auth-logo img { height: 52px; }
}
