:root {
    color-scheme: light;
    --background: #f4f6f4;
    --surface: #ffffff;
    --surface-muted: #edf2ee;
    --text: #1e2b24;
    --text-muted: #657168;
    --border: #dde5df;
    --brand: #214f39;
    --brand-dark: #173927;
    --brand-soft: #dfeee5;
    --ok: #197344;
    --ok-soft: #e2f5e9;
    --error: #9d2a2a;
    --error-soft: #fbe4e4;
    --warning: #8a6417;
    --warning-soft: #fff1cc;
    --shadow: 0 18px 55px rgba(31, 44, 37, 0.09);
}

* { box-sizing: border-box; }

html {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--background);
    color: var(--text);
}

body {
    margin: 0;
    min-height: 100vh;
}

a { color: inherit; }

h1, h2, h3, p { margin-top: 0; }

h1 {
    margin-bottom: 10px;
    font-size: clamp(1.8rem, 4vw, 2.7rem);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

h2 { letter-spacing: -0.025em; }

p {
    color: var(--text-muted);
    line-height: 1.65;
}

.eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--brand);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.topbar {
    min-height: 76px;
    padding: 0 max(24px, calc((100vw - 1180px) / 2));
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.94);
    display: flex;
    align-items: center;
    gap: 34px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand__mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--brand);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 900;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: .7rem;
}

.topbar__nav {
    display: flex;
    gap: 6px;
}

.topbar__nav a {
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--text-muted);
    font-size: .9rem;
    text-decoration: none;
}

.topbar__nav a:hover,
.topbar__nav a.active {
    background: var(--surface-muted);
    color: var(--text);
}

.user-menu {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .88rem;
}

.user-menu form { margin: 0; }

.app-shell {
    width: min(1180px, calc(100% - 40px));
    min-height: calc(100vh - 140px);
    margin: 0 auto;
    padding: 48px 0 64px;
}

