:root {
    --primary: #facc15;
    --primary-dark: #eab308;
    --sidebar-bg: #ffffff;
    --main-bg: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text-dark: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: 0 14px 35px rgba(15, 23, 42, .08);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { min-height: 100%; }

body {
    min-height: 100vh;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--main-bg);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

.app-container { display: flex; min-height: 100vh; width: 100%; }
.sidebar { width: 248px; flex: 0 0 248px; background: linear-gradient(180deg, #ffffff 0%, #fbfcff 58%, #f8fafc 100%); border-right: 1px solid rgba(226, 232, 240, .9); display: flex; flex-direction: column; }
.sidebar-header { padding: 2rem 1.45rem 1.15rem; }
.brand-title { position: relative; display: inline-block; font-size: .74rem; font-weight: 850; text-transform: uppercase; letter-spacing: .18em; line-height: 1.45; margin-bottom: .95rem; color: #0f172a; }
.brand-title::before { content: ''; position: absolute; left: -.55rem; top: .15rem; bottom: .15rem; width: 2px; border-radius: 999px; background: linear-gradient(180deg, var(--primary), #f59e0b); }
.brand-accent { width: 2.35rem; height: 2px; background: linear-gradient(90deg, var(--primary), rgba(250, 204, 21, 0)); border-radius: 999px; }
.nav-section { flex: 1; padding: .45rem .8rem 1rem; overflow-y: auto; }
.nav-heading { padding: 1rem .8rem .45rem; color: var(--text-light); text-transform: uppercase; letter-spacing: .11em; font-size: .68rem; font-weight: 800; pointer-events: none; }
.nav-heading-main { color: #111827; }
.nav-item { display: flex; align-items: center; min-height: 36px; padding: .55rem .8rem; color: var(--text-muted); text-decoration: none; border-radius: 10px; font-size: .88rem; font-weight: 650; transition: background-color .18s ease, color .18s ease, box-shadow .18s ease; }
.nav-item:hover { background: #f8fafc; color: var(--text-dark); }
.nav-item.active { color: #0f172a; background: #fffbea; box-shadow: inset 3px 0 0 var(--primary-dark); }
.sub-item { margin-left: .55rem; font-size: .84rem; }
.sidebar-footer { padding: 1.25rem 1.5rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-muted); }
.sidebar-location { font-weight: 800; color: var(--text-dark); }
.sidebar-user { margin-top: .2rem; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-bar { height: 72px; background: rgba(255,255,255,.86); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; backdrop-filter: blur(12px); }
.top-bar-title { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .18em; color: #475569; }
.content-scroll { flex: 1; overflow-y: auto; }
.page-container { width: min(100%, 1440px); margin: 0 auto; padding: clamp(1rem, 3vw, 2.75rem) clamp(1rem, 3vw, 2rem) 4rem; }
.page-title { margin-bottom: 1.35rem; font-size: 1.85rem; line-height: 1.2; font-weight: 750; letter-spacing: -.035em; color: #0f172a; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 38px; padding: .6rem 1rem; border-radius: 10px; font-size: .88rem; font-weight: 750; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease; border: 1px solid transparent; text-decoration: none; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #111827; box-shadow: 0 10px 20px rgba(234, 179, 8, .18); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; border-color: var(--border); color: #475569; box-shadow: var(--shadow-sm); }
.btn-small { min-height: 32px; padding: .42rem .7rem; font-size: .78rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: clamp(1rem, 2.5vw, 1.35rem); margin-top: 1rem; box-shadow: var(--shadow-sm); }
.card h3 { font-size: 1.08rem; line-height: 1.3; font-weight: 750; letter-spacing: -.015em; color: #0f172a; }
.card p, .muted, .empty-state { color: var(--text-muted); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; }
.card-head p { margin-top: .25rem; max-width: 64ch; }

.field { display: grid; gap: .42rem; margin-bottom: 1rem; }
.field label, .lookup-form label { font-size: .82rem; font-weight: 750; color: #334155; }
input, select, textarea { width: 100%; padding: .68rem .78rem; border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; color: #111827; outline: none; transition: border-color .18s ease, box-shadow .18s ease; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-dark); box-shadow: 0 0 0 4px rgba(250, 204, 21, .22); }
textarea { min-height: 128px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.inline-form { display: flex; gap: .7rem; flex-wrap: wrap; align-items: end; }
.inline-form input, .inline-form select { min-width: 170px; }
.notice { padding: .8rem 1rem; background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 12px; margin-bottom: 1rem; color: #047857; font-weight: 650; }
.error-box { margin: -.2rem 0 1rem; padding: .85rem .95rem; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 12px; font-weight: 650; }

table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; background: var(--surface); }
th, td { padding: .82rem .95rem; border-bottom: 1px solid var(--border); text-align: left; }
th { font-weight: 800; }
.table-tools { display: grid; grid-template-columns: minmax(240px, 1fr) 190px; gap: .8rem; margin: 1rem 0; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.table-wrap th, .data-table th { position: sticky; top: 0; z-index: 1; background: #f8fafc; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: #475569; white-space: nowrap; cursor: pointer; user-select: none; }
.table-wrap th::after, .data-table th::after { content: '◇'; display: inline-block; margin-left: .45rem; color: #cbd5e1; font-size: .72rem; transition: transform .18s ease, color .18s ease; }
.table-wrap th.sorted-asc::after, .data-table th.sorted-asc::after { content: '▲'; color: #111827; }
.table-wrap th.sorted-desc::after, .data-table th.sorted-desc::after { content: '▼'; color: #111827; }
.table-wrap th:focus-visible, .data-table th:focus-visible { outline: 3px solid rgba(250, 204, 21, .35); outline-offset: -3px; }
.table-wrap tbody tr, .data-table tbody tr { transition: background-color .18s ease; }
.table-wrap tbody tr:hover, .data-table tbody tr:hover { background: #fffbeb; }
.table-wrap td, .data-table td { vertical-align: middle; }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; background: #ecfdf5; color: #047857; padding: .24rem .6rem; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.member-number { display: inline-flex; align-items: center; gap: .85rem; background: linear-gradient(135deg,#111827,#334155); color: white; border-radius: 16px; padding: .9rem 1rem; margin: 1rem 0 1.2rem; box-shadow: var(--shadow-md); }
.member-number span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #cbd5e1; font-weight: 750; }
.member-number strong { font-size: 1.35rem; letter-spacing: -.03em; }
.lookup-form { padding: 1rem; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius-md); margin: 1rem 0; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 18% 16%, rgba(250,204,21,.30), transparent 28%), linear-gradient(135deg, #0f172a 0%, #18243a 50%, #f8fafc 50%, #eef2f7 100%); }
.login-wrap::before { content: ''; position: fixed; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(135deg, #000 0%, transparent 72%); }
.login-card { position: relative; width: min(100%, 440px); background: rgba(255,255,255,.97); border: 1px solid rgba(226,232,240,.95); border-radius: var(--radius-lg); padding: 2rem; box-shadow: 0 28px 70px rgba(15, 23, 42, .22); }
.login-page-logo { margin-bottom: 1.65rem; }
.login-page-title { font-size: .86rem; font-weight: 850; letter-spacing: .14em; line-height: 1.35; text-transform: uppercase; color: #0f172a; }
.login-page-title span { display: block; }
.login-page-logo .brand-accent { margin-top: .8rem; }
.login-card h2 { font-size: 1.75rem; line-height: 1.18; font-weight: 800; letter-spacing: -.04em; color: #0f172a; }
.login-subtitle { margin: .45rem 0 1.55rem; font-size: .95rem; color: #64748b; }
.login-card .field { margin-bottom: 1rem; }
.login-card .field label { font-size: .82rem; font-weight: 780; color: #334155; }
.login-card input { height: 50px; padding: .75rem .9rem; border-radius: 13px; border-color: #cbd5e1; background: #fff; font-size: 1rem; }
.login-card .btn { width: 100%; min-height: 50px; margin-top: .2rem; border-radius: 13px; font-size: .95rem; }
.login-links { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); width: min(100% - 2rem, 440px); text-align: center; }
.login-links a, .login-links a:visited { display: inline-block; font-size: .9rem; font-weight: 650; color: rgba(255,255,255,.78); text-decoration: none; transition: color .18s ease; }
.login-links a:hover, .login-links a:focus { color: #fff; text-decoration: underline; }
.login-links a:not(:first-child) { margin-left: 1rem; }

@media (max-width: 1024px) {
    .app-container { display: block; }
    .sidebar { width: 100%; min-height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar-header { padding: 1rem 1rem .6rem; }
    .nav-section { display: flex; gap: .45rem; padding: .65rem 1rem 1rem; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
    .nav-heading { display: none; }
    .nav-item { flex: 0 0 auto; min-height: 38px; white-space: nowrap; background: #f8fafc; }
    .sub-item { margin-left: 0; }
    .sidebar-footer { display: none; }
    .main-content { min-height: calc(100vh - 94px); }
    .top-bar { height: auto; min-height: 64px; padding: .75rem 1rem; gap: .75rem; }
    .page-title { font-size: clamp(1.4rem, 5vw, 1.85rem); }
    .table-tools, .grid2 { grid-template-columns: 1fr; }
    .card-head { display: block; }
    .card-head .btn { margin-top: 1rem; width: 100%; }
    .inline-form { display: grid; grid-template-columns: 1fr; }
    .inline-form input, .inline-form select, .inline-form .btn { min-width: 0; width: 100%; }
}

@media (max-width: 640px) {
    .login-wrap { padding: 1rem; align-items: center; }
    .login-card { padding: 1.45rem; border-radius: 20px; }
    .login-card h2 { font-size: 1.45rem; }
    .login-links { position: static; transform: none; margin-top: 1rem; }
    .login-links a, .login-links a:visited { color: #475569; }
}
.activity-log { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.activity-log h4 { margin-bottom: .85rem; font-size: 1rem; color: #0f172a; }
.activity-list { display: grid; gap: .75rem; }
.activity-item { padding: .85rem .95rem; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 12px; }
.activity-item p { margin-top: .35rem; color: #334155; }
.nav-heading-nested { padding-top: .65rem; padding-left: 1.35rem; color: #334155; font-size: .64rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem .9rem; margin: .85rem 0 1rem; }
.checkbox-grid label { display: flex; align-items: center; gap: .5rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); font-weight: 650; color: #334155; }
.checkbox-grid input { width: auto; }
@media (max-width: 760px) { .checkbox-grid { grid-template-columns: 1fr; } }
.permission-groups { display: grid; gap: 1rem; margin: .85rem 0 1rem; }
.permission-group { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); padding: .9rem; }
.permission-group h5 { margin-bottom: .7rem; color: #0f172a; font-size: .86rem; text-transform: uppercase; letter-spacing: .08em; }
.permission-group label, .check-line { display: flex; align-items: center; gap: .55rem; margin: .45rem 0; font-weight: 650; color: #334155; }
.permission-group input, .check-line input { width: auto; }

.form-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }


@media (max-width: 640px) {
    body { font-size: 13px; }
    .btn { width: 100%; }
    .form-actions { display: grid; grid-template-columns: 1fr; }
    .member-number { width: 100%; justify-content: space-between; }
    .table-wrap { margin-inline: -.25rem; border-radius: 12px; }
    th, td { padding: .72rem .78rem; }
    .table-tools { gap: .65rem; }
}

.mobile-header { display: none; }
.hamburger-button { width: 44px; height: 44px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); }
.hamburger-button span { width: 20px; height: 2px; border-radius: 999px; background: #111827; transition: transform .18s ease, opacity .18s ease; }
.hamburger-button[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-button[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger-button[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.column-filter { min-width: 110px; margin-top: .45rem; padding: .42rem .5rem; border-radius: 8px; font-size: .74rem; text-transform: none; letter-spacing: 0; font-weight: 600; }
#membersTable th span { display: block; }
.member-row { cursor: pointer; }
.member-row.is-expanded { background: #fffbeb; }
.member-detail-row { display: none; }
.member-detail-row > td { padding: 0; background: #f8fafc; }
.inline-edit-card { padding: 1.1rem; border-top: 1px solid var(--border); }
.inline-edit-card h4 { margin-bottom: .5rem; font-size: 1rem; color: #0f172a; }
.members-card .table-tools { grid-template-columns: minmax(240px, 1fr); }

@media (max-width: 1024px) {
    .app-container { padding-top: 65px; }
    .mobile-header { position: fixed; top: 0; left: 0; right: 0; z-index: 30; min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
    .mobile-header .brand-title { margin-bottom: 0; }
    .sidebar { display: none; position: fixed; top: 65px; left: 0; right: 0; z-index: 25; max-height: calc(100vh - 65px); overflow: auto; box-shadow: var(--shadow-md); }
    .sidebar.is-open { display: flex; }
    .sidebar .sidebar-header { display: none; }
    .nav-section { display: grid; gap: .4rem; padding: .85rem 1rem 1rem; overflow: visible; }
    .nav-heading { display: block; padding-top: .75rem; }
    .nav-item { width: 100%; white-space: normal; }
    .top-bar { display: none; }
    .main-content { min-height: calc(100vh - 65px); }
}

@media (max-width: 640px) {
    .column-filter { min-width: 96px; }
    .inline-edit-card { padding: .85rem; }
}

.sidebar-meta { display: flex; align-items: center; justify-content: space-between; gap: .85rem; }
.logout-icon { width: 38px; height: 38px; flex: 0 0 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 11px; background: #f8fafc; color: #475569; text-decoration: none; font-size: 1.1rem; font-weight: 900; box-shadow: var(--shadow-sm); }
.logout-icon:hover { color: #111827; background: #fffbea; }
.icon-action { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: #111827; text-decoration: none; font-weight: 900; box-shadow: var(--shadow-sm); }
.icon-action:hover { background: #fffbea; border-color: var(--primary-dark); }
.btn-danger { background: #e5e7eb; border-color: #d1d5db; color: #374151; box-shadow: var(--shadow-sm); }
.btn-danger:hover { background: #d1d5db; }
.signature-pad { width: 100%; height: 220px; display: block; border: 1px dashed var(--border-strong); border-radius: 14px; background: #fff; touch-action: none; }
.member-edit-card { max-width: 1120px; }
.member-form .form-actions { margin-top: .25rem; }

@media (max-width: 1024px) {
    .sidebar-footer { display: block; }
}

/* Refinements for the membership module */
.brand-title { min-height: 2.1em; }
.nav-item { font-weight: 500; }
.nav-heading { font-weight: 850; }
.nav-heading-main::after { content: ''; display: block; width: 2rem; height: 3px; margin-top: .45rem; border-radius: 999px; background: var(--primary); }
.table-wrap th::after, .data-table th::after { content: none; }
.table-wrap th, .data-table th { cursor: pointer; }
.table-wrap th span, .data-table th span { display: inline; vertical-align: middle; }
.sort-glyph { margin-left: .45rem; color: #cbd5e1; font-size: .72rem; }
th.sorted-asc .sort-glyph, th.sorted-desc .sort-glyph { color: #111827; }
th.sorted-asc .sort-glyph { content: '▲'; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.kpi-card span { display: block; color: var(--text-muted); font-weight: 750; text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; }
.kpi-card strong { display: block; margin: .3rem 0; font-size: 2.4rem; line-height: 1; letter-spacing: -.06em; }
.legal-preview { margin: .45rem 0; padding: .7rem .85rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.legal-preview summary { cursor: pointer; font-weight: 700; }
.state-toggle { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--border); background: #e5e7eb; color: #6b7280; font-weight: 900; cursor: pointer; }
.state-toggle.paid.is-on { background: #22c55e; border-color: #16a34a; color: #fff; }
.state-toggle.cancelled.is-on { background: #facc15; border-color: #eab308; color: #111827; }
@media (max-width: 1024px) {
    .sidebar { display: flex; position: fixed; top: 65px; bottom: 0; left: 0; right: auto; width: 248px; max-width: calc(100vw - 3rem); z-index: 25; max-height: none; overflow: auto; box-shadow: var(--shadow-md); transform: translateX(-110%); transition: transform .2s ease; border-right: 1px solid var(--border); border-bottom: 0; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar .sidebar-header { display: flex; flex-direction: column; padding: 1.25rem 1.5rem 1rem; }
    .nav-section { display: block; padding: .65rem .9rem 1rem; overflow-y: auto; }
    .nav-heading { display: block; }
    .nav-item { width: 100%; background: transparent; white-space: normal; }
    .sub-item { margin-left: .55rem; }
}

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: stretch; }
.kpi-card, .chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.kpi-card-large { background: linear-gradient(135deg, #facc15, #f59e0b); color: #111827; }
.kpi-card span { display: block; font-weight: 850; text-transform: uppercase; letter-spacing: .09em; font-size: .75rem; }
.kpi-card strong { display: block; font-size: clamp(2.4rem, 6vw, 4.2rem); line-height: 1; margin: .65rem 0; }
.chart-card h3 { margin-bottom: 1rem; }
.bar-chart { min-height: 190px; display: flex; align-items: end; gap: .55rem; padding-top: 1.4rem; }
.bar-chart.compact { min-height: 145px; }
.bar-item { flex: 1; min-width: 28px; height: 170px; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: .35rem; color: var(--text-muted); font-size: .72rem; }
.compact .bar-item { height: 125px; }
.bar { width: 100%; max-width: 42px; border-radius: 10px 10px 4px 4px; background: linear-gradient(180deg, #facc15, #f59e0b); box-shadow: inset 0 -8px 14px rgba(120,53,15,.12); }
.bar-value { font-weight: 850; color: #0f172a; }
.horizontal-bars { display: grid; gap: .75rem; }
.hbar-row { display: grid; grid-template-columns: minmax(120px, 1fr) 42px; gap: .6rem; align-items: center; }
.hbar-row div { grid-column: 1 / -1; height: 10px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.hbar-row i { display: block; height: 100%; background: linear-gradient(90deg, #facc15, #f59e0b); border-radius: inherit; }
.login-wrap { background: radial-gradient(circle at 18% 16%, rgba(255,245,157,.42), transparent 28%), linear-gradient(135deg, #f59e0b 0%, #facc15 50%, #fff7cc 50%, #fffbea 100%); }
.sepa-modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(15,23,42,.58); }
.sepa-modal.is-open { display: flex; }
.sepa-dialog { width: min(100%, 760px); max-height: calc(100vh - 2rem); overflow: auto; background: #fff; border-radius: 20px; padding: 1.4rem; box-shadow: 0 28px 70px rgba(15,23,42,.28); }
@media (max-width: 1100px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Navigation and dashboard refresh */
.sidebar { position: sticky; top: 0; height: 100vh; }
.nav-section { min-height: 0; }
.sidebar-footer { margin-top: auto; background: rgba(255, 255, 255, .72); backdrop-filter: blur(12px); }
.nav-group { display: grid; gap: .22rem; padding: .2rem 0; }
.nav-heading { width: 100%; display: flex; align-items: center; justify-content: space-between; border: 0; background: transparent; cursor: pointer; text-align: left; }
.nav-chevron { transition: transform .18s ease; font-size: .9rem; color: #94a3b8; }
.nav-group.is-open .nav-chevron { transform: rotate(180deg); }
.nav-items { display: none; }
.nav-group.is-open .nav-items { display: grid; gap: .08rem; }
.nav-item { font-weight: 500; background: transparent; }
.sub-item { margin-left: 1.35rem; padding-left: .7rem; }
.nav-item.active { background: transparent; box-shadow: none; color: #111827; }
.nav-item:hover { background: transparent; color: #111827; }
.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.kpi-card, .kpi-card-large, .chart-card { background: #fff; border: 1px solid #eef2f7; border-radius: 18px; padding: 1.15rem; box-shadow: 0 18px 40px rgba(15,23,42,.05); }
.kpi-card-large { grid-column: span 4; min-height: 140px; }
.chart-card { grid-column: span 6; }
.chart-card:nth-child(3) { grid-column: span 8; }
.kpi-card-large span, .chart-card h3 { color: #64748b; }
.kpi-card-large strong { display: block; margin-top: .5rem; font-size: 2.5rem; letter-spacing: -.06em; }
.bar-chart { min-height: 180px; display: flex; gap: .7rem; align-items: end; padding-top: 1rem; }
.bar-item { flex: 1; display: grid; justify-items: center; gap: .35rem; color: #64748b; font-size: .75rem; }
.bar { width: 100%; max-width: 34px; min-height: 8px; border-radius: 999px 999px 6px 6px; background: linear-gradient(180deg,#6366f1,#facc15); }
.horizontal-bars { display: grid; gap: .8rem; margin-top: 1rem; }
.hbar-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; }
.hbar-row div { grid-column: 1 / -1; height: 9px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.hbar-row i { display: block; height: 100%; border-radius: inherit; background: #6366f1; }
.form-block { margin: 1rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: 16px; background: #fff; }
.form-block:has(input:valid), .legal-block:has(input:checked) { border-color: #86efac; background: #f0fdf4; }
.form-block h4 { margin-bottom: .8rem; font-size: 1rem; color: #0f172a; }
.legal-preview { background: rgba(255,255,255,.72); }
.login-links a, .login-links a:visited { color: #0f172a; background: rgba(255,255,255,.75); padding: .35rem .7rem; border-radius: 999px; }
.login-links a:hover, .login-links a:focus { color: #0f172a; background: #fff; }
@media (max-width: 1024px) {
  .sidebar { position: fixed; height: auto; }
  .nav-item { background: transparent; box-shadow: none; }
  .sub-item { margin-left: 1.1rem; }
  .dashboard-grid, .kpi-card-large, .chart-card, .chart-card:nth-child(3) { display: block; }
  .kpi-card-large, .chart-card { margin-bottom: 1rem; }
}

/* Cleaner navigation headings and separate template blocks */
.nav-heading {
    position: relative;
    min-height: 0;
    margin: .9rem 0 .2rem;
    padding: 0 .75rem 0 1.05rem;
    color: #94a3b8;
    font-size: .64rem;
    font-weight: 850;
    letter-spacing: .14em;
    line-height: 1.2;
    text-transform: uppercase;
    border-radius: 0;
    pointer-events: auto;
}
.nav-heading::before {
    content: '';
    position: absolute;
    left: .25rem;
    top: 50%;
    width: .35rem;
    height: .35rem;
    border-radius: 999px;
    background: #facc15;
    box-shadow: 0 0 0 4px rgba(250, 204, 21, .12);
    transform: translateY(-50%);
}
.nav-heading:hover,
.nav-heading:focus {
    background: transparent;
    color: #64748b;
    box-shadow: none;
}
.nav-chevron {
    display: none;
}
.nav-items {
    position: relative;
    padding: .1rem 0 .2rem;
}
.sub-item {
    position: relative;
    margin-left: .9rem;
    padding: .52rem .85rem .52rem 1rem;
    color: #64748b;
    border-radius: 9px;
}
.sub-item::before {
    content: '';
    position: absolute;
    left: .28rem;
    top: 50%;
    width: .25rem;
    height: .25rem;
    border-radius: 999px;
    background: #cbd5e1;
    transform: translateY(-50%);
    transition: background-color .18s ease, box-shadow .18s ease;
}
.sub-item:hover {
    color: #0f172a;
    background: rgba(248, 250, 252, .72);
}
.sub-item:hover::before {
    background: #94a3b8;
}
.sub-item.active {
    font-weight: 760;
    color: #0f172a;
    background: linear-gradient(90deg, rgba(250, 204, 21, .16), rgba(250, 204, 21, 0));
}
.sub-item.active::before {
    background: var(--primary-dark);
    box-shadow: 0 0 0 4px rgba(250, 204, 21, .22);
}
.template-card {
    border-radius: 18px;
    border-color: #eef2f7;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .05);
}
.template-card textarea {
    min-height: 260px;
}

/* TailAdmin-inspired page headers and dashboard cards */
.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-eyebrow,
.section-kicker,
.metric-label {
    display: block;
    color: #667085;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
    line-height: 1.2;
    text-transform: uppercase;
}
.page-title {
    margin: .35rem 0 .25rem;
    color: #101828;
    font-size: clamp(1.65rem, 2.4vw, 2.15rem);
    font-weight: 800;
    letter-spacing: -.04em;
}
.page-subtitle {
    max-width: 720px;
    color: #667085;
    font-size: .95rem;
}
.dashboard-shell { display: grid; gap: 1rem; }
.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}
.metric-card {
    position: relative;
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 1rem;
    align-items: center;
    min-height: 132px;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: 18px;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .05);
}
.metric-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #f3f6ff;
    display: grid;
    place-items: center;
}
.metric-icon::before {
    content: '';
    width: 22px;
    height: 22px;
    border: 2px solid #465fff;
    border-radius: 7px;
}
.metric-icon-users::before { border-radius: 999px; box-shadow: 12px 8px 0 -5px #465fff; }
.metric-icon-cube::before { transform: rotate(45deg); border-radius: 5px; }
.metric-icon-bell::before { border-radius: 11px 11px 7px 7px; border-bottom-width: 4px; }
.metric-card strong {
    display: block;
    margin: .25rem 0 .15rem;
    color: #101828;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -.045em;
    line-height: 1;
}
.metric-card span { color: #667085; font-size: .86rem; }
.metric-card em {
    align-self: end;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: #ecfdf3;
    color: #12b76a;
    font-size: .72rem;
    font-style: normal;
    font-weight: 800;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}
.chart-card,
.kpi-card,
.kpi-card-large {
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: 18px;
    padding: 1.25rem;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .05);
}
.chart-card { grid-column: span 6; }
.chart-card-wide { grid-column: span 8; }
.partner-card { grid-column: span 4; }
.chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.15rem;
}
.chart-head h3 {
    margin: .25rem 0 .15rem;
    color: #101828;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.015em;
}
.chart-head span { color: #667085; font-size: .82rem; }
.ghost-menu {
    width: 34px;
    height: 34px;
    border: 1px solid #eef2f7;
    border-radius: 999px;
    background: #fff;
    color: #98a2b3;
    cursor: default;
}
.bar-chart {
    min-height: 205px;
    display: flex;
    align-items: end;
    gap: .7rem;
    padding: .75rem .25rem .15rem;
    background-image: linear-gradient(to top, #f2f4f7 1px, transparent 1px);
    background-size: 100% 42px;
}
.bar-chart.compact { min-height: 155px; }
.bar-item {
    flex: 1;
    min-width: 30px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: end;
    align-items: center;
    gap: .38rem;
    color: #667085;
    font-size: .72rem;
}
.compact .bar-item { height: 130px; }
.bar {
    width: 100%;
    max-width: 34px;
    min-height: 9px;
    border-radius: 999px 999px 6px 6px;
    background: linear-gradient(180deg, #465fff 0%, #6d7dff 100%);
    box-shadow: 0 10px 20px rgba(70, 95, 255, .18);
}
.bar-value { color: #344054; font-weight: 800; }
.horizontal-bars { display: grid; gap: .9rem; }
.hbar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .5rem .75rem;
    align-items: center;
}
.hbar-row span { color: #344054; font-weight: 700; }
.hbar-row strong { color: #101828; }
.hbar-row div {
    grid-column: 1 / -1;
    height: 8px;
    border-radius: 999px;
    background: #f2f4f7;
    overflow: hidden;
}
.hbar-row i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #465fff, #9aa6ff);
}
@media (max-width: 1180px) {
    .dashboard-kpis { grid-template-columns: 1fr; }
    .chart-card,
    .chart-card-wide,
    .partner-card { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .page-heading { display: block; }
    .metric-card { grid-template-columns: 44px 1fr; }
    .metric-card em { grid-column: 2; justify-self: start; }
    .metric-icon { width: 44px; height: 44px; }
}

/* TailAdmin-style sidebar refresh */
.sidebar { background: #fff; border-right: 1px solid #eef2f7; box-shadow: 10px 0 30px rgba(15, 23, 42, .03); }
.brand-title::before { content: none; }
.brand-accent { width: 2.6rem; height: 2px; background: var(--primary); }
.nav-section { padding: .35rem .9rem 1rem; }
.nav-heading { display: flex; align-items: center; gap: .55rem; width: 100%; min-height: 38px; margin: .55rem 0 .12rem; padding: .55rem .65rem; border: 0; background: transparent; color: #111827; text-transform: none; letter-spacing: 0; font-size: .84rem; font-weight: 760; cursor: pointer; }
.nav-heading::before, .sub-item::before { content: none; }
.nav-heading:hover, .nav-heading:focus { background: #f8fafc; color: #111827; border-radius: 10px; }
.nav-heading-icon { width: 18px; height: 18px; display: inline-flex; color: #667085; }
.nav-heading-icon svg, .logout-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-heading-icon svg path:first-child:last-child { fill: currentColor; stroke: none; }
.nav-chevron { display: inline-flex; margin-left: auto; width: 16px; height: 16px; align-items: center; justify-content: center; color: #98a2b3; }
.nav-chevron::before { content: '⌃'; font-size: 1rem; line-height: 1; }
.nav-group:not(.is-open) .nav-chevron::before { content: '⌄'; }
.nav-items { display: grid; gap: .04rem; padding: .05rem 0 .32rem 2.1rem; }
.nav-group:not(.is-open) .nav-items { display: none; }
.sub-item { margin-left: 0; min-height: 28px; padding: .24rem .65rem; color: #475467; border-radius: 8px; font-size: .78rem; font-weight: 560; }
.sub-item:hover { background: #f8fafc; color: #101828; }
.sub-item.active { background: #f2f4f7; box-shadow: none; color: #101828; font-weight: 700; }
.logout-icon { color: #475467; }
.logout-icon:hover { background: #f8fafc; color: #111827; }

/* Form completion states: only turn green after all required fields in a block are valid. */
.form-block:has(input:valid), .legal-block:has(input:checked) { border-color: var(--border); background: #fff; }
.form-block:has(:is(input, select, textarea):required):not(:has(:is(input, select, textarea):required:invalid)),
.legal-block:has(input:checked) { border-color: #86efac; background: #f0fdf4; }
.consent-box { padding: .8rem .9rem; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; color: #475569; font-weight: 650; }
.login-link-editor { display: grid; gap: .7rem; margin-top: .35rem; padding: 1rem; border: 1px solid var(--border); border-radius: 14px; background: #f8fafc; }
.login-link-row { display: grid; grid-template-columns: 120px minmax(150px, 1fr) minmax(220px, 2fr); gap: .8rem; align-items: end; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.login-link-row .field, .login-link-row .check-line { margin-bottom: 0; }
.login-wrap { background: linear-gradient(135deg, #0f172a 0%, #18243a 48%, #f8fafc 48%, #eef2f7 100%); }
@media (max-width: 760px) { .login-link-row { grid-template-columns: 1fr; } }

.logout-icon { width: 30px; height: 30px; flex-basis: 30px; border-radius: 999px; background: transparent; box-shadow: none; color: #94a3b8; }
.logout-icon svg { width: 18px; height: 18px; }
.logout-icon:hover { background: #f1f5f9; color: #475569; }
.dashboard-actions { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.custom-dashboard .tile-small { grid-column: span 1; }
.custom-dashboard .tile-medium { grid-column: span 2; }
.custom-dashboard .tile-wide { grid-column: 1 / -1; }
.tile-editor-list { display: grid; gap: .8rem; margin: 1rem 0; }
.tile-editor-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: .8rem; padding: .85rem; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.tile-editor-row .field { margin-bottom: 0; }
.muted-row { background: #f8fafc; border-style: dashed; }
.radio-stack { display: grid; gap: .5rem; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; }
.radio-stack label { display: flex; gap: .55rem; align-items: center; font-weight: 650; color: #334155; }
.radio-stack input { width: auto; }
.password-first { margin: 1rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: 14px; background: #f8fafc; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; background: rgba(15, 23, 42, .55); }
.modal-backdrop[hidden] { display: none; }
.modal-card { position: relative; width: min(100%, 640px); max-height: 82vh; overflow: auto; padding: 1.5rem; border-radius: 18px; background: #fff; box-shadow: 0 28px 70px rgba(15, 23, 42, .28); }
.modal-card h3 { margin-bottom: .8rem; }
.modal-close { position: absolute; top: .75rem; right: .75rem; width: 34px; height: 34px; border: 0; border-radius: 999px; background: #f1f5f9; cursor: pointer; font-size: 1.2rem; }
@media (max-width: 900px) { .tile-editor-row { grid-template-columns: 1fr; } .custom-dashboard .tile-medium, .custom-dashboard .tile-wide { grid-column: 1 / -1; } }
.status-pill.payment-status-open { background: #f3f4f6; color: #4b5563; }
.status-pill.payment-status-paid { background: #ecfdf5; color: #047857; }
.status-pill.payment-status-cancelled { background: #fef9c3; color: #854d0e; }
.period-label { font-weight: 800; color: #111827; }
.dashboard-analytics-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.dashboard-analytics-row .chart-card:last-child { grid-column: 1 / -1; }
.compact-table { min-width: 420px; }
.grouped-bars small { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .dashboard-analytics-row { grid-template-columns: 1fr; } }

/* Dashboard and email protocol refinements */
.dashboard-kpi-hero {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.metric-card.metric-card-large {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: .9rem;
    padding: clamp(1.35rem, 3vw, 2rem);
    overflow: hidden;
}
.metric-card.metric-card-large .metric-label {
    max-width: 100%;
    overflow-wrap: anywhere;
    color: #78350f;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .09em;
}
.metric-card.metric-card-large strong {
    display: block;
    max-width: 100%;
    font-size: clamp(3rem, 9vw, 5.4rem);
    line-height: .95;
    letter-spacing: -.08em;
    overflow-wrap: anywhere;
}
.metric-card.metric-card-large span {
    color: #78350f;
    font-weight: 750;
}
.email-activity {
    border-color: #fde68a;
    background: #fffbeb;
}
.email-activity p {
    white-space: normal;
}
.payment-toggle-form {
    margin: 0;
}
.payment-state-cell {
    text-align: center;
    min-width: 86px;
}
.payment-state-cell .state-toggle {
    display: inline-grid;
    place-items: center;
}
.payment-date {
    display: block;
    margin-top: .35rem;
    white-space: nowrap;
}
@media (max-width: 760px) {
    .dashboard-kpi-hero {
        grid-template-columns: 1fr;
    }
    .metric-card.metric-card-large {
        min-height: 155px;
    }
    .map-card {
        min-height: auto;
    }
}

.status-table { min-width: 980px; }
.process-stream { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: .35rem 0; }
.process-step { position: relative; display: grid; justify-items: center; gap: .35rem; min-width: 128px; margin: 0; color: #6b7280; font-size: .76rem; font-weight: 800; text-align: center; }
.process-step:not(:last-child)::after { content: ''; position: absolute; top: 19px; left: calc(50% + 23px); width: calc(100% - 46px); border-top: 2px dashed #d1d5db; }
.process-circle { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 2px dashed #cbd5e1; border-radius: 999px; background: #f3f4f6; color: #6b7280; font-weight: 900; cursor: pointer; transition: .16s ease; }
.process-circle.is-on { border-style: solid; border-color: #f59e0b; background: #ffcc00; color: #111827; box-shadow: 0 8px 18px rgba(245, 158, 11, .22); }
.process-circle:hover { transform: translateY(-1px); border-color: #f59e0b; }
@media (max-width: 760px) { .process-step { min-width: 112px; } }
.state-toggle.reminder.is-on { background: #22c55e; border-color: #16a34a; color: #fff; }
hr { border: 0; border-top: 1px solid #e5e7eb; margin: 1.5rem 0; }

/* Membership page consistency and payment views */
html { font-size: 14px; }
.page-container { width: min(100% - 2rem, 1280px); }
.filter-buttons { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin: .85rem 0; }
.payment-state-cell { min-width: 104px; text-align: center; vertical-align: middle; }
.payment-toggle-form { display: inline-flex; justify-content: center; vertical-align: top; }
.payment-date, .payment-count { display: block; margin-top: .22rem; min-height: .86rem; font-size: .72rem; line-height: 1.2; white-space: nowrap; }
.pdf-link { display: inline-block; margin-top: .2rem; color: var(--text-muted); font-size: .72rem; font-weight: 650; line-height: 1.2; text-decoration: underline; text-underline-offset: 2px; }
.process-number { color: #111827; font-weight: 400; text-decoration: none; }
.filter-label { font-weight: 800; color: #78350f; }
.revenue-kpis { margin: 1rem 0; }
.revenue-kpis .kpi-card strong { font-size: clamp(1.5rem, 3vw, 2.4rem); }
.revenue-table tbody td { border-bottom-color: #fde68a; }
.payments-table th:nth-last-child(-n+3), .payments-table td:nth-last-child(-n+3) { text-align: center; width: 112px; }
.payments-table tr.is-cancelled td { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--text-muted); }
.payments-table tr.is-cancelled .payment-state-cell,
.payments-table tr.is-cancelled a,
.payments-table tr.is-cancelled button { text-decoration: none; }
.revenue-table { min-width: 980px; }
.matrix-group td { background: #eef2ff; color: #1e3a8a; font-weight: 850; }
.matrix-group summary { cursor: pointer; list-style-position: inside; }
.period-pies { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.period-pie-card { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-muted); }
.period-pie-card span { display: block; color: var(--text-muted); font-size: .86rem; }
.pie { width: 76px; height: 76px; flex: 0 0 76px; border-radius: 999px; background: conic-gradient(#22c55e 0 var(--paid-deg), #f59e0b var(--paid-deg) 360deg); box-shadow: inset 0 0 0 10px #fff; }
.legal-preview-output { padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); color: #334155; }
@media (max-width: 640px) { .page-container { width: min(100% - 1rem, 1280px); } .filter-buttons .btn { width: auto; flex: 1 1 auto; } }

.payment-state-cell { vertical-align: top; }
.payment-state-cell .state-toggle { margin-bottom: .22rem; }
.dashboard-kpi-hero-wide { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.dashboard-mini-table table { min-width: 640px; }
.revenue-month-row td { background: #fff7ed; font-weight: 850; }
.revenue-day-row td:first-child { padding-left: 1.6rem; color: var(--text-muted); }
