:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #243041;
  --muted: #6b7a8c;
  --line: #e2e8f0;
  --brand: #9b1c1c;
  --brand-dark: #7a1515;
  --brand-soft: #f8ecec;
  --ok: #157347;
  --ok-bg: #e8f6ee;
  --warn: #b45309;
  --warn-bg: #fff4e5;
  --danger: #b42318;
  --danger-bg: #fdecec;
  --info: #1d4f91;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 10px 28px rgba(16,24,40,.05);
  --radius: 14px;
  --sidebar: 250px;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --field-h: 46px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
.container { width: min(1200px, calc(100% - 2rem)); margin-inline: auto; }
h1,h2,h3,h4 { letter-spacing: -.01em; font-weight: 650; }

/* Auth */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 10% 10%, rgba(155,28,28,.12), transparent 40%),
    linear-gradient(160deg, #f7f8fa 0%, #eef2f6 55%, #f8ecec 100%);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
}
.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-brand .badge-org {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  padding: .35rem .7rem;
  border-radius: 999px;
  margin-bottom: .75rem;
}
.auth-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}
.auth-brand p { margin: .4rem 0 0; color: var(--muted); font-size: .92rem; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, #1b2430 0%, #141b24 100%);
  color: #e8eef5;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand strong { display: block; font-size: .95rem; line-height: 1.3; }
.sidebar-brand span { display: block; color: #9fb0c3; font-size: .75rem; margin-top: .25rem; }
.nav { padding: .75rem .6rem 1.5rem; display: grid; gap: .25rem; }
.nav a {
  color: #d5deea;
  padding: .7rem .8rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 600;
  font-size: .92rem;
}
.nav a:hover, .nav a.active {
  background: rgba(155,28,28,.92);
  color: #fff;
}
.nav .ico { width: 1.1rem; text-align: center; opacity: .9; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.user-chip {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: .35rem .75rem;
  font-size: .85rem;
  font-weight: 700;
}
.content { padding: 1.25rem; flex: 1; }
.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: .45rem .7rem;
  cursor: pointer;
}

/* Cards / stats */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 1.25rem 1.35rem; }
.card-header {
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
}
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.stat {
  padding: 1rem 1.1rem;
  display: grid;
  gap: .35rem;
}
.stat .label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat .value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.stat.brand { border-left: 4px solid var(--brand); }
.stat.ok { border-left: 4px solid var(--ok); }
.stat.warn { border-left: 4px solid var(--warn); }
.stat.info { border-left: 4px solid var(--info); }

/* Forms */
.form-grid {
  display: grid;
  gap: 1rem 1.15rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid > label {
  display: flex;
  flex-direction: column;
  gap: .42rem;
  min-width: 0;
  margin: 0;
  font-size: .86rem;
  font-weight: 600;
  color: #3d4d63;
  letter-spacing: .01em;
}
.form-grid > label > .hint {
  order: 3;
  font-weight: 450;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}
label {
  display: flex;
  flex-direction: column;
  gap: .42rem;
  font-size: .86rem;
  font-weight: 600;
  color: #3d4d63;
}
label .hint { font-weight: 450; color: var(--muted); font-size: .78rem; }
.req::before {
  content: none;
}
.req .lbl::after,
label.req::after {
  content: none;
}
/* Asterisk di teks label via span .req-mark agar tidak rusak grid */
.req-mark { color: var(--danger); font-weight: 700; margin-left: .15rem; }
.hint-required {
  color: var(--danger) !important;
  font-weight: 550;
}

input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  min-height: var(--field-h);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem .9rem;
  background: #fff;
  color: var(--ink);
  font-weight: 450;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7a8c' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .95rem center;
  padding-right: 2.4rem;
}
input[type=file] {
  width: 100%;
  min-height: var(--field-h);
  border: 1px dashed #c9d4e0;
  border-radius: 12px;
  padding: .65rem .85rem;
  background: #fafbfc;
  color: var(--muted);
}
textarea {
  min-height: 100px;
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #c45a5a;
  box-shadow: 0 0 0 3px rgba(155,28,28,.12);
}
input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(180,35,24,.12);
  background: #fff8f8;
}
.field-error {
  color: var(--danger) !important;
  font-weight: 550;
}
.form-photo-block {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}
.photo-pick {
  cursor: pointer;
  text-align: center;
  margin: 0;
}
.photo-pick input { display: none !important; }
@media (max-width: 480px) {
  .photo-actions { grid-template-columns: 1fr; }
}
.help {
  background: #fff8e8;
  border: 1px solid #f0d7a3;
  color: #7a4d00;
  border-radius: 12px;
  padding: .85rem 1rem;
  font-size: .86rem;
  font-weight: 500;
  line-height: 1.45;
}
.wizard-pane h3 {
  margin: 0 0 .25rem;
  font-size: 1.15rem;
  font-weight: 650;
  color: #1f2a3a;
}
.card-body .form-grid { margin-top: 1.15rem; }
.card-body .btn-group { margin-top: 1.25rem; }

