/* ==========================================================================
   दिव्यांग साथी धुळे — Gram Panchayat portal (loaded after css/style.css)
   Uses the same tokens, buttons and header/footer as the public website.
   ========================================================================== */

/* Header chip showing the logged-in Gram Panchayat */
.portal-gp-chip { max-width: 20rem; }
.portal-gp-chip small { font-weight: 500; color: var(--c-muted); }

.portal-hero { padding-block: clamp(1.5rem, 4vw, 2.5rem); background: linear-gradient(135deg, var(--c-primary-800), var(--c-primary)); color: #fff; }
.portal-hero h1 { color: #fff; margin: .25rem 0; font-size: clamp(1.6rem, 1.3rem + 1.5vw, 2.3rem); }
.portal-hero .page-hero__lead { color: var(--c-on-dark-muted); margin: 0; max-width: 60rem; }
.portal-hero .breadcrumb a { color: #fff; }
.portal .page-body { padding-block: clamp(1.5rem, 4vw, 2.75rem); }
.container.narrow { max-width: 50rem; }
.muted { color: var(--c-muted); }
[hidden] { display: none !important; }

/* ---------- Auth pages ---------- */
.auth-wrap { display: grid; grid-template-columns: minmax(0, 30rem) minmax(0, 22rem); gap: 2rem; justify-content: center; align-items: start; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: minmax(0, 32rem); } }
.auth-card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-top: 5px solid var(--c-accent);
  border-radius: var(--radius-lg); padding: clamp(1.25rem, 4vw, 2rem); box-shadow: var(--shadow);
}
.auth-card__title { font-size: 1.5rem; margin-bottom: 1rem; }
.auth-aside { background: var(--c-primary-50); border-radius: var(--radius); padding: 1.25rem 1.4rem; }
.auth-aside h2 { font-size: 1.15rem; }
.auth-aside ul, .auth-aside ol { padding-left: 1.2rem; display: grid; gap: .45rem; margin: 0 0 .75rem; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; margin: 1.25rem 0 0; font-weight: 600; }
.btn--block { width: 100%; }
.btn-row-p { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1rem 0 0; }

/* ---------- Form controls ---------- */
.pform { display: grid; gap: 1.1rem; }
.pfieldset { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1rem 1.1rem 1.25rem; margin: 0; display: grid; gap: 1rem; }
.pfieldset legend { font-weight: 700; color: var(--c-primary-800); padding: 0 .4rem; font-size: 1.05rem; }
.pfield { display: grid; gap: .3rem; min-width: 0; }
.pfield label { font-weight: 700; color: var(--c-primary-800); }
.pfield .req { color: var(--c-accent); }
.pfield__hint { margin: 0; font-size: .95rem; color: var(--c-muted); line-height: 1.5; }
.pfield__error { margin: 0; font-size: .98rem; font-weight: 600; color: var(--c-accent-700); min-height: 0; }
.pfield__error:empty { display: none; }
.pfield input, .pfield select, .pfield textarea {
  width: 100%; min-height: 50px; padding: .55rem .85rem; font: inherit; font-size: 1.08rem; color: var(--c-text);
  background: var(--c-surface); border: 2px solid #7d8a99; border-radius: var(--radius-sm);
}
.pfield textarea { min-height: 5rem; resize: vertical; }
.pfield input:focus-visible, .pfield select:focus-visible, .pfield textarea:focus-visible { border-color: var(--c-primary); }
.pfield [aria-invalid="true"] { border-color: var(--c-accent); background: #fff8f8; }
.pfield input:disabled, .pfield select:disabled { background: var(--c-tint); color: var(--c-muted); }
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem 1.25rem; }
.pgrid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .pgrid--3 { grid-template-columns: 1fr; } }

