/* ============================================================
   style.css - UV Kavling Admin System
   ============================================================ */

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

:root {
  --navy:    #1a237e;
  --navy2:   #283593;
  --accent:  #3949ab;
  --light:   #e8eaf6;
  --white:   #ffffff;
  --border:  #dde1e7;
  --text:    #263238;
  --text2:   #546e7a;
  --shadow:  rgba(0,0,0,.12);
  --radius:  8px;

  --available: #e8f5e9;
  --sold:      #ffebee;
  --reserved:  #fff3e0;
  --blocked:   #f5f5f5;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f0f2f5;
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.auth-pending,
body.auth-locked {
  background: #eef2f7;
}

body.auth-pending > header,
body.auth-pending > .view,
body.auth-pending > #login-screen,
body.auth-pending > #edit-modal,
body.auth-pending > #modal-overlay,
body.auth-pending > #import-modal,
body.auth-pending > #proj-backdrop,
body.auth-pending > #proj-panel,
body.auth-pending > #new-block-dialog,
body.auth-pending > #toast-container,
body.auth-locked > header,
body.auth-locked > .view,
body.auth-locked > #edit-modal,
body.auth-locked > #modal-overlay,
body.auth-locked > #import-modal,
body.auth-locked > #proj-backdrop,
body.auth-locked > #proj-panel,
body.auth-locked > #new-block-dialog,
body.auth-locked > #toast-container {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  width: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(26,35,126,.92), rgba(57,73,171,.86)),
    radial-gradient(circle at top left, rgba(255,255,255,.2), transparent 34%),
    #1a237e;
}

body.auth-locked .login-screen {
  display: flex;
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0,0,0,.24);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--navy), var(--accent));
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.login-brand h1 {
  font-size: 24px;
  line-height: 1.1;
  color: var(--navy);
}

.login-brand p {
  margin-top: 4px;
  color: var(--text2);
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.login-field label {
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
}

.login-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(57,73,171,.13);
}

.login-error {
  min-height: 18px;
  color: #c62828;
  font-size: 12px;
  font-weight: 600;
}

.login-submit,
.logout-btn {
  border: 0;
  cursor: pointer;
  font-weight: 700;
  transition: background .15s, color .15s, transform .15s;
}

.login-submit {
  width: 100%;
  margin-top: 2px;
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
}

.login-submit:hover {
  background: var(--accent);
}

.login-submit:active,
.logout-btn:active {
  transform: translateY(1px);
}

/* ── Header ─────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--accent) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  box-shadow: 0 2px 8px var(--shadow);
  flex-shrink: 0;
  z-index: 10;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}
.logo span { opacity: .7; font-weight: 400; font-size: 12px; margin-left: 6px; }

header nav { display: flex; gap: 4px; }

.nav-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: rgba(255,255,255,.85);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: all .2s;
}
.nav-btn:hover, .nav-btn.active {
  background: rgba(255,255,255,.9);
  color: var(--navy);
  font-weight: 600;
}

.header-stats {
  display: flex;
  gap: 10px;
  margin-left: auto;
  align-items: center;
  min-width: 0;
}
.header-status-chips {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  overflow: hidden;
}
.stat-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.15);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
}
.stat-chip strong { font-size: 15px; }
.stat-available { color: #a5d6a7; }
.stat-sold      { color: #ef9a9a; }
.stat-reserved  { color: #ffcc80; }
.stat-blocked   { color: #bdbdbd; }

.logout-btn {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 16px;
  color: #fff;
  padding: 5px 12px;
  font-size: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}

.logout-btn:hover {
  background: #fff;
  color: var(--navy);
}

/* ── Views ───────────────────────────────────────────────── */
.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; }

/* ── MAP VIEW ────────────────────────────────────────────── */
#view-map {
  flex-direction: row;
  gap: 0;
  position: relative;
}

.map-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.map-toolbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.map-toolbar label { font-size: 12px; color: var(--text2); }
.map-toolbar select, .map-toolbar button {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}
.map-toolbar button { background: var(--light); color: var(--navy); font-weight: 600; transition: all .15s; }
.map-toolbar button:hover { background: var(--accent); color: #fff; }
#btn-lock-all   { color: #2e7d32; }
#btn-lock-all:hover   { background: #e8f5e9 !important; }
#btn-unlock-all { color: #e65100; }
#btn-unlock-all:hover { background: #fff3e0 !important; }
.map-toolbar .sep { width: 1px; height: 24px; background: var(--border); }

/* ── Burger menu ─────────────────────────────────────────── */
.burger-wrap {
  position: relative;
}
.burger-btn {
  background: var(--light) !important;
  color: var(--navy) !important;
  font-size: 18px !important;
  line-height: 1;
  padding: 3px 10px !important;
  border-radius: 6px !important;
  letter-spacing: 2px;
}
.burger-btn:hover, .burger-btn.active {
  background: var(--accent) !important;
  color: #fff !important;
}
.burger-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  min-width: 200px;
  padding: 6px 0;
  flex-direction: column;
}
.burger-menu.open { display: flex; }
.burger-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text2);
  padding: 8px 14px 4px;
  margin-top: 2px;
}
.burger-section:first-child { margin-top: 0; }
.burger-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s;
}
.burger-menu button:hover { background: var(--light); color: var(--navy); }
.burger-menu #btn-edit-pos.active { background: #e8f5e9; color: #2e7d32; font-weight: 700; }

.map-iuran-period {
  display: none;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}
.map-iuran-period-label {
  font-size: 11px;
  color: var(--text2);
  font-weight: 600;
}
.map-iuran-period select {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #c5cae9;
  border-radius: 5px;
  background: #f0f4ff;
  cursor: pointer;
}
.map-iuran-period-sep {
  font-size: 11px;
  color: var(--text2);
}

.map-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #eceff1;
}

#bg-img-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform-origin: top left;
  pointer-events: none;
  z-index: 1;
}
#bg-img-el {
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}

#plot-map {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: top left;
  z-index: 2;
  user-select: none;
  text-rendering: geometricPrecision;
  shape-rendering: geometricPrecision;
  will-change: transform;
}
#plot-map text {
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: subpixel-antialiased;
  paint-order: stroke fill;
}