.form-grid > label > .lbl,
label > .lbl {
  order: 0;
  display: block;
  line-height: 1.35;
}
.form-grid > label > input,
.form-grid > label > select,
.form-grid > label > textarea,
label > input,
label > select,
label > textarea {
  order: 1;
}
.form-grid > label > .hint,
label > .hint {
  order: 2;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: .7rem 1.1rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  background: #eef2f6;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
}
.btn:hover { filter: brightness(.97); color: inherit; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-success { background: var(--ok); color: #fff; }
.btn-warning { background: #d97706; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); }
.btn-sm { padding: .35rem .6rem; font-size: .82rem; border-radius: 8px; }
.btn-group { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Table */
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
table.data th, table.data td {
  padding: .65rem .7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
table.data th {
  background: #f7fafc;
  color: #425466;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data tr:hover td { background: #fafbfc; }
.avatar {
  width: 36px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eee;
  display: block;
}
.avatar-empty { min-width: 36px; }

/* Members table tidy layout */
.members-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}
.members-table { min-width: 980px; }
.members-table .nowrap { white-space: nowrap; }
.members-table .col-no { width: 44px; text-align: center; color: var(--muted); }
.members-table .col-foto { width: 52px; }
.members-table th, .members-table td {
  text-align: center;
  vertical-align: middle;
}
.members-table .col-jk { width: 100px; white-space: nowrap; }
.members-table .col-nama { min-width: 140px; max-width: 220px; }
.members-table .col-aksi {
  min-width: 300px;
  text-align: center;
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -8px 0 12px rgba(16,24,40,.04);
  z-index: 2;
}
.members-table thead .col-aksi { background: #f7fafc; z-index: 3; }
.members-table tr:hover .col-aksi { background: #fafbfc; }
.members-table .col-status { width: 96px; }
.row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: .3rem;
}
.row-actions-scroll {
  display: flex;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  justify-content: flex-start;
  padding-bottom: .15rem;
}
.row-actions .act-form { display: inline; margin: 0; flex: 0 0 auto; }
.row-actions .act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: .75rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1;
  flex: 0 0 auto;
}
.row-actions .act:hover { border-color: #c9d4e0; background: #f8fafc; color: #0f172a; }
.row-actions .act-danger {
  border-color: #f3c1c1;
  background: #fdecec;
  color: var(--danger);
}
.row-actions .act-danger:hover { background: #fadada; }
.filter-actions { align-self: end; }
.filter-actions .btn { width: auto; flex: 0 0 auto; }

/* Mobile member cards */
.members-cards { display: none; padding: .75rem; gap: .75rem; }
.member-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: .9rem;
  display: grid;
  gap: .75rem;
}
.member-card-top {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: .75rem;
  align-items: center;
}
.member-card-meta { display: grid; gap: .2rem; min-width: 0; }
.member-card-meta strong { font-size: .98rem; line-height: 1.3; }
.member-card-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .2rem; }
.chip-text {
  display: inline-flex;
  align-items: center;
  background: #eef2f6;
  color: #334155;
  border-radius: 999px;
  padding: .15rem .55rem;
  font-size: .72rem;
  font-weight: 650;
}
.member-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem .7rem;
  margin: 0;
}
.member-card-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
}
.member-card-grid dd {
  margin: .1rem 0 0;
  font-size: .86rem;
  font-weight: 650;
  word-break: break-word;
}
.desktop-only { display: block; }

@media (max-width: 860px) {
  .members-cards { display: grid; }
  .desktop-only { display: none !important; }
  .members-table .col-aksi { position: static; box-shadow: none; }
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: 999px;
  padding: .2rem .55rem;
  font-size: .75rem;
  font-weight: 700;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: #eef2f6; color: #526275; }

/* Wizard */
.steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .55rem;
  margin-bottom: 1.15rem;
}
.step {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem .8rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.step.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.step.done { border-color: #86efac; color: var(--ok); background: var(--ok-bg); }
.wizard-pane { display: none; }
.wizard-pane.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Profile */
.profile-hero {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  align-items: center;
}
.profile-photo {
  width: 110px;
  height: 146px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eee;
}
.kv { display: grid; grid-template-columns: 200px 1fr; gap: .4rem .75rem; font-size: .92rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

/* Alerts / toast */
.alert {
  border-radius: 10px;
  padding: .8rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: .92rem;
}
.alert-success { background: var(--ok-bg); color: var(--ok); border: 1px solid #b7e4c7; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c1c1; }
.alert-info { background: #e8f1fb; color: var(--info); border: 1px solid #bfd3f0; }
.toast-wrap {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: grid;
  gap: .5rem;
}
.chart-card .chart-wrap {
  height: 280px;
  position: relative;
}
.chart-card .chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
@media (max-width: 860px) {
  .chart-card .chart-wrap { height: 260px; }
}
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.pagination { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination span {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: .35rem .65rem;
  color: var(--ink);
  font-weight: 700;
  font-size: .85rem;
}
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.filters { display: grid; gap: .75rem; grid-template-columns: 2fr repeat(3, 1fr) auto; align-items: end; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.loading-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  transform: translateX(-100%);
  animation: load 1s linear infinite;
  z-index: 200;
  display: none;
}
.loading-bar.on { display: block; }
@keyframes load { to { transform: translateX(100%); } }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 30;
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; gap: .15rem; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .profile-hero { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .content { padding: .9rem; }
  .card-body { padding: 1rem; }
  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .step { font-size: .75rem; padding: .6rem .55rem; }
  .topbar h1 { font-size: 1rem; }
}
@media (max-width: 480px) {
  .steps { grid-template-columns: 1fr 1fr; gap: .4rem; }
  .btn { width: 100%; }
  .btn-group { width: 100%; }
  .btn-group .btn { flex: 1; }
}
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main, .content { padding: 0; }
  body { background: #fff; }
}
