:root {
    --green: #00e72e;
    --green-dark: #029b27;
    --blue: #0019cc;
    --red: #f20d18;
    --ink: #101214;
    --muted: #667085;
    --line: #d6dbe3;
    --surface: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: #eef2f6;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.auth-page {
    min-height: 100vh;
    background: linear-gradient(rgba(255, 255, 255, .7), rgba(255, 255, 255, .78)), url("../../bg.jpg") center / cover fixed;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(430px, 100%);
    background: rgba(255, 255, 255, .96);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 24px 80px rgba(16, 24, 40, .16);
    text-align: center;
}

.auth-card.wide {
    width: min(560px, 100%);
}

.auth-logo {
    width: 260px;
    max-width: 90%;
    height: auto;
    margin-bottom: 18px;
}

.auth-card h1,
.panel h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.auth-card p {
    margin: 0 0 22px;
    color: var(--muted);
}

.form-stack,
.form-grid {
    display: grid;
    gap: 16px;
    text-align: left;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #c8d0db;
    border-radius: 6px;
    padding: 12px 13px;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(0, 231, 46, .2);
    border-color: #00a827;
}

.primary-button,
.secondary-button,
.row-actions button {
    border: 0;
    border-radius: 6px;
    padding: 12px 18px;
    font-weight: 800;
    cursor: pointer;
}

.primary-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: #00b82c;
    color: #fff;
}

.primary-button.small {
    padding: 10px 14px;
}

.secondary-button {
    background: #edf1f5;
    color: #1f2937;
}

.alert {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-weight: 700;
}

.alert.error {
    background: #ffe8e8;
    color: #b00020;
}

.alert.success {
    background: #e7f8eb;
    color: #087520;
}

.secret-box {
    overflow-wrap: anywhere;
    border: 2px dashed #00a827;
    background: #f2fff5;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 2px;
}

.otp-link {
    display: inline-block;
    margin-bottom: 18px;
    color: #0057c2;
    font-weight: 700;
}

.qr-panel {
    display: flex;
    justify-content: center;
    margin: 16px 0 14px;
}

.qr-image {
    width: 196px;
    height: 196px;
    object-fit: contain;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.village-dashboard {
    position: relative;
    min-height: 100vh;
    padding: 42px clamp(18px, 6vw, 92px) 30px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 36px;
    overflow: auto;
}

.dashboard-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    background: linear-gradient(110deg, rgba(247, 250, 255, .78), rgba(226, 233, 241, .66)), url("../../bg.jpg") center / cover no-repeat;
}

.dashboard-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255, 255, 255, .14), rgba(255, 255, 255, .34));
    z-index: -1;
}

.dash-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 24px;
}

.dash-logo {
    justify-self: center;
    margin-left: clamp(0px, 13vw, 260px);
}

.dash-logo img {
    width: min(420px, 50vw);
    height: auto;
}

.dash-actions {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.dash-button {
    min-width: 126px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 4px solid currentColor;
    box-shadow: 0 10px 24px rgba(16, 24, 40, .14);
    font-size: 19px;
    font-weight: 900;
    color: var(--ink);
    line-height: 1;
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.dash-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(16, 24, 40, .18);
}

.dash-button.blue {
    color: var(--blue);
}

.dash-button.red {
    color: var(--red);
}

.dash-button.blue,
.dash-button.red {
    color: var(--ink);
}

.dash-button.blue {
    border-color: var(--blue);
}

.dash-button.red {
    border-color: var(--red);
}

.dash-settings {
    position: relative;
}

.dash-settings button {
    cursor: pointer;
}

.dash-menu,
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    min-width: 210px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 18px 50px rgba(16, 24, 40, .16);
    z-index: 10;
}

.dash-settings:hover .dash-menu,
.dropdown:hover .dropdown-menu {
    display: grid;
}

.dash-menu a,
.dropdown-menu a {
    padding: 13px 15px;
    font-weight: 700;
}