/* Legend */
.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(255,255,255,.95);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  box-shadow: 0 2px 8px var(--shadow);
  pointer-events: none;
}
.map-legend h4 { font-size: 11px; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; }
.legend-item { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.legend-dot  { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid; }

/* Detail Panel */
/* ── Sidebar toggle tab ──────────────────────────────────── */
#sidebar-toggle {
  width: 18px;
  min-width: 18px;
  align-self: stretch;
  background: #f0f2f5;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
  color: var(--text2);
  font-size: 11px;
  padding: 0;
  flex-shrink: 0;
  transition: background .15s;
  z-index: 35;
}
#sidebar-toggle:hover { background: var(--light); color: var(--navy); }

#view-map.sidebar-collapsed #detail-panel { display: none; }

#detail-panel {
  position: absolute;
  right: 18px;   /* sits to the left of #sidebar-toggle (18px wide) */
  top: 0;
  bottom: 0;
  width: 300px;
  background: #fff;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 30;
  box-shadow: -3px 0 16px rgba(0,0,0,.12);
}

.panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text2);
  padding: 30px;
  gap: 10px;
}
.panel-icon { font-size: 36px; }
.hint { font-size: 11px; color: #90a4ae; margin-top: 8px; line-height: 1.6; }

.detail-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--accent) 100%);
  color: #fff;
  padding: 16px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.detail-id { font-size: 22px; font-weight: 700; }
.detail-id-wrap { flex: 1; min-width: 0; }
.detail-id-input {
  font-size: 22px; font-weight: 700; color: #fff;
  background: transparent; border: 1px solid transparent;
  border-radius: 5px; padding: 2px 4px; width: 100%;
  font-family: inherit; outline: none;
}
/* readonly = display mode (still clickable so dblclick works) */
.detail-id-input[readonly] { cursor: text; }
.detail-id-input[readonly]:hover { border-color: rgba(255,255,255,.25); }
/* editable mode after dblclick */
.detail-id-input:not([readonly]) { border-color: rgba(255,255,255,.8); background: rgba(255,255,255,.15); }
.detail-id-sub { font-size: 10px; opacity: .65; margin-top: 2px; padding-left: 4px; }
.detail-section { font-size: 12px; opacity: .8; margin: 2px 0 4px; text-align: right; }