.login-shell {
    width: min(460px, calc(100% - 36px));
    min-height: calc(100vh - 70px);
    margin: 0 auto;
    padding: 9vh 0 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-card {
    padding: clamp(28px, 6vw, 44px);
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-card__heading {
    margin-bottom: 28px;
}

.form-stack {
    display: grid;
    gap: 18px;
}

.form-stack label span {
    display: block;
    margin-bottom: 7px;
    font-size: .85rem;
    font-weight: 700;
}

input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #cfd8d1;
    border-radius: 10px;
    background: white;
    color: var(--text);
    font: inherit;
}

input:focus {
    outline: 3px solid var(--brand-soft);
    border-color: var(--brand);
}

.button {
    min-height: 38px;
    padding: 9px 14px;
    border: 0;
    border-radius: 9px;
    font: inherit;
    font-size: .86rem;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.button--primary {
    background: var(--brand);
    color: white;
}

.button--primary:hover { background: var(--brand-dark); }

.button--secondary {
    background: var(--surface-muted);
    color: var(--brand);
}

.button--ghost {
    background: transparent;
    color: var(--text-muted);
}

.button--wide { width: 100%; }

.flash {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 10px;
    font-size: .88rem;
}

.flash--error {
    color: var(--error);
    background: var(--error-soft);
}

.flash--warning {
    color: var(--warning);
    background: var(--warning-soft);
}

.flash--success {
    color: var(--ok);
    background: var(--ok-soft);
}

.page-heading {
    margin-bottom: 30px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.page-heading p {
    max-width: 720px;
    margin-bottom: 0;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.module-card {
    min-height: 245px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.module-card--disabled {
    background: rgba(255,255,255,.62);
}

.module-card__icon {
    min-width: 42px;
    height: 42px;
    margin-bottom: 22px;
    padding: 0 10px;
    border-radius: 11px;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-grid;
    place-items: center;
    font-size: .78rem;
    font-weight: 900;
}

.module-card h2 {
    margin-bottom: 8px;
    font-size: 1.15rem;
}

.module-card p {
    flex-grow: 1;
    margin-bottom: 20px;
    font-size: .9rem;
}

.badge {
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 800;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.status-card {
    min-height: 120px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface);
    display: flex;
    gap: 15px;
}

.status-card h2 {
    margin-bottom: 7px;
    font-size: 1rem;
}

.status-card p {
    margin-bottom: 0;
    font-size: .86rem;
}

.status-card__icon {
    flex: 0 0 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 900;
}

.status-card--ok .status-card__icon {
    color: var(--ok);
    background: var(--ok-soft);
}

.status-card--error .status-card__icon {
    color: var(--error);
    background: var(--error-soft);
}

.status-card--pending .status-card__icon {
    color: var(--warning);
    background: var(--warning-soft);
}

.site-footer {
    min-height: 64px;
    padding: 20px max(24px, calc((100vw - 1180px) / 2));
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: .76rem;
    display: flex;
    justify-content: space-between;
}

@media (max-width: 850px) {
    .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar__nav { display: none; }
}

@media (max-width: 620px) {
    .topbar { padding: 12px 18px; }
    .brand small, .user-menu > span { display: none; }
    .app-shell { width: min(100% - 28px, 1180px); padding-top: 30px; }
    .module-grid, .status-grid { grid-template-columns: 1fr; }
    .module-card { min-height: 220px; }
}
select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #cfd8d1;
    border-radius: 10px;
    background: white;
    color: var(--text);
    font: inherit;
}

.panel {
    margin-bottom: 24px;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
}

.panel--narrow { max-width: 720px; }

.help {
    margin: -8px 0 0;
    font-size: .82rem;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
}

.page-heading--actions {
    display: flex;
    gap: 24px;
    align-items: flex-end;
    justify-content: space-between;
}

.table-wrap {
    overflow-x: auto;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .86rem;
}

.data-table th,
.data-table td {
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.data-table th {
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: .72rem;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfa; }
.row-error { background: var(--error-soft); }

.confirm-bar {
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.confirm-bar strong,
.confirm-bar span { display: block; }

.confirm-bar span {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: .82rem;
}

.metric-grid {
    margin-bottom: 26px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric-grid article {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}

.metric-grid strong,
.metric-grid span { display: block; }

.metric-grid strong {
    overflow: hidden;
    font-size: 1.7rem;
    letter-spacing: -.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-grid span {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: .78rem;
}

.metric-grid .metric-wide { grid-column: span 2; }

.module-grid--compact .module-card { min-height: 225px; }

.search-bar {
    margin-bottom: 18px;
    display: flex;
    gap: 10px;
}

.search-bar input { max-width: 480px; }

.pagination {
    display: flex;
    justify-content: center;
    gap: 24px;
    align-items: center;
    font-size: .85rem;
}

.error-list {
    margin-bottom: 0;
    color: var(--error);
    line-height: 1.6;
}

@media (max-width: 760px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .metric-grid .metric-wide { grid-column: span 2; }
    .page-heading--actions,
    .confirm-bar { align-items: stretch; flex-direction: column; }
}

/* INDIA ADMIN SITES V1 START */

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

.button--danger {
    border-color: #b42318;
    background: #fff;
    color: #b42318;
}

.button--danger:hover {
    background: #fff1f0;
}

.site-filters {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 190px 210px auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
}

.site-filters label > span {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: .76rem;
    font-weight: 700;
}

.site-filters__search input {
    height: 48px;
}

.sites-table .site-name {
    color: var(--text);
    font-weight: 650;
    text-decoration: none;
}

.sites-table a:hover {
    text-decoration: underline;
}

.table-action {
    color: var(--primary);
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: .78rem;
    font-weight: 700;
}

.status-dot::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    content: "";
}

.status-dot.is-on::before {
    background: #2e7d32;
}

.status-dot.is-off::before {
    background: #b42318;
}

.empty-state {
    padding: 30px !important;
    color: var(--text-muted);
    text-align: center !important;
}

.site-editor {
    padding-bottom: 92px;
}

.site-tabs {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 6px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(8px);
}

.site-tab {
    padding: 11px 17px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-size: .86rem;
    font-weight: 700;
}

.site-tab.active {
    background: var(--surface-muted);
    color: var(--primary);
}

.site-tab-panel {
    display: none;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
}

.site-tab-panel.active {
    display: block;
}

.form-section-heading {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.form-section-heading h2 {
    margin: 0 0 5px;
    font-size: 1.35rem;
}

.form-section-heading p {
    margin: 0;
    color: var(--text-muted);
    font-size: .86rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-grid label > span,
.coordinate-layout label > span {
    display: block;
    margin-bottom: 7px;
    color: var(--text);
    font-size: .82rem;
    font-weight: 700;
}

.form-grid label small {
    margin-left: 5px;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 500;
}

.form-grid input,
.form-grid textarea,
.coordinate-layout input {
    width: 100%;
}

.form-grid textarea {
    resize: vertical;
}

.field-wide {
    grid-column: 1 / -1;
}

.record-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 28px 0 0;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.record-meta div {
    padding: 14px;
    border-radius: 12px;
    background: var(--surface-muted);
}

.record-meta dt {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.record-meta dd {
    margin: 0;
    font-size: .82rem;
}

.coordinate-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 22px;
}

.site-map {
    min-height: 520px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-muted);
}

.map-unavailable {
    display: grid;
    min-height: 520px;
    place-items: center;
    padding: 30px;
    color: var(--text-muted);
    text-align: center;
}

.map-attribution-note {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: .72rem;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 13px;
}

.history-item > div {
    display: inline-flex;
    flex-direction: column;
    margin-left: 10px;
}

.history-item time {
    color: var(--text-muted);
    font-size: .75rem;
}

.history-action {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 99px;
    background: var(--surface-muted);
    color: var(--primary);
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.history-item details {
    margin-top: 13px;
}

.history-item summary {
    color: var(--primary);
    cursor: pointer;
    font-size: .78rem;
    font-weight: 700;
}

.history-json-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.history-json-grid h3 {
    font-size: .78rem;
}

.history-json-grid pre {
    max-height: 360px;
    overflow: auto;
    padding: 14px;
    border-radius: 10px;
    background: #16231d;
    color: #eaf2ed;
    font-size: .7rem;
    white-space: pre-wrap;
}

.site-save-bar {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    padding: 14px max(24px, calc((100vw - 1440px) / 2));
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,.96);
    box-shadow: 0 -8px 26px rgba(18, 42, 31, .08);
    backdrop-filter: blur(8px);
}

.site-save-bar span {
    color: var(--text-muted);
    font-size: .8rem;
}

@media (max-width: 900px) {
    .site-filters {
        grid-template-columns: 1fr 1fr;
    }

    .site-filters__search {
        grid-column: 1 / -1;
    }

    .coordinate-layout {
        grid-template-columns: 1fr;
    }

    .record-meta {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .site-filters,
    .form-grid,
    .history-json-grid {
        grid-template-columns: 1fr;
    }

    .field-wide,
    .site-filters__search {
        grid-column: auto;
    }

    .site-tab-panel {
        padding: 18px;
    }

    .site-map {
        min-height: 380px;
    }

    .site-save-bar {
        align-items: stretch;
        flex-direction: column;
        gap: 7px;
        padding: 12px 18px;
    }

    .site-save-bar .button {
        width: 100%;
    }
}

/* INDIA ADMIN SITES V1 END */