/* ---------- Alerts ---------- */
.palert {
  display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1.1rem; margin: 0 0 1.25rem;
  border-radius: var(--radius-sm); border: 1px solid #c9d6e2; border-left: 5px solid var(--c-primary-600);
  background: var(--c-primary-50); color: var(--c-text);
}
.palert .icon { width: 1.5rem; height: 1.5rem; flex-shrink: 0; margin-top: .15rem; color: var(--c-primary-600); }
.palert--error { border-color: #efc6c9; border-left-color: var(--c-accent); background: #fdf2f3; }
.palert--error .icon { color: var(--c-accent); }
.palert--warn { border-color: #f0dcb3; border-left-color: #b45309; background: #fff8eb; }
.palert--warn .icon { color: #b45309; }
.palert--ok { border-color: #c5e3cc; border-left-color: #1f7a3a; background: #eff8f1; }
.palert ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.palert .btn { margin-left: .5rem; }

/* ---------- Dashboard ---------- */
.gp-identity {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 1.5rem; align-items: center;
  background: var(--c-surface); border: 1px solid var(--c-border); border-left: 6px solid var(--c-accent);
  border-radius: var(--radius-lg); padding: clamp(1.1rem, 3vw, 1.75rem); margin-bottom: 2rem; box-shadow: var(--shadow-sm);
}
@media (max-width: 760px) { .gp-identity { grid-template-columns: 1fr; } }
.gp-identity__label { margin: 0; color: var(--c-muted); font-weight: 600; }
.gp-identity__name { margin: 0; font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.2rem); font-weight: 800; color: var(--c-primary-800); line-height: 1.25; }
.gp-identity__en { margin: 0; font-size: 1.15rem; color: var(--c-muted); }
.kv { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .75rem 1.25rem; }
.kv > div { min-width: 0; }
.kv dt { font-size: .92rem; color: var(--c-muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 700; color: var(--c-text); overflow-wrap: anywhere; }
.kv--stack { grid-template-columns: 1fr; }
.kv--stack > div { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--c-border); }
@media (max-width: 520px) { .kv--stack > div { grid-template-columns: 1fr; gap: .1rem; } }
.kv--inline { grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }

.status-pill { display: inline-block; padding: .1rem .7rem; border-radius: 999px; font-size: .9rem; font-weight: 700; border: 1px solid transparent; }
.status-pill--active, .status-pill--ok { background: #e6f4ea; color: #1b5e2e; border-color: #b6dcc0; }
.status-pill--pending, .status-pill--draft { background: #fff4d6; color: #6b4a00; border-color: #e7c979; }
.status-pill--suspended, .status-pill--disabled { background: #fdecee; color: var(--c-accent-700); border-color: #efc6c9; }
.status-pill--none { background: var(--c-tint); color: var(--c-muted); border-color: var(--c-border); }

.dash-forms h2 { margin-bottom: .25rem; }
.form-cards { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1.1rem; }
.form-card {
  display: flex; flex-direction: column; gap: .5rem; padding: 1.25rem; background: var(--c-surface);
  border: 1px solid var(--c-border); border-top: 5px solid var(--c-primary); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.form-card__top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.form-card__no { font-weight: 800; color: var(--c-accent); font-size: 1.05rem; }
.form-card__title { font-size: 1.1rem; margin: 0; line-height: 1.45; }
.form-card__meta { margin: 0; color: var(--c-muted); font-size: .98rem; }
.form-card .btn { margin-top: auto; align-self: flex-start; }
.is-disabled { opacity: .7; cursor: not-allowed; }

.panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: clamp(1.1rem, 3vw, 1.6rem); margin-bottom: 1.5rem; }
.panel h2 { font-size: 1.3rem; }

/* ---------- Form pages ---------- */
.form-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.form-head .kv { flex: 1 1 32rem; }
.form-status { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.fsection { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.5rem); margin-bottom: 1.5rem; }
.fsection > h2 { font-size: 1.25rem; margin-bottom: .35rem; }
.fsection__intro { color: var(--c-muted); margin: 0 0 1rem; }
.fsection__bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.fsection__bar h2, .fsection__bar h3 { margin: 0; }
.sum-hint { font-size: .95rem; color: var(--c-primary-600); font-weight: 600; margin: 0; }

/* Dynamic table → stacked cards on small screens */
.dtable-wrap { border: 1px solid var(--c-border); border-radius: var(--radius-sm); overflow-x: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: 1.02rem; }
.dtable caption { text-align: left; padding: .6rem .9rem; font-weight: 700; color: var(--c-primary-800); }
.dtable th, .dtable td { padding: .65rem .8rem; border-bottom: 1px solid var(--c-border); text-align: left; vertical-align: top; }
.dtable th { background: var(--c-tint); color: var(--c-primary-800); font-size: .92rem; line-height: 1.35; }
.dtable td.num, .dtable th.num { text-align: right; white-space: nowrap; }
.dtable tr:last-child td { border-bottom: 0; }
.dtable .row-actions { white-space: nowrap; text-align: right; }
.dtable .row-actions .btn { margin-left: .35rem; }
.dtable-empty { padding: 1.25rem; text-align: center; color: var(--c-muted); background: var(--c-surface); }
@media (max-width: 900px) {
  .dtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; width: 100%; }
  .dtable tr { padding: .75rem .9rem; border-bottom: 1px solid var(--c-border); }
  .dtable td { border: 0; padding: .2rem 0; display: grid; grid-template-columns: minmax(8rem, 40%) 1fr; gap: .5rem; text-align: left !important; white-space: normal !important; }
  .dtable td::before { content: attr(data-label); font-weight: 700; color: var(--c-muted); font-size: .95rem; }
  .dtable td.row-actions { display: flex; gap: .5rem; padding-top: .6rem; }
  .dtable td.row-actions::before { content: none; }
  .dtable .row-actions .btn { margin: 0; }
}
@media (max-width: 1400px) {
  .dtable--wide thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dtable--wide, .dtable--wide tbody, .dtable--wide tr, .dtable--wide td { display: block; width: 100%; }
  .dtable--wide tr { padding: .75rem .9rem; border-bottom: 1px solid var(--c-border); }
  .dtable--wide td { border: 0; padding: .2rem 0; display: grid; grid-template-columns: minmax(8rem, 40%) 1fr; gap: .5rem; text-align: left !important; white-space: normal !important; }
  .dtable--wide td::before { content: attr(data-label); font-weight: 700; color: var(--c-muted); font-size: .95rem; }
  .dtable--wide td.row-actions { display: flex; gap: .5rem; padding-top: .6rem; }
  .dtable--wide td.row-actions::before { content: none; }
  .dtable--wide .row-actions .btn { margin: 0; }
}
@media (max-width: 420px) { .dtable td { grid-template-columns: 1fr; gap: 0; } }

.btn--sm { min-height: 44px; padding: .4rem .95rem; font-size: .98rem; }
.btn--danger { background: var(--c-surface); color: var(--c-accent-700); border-color: #e2a6ab; }
.btn--danger:hover { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.btn--ghost { background: var(--c-surface); color: var(--c-primary); border-color: var(--c-border); }
.btn--ghost:hover { border-color: var(--c-primary); background: var(--c-primary-50); color: var(--c-primary); }
.btn--navy { background: var(--c-primary); color: #fff; }
.btn--navy:hover { background: var(--c-primary-600); color: #fff; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }

/* Inline editor (add / edit a record) */
.editor {
  border: 2px solid var(--c-primary-600); border-radius: var(--radius); background: var(--c-primary-50);
  padding: 1rem 1.1rem 1.2rem; margin: 1rem 0;
}
.editor h3 { font-size: 1.1rem; margin-bottom: .75rem; }
.editor__actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.suggest { font-size: .95rem; margin: .2rem 0 0; color: var(--c-primary-600); }
.suggest button { font: inherit; font-weight: 700; background: none; border: 0; color: var(--c-primary-600); text-decoration: underline; cursor: pointer; padding: 0 .2rem; min-height: 32px; }

.beneficiary { border: 1px solid var(--c-border); border-left: 5px solid var(--c-primary-600); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; background: var(--c-surface); }
.beneficiary__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.beneficiary__head h3 { margin: 0; font-size: 1.15rem; }
.beneficiary__link { font-size: .95rem; color: var(--c-muted); margin: 0; }

/* Sticky action bar at the bottom of form pages (useful on phones) */
.form-actions {
  position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end;
  padding: .75rem 1rem; margin-top: 1.5rem; background: rgb(255 255 255 / .96); border: 1px solid var(--c-border);
  border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -4px 16px -8px rgb(14 58 91 / .25);
}
.form-actions > a { margin-right: auto; }

.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 2rem);
  background: #1b5e2e; color: #fff; font-weight: 700; padding: .7rem 1.2rem; border-radius: 999px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.is-visible { opacity: 1; }
.toast.is-error { background: var(--c-accent-700); }

/* Logout button inside nav (reuses .btn--login look) */
.main-nav__inner [data-logout] { cursor: pointer; }

/* ---------- High contrast ---------- */
html[data-contrast="high"] .auth-card, html[data-contrast="high"] .auth-aside, html[data-contrast="high"] .gp-identity,
html[data-contrast="high"] .form-card, html[data-contrast="high"] .panel, html[data-contrast="high"] .form-head,
html[data-contrast="high"] .fsection, html[data-contrast="high"] .editor, html[data-contrast="high"] .beneficiary,
html[data-contrast="high"] .palert, html[data-contrast="high"] .dtable-wrap, html[data-contrast="high"] .pfieldset,
html[data-contrast="high"] .form-actions, html[data-contrast="high"] .dtable th, html[data-contrast="high"] .dtable-empty {
  background: #000; color: #fff; border-color: #fff;
}
html[data-contrast="high"] .portal-hero { background: #000; border-bottom: 1px solid #fff; }
html[data-contrast="high"] .pfield input, html[data-contrast="high"] .pfield select, html[data-contrast="high"] .pfield textarea { background: #000; color: #fff; border-color: #fff; }
html[data-contrast="high"] .page-body :is(label, legend, dt, dd, h2, h3, strong, .gp-identity__name, .form-card__title, .pfield__hint, .muted, .form-card__meta, .gp-identity__en, .gp-identity__label, .fsection__intro, .beneficiary__link) { color: #fff; }
html[data-contrast="high"] .pfield__error, html[data-contrast="high"] .sum-hint, html[data-contrast="high"] .suggest, html[data-contrast="high"] .suggest button, html[data-contrast="high"] .form-card__no { color: #ffd34e; }
html[data-contrast="high"] .status-pill { background: #000; color: #ffd34e; border-color: #ffd34e; }
html[data-contrast="high"] .palert .icon { color: #ffd34e; }
html[data-contrast="high"] .btn--danger, html[data-contrast="high"] .btn--ghost { background: #000; color: #ffd34e; border-color: #ffd34e; }
html[data-contrast="high"] .portal-gp-chip small { color: #fff; }

/* ---------- District / Super Admin ---------- */
.stat-grid { list-style: none; margin: 1rem 0 2rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); gap: 1rem; }
.stat-card a {
  display: flex; flex-direction: column; gap: .25rem; height: 100%; padding: 1.1rem 1.2rem; text-decoration: none;
  background: var(--c-surface); border: 1px solid var(--c-border); border-top: 5px solid var(--c-primary); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); color: var(--c-text);
}
.stat-card a:hover { box-shadow: var(--shadow); border-top-color: var(--c-accent); color: var(--c-text); }
.stat-card__value { font-size: 2rem; font-weight: 800; color: var(--c-primary-800); line-height: 1.1; }
.stat-card__label { font-weight: 600; color: var(--c-muted); }
.stat-card--ok a { border-top-color: #1f7a3a; }
.stat-card--warn a { border-top-color: #b45309; }
.stat-card--danger a { border-top-color: var(--c-accent); }

.filter-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .9rem 1rem; align-items: end;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.filter-bar__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.result-count { font-weight: 700; color: var(--c-primary-800); }
.pager { display: flex; align-items: center; justify-content: center; gap: .5rem; margin: 1rem 0; }
.toggle-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 600; min-height: 44px; }
.check input { width: 1.25rem; height: 1.25rem; }
.tag-demo, .tag-deleted { display: inline-block; margin-left: .4rem; padding: 0 .5rem; border-radius: 6px; font-size: .8rem; font-weight: 700; }
.tag-demo { background: #efe7ff; color: #4b2a8a; border: 1px solid #cdbbf2; }
.tag-deleted { background: #eef0f2; color: #3d4652; border: 1px solid #c4cad1; }
.panel--danger { border-left: 5px solid var(--c-accent); }
.temp-pw code { font-size: 1.15rem; font-weight: 700; background: #fff; padding: .1rem .5rem; border-radius: 6px; border: 1px solid var(--c-border); user-select: all; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1.25rem; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.bar-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--c-border); }
.total-row td { font-weight: 800; background: var(--c-tint); }
html[data-contrast="high"] .stat-card a, html[data-contrast="high"] .filter-bar { background: #000; border-color: #fff; color: #fff; }
html[data-contrast="high"] .stat-card__value, html[data-contrast="high"] .stat-card__label, html[data-contrast="high"] .result-count { color: #fff; }
html[data-contrast="high"] .tag-demo, html[data-contrast="high"] .tag-deleted, html[data-contrast="high"] .total-row td { background: #000; color: #ffd34e; border-color: #ffd34e; }