.detail-body { padding: 14px 16px; flex: 1; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: 12px;
}
.detail-label {
  color: #5f7482;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .1px;
}
.detail-value {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  text-align: right;
  word-break: break-word;
  font-weight: 500;
}
.dp-editable {
  cursor: text;
  min-width: 0;
  max-width: 100%;
  width: auto;
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.dp-editable:hover { border-color: #dde3ee; }
.dp-editable.is-editing {
  border-color: #c5cae9;
  box-shadow: inset 0 0 0 1px rgba(63,81,181,.08);
}
.dp-inline-input,
.dp-inline-select {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: right;
  outline: none;
  margin: 0;
  padding: 0;
  line-height: inherit;
  border-radius: 0;
  appearance: none;
}
.dp-inline-input:focus,
.dp-inline-select:focus {
  box-shadow: inset 0 -2px 0 #7986cb;
}
.dp-chip-editor {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
  align-items: center;
}
.dp-chip-token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: default;
  max-width: 100%;
}
.dp-chip-remove {
  border: none;
  background: transparent;
  color: #607d8b;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  opacity: .8;
  padding: 0 1px;
}
.dp-chip-remove:hover { opacity: 1; color: #c62828; }
.dp-chip-text {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-chip-input {
  min-width: 112px;
  max-width: 180px;
  border: 1px solid #d1d9e6;
  border-radius: 10px;
  padding: 3px 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  text-align: right;
  outline: none;
}
.dp-chip-input:focus { border-color: #5c6bc0; box-shadow: 0 0 0 2px rgba(63,81,181,.14); }
.dp-status-picker {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
  align-items: center;
}
.dp-status-chip {
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.dp-status-chip:hover { filter: brightness(.98); transform: translateY(-1px); }
.detail-notes {
  margin-top: 12px;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text2);
  font-style: italic;
}
.detail-updated { font-size: 11px; color: #90a4ae; margin-top: 10px; }
.detail-actions {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* ── ADMIN/TABLE VIEW ────────────────────────────────────── */
#view-admin {
  flex-direction: column;
  overflow: hidden;
}

.admin-toolbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}
.search-box input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-icon {
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text2);
  pointer-events: none;
}

.admin-toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  outline: none;
}
.admin-toolbar select:focus { border-color: var(--accent); }

.count-badge {
  font-size: 12px;
  color: var(--text2);
  margin-left: auto;
}

/* Stats row */
.stats-row {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  background: var(--light);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tbl-status-cards {
  display: flex;
  gap: 10px;
  flex: 1;
}
.stat-card {
  flex: 1;
  background: #fff;
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px var(--shadow);
  border-left: 4px solid transparent;
}
.status-card { min-width: 130px; }
.stat-card.available { border-left-color: #43a047; }
.stat-card.sold      { border-left-color: #e53935; }
.stat-card.reserved  { border-left-color: #fb8c00; }
.stat-card.blocked   { border-left-color: #757575; }
.stat-card.total     { border-left-color: var(--accent); }
.stat-num  { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-lbl  { font-size: 11px; color: var(--text2); }

/* Table */
.table-wrapper {
  flex: 1;
  overflow: auto;
}
#admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
#admin-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--navy);
  color: #fff;
}
#admin-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}
#admin-table th[data-sort]:hover { background: var(--accent); }
#admin-table th.sort-asc::after  { content: ' ▲'; font-size: 10px; }
#admin-table th.sort-desc::after { content: ' ▼'; font-size: 10px; }

#admin-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
#admin-table tbody tr:hover { background: var(--light); }
#admin-table tbody tr:last-child { border-bottom: none; }
#admin-table td { padding: 10px 12px; vertical-align: middle; }
#admin-table th:last-child,
#admin-table td.action-cell { width: 92px; min-width: 92px; }
#admin-table th:nth-child(5),
#admin-table td:nth-child(5) { width: 220px; }
#admin-table tbody tr { height: 56px; }

.plot-badge {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  font-family: monospace;
}
.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.status-badge.status-dyn {
  background: #e8eaf6;
  color: #1a237e;
  border: 1px solid #c5cae9;
  text-transform: none;
  letter-spacing: 0;
}
.status-available { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.status-sold      { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.status-reserved  { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.status-blocked   { background: #f5f5f5; color: #616161; border: 1px solid #bdbdbd; }

.empty { color: #90a4ae; font-style: italic; }
.phone-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.phone-cell .cell-val { display: block; padding-right: 20px; }
.phone-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  background: #e8f4fd;
  border: 1px solid #90caf9;
  color: #0d47a1;
  font-size: 11px;
  text-decoration: none;
}
/* ── Multi-select bulk bar ───────────────────────────────── */
#bulk-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #e3f2fd;
  border-bottom: 1px solid #90caf9;
  font-size: 13px;
  font-weight: 600;
  color: #1565c0;
  flex-shrink: 0;
}
#bulk-count { margin-right: 4px; }

/* Checkbox column */
.cb-th { width: 36px; padding: 0 8px !important; }
.cb-cell { width: 36px; padding: 0 8px !important; }
.row-cb { cursor: pointer; width: 15px; height: 15px; accent-color: var(--accent); }
#admin-table th.cb-th,
#admin-table td.cb-cell { vertical-align: middle !important; }
#admin-table th.cb-th input,
#admin-table td.cb-cell .row-cb {
  display: block;
  margin: 0 auto;
}
#admin-table tbody tr.row-selected { background: #e8f4fd !important; }

/* ── Inline editing ──────────────────────────────────────── */
.editable-cell { position: relative; }
.editable-cell.editing { padding: 4px 6px !important; background: #fff9c4 !important; }
.edit-pencil {
  display: none;
  position: absolute; right: 3px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  padding: 0; line-height: 1;
  font-size: 11px; cursor: pointer;
  border: 1px solid #b0bec5; border-radius: 3px;
  background: #fff; color: #78909c;
  align-items: center; justify-content: center;
}
.editable-cell:hover .edit-pencil { display: inline-flex; }
.edit-pencil:hover { background: #e3f2fd; border-color: var(--accent); color: var(--accent); }
.cell-input {
  width: calc(100% - 28px);
  padding: 3px 6px;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  vertical-align: middle;
}
.cell-input:focus { box-shadow: 0 0 0 2px rgba(57,73,171,.15); }
.cell-confirm {
  width: 24px; height: 24px;
  margin-left: 3px;
  border: 1.5px solid #2e7d32;
  border-radius: 4px;
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  padding: 0;
  line-height: 1;
}
.cell-confirm:hover { background: #2e7d32; color: #fff; }

.action-cell { white-space: nowrap; }
.action-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 14px;
  transition: all .15s;
}
.btn-icon:hover { background: var(--light); border-color: var(--accent); }
.btn-del:hover  { background: #ffebee; border-color: #e53935; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .2s;
  text-decoration: none;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--navy); }
.btn-secondary { background: var(--light); color: var(--navy); border: 1px solid var(--border); }
.btn-secondary:hover { background: #c5cae9; }
.btn-danger    { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.btn-danger:hover { background: #c62828; color: #fff; }
.btn-success   { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.btn-success:hover { background: #2e7d32; color: #fff; }

/* ── Edit Panel (inside #detail-panel when in edit mode) ─── */
.edit-panel { padding: 2px 0; }
.ep-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.ep-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.ep-name-input {
  font-size: 15px; font-weight: 700; color: var(--navy);
  border: 1px solid transparent; border-radius: 5px;
  padding: 2px 6px; background: transparent;
  width: 0; flex: 1; min-width: 0;
  font-family: inherit; cursor: text; outline: none;
}
.ep-name-input:hover { border-color: var(--border); background: #f5f7ff; }
.ep-name-input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 2px rgba(57,73,171,.15); }
.ep-lock-status {
  font-size: 11px; padding: 3px 8px; border-radius: 12px;
  background: #fff3e0; color: #e65100; font-weight: 600;
}
.ep-lock-status.locked { background: #e8f5e9; color: #2e7d32; }

.ep-section { margin-bottom: 14px; }
.ep-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text2); margin-bottom: 8px;
}
.ep-info {
  text-align: center; font-size: 10px; font-family: monospace;
  color: #90a4ae; margin-top: 5px;
}
/* Info block (simplified panel) */
.ep-info-block {
  background: #f8f9fa; border-radius: 8px; padding: 10px 12px;
  margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px;
}
.ep-info-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text2);
}
.ep-info-row code {
  font-family: monospace; font-size: 11px; color: #546e7a;
  background: #eceff1; padding: 2px 6px; border-radius: 4px;
}
.ep-hint {
  font-size: 11px; color: var(--text2); line-height: 1.6;
  margin-bottom: 12px; padding: 8px; background: #f0f4ff;
  border-radius: 6px; border-left: 3px solid var(--accent);
}

/* D-pad */
.ep-dpad {
  display: grid; grid-template-columns: repeat(3, 38px);
  grid-template-rows: repeat(3, 38px); gap: 3px; justify-content: center; margin: 4px auto;
}
.dpad-btn {
  width: 38px; height: 38px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--light); color: var(--navy);
  font-size: 15px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; user-select: none; transition: all .1s;
}
.dpad-btn:hover  { background: var(--accent); color: #fff; border-color: var(--accent); }
.dpad-btn:active { transform: scale(.90); }
.dpad-ctr {
  width: 38px; height: 38px; display: flex; align-items: center;
  justify-content: center; font-size: 18px; color: #cfd8dc;
}
.ep-step-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text2); margin-top: 6px;
}
.ep-step-row input[type=range] { flex: 1; }

/* Rotation buttons */
.ep-rot-btns {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
}
.ep-rot-btns button {
  padding: 6px 2px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--light); color: var(--navy);
  font-size: 11px; cursor: pointer; white-space: nowrap;
  transition: all .1s;
}
.ep-rot-btns button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Action buttons */
.ep-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.ep-actions .btn { flex: 1; font-size: 12px; padding: 8px; }
.ep-global {
  display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border);
}
.ep-global .btn { flex: 1; font-size: 11px; padding: 6px; }

.btn-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.btn-warning:hover { background: #e65100; color: #fff; }
.btn-sm { font-size: 11px !important; padding: 5px 8px !important; }

/* ── Modal ───────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  display: none;
}
#edit-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.96);
  z-index: 101;
  background: #fff;
  border-radius: 12px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: none;
  opacity: 0;
  transition: all .2s;
}
#edit-modal.open, #edit-modal.open + #modal-overlay { display: block; }
#edit-modal.open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
/* Override overlay when modal open */
#edit-modal.open ~ * { pointer-events: none; }

.modal-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--accent) 100%);
  color: #fff;
  padding: 18px 22px;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 16px; }
.modal-header .section-info { font-size: 12px; opacity: .75; margin-top: 2px; }
.modal-close {
  background: none; border: none; color: rgba(255,255,255,.7);
  font-size: 20px; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: #fff; }

.modal-body { padding: 20px 22px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text2); text-transform: uppercase; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 70px; }
.modal-chip-editor,
.modal-status-editor { width: 100%; }
.modal-chip-editor-inner,
.modal-status-picker {
  justify-content: flex-start;
  min-height: 38px;
  padding: 6px 8px;
  border: 1px solid #dde3ee;
  border-radius: 10px;
}
.modal-chip-input { text-align: left; min-width: 140px; }
.dp-status-chip.active {
  box-shadow: 0 0 0 2px rgba(0,0,0,.14), inset 0 0 0 1px rgba(255,255,255,.35);
  transform: translateY(-1px) scale(1.01);
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Tooltip ─────────────────────────────────────────────── */
.map-tooltip {
  position: fixed;
  display: none;
  background: rgba(26,35,126,.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
  pointer-events: none;
  z-index: 50;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.3);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c5cae9; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Annotation toolbar — floats over map, no layout shift ── */
.ann-toolbar {
  display: none;
  position: absolute;
  top: 44px;
  left: 0; right: 0;
  z-index: 25;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #f8f9fd;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 3px 8px rgba(0,0,0,.08);
  flex-wrap: wrap;
}
.ann-toolbar.visible { display: flex; }

.iuran-toolbar {
  display: none;
  position: absolute;
  top: 44px;
  left: 0; right: 0;
  z-index: 24;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #f0f4ff;
  border-bottom: 2px solid #c5cae9;
  box-shadow: 0 3px 8px rgba(0,0,0,.08);
  flex-wrap: wrap;
}
.iuran-toolbar.visible { display: flex; }
.iuran-toolbar-label {
  font-size: 12px; font-weight: 700;
  color: var(--navy); white-space: nowrap;
}
.iuran-toolbar select {
  padding: 3px 7px;
  border: 1px solid #c5cae9;
  border-radius: 5px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
}
.ann-toolbar label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-right: 2px;
}

.ann-tool-btn {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  color: var(--text);
  white-space: nowrap;
}
.ann-tool-btn:hover  { background: var(--light); border-color: var(--accent); }
.ann-tool-btn.active { background: #e3f2fd; border-color: #1565c0; color: #1565c0; font-weight: 700; }

.ann-hint {
  display: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 25;
  padding: 6px 14px;
  background: #e3f2fd;
  border-top: 1px solid #90caf9;
  font-size: 12px;
  color: #1565c0;
}

#ann-sel-info {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  background: #e8f4fd;
  border: 1px solid #90caf9;
  border-radius: 6px;
  font-size: 12px;
}
.ann-sel-label { font-weight: 600; color: #1565c0; }
#ann-rot-handle circle { transition: r .1s; }
#ann-rot-handle circle:hover { r: 8; }

/* ── Background image panel ───────────────────────────────── */
.bg-panel {
  padding: 8px 14px;
  background: #eceff1;
  border-top: 1px solid #b0bec5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bg-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-upload {
  padding: 5px 12px;
  background: #fff;
  border: 1.5px solid #90a4ae;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: #37474f;
  font-weight: 600;
  white-space: nowrap;
}
.btn-upload:hover { background: #e0e0e0; }
.bg-btn {
  padding: 4px 10px;
  border: 1.5px solid #90a4ae;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  color: #37474f;
}
.bg-btn:hover    { background: #eceff1; }
.bg-btn-del      { border-color: #ef9a9a; color: #c62828; }
.bg-btn-del:hover{ background: #ffebee; }

/* ── New block dialog ─────────────────────────────────────── */
#new-block-dialog {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.45);
  align-items: center;
  justify-content: center;
}
.nb-box {
  background: #fff;
  border-radius: 12px;
  width: 380px;
  max-width: 95vw;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.nb-head {
  background: linear-gradient(135deg,#1b5e20,#388e3c);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
}
.nb-head button {
  background: none; border: none; color: rgba(255,255,255,.8);
  font-size: 20px; cursor: pointer; line-height: 1;
}
.nb-body { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nb-body .full { grid-column: 1 / -1; }
.nb-body label { display: block; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; margin-bottom: 4px; }
.nb-body input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: inherit; outline: none;
}
.nb-body input:focus { border-color: #388e3c; }
.nb-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Modern Enhancement Layer ────────────────────────────── */

/* Better shadows + hover lift on buttons */
.btn { box-shadow: 0 1px 3px rgba(0,0,0,.1); letter-spacing: .2px; }
.btn:hover  { box-shadow: 0 4px 12px rgba(0,0,0,.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.btn-danger:hover, .btn-success:hover, .btn-primary:hover, .btn-secondary:hover,
.btn-warning:hover { transform: translateY(-1px); }

/* detail-panel is absolutely positioned — see base rule above */

/* Subtle toolbar shadow */
.map-toolbar { box-shadow: 0 2px 6px rgba(0,0,0,.07); }

/* Slightly darker map canvas for contrast */
.map-container { background: #cfd8dc; }

/* Table zebra stripes */
#admin-table tbody tr:nth-child(even) { background: #fafbff; }
#admin-table tbody tr:nth-child(even):hover { background: var(--light); }

/* Better input focus ring */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { box-shadow: 0 0 0 3px rgba(57,73,171,.12); }

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px;
  color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  min-width: 220px; max-width: 320px;
  transform: translateX(120%); opacity: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  pointer-events: auto; cursor: default;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { background: linear-gradient(135deg,#1b5e20,#2e7d32); border-left: 4px solid #81c784; }
.toast-error   { background: linear-gradient(135deg,#b71c1c,#c62828); border-left: 4px solid #ef9a9a; }
.toast-warning { background: linear-gradient(135deg,#e65100,#f57c00); border-left: 4px solid #ffcc80; }
.toast-info    { background: linear-gradient(135deg,#1a237e,#3949ab); border-left: 4px solid #9fa8da; }
.toast-icon    { font-size: 18px; flex-shrink: 0; }

/* ── Quick Status Buttons (Detail Panel) ─────────────────── */
.qs-group {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 4px;
  padding: 10px 12px; background: #f5f7fa;
  border-bottom: 1px solid var(--border);
}
.qs-btn {
  padding: 7px 2px; border-radius: 6px; border: 1.5px solid;
  font-size: 10px; font-weight: 700; cursor: pointer;
  text-align: center; transition: all .15s;
  text-transform: uppercase; letter-spacing: .3px; line-height: 1.3;
}
.qs-available { background:#e8f5e9; color:#2e7d32; border-color:#a5d6a7; }
.qs-sold      { background:#ffebee; color:#c62828; border-color:#ef9a9a; }
.qs-reserved  { background:#fff3e0; color:#e65100; border-color:#ffcc80; }
.qs-blocked   { background:#f5f5f5; color:#616161; border-color:#bdbdbd; }
.qs-available.active { background:#2e7d32; color:#fff; border-color:#2e7d32; }
.qs-sold.active      { background:#c62828; color:#fff; border-color:#c62828; }
.qs-reserved.active  { background:#e65100; color:#fff; border-color:#e65100; }
.qs-blocked.active   { background:#616161; color:#fff; border-color:#616161; }
.qs-btn:not(.active):hover { filter: brightness(.94); transform: translateY(-1px); }

/* ── Detail Panel: copy & section label ─────────────────── */
.detail-id-row { display:flex; align-items:center; gap:4px; min-width:0; flex:1; }
.copy-id-btn {
  background:none; border:none; cursor:pointer; font-size:14px;
  opacity:.55; padding:2px 4px; border-radius:4px; flex-shrink:0;
  transition: opacity .15s, background .15s; color:#fff;
}
.copy-id-btn:hover { opacity:1; background:rgba(255,255,255,.2); }

/* ── Legend with live counts ─────────────────────────────── */
.map-legend { backdrop-filter: blur(4px); background: rgba(255,255,255,.92); }
.legend-item { justify-content: space-between; }
.legend-count {
  font-size: 11px; font-weight: 700; color: var(--navy);
  background: var(--light); border-radius: 8px; padding: 1px 7px; min-width: 24px; text-align: center;
}

/* ── Keyboard shortcut hints ─────────────────────────────── */
.kbd {
  display: inline-block; font-family: monospace; font-size: 10px;
  background: #eceff1; border: 1px solid #b0bec5; border-radius: 3px;
  padding: 1px 4px; color: #455a64; margin: 0 1px; vertical-align: middle;
}

/* ── Save/Load toolbar buttons ───────────────────────────── */
#btn-save { background:#e8f5e9 !important; color:#1b5e20 !important; border-color:#a5d6a7 !important; }
#btn-save:hover { background:#1b5e20 !important; color:#fff !important; }
#btn-load { background:#f3e5f5 !important; color:#6a1b9a !important; border-color:#ce93d8 !important; }
#btn-load:hover { background:#6a1b9a !important; color:#fff !important; }

/* ── Project Panel (dropdown) ────────────────────────────── */
@keyframes proj-shake {
  0%,100%{ transform:translateX(0) } 25%{ transform:translateX(-5px) } 75%{ transform:translateX(5px) }
}
#proj-backdrop {
  display:none; position:fixed; inset:0; z-index:290;
}
#proj-backdrop.open { display:block; }

#proj-panel {
  position:fixed; top:48px; right:8px; z-index:300;
  width:340px; max-height:calc(100vh - 60px);
  background:#fff; border-radius:12px;
  box-shadow:0 8px 32px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  border:1px solid #dde3ee;
  display:flex; flex-direction:column; overflow:hidden;
  visibility:hidden; opacity:0; transform:translateY(-6px) scale(.98);
  transition:opacity .15s, transform .15s, visibility 0s .15s;
}
#proj-panel.open {
  visibility:visible; opacity:1; transform:translateY(0) scale(1);
  transition:opacity .15s, transform .15s, visibility 0s;
}

.proj-panel-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px; background:#f4f6fb; border-bottom:1px solid #e8edf4;
  font-size:12px; font-weight:700; color:#3949ab; flex-shrink:0;
}
.proj-panel-head button {
  background:none; border:none; color:#90a4ae; cursor:pointer;
  font-size:15px; line-height:1; padding:0 2px;
}
.proj-panel-head button:hover { color:#e53935; }

.proj-panel-body { flex:1; overflow-y:auto; padding:10px 12px; min-height:0; }

.proj-save-row { display:flex; gap:6px; margin-bottom:10px; }
.proj-save-row input {
  flex:1; height:32px; padding:0 10px; font-size:12px;
  border:1.5px solid #dde3ee; border-radius:7px;
  outline:none; color:#263238; background:#fff;
  transition:border-color .15s;
}
.proj-save-row input::placeholder { color:#b0bec5; }
.proj-save-row input:focus { border-color:#5c6bc0; }
.proj-save-row > button {
  height:32px; width:36px; border-radius:7px; border:none;
  background:#3949ab; color:#fff; font-size:14px; cursor:pointer;
  transition:background .15s;
}
.proj-save-row > button:hover { background:#1a237e; }

.proj-slots-label {
  font-size:10px; font-weight:700; color:#90a4ae;
  text-transform:uppercase; letter-spacing:.6px; margin-bottom:6px;
}
#proj-slot-count { color:#5c6bc0; font-weight:600; }

.proj-empty {
  text-align:center; padding:18px 0 10px; color:#b0bec5; font-size:12px; line-height:1.7;
}
.proj-empty-icon { font-size:26px; margin-bottom:6px; }

.proj-card {
  display:flex; align-items:center; gap:8px;
  padding:8px 10px; margin-bottom:5px;
  border:1px solid #e8edf4; border-radius:8px; background:#fafbfd;
  transition:background .12s, border-color .12s;
}
.proj-card:hover { background:#eef2fb; border-color:#c5cae9; }
.proj-card-icon { font-size:16px; opacity:.6; flex-shrink:0; }
.proj-card-body { flex:1; min-width:0; }
.proj-card-name {
  font-size:12px; font-weight:600; color:#283593;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.proj-card-meta { font-size:10px; color:#90a4ae; margin-top:1px; }
.proj-card-actions { display:flex; gap:3px; flex-shrink:0; }
.proj-card-actions button {
  width:26px; height:26px; border-radius:6px; border:1px solid #dde3ee;
  background:#fff; font-size:12px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:background .12s;
}
.proj-act-load:hover { background:#e8f5e9; border-color:#81c784; }
.proj-act-exp:hover  { background:#e3f2fd; border-color:#64b5f6; }
.proj-act-del:hover  { background:#ffebee; border-color:#e57373; }

.proj-panel-foot {
  display:flex; gap:6px; padding:8px 12px;
  border-top:1px solid #e8edf4; background:#f4f6fb; flex-shrink:0;
}
.proj-panel-foot button {
  flex:1; height:30px; font-size:11px; font-weight:500;
  border:1px solid #dde3ee; border-radius:7px;
  background:#fff; color:#546e7a; cursor:pointer;
  transition:background .12s;
}
.proj-panel-foot button:hover { background:#e3f2fd; border-color:#64b5f6; color:#1565c0; }

/* ── Iuran Bulanan View ───────────────────────────────────── */
#view-iuran {
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}
.iu-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.iu-table-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
}
.iu-table {
  border-collapse: collapse;
  font-size: 12px;
  width: max-content;
  min-width: 100%;
}
.iu-table thead th {
  position: sticky;
  top: 0;
  background: #f4f6fb;
  border: 1px solid var(--border);
  padding: 5px 6px;
  white-space: nowrap;
  font-size: 11px;
  text-align: center;
  z-index: 2;
}
.iu-table thead tr:first-child th { z-index: 3; height: 30px; }
.iu-table thead .iu-subhead th { top: 30px; background: #f4f6fb; z-index: 2; }
.iu-table thead .iu-subhead .iu-th-fixed { z-index: 5 !important; }
.iu-th-id, .iu-th-blok, .iu-th-va, .iu-th-sum {
  position: sticky;
  left: 0;
  background: #f4f6fb;
  z-index: 4 !important;
  text-align: left;
}
.iu-table thead tr:first-child .iu-th-fixed { z-index: 6 !important; }
.iu-th-blok { left: 64px; }
.iu-th-va   { left: 128px; }
.iu-th-sum  { left: 322px; }
.iu-year-head {
  background: var(--light) !important;
  color: var(--navy);
  font-weight: 700;
  font-size: 12px !important;
}
.iu-th-month {
  font-size: 10px !important;
  min-width: 30px;
  line-height: 1.2;
}
.iu-row { cursor: pointer; }
.iu-row:hover td { background: #f0f4ff !important; }
.iu-row:nth-child(even) td { background: #fafbfc; }
.iu-table td {
  border: 1px solid #eef0f4;
  padding: 4px 6px;
  vertical-align: middle;
}
.iu-td-id, .iu-td-blok, .iu-td-va, .iu-td-sum {
  position: sticky;
  background: #fff;
}
.iu-td-id   { left: 0; min-width: 64px; }
.iu-td-blok { left: 64px; min-width: 64px; }
.iu-td-va   { left: 128px; min-width: 104px; font-size: 10px; color: #78909c; }
.iu-td-sum  { left: 322px; min-width: 56px; text-align: center; font-size: 12px; }
.iu-cell {
  text-align: center;
  font-size: 11px;
  min-width: 28px;
  font-weight: 600;
}
.iu-paid   { background: #e8f5e9; color: #2e7d32; }
.iu-unpaid { background: #ffebee; color: #c62828; }
.iu-empty  { color: #bdbdbd; font-weight: 400; }

/* ── Iuran Sidebar Section ───────────────────────────────── */
.iu-sidebar {
  margin: 8px 0 4px;
  border: 1px solid #e0e7ff;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9ff;
}
.iu-sb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  background: #e8eaf6;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
}
.iu-sb-va {
  padding: 4px 12px;
  font-size: 10px;
  color: #78909c;
  border-bottom: 1px solid #e8edf4;
}
.iu-sb-grid {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.iu-sb-year-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.iu-sb-yr {
  font-size: 10px;
  font-weight: 600;
  color: #546e7a;
  min-width: 30px;
}
.iu-sb-months { display: flex; gap: 2px; flex-wrap: wrap; }
.iu-sb-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  cursor: default;
}
.iu-sb-paid    { background: #c8e6c9; color: #2e7d32; }
.iu-sb-unpaid  { background: #ffcdd2; color: #c62828; }
.iu-sb-empty   { background: #f5f5f5; color: #bdbdbd; }
.iu-sb-outside { background: transparent; width: 18px; }
.iu-sb-status-chip {
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 10px;
}
.iu-sb-summary {
  display: flex; gap: 10px;
  padding: 4px 12px 2px;
  font-size: 11px; font-weight: 600;
}

/* Period selector */
.iu-period-wrap {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: #f0f2f5;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
}
.iu-period-label {
  font-size: 11px; font-weight: 600;
  color: var(--text2); white-space: nowrap;
}
.iu-period-wrap select {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
}

/* Table enhancements */
.iu-th-status, .iu-td-status {
  position: sticky;
  left: 232px;
  background: inherit;
}
.iu-th-wa, .iu-td-wa {
  position: sticky;
  left: 378px;
  background: inherit;
  min-width: 32px;
  text-align: center;
  padding: 2px !important;
}
.iu-th-fixed.iu-th-wa { background: #f4f6fb; }
.iu-td-fixed.iu-td-wa  { background: #fff; }
.iu-wa-btn {
  background: none; border: none;
  cursor: pointer; font-size: 14px;
  padding: 2px 3px; border-radius: 4px;
  opacity: 0.5; line-height: 1; display: inline-block;
}
.iu-wa-btn:hover { opacity: 1; background: #e8f5e9; }
.iu-no-hp {
  font-size: 13px; opacity: 0.35; cursor: default;
  display: inline-block; padding: 2px 3px;
}
.iu-paid-icon {
  font-size: 13px; font-weight: 700; color: #43a047;
  display: inline-block; padding: 2px 3px; cursor: default;
}
.wa-popover {
  background: #fff;
  border: 1px solid #e0e7ef;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  padding: 5px;
  display: flex; flex-direction: column; gap: 3px;
  min-width: 170px;
}
.wa-popover-btn {
  background: #f8f9fc; border: 1px solid #e8edf2;
  border-radius: 5px; padding: 6px 10px;
  font-size: 11px; cursor: pointer;
  text-align: left; color: #263238; white-space: nowrap;
}
.wa-popover-btn:hover { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.iu-th-status { min-width: 90px; }
.iu-td-fixed.iu-td-status { background: #fff; }
.iu-th-fixed.iu-th-status { background: #f4f6fb; }
.iu-status-chip { font-size: 11px; font-weight: 600; }
.iu-tunggakan {
  font-size: 10px; font-weight: 600;
  color: #c62828; margin-left: 4px;
}
.iu-in-period { background: #e8eaf6 !important; }
.iu-cell.iu-outside { background: #fafafa; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  #detail-panel { display: none; }
  .stats-row { flex-wrap: wrap; }
  .stat-card { min-width: calc(50% - 5px); }
  .form-row { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════
   Report Page — Screen + Print
   ══════════════════════════════════════════════════════════ */
#view-report {
  overflow-y: auto;
  background: #f0f2f7;
}

/* ── Wrapper & toolbar ─────────────────────────────────── */
.rpt-wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.rpt-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.rpt-period-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
}
.rpt-period-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.rpt-period-sep { font-size: 13px; color: #90a4ae; }
.rpt-period-select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
}
.rpt-gen-btn {
  background: #1565c0 !important;
  color: #fff !important;
  border: none !important;
  font-size: 12px !important;
  padding: 7px 18px !important;
  border-radius: 7px !important;
  font-weight: 700 !important;
  cursor: pointer;
  letter-spacing: .02em;
}
.rpt-gen-btn:hover  { background: #0d47a1 !important; }
.rpt-gen-btn:disabled { opacity: .6; cursor: wait; }
.rpt-print-btn {
  background: #546e7a !important;
  color: #fff !important;
  border: none !important;
  font-size: 12px !important;
  padding: 7px 14px !important;
  border-radius: 7px !important;
  font-weight: 600 !important;
  cursor: pointer;
}
.rpt-print-btn:hover { opacity: .88; }

/* ── Document container ────────────────────────────────── */
.rpt-doc {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0,0,0,.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Letterhead ────────────────────────────────────────── */
.rpt-letterhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 20px;
  background: linear-gradient(135deg, #1a2332 0%, #263248 100%);
  color: #fff;
  gap: 16px;
  flex-wrap: wrap;
}
.rpt-lh-left { display: flex; align-items: center; gap: 16px; }
.rpt-lh-logo {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -.5px;
  color: #fff;
  flex-shrink: 0;
}
.rpt-lh-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.rpt-lh-sub { font-size: 12px; color: rgba(255,255,255,.6); margin-top: 2px; }
.rpt-lh-right { text-align: right; }
.rpt-lh-date { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.9); }
.rpt-lh-period { font-size: 11px; color: rgba(255,255,255,.6); margin-top: 4px; }
.rpt-lh-period strong { color: rgba(255,255,255,.9); }

/* ── KPI Cards ─────────────────────────────────────────── */
.rpt-kpi-row {
  display: flex;
  flex-wrap: nowrap;
  border-bottom: 1px solid #eef0f5;
}
.rpt-kpi {
  flex: 1 1 0;
  min-width: 0;
  padding: 18px 16px 16px;
  border-right: 1px solid #eef0f5;
  text-align: center;
  position: relative;
}
.rpt-kpi:last-child { border-right: none; }
.rpt-kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 0;
}
.rpt-kpi-blue::before   { background: #3f51b5; }
.rpt-kpi-slate::before  { background: #546e7a; }
.rpt-kpi-green::before  { background: #2e7d32; }
.rpt-kpi-red::before    { background: #c62828; }
.rpt-kpi-orange::before { background: #f57c00; }
.rpt-kpi-val {
  font-size: 28px;
  font-weight: 900;
  color: #1a2332;
  line-height: 1;
  margin-bottom: 4px;
}
.rpt-kpi-lbl {
  font-size: 10px;
  color: #78909c;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  line-height: 1.3;
}

/* ── Section boxes ─────────────────────────────────────── */
.rpt-section-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #eef0f5;
}
.rpt-section-box {
  padding: 22px 28px;
  border-right: 1px solid #eef0f5;
}
.rpt-section-box:last-child { border-right: none; }
.rpt-section-full {
  border-right: none;
  border-bottom: 1px solid #eef0f5;
}
.rpt-section-full:last-child { border-bottom: none; }

.rpt-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #1a2332;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 18px;
}
.rpt-section-bar {
  display: inline-block;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  flex-shrink: 0;
}
.rpt-bar-blue   { background: #3f51b5; }
.rpt-bar-green  { background: #2e7d32; }
.rpt-bar-slate  { background: #546e7a; }
.rpt-bar-orange { background: #f57c00; }
.rpt-section-period {
  font-size: 11px;
  font-weight: 400;
  color: #90a4ae;
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
}

/* ── Stat list ─────────────────────────────────────────── */
.rpt-stat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* dot | icon | label | val | pct | bar */
.rpt-stat-row {
  display: grid;
  grid-template-columns: 10px 18px 1fr 36px 38px 1fr;
  align-items: center;
  gap: 7px;
}
.rpt-stat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rpt-stat-icon { font-size: 14px; line-height: 1; text-align: center; }
.rpt-stat-lbl  { font-size: 12px; color: #37474f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rpt-stat-val  { text-align: right; font-size: 13px; font-weight: 700; }
.rpt-stat-pct  { text-align: right; font-size: 11px; color: #90a4ae; }
.rpt-bar-wrap  { height: 5px; background: #eef0f5; border-radius: 3px; overflow: hidden; }
.rpt-bar-fill  { height: 100%; border-radius: 3px; transition: width .3s; }

/* ── Table ─────────────────────────────────────────────── */
.rpt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.rpt-table th {
  background: #f8f9fc;
  color: #546e7a;
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid #e8eaf0;
  white-space: nowrap;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.rpt-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f2f7;
  color: #37474f;
  font-size: 12px;
}
.rpt-table tbody tr:hover td { background: #f8f9fd; }
.rpt-table tfoot td {
  border-top: 2px solid #dde1ea;
  border-bottom: none;
  background: #f4f6fb;
  font-size: 12px;
}
.rpt-blk-name { font-weight: 700; color: #1a2332; }
.rpt-num { text-align: right; font-variant-numeric: tabular-nums; }
.rpt-th-sep { border-left: 2px solid #e0e4ed; padding-left: 14px !important; }
td.rpt-th-sep { border-left: 1px solid #e8eaf0; }
.rpt-lunas   { color: #2e7d32; font-weight: 600; }
.rpt-sebagian{ color: #e65100; font-weight: 600; }
.rpt-belum   { color: #c62828; font-weight: 600; }
.rpt-warn    { color: #f57c00; font-weight: 600; }

/* Inline bar in table */
.rpt-inline-bar-wrap {
  display: inline-block;
  width: 40px;
  height: 4px;
  background: #eef0f5;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
  overflow: hidden;
}
.rpt-inline-bar-fill { height: 100%; border-radius: 2px; display: block; }
.rpt-inline-pct { font-size: 11px; font-weight: 700; }

/* ── Tags ──────────────────────────────────────────────── */
.rpt-tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.rpt-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
}
.rpt-tag-click { cursor: pointer; transition: opacity .15s; }
.rpt-tag-click:hover { opacity: .75; }

/* ── Print footer ──────────────────────────────────────── */
.rpt-print-footer {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #90a4ae;
  padding: 14px 28px;
  border-top: 1px solid #eef0f5;
  background: #fafbfd;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 720px) {
  .rpt-section-2col { grid-template-columns: 1fr; }
  .rpt-section-box { border-right: none; border-bottom: 1px solid #eef0f5; }
  .rpt-stat-row { grid-template-columns: 16px 1fr 32px 36px; }
  .rpt-stat-row .rpt-bar-wrap { display: none; }
}

/* ══════════════════════════════════════════════════════════
   WA REMINDER MODAL
   ══════════════════════════════════════════════════════════ */
.wa-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.wa-modal {
  background: #fff;
  border-radius: 12px;
  width: 780px; max-width: 98vw;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  overflow: hidden;
}
.wa-modal-hdr {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 20px; gap: 12px;
  background: #1a2332; flex-shrink: 0;
}
.wa-modal-hdr-left { display: flex; flex-direction: column; gap: 3px; }
.wa-modal-title { font-size: 14px; font-weight: 700; color: #fff; }
.wa-modal-meta  { font-size: 11px; color: #8fa5b8; }
.wa-close-btn {
  background: none; border: none; color: #8fa5b8;
  font-size: 20px; cursor: pointer; padding: 0 2px; line-height: 1;
  flex-shrink: 0;
}
.wa-close-btn:hover { color: #fff; }
.wa-tpl-section {
  padding: 12px 20px 10px;
  border-bottom: 1px solid #e8edf2;
  background: #f8f9fc; flex-shrink: 0;
}
.wa-tpl-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.wa-tpl-label { font-size: 11px; font-weight: 700; color: #546e7a; }
.wa-tpl-vars  { font-size: 10px; color: #90a4ae; }
.wa-tpl-vars code {
  background: #e3e8ef; padding: 1px 4px; border-radius: 3px;
  font-size: 9.5px; color: #37474f; margin: 0 1px;
}
.wa-tpl-input {
  width: 100%; height: 110px;
  border: 1px solid #cfd8dc; border-radius: 6px;
  padding: 8px 10px; font-size: 11.5px; line-height: 1.55;
  font-family: inherit; resize: vertical; color: #263238;
  box-sizing: border-box;
}
.wa-tpl-input:focus { outline: none; border-color: #3949ab; }
.wa-list-hdr {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 20px; flex-shrink: 0;
  border-bottom: 1px solid #e8edf2;
  font-size: 11px; font-weight: 600; color: #546e7a;
  background: #f8f9fc;
}
.wa-list { overflow-y: auto; flex: 1; }
.wa-item {
  display: grid;
  grid-template-columns: 80px 1fr 1fr auto;
  align-items: center; gap: 10px;
  padding: 9px 20px;
  border-bottom: 1px solid #f0f2f5;
  transition: background .12s;
}
.wa-item:hover { background: #f5f7fb; }
.wa-item-id   { font-size: 13px; font-weight: 700; color: #1a2332; }
.wa-item-status { font-size: 10px; font-weight: 600; margin-top: 1px; }
.wa-item-months { font-size: 10px; color: #78909c; margin-top: 1px; }
.wa-item-owner  { font-size: 12px; color: #37474f; font-weight: 500; }
.wa-item-phone  { font-size: 11px; color: #78909c; margin-top: 2px; }
.wa-item-phones { display: flex; flex-direction: column; gap: 3px; }
.btn-wa {
  background: #e8f5e9; color: #2e7d32;
  border: 1px solid #a5d6a7;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 5px 11px; border-radius: 6px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn-wa:hover { background: #25D366; color: #fff; border-color: #25D366; }
.btn-wa:disabled { opacity: .45; cursor: not-allowed; }
.wa-phone-btn {
  background: #e8f5e9; color: #2e7d32;
  border: 1px solid #a5d6a7; border-radius: 5px;
  font-size: 10.5px; padding: 3px 8px; cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
.wa-phone-btn:hover { background: #25D366; color: #fff; border-color: #25D366; }
.wa-no-phone { font-size: 10px; color: #bdbdbd; font-style: italic; }

/* ══════════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════════ */
@media print {
  @page {
    size: A4;
    margin: 12mm 14mm;
  }

  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Hide all UI chrome */
  header, nav, #detail-panel, .nav-btn, .no-print,
  .rpt-toolbar, .rpt-print-btn, .admin-toolbar,
  .map-toolbar, .toast-container { display: none !important; }

  /* Full-width document */
  body { background: #fff !important; }
  #app, .main-content, #view-report, .rpt-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
  }
  .view { display: block !important; }
  .view:not(.active) { display: none !important; }

  .rpt-doc {
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Letterhead */
  .rpt-letterhead {
    -webkit-print-color-adjust: exact;
    background: #1a2332 !important;
    padding: 16px 20px !important;
  }

  /* KPI — 1 row, equal width, nothing cut off */
  .no-print    { display: none !important; }
  .rpt-kpi-row { flex-wrap: nowrap !important; }
  .rpt-kpi     { flex: 1 1 0 !important; min-width: 0 !important; padding: 10px 6px !important; }
  .rpt-kpi-val { font-size: 20px !important; }
  .rpt-kpi-lbl { font-size: 7.5px !important; letter-spacing: 0 !important; }

  /* Stat rows — prevent label truncation */
  .rpt-stat-row { grid-template-columns: 8px 16px 2fr 30px 30px 1fr !important; gap: 4px !important; }
  .rpt-stat-lbl { font-size: 10px !important; white-space: normal !important; overflow: visible !important; text-overflow: clip !important; }
  .rpt-stat-val { font-size: 11px !important; }
  .rpt-stat-pct { font-size: 9px !important; }

  /* Page breaks */
  .rpt-section-2col { page-break-inside: avoid; }
  .rpt-section-box  { page-break-inside: avoid; }
  .rpt-section-full { page-break-inside: avoid; }
  .rpt-table        { page-break-inside: auto; }
  .rpt-table tr     { page-break-inside: avoid; }

  /* Table fits on page */
  .rpt-table { font-size: 9pt !important; }
  .rpt-table th, .rpt-table td { padding: 4px 6px !important; }
  .rpt-table th { font-size: 7pt !important; }
  .rpt-blk-name { font-size: 9pt !important; }

  /* Footer visible on print */
  .rpt-print-footer { display: flex !important; }

  /* Bars */
  .rpt-bar-fill, .rpt-inline-bar-fill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