.module-grid {
    align-self: center;
    display: grid;
    grid-template-columns: repeat(3, minmax(190px, 1fr));
    gap: clamp(22px, 3vw, 34px);
}

.module-tile {
    position: relative;
    min-height: 172px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    align-items: center;
    justify-items: center;
    gap: 12px;
    padding: 20px 18px 17px;
    background: rgba(255, 255, 255, .94);
    border: 6px solid var(--green);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(16, 24, 40, .12);
    color: #050505;
    text-align: center;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background-color .18s ease;
}

.module-tile::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background: linear-gradient(180deg, rgba(0, 231, 46, .08), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.module-icon {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #ecfff0;
    border: 1px solid rgba(0, 168, 39, .22);
    color: var(--green-dark);
}

.module-icon svg {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.module-title {
    display: block;
    font-size: clamp(22px, 1.7vw, 31px);
    line-height: 1.13;
    font-weight: 900;
    letter-spacing: 0;
}

.module-status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 5px 10px;
    border-radius: 6px;
    background: #ecfff0;
    color: #087520;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}

.module-tile.is-enabled:hover {
    transform: translateY(-3px);
    border-color: var(--green-dark);
    box-shadow: 0 24px 54px rgba(16, 24, 40, .2);
    background: #fff;
}

.module-tile.is-disabled {
    cursor: not-allowed;
    border-color: #b9c2cf;
    background: rgba(245, 247, 250, .86);
    color: #6b7280;
    box-shadow: 0 12px 28px rgba(16, 24, 40, .08);
    filter: grayscale(.25);
}

.module-tile.is-disabled::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 14px;
    width: 22px;
    height: 22px;
    border: 2px solid #8b95a3;
    border-radius: 5px;
    background:
        linear-gradient(#8b95a3, #8b95a3) center 10px / 10px 2px no-repeat,
        linear-gradient(#8b95a3, #8b95a3) center 14px / 10px 2px no-repeat;
}

.module-tile.is-disabled .module-icon {
    background: #f1f3f6;
    border-color: #d2d8e1;
    color: #8b95a3;
}

.module-tile.is-disabled .module-status {
    background: #eef1f5;
    color: #667085;
}

.dash-footer {
    text-align: center;
    font-size: clamp(20px, 1.7vw, 30px);
    font-weight: 800;
}

.app-page {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 14px clamp(16px, 4vw, 42px);
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
}

.brand-mini {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 900;
}

.brand-mini img {
    width: 160px;
    max-width: 42vw;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.topnav a,
.topnav button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 10px 13px;
    font-weight: 800;
}

.logout-link {
    color: #b00020;
}

.dropdown {
    position: relative;
}

.content {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto;
}

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(18px, 3vw, 30px);
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
}

.panel.narrow {
    width: min(620px, 100%);
    margin: 0 auto;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.table-wrap,
.permission-table {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 13px;
    text-align: left;
}

th {
    background: #f5f7fa;
}

.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.row-actions a,
.row-actions button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 8px 10px;
}

.row-actions button {
    color: #b00020;
}

.muted-status {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e8eef7;
    color: #15315d;
    font-size: 12px;
    font-weight: 900;
}

.status-pill.active {
    background: #e9fbe8;
    color: #087520;
}

.check-card {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid #cfe5cc;
    border-left: 6px solid #21bf33;
    border-radius: 8px;
    background: #f4fff2;
}

.check-card input {
    width: 18px;
    height: 18px;
    margin-top: 3px;
}

.check-card span {
    display: grid;
    gap: 3px;
}

.check-card strong {
    color: #0f172a;
}

.check-card small {
    color: var(--muted);
    font-weight: 700;
    line-height: 1.4;
}

.running-text-preview {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid #dce5f0;
    border-radius: 8px;
    background: #f8fafc;
}

.running-text-preview strong {
    color: #0f172a;
}

.running-text-preview ol {
    display: grid;
    gap: 7px;
    margin: 0;
    padding-left: 20px;
}

.running-text-preview li {
    color: #263141;
    font-weight: 800;
}

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

.check-line {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.check-line input,
.permission-table input {
    width: auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 6px;
}

.head-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.sensus-shell {
    display: grid;
    gap: 20px;
}

.portal-shell {
    display: grid;
    gap: 20px;
}

.portal-module {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.portal-sidebar {
    position: sticky;
    top: 86px;
    display: grid;
    gap: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
}

.portal-sidebar-brand {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.portal-sidebar-brand strong {
    font-size: 18px;
}

.portal-sidebar-brand span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.portal-sidebar nav {
    display: grid;
    gap: 8px;
}

.portal-sidebar nav a,
.portal-sidebar nav span,
.portal-preview {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-weight: 900;
}

.portal-sidebar nav a.active {
    border-color: var(--green-dark);
    background: #ecfff0;
    color: var(--green-dark);
}

.portal-sidebar nav span {
    background: #f3f5f8;
    color: var(--muted);
}

.portal-preview {
    justify-content: center;
    background: #101214;
    color: #fff;
}

.portal-content {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.portal-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 26px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
}

.portal-hero h1 {
    margin: 0;
}

.portal-hero p {
    margin: 8px 0 0;
    color: var(--muted);
}

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

.portal-menu-grid a {
    padding: 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 6px solid var(--green-dark);
    border-radius: 8px;
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
    font-weight: 900;
}

.sensus-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sensus-tabs a,
.sensus-tabs span {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 900;
}

.sensus-tabs a.active {
    background: #ecfff0;
    border-color: var(--green-dark);
    color: var(--green-dark);
}

.sensus-tabs span {
    color: var(--muted);
    background: #f3f5f8;
}

.sensus-hero,
.filter-panel,
.family-node,
.sensus-form,
.detail-grid {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
}

.sensus-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 26px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--green-dark);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.sensus-hero h1,
.section-head h1 {
    margin: 0;
}

.sensus-hero p {
    margin: 8px 0 0;
    color: var(--muted);
}

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

.sensus-stat {
    display: grid;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #ecfff0;
    color: var(--green-dark);
    font-weight: 900;
}

.sensus-stat strong {
    font-size: 34px;
}

.sensus-stat p {
    margin: 0;
    color: var(--muted);
    font-weight: 800;
}

.filter-panel {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
    padding: 18px;
}

.filter-actions {
    display: flex;
    gap: 10px;
}

.family-tree {
    display: grid;
    gap: 14px;
}

.family-node {
    overflow: hidden;
}

.family-node summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 16px 18px;
    cursor: pointer;
    background: #f7fafc;
}

.family-node summary strong,
.family-node summary small {
    display: block;
}

.family-node summary small {
    margin-top: 4px;
    color: var(--muted);
}

.family-node summary em {
    font-style: normal;
    color: var(--green-dark);
    font-weight: 900;
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 26px;
    background: #fff;
    color: var(--muted);
    text-align: center;
    font-weight: 800;
}

.sensus-form {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.portal-setting-box {
    display: grid;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #f8fbff;
}

.portal-setting-box legend {
    padding: 0 8px;
    color: #0b8b24;
    font-weight: 900;
}

.builder-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
    padding: 18px;
}

.builder-intro strong {
    display: block;
    margin-bottom: 4px;
    font-size: 20px;
}

.builder-intro p {
    margin: 0;
    color: var(--muted);
}

.builder-page {
    margin: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100dvh;
    min-height: 100vh;
    overflow: hidden;
    background: #20242a;
}

.builder-topbar {
    position: relative;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 74px;
    padding: 12px 18px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.builder-title {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.builder-title span {
    color: #0b8b24;
    font-size: 12px;
    font-weight: 900;
}

.builder-title strong {
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.builder-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    min-width: 0;
}

.builder-tools button {
    min-height: 38px;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    padding: 8px 10px;
    background: #f8fafc;
    color: #0f172a;
    font-weight: 900;
    cursor: pointer;
}

.builder-tools button.active,
.builder-tools button:hover {
    border-color: #21bf33;
    background: #e9fbe8;
    color: #087520;
}

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

.builder-status {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    min-width: 180px;
    min-height: 0;
    padding: 10px 12px;
    border-radius: 6px;
    background: rgba(17, 24, 39, .9);
    color: #fff;
    font-weight: 800;
}

.builder-status:empty {
    display: none;
}

.builder-workspace {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    height: auto;
    min-height: 0;
    overflow: hidden;
}

.blocks-container {
    min-height: 0;
    overflow-y: auto;
    background: #111827;
    color: #fff;
}

.block-search-wrap {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    gap: 7px;
    padding: 12px;
    background: #0f172a;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.block-search-wrap label {
    color: #b7c3d7;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.builder-block-search {
    width: 100%;
    min-height: 38px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 6px;
    padding: 9px 11px;
    background: #fff;
    color: #0f172a;
    font: inherit;
}

.builder-page .gjs-editor {
    min-width: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.builder-page .gjs-cv-canvas {
    top: 40px;
    width: calc(100% - 260px);
    height: calc(100% - 40px);
}

.builder-page .gjs-pn-panel {
    position: static;
}

.builder-page .gjs-pn-panels {
    position: relative;
    z-index: 5;
}

.builder-page .gjs-block {
    width: calc(50% - 8px);
    min-height: 82px;
    margin: 6px 4px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 6px;
    color: #fff;
}

.builder-page .gjs-block-label {
    font-size: 12px;
    line-height: 1.25;
}

.builder-page .gjs-block-category .gjs-title,
.builder-page .gjs-sm-sector .gjs-sm-title {
    background: #0f172a;
    color: #fff;
    font-weight: 900;
}

.html-sandbox-panel {
    display: none;
    height: calc(100vh - 74px);
    padding: 18px;
    background: #eaf0f6;
}

.html-sandbox-mode .builder-workspace {
    display: none;
}

.html-sandbox-mode .html-sandbox-panel {
    display: block;
}

.html-sandbox-editor {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 12px;
    height: 100%;
}

.html-sandbox-head,
.html-sandbox-previewbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.html-sandbox-head {
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.html-sandbox-head span {
    display: block;
    color: #0a8f18;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .04em;
}

.html-sandbox-head strong {
    display: block;
    margin-top: 3px;
    color: #0f172a;
    font-size: clamp(18px, 2vw, 26px);
}

.html-sandbox-head button,
.html-sandbox-previewbar button {
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    padding: 10px 13px;
    background: #111827;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.html-sandbox-help {
    padding: 12px 14px;
    border-left: 6px solid #22b72b;
    background: #efffeb;
    color: #20442a;
    font-weight: 800;
}

.html-sandbox-grid {
    display: grid;
    grid-template-columns: minmax(320px, .9fr) minmax(0, 1.1fr);
    gap: 14px;
    min-height: 0;
}

.html-sandbox-code,
.html-sandbox-preview {
    display: grid;
    gap: 10px;
    min-height: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.html-sandbox-code label {
    color: #0f172a;
    font-weight: 900;
}

.html-sandbox-code input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px dashed #9da9ba;
    border-radius: 6px;
    background: #f8fafc;
}

.html-sandbox-code textarea {
    width: 100%;
    min-height: 0;
    height: 100%;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 14px;
    background: #0b1220;
    color: #e5eefc;
    font: 13px/1.55 Consolas, Monaco, monospace;
}

.html-sandbox-preview iframe {
    width: 100%;
    height: 100%;
    min-height: 420px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
}

.blocks-collapsed .builder-workspace {
    grid-template-columns: 1fr;
}

.blocks-collapsed .blocks-container {
    display: none;
}

.blocks-collapsed .builder-page .gjs-editor,
.blocks-collapsed .gjs-editor {
    margin-left: 0;
}

.blocks-collapsed .builder-page .gjs-cv-canvas,
.blocks-collapsed .gjs-cv-canvas {
    width: 100%;
}

@media (max-width: 1180px) {
    .builder-topbar {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .builder-tools,
    .builder-actions {
        justify-content: flex-start;
    }

    .builder-tools {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 3px;
        scrollbar-width: thin;
    }

    .builder-tools button { flex: 0 0 auto; }
}

@media (max-width: 860px) {
    .builder-page {
        grid-template-rows: auto auto minmax(0, 1fr);
        overflow: hidden;
    }

    .builder-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        height: 100%;
        min-height: 0;
    }

    .blocks-container {
        width: 100%;
        max-height: 210px;
        border-bottom: 1px solid rgba(255,255,255,.12);
    }

    .builder-page .gjs-editor {
        margin-left: 0;
        min-height: 0;
        height: 100%;
    }

    .builder-page .gjs-cv-canvas {
        left: 0;
        width: 100%;
        height: calc(100% - 40px);
    }

    .builder-page .gjs-pn-views-container { display: none; }


    .builder-page .gjs-block {
        width: 136px;
        min-height: 72px;
    }

    .builder-page .gjs-blocks-c {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        padding: 8px 8px 12px;
    }

    .builder-page .gjs-block-category {
        min-width: 100%;
    }

    .block-search-wrap {
        position: static;
    }

    .html-sandbox-panel {
        height: auto;
        min-height: calc(100vh - 180px);
        padding: 12px;
    }

    .html-sandbox-grid {
        grid-template-columns: 1fr;
    }

    .html-sandbox-code textarea {
        min-height: 340px;
    }

    .html-sandbox-preview iframe {
        min-height: 360px;
    }
}

@media (max-width: 560px) {
    .builder-topbar {
        padding: 10px;
    }

    .builder-tools button {
        flex: 0 0 auto;
        min-height: 36px;
        padding: 8px 10px;
    }

    .builder-actions a,
    .builder-actions button {
        flex: 1 1 calc(33.333% - 8px);
        justify-content: center;
        min-width: 0;
        padding: 10px 8px;
    }

    .builder-title strong {
        white-space: normal;
    }

    .builder-workspace { min-height: 0; }

    .blocks-container { max-height: 168px; }

    .builder-page .gjs-block {
        width: 122px;
        min-height: 66px;
    }

    .builder-status {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .html-sandbox-head,
    .html-sandbox-previewbar {
        align-items: stretch;
        flex-direction: column;
    }
}

.member-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.member-toolbar p {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.member-list {
    display: grid;
    gap: 14px;
}

.member-card {
    border: 1px solid #dfe5ee;
    border-radius: 8px;
    background: #fbfcfe;
    padding: 16px;
}

.member-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.member-card-head strong {
    color: var(--green-dark);
}

.secondary-button.small {
    padding: 8px 12px;
}

.secondary-button.danger {
    color: #b00020;
}

.import-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
    gap: 18px;
}

.template-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
    padding: 22px;
}

.template-card h2 {
    margin: 0 0 10px;
}

.template-card p {
    margin: 0 0 16px;
    color: var(--muted);
    font-weight: 700;
    line-height: 1.5;
}

.template-actions {
    display: grid;
    gap: 10px;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

legend {
    padding: 0 8px;
    font-weight: 900;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    padding: 1px;
    overflow: hidden;
}

.detail-item {
    display: grid;
    gap: 6px;
    background: #fff;
    padding: 16px;
}

.detail-item span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.detail-item strong {
    overflow-wrap: anywhere;
}

.permission-tree {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.permission-head,
.permission-branch summary,
.permission-leaf {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(4, 90px);
    align-items: center;
    gap: 10px;
}

.permission-head {
    background: #f5f7fa;
    padding: 12px 16px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.permission-branch {
    border-top: 1px solid var(--line);
}

.permission-branch summary {
    padding: 14px 16px;
    cursor: pointer;
    background: #fff;
    font-weight: 900;
}

.permission-leaf {
    padding: 12px 16px 12px 42px;
    background: #fbfcfe;
    border-top: 1px solid #eef1f5;
}

.permission-leaf .permission-name::before {
    content: "└ ";
    color: var(--muted);
}

.permission-check {
    display: flex;
    justify-content: center;
}

.permission-check input {
    width: 18px;
    height: 18px;
}

@media (max-width: 1100px) {
    .village-dashboard {
        gap: 38px;
    }

    .dash-header {
        grid-template-columns: 1fr;
    }

    .dash-logo {
        margin-left: 0;
    }

    .dash-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    .module-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .portal-module {
        grid-template-columns: 1fr;
    }

    .portal-sidebar {
        position: static;
    }

    .portal-sidebar nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-panel,
    .sensus-stat-grid,
    .portal-menu-grid,
    .form-grid-3,
    .detail-grid,
    .import-layout,
    .permission-head,
    .permission-branch summary,
    .permission-leaf {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .village-dashboard {
        padding: 28px 16px;
        gap: 28px;
    }

    .dash-logo img {
        width: min(330px, 92vw);
    }

    .dash-actions {
        gap: 12px;
    }

    .dash-button {
        min-width: 145px;
        height: 48px;
        border-width: 4px;
        font-size: 20px;
    }

    .module-grid {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .module-tile {
        min-height: 148px;
        border-width: 5px;
    }

    .module-title {
        font-size: 25px;
    }

    .topbar,
    .section-head,
    .two-col {
        flex-direction: column;
        display: flex;
        align-items: stretch;
    }

    .head-actions,
    .member-toolbar,
    .member-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .portal-sidebar nav {
        grid-template-columns: 1fr;
    }

    .topnav {
        flex-wrap: wrap;
    }

    .sensus-hero,
    .portal-hero,
    .filter-panel,
    .sensus-stat-grid,
    .portal-menu-grid,
    .form-grid-3,
    .detail-grid,
    .import-layout {
        grid-template-columns: 1fr;
        display: grid;
    }

    .permission-tree {
        overflow-x: auto;
    }

    .permission-head,
    .permission-branch summary,
    .permission-leaf {
        min-width: 620px;
        grid-template-columns: minmax(220px, 1fr) repeat(4, 80px);
    }

    .filter-actions,
    .sensus-hero,
    .portal-hero {
        align-items: stretch;
    }
}


/* Builder canvas scrolling */
.builder-workspace > #gjs {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.builder-page .gjs-editor,
.builder-page .gjs-cv-canvas,
.builder-page .gjs-frame-wrapper {
    min-height: 0;
}

.builder-page .gjs-frame {
    overflow: auto !important;
    overscroll-behavior: contain;
}

@media (max-width: 860px) {
    .builder-workspace > #gjs {
        min-height: 420px;
    }
}

@media (max-width: 560px) {
    .builder-workspace > #gjs {
        min-height: 360px;
    }
}

/* Rich article editor */
.post-editor-form { max-width: 1180px; }
.post-media-box { display:grid; grid-template-columns:minmax(180px,1fr) auto; gap:14px; align-items:center; padding:16px; border:1px solid var(--line); border-radius:8px; background:#f8fbff; }
.post-media-box > div:first-child { display:grid; gap:4px; }
.post-media-box span { color:var(--muted); font-size:13px; }
.post-upload-control { position:relative; display:inline-flex; align-items:center; justify-content:center; min-height:42px; padding:10px 14px; border:1px solid #20a636; border-radius:6px; background:#effdeb; color:#087520; font-weight:900; cursor:pointer; }
.post-upload-control input { position:absolute; inset:0; opacity:0; cursor:pointer; }
.post-image-preview,.post-gallery-preview { grid-column:1/-1; display:flex; flex-wrap:wrap; gap:10px; }
.post-image-preview img { width:min(320px,100%); aspect-ratio:16/9; object-fit:cover; border-radius:6px; }
.post-gallery-preview img { width:120px; aspect-ratio:4/3; object-fit:cover; border-radius:6px; }
.rich-editor-field { display:grid; gap:0; }
.field-label { margin-bottom:8px; font-weight:900; }
.rich-editor-toolbar { display:flex; flex-wrap:wrap; gap:5px; padding:8px; border:1px solid #cbd5e1; border-bottom:0; border-radius:7px 7px 0 0; background:#eef3f7; }
.rich-editor-toolbar button,.rich-editor-toolbar select { min-height:36px; border:1px solid #cbd5e1; border-radius:5px; padding:7px 10px; background:#fff; color:#111827; font:inherit; cursor:pointer; }
.rich-editor-content { min-height:360px; max-height:65vh; overflow-y:auto; padding:18px; border:1px solid #cbd5e1; border-radius:0 0 7px 7px; background:#fff; line-height:1.65; outline:none; }
.rich-editor-content:focus { border-color:#20a636; box-shadow:0 0 0 3px rgba(32,166,54,.12); }
@media(max-width:680px){.post-media-box{grid-template-columns:1fr}.post-upload-control{width:100%}.rich-editor-toolbar{flex-wrap:nowrap;overflow-x:auto}.rich-editor-toolbar>*{flex:0 0 auto}.rich-editor-content{min-height:300px}}
/* Familiar document editor */
.document-editor{border:1px solid #b8c0ca;border-radius:4px;background:#fff;overflow:hidden}.editor-menubar{display:flex;align-items:center;gap:2px;min-height:42px;padding:4px 8px;border-bottom:1px solid #d8dde4;background:#f7f8fa}.editor-menubar details{position:relative}.editor-menubar summary{list-style:none;padding:7px 9px;border-radius:3px;cursor:pointer;color:#172033}.editor-menubar summary::-webkit-details-marker{display:none}.editor-menubar summary::after{content:' ▾';font-size:10px}.editor-menubar details[open] summary,.editor-menubar summary:hover{background:#e7ebef}.editor-menubar details>div{position:absolute;top:100%;left:0;z-index:20;display:grid;min-width:155px;padding:5px;border:1px solid #cbd5e1;background:#fff;box-shadow:0 10px 25px rgba(15,23,42,.16)}.editor-menubar details button{border:0;padding:9px 11px;background:#fff;text-align:left;cursor:pointer}.editor-menubar details button:hover{background:#eef6f1}.document-editor .rich-editor-toolbar{gap:2px;padding:5px 8px;border:0;border-bottom:1px solid #cbd5e1;border-radius:0;background:#f2f4f6}.document-editor .rich-editor-toolbar button,.document-editor .rich-editor-toolbar select,.document-editor .rich-editor-toolbar input[type=color]{min-width:36px;height:36px;min-height:36px;border:0;border-right:1px solid #d7dce3;border-radius:0;padding:6px 9px;background:transparent}.document-editor .rich-editor-toolbar button:hover,.document-editor .rich-editor-toolbar select:hover{background:#dde4e9}.document-editor .rich-editor-toolbar input[type=color]{width:40px;padding:7px}.toolbar-separator{width:1px;height:26px;margin:5px;background:#ccd2d9}.document-editor .rich-editor-content{min-height:360px;max-height:65vh;border:0;border-radius:0;padding:16px 12px;box-shadow:none;font-family:Aptos,Arial,sans-serif}.document-editor .rich-editor-content:focus{border:0;box-shadow:none}.document-editor .rich-editor-content table{width:100%;border-collapse:collapse}.document-editor .rich-editor-content td{min-width:80px;border:1px solid #adb5bd;padding:8px}.editor-statusbar{display:flex;justify-content:space-between;padding:7px 12px;border-top:1px solid #cbd5e1;background:#f5f6f8;color:#344054;font-size:13px}.is-editor-fullscreen .document-editor{position:fixed;inset:10px;z-index:1000;display:grid;grid-template-rows:auto auto minmax(0,1fr) auto}.is-editor-fullscreen .rich-editor-content{max-height:none}.is-editor-fullscreen .field-label{display:none}@media(max-width:700px){.editor-menubar{overflow-x:auto}.editor-menubar details{flex:0 0 auto}.document-editor .rich-editor-toolbar{flex-wrap:nowrap;overflow-x:auto}.document-editor .rich-editor-content{min-height:320px}.is-editor-fullscreen .document-editor{inset:0}}
/* KK master-detail table */
.kk-master-card{border:1px solid var(--line);border-radius:8px;background:#fff;overflow:hidden}.kk-master-table{min-width:1050px}.kk-master-table th{white-space:nowrap}.kk-master-row>td{vertical-align:middle}.kk-master-row:hover{background:#f6fbf7}.kk-toggle{display:grid;place-items:center;width:34px;height:34px;border:1px solid #cbd5e1;border-radius:5px;background:#fff;color:#0b8b24;font-size:26px;line-height:1;cursor:pointer;transition:transform .18s ease,background .18s ease}.kk-toggle.is-open{transform:rotate(90deg);background:#e9fbe8}.table-subtext{display:block;max-width:250px;margin-top:4px;color:var(--muted);font-size:12px}.status-badge{display:inline-flex;padding:5px 8px;border-radius:4px;background:#e8f8eb;color:#167832;font-size:12px;font-weight:900}.status-badge.sementara{background:#fff4d9;color:#8a5a00}.family-members-row>td{padding:0!important;background:#edf4f0}.family-members-panel{padding:16px 20px 20px;border-left:5px solid #2f9e55}.family-members-head{display:flex;justify-content:space-between;gap:12px;margin-bottom:12px}.family-members-panel table{background:#fff}.field-span-3{grid-column:1/-1}@media(max-width:760px){.kk-master-card{border-radius:0}.family-members-panel{padding:12px}.family-members-head{flex-direction:column}.field-span-3{grid-column:auto}}
/* Data table controls and pagination */
.search-field{min-width:260px}.search-input-wrap{position:relative;display:flex;align-items:center}.search-input-wrap input{padding-right:44px}.search-rule-info{position:absolute;right:7px;top:50%;z-index:12;transform:translateY(-50%)}.search-rule-info summary{display:grid;place-items:center;width:26px;height:26px;border:1px solid #2f9e55;border-radius:50%;background:#eaf7ee;color:#167832;font-weight:900;cursor:pointer;list-style:none}.search-rule-info summary::-webkit-details-marker{display:none}.search-rule-info>div{position:absolute;right:0;top:34px;width:min(320px,80vw);padding:14px;border:1px solid #cbd5e1;border-radius:7px;background:#fff;box-shadow:0 14px 32px rgba(15,23,42,.18);font-weight:400}.search-rule-info p{margin:6px 0 0;color:var(--muted);line-height:1.45}.search-error{margin:0 0 14px}.table-pagination-bar{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 2px;color:var(--muted);font-size:14px}.pagination{display:flex;flex-wrap:wrap;gap:5px}.pagination a{display:inline-flex;align-items:center;justify-content:center;min-width:36px;min-height:36px;padding:7px 10px;border:1px solid #cbd5e1;border-radius:5px;background:#fff;color:#24313a;font-weight:800}.pagination a.active{border-color:#2f9e55;background:#2f9e55;color:#fff}.pagination a.disabled{pointer-events:none;opacity:.45}@media(max-width:760px){.table-pagination-bar{align-items:flex-start;flex-direction:column}.pagination{width:100%;overflow-x:auto;flex-wrap:nowrap}.pagination a{flex:0 0 auto}.search-field{min-width:100%}}