:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #cbd5e1;
  --border-light: #e2e8f0;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #15803d;
  --success-soft: #dcfce7;
  --radius-sm: 6px;
  --radius-md: 8px;
}

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

/* PROTEKSI TEKS / ANTI-COPY */
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, [contenteditable] {
  -webkit-user-select: auto;
  user-select: auto;
}

.hidden { display: none !important; }

/* OVERLAYS & MODALS */
.loading-overlay { position: fixed; inset: 0; background: var(--bg-card); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border-light); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9500; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; border-left: 4px solid var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.toast.error { border-left-color: var(--danger); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 9000; }
.modal-card { background: var(--bg-card); border-radius: var(--radius-md); width: 100%; max-width: 420px; padding: 20px; }
.modal-header h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-body { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* AUTH */
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); width: 100%; max-width: 400px; padding: 28px 24px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 20px; font-weight: 700; }
.auth-brand p { font-size: 13px; color: var(--text-muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-subtle); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.auth-tab { border: none; background: transparent; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-radius: 4px; cursor: pointer; }
.auth-tab.active { background: var(--bg-card); color: var(--text-main); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

/* FORMS */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-row-responsive { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.flex-1 { flex: 1 1 220px; }
.width-kelas { flex: 0 0 160px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; }
.form-input, .form-textarea, .dropdown-trigger { width: 100%; padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--text-main); background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); min-height: 44px; transition: border-color 0.15s ease; }
.form-input:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(29,78,216,0.12); }

/* CUSTOM DROPDOWN */
.custom-dropdown { position: relative; width: 100%; }
.dropdown-trigger { display: flex; align-items: center; justify-content: space-between; cursor: pointer; text-align: left; }
.custom-dropdown.open .dropdown-trigger { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(29,78,216,0.12); }
.custom-dropdown.open .dropdown-arrow { transform: rotate(180deg); color: var(--primary); }
.dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); box-shadow: 0 8px 20px rgba(0,0,0,0.1); list-style: none; z-index: 1000; display: none; padding: 4px; max-height: 220px; overflow-y: auto; }
.custom-dropdown.open .dropdown-menu { display: block; }
.dropdown-item { padding: 9px 10px; font-size: 14px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; }
.dropdown-item:hover { background: var(--bg-subtle); }
.dropdown-item.selected { background: #eff6ff; color: var(--primary); font-weight: 600; }
.dropdown-item.selected::after { content: "✓"; font-weight: 700; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; font-size: 13.5px; font-weight: 600; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; min-height: 44px; transition: 0.15s; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; min-height: 36px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-subtle); border-color: var(--border-color); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-danger-outline { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-outline { background: var(--bg-card); border-color: var(--border-color); }
.divider { display: flex; align-items: center; margin: 18px 0; color: var(--text-muted); font-size: 11px; font-weight: 600; }
.divider::before, .divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--border-light); }
.divider span { padding: 0 10px; }

/* TOPBAR & TABS */
.topbar { background: var(--bg-card); border-bottom: 1px solid var(--border-light); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 500; }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.header-logo { height: 34px; width: auto; object-fit: contain; }
.class-badge-container { display: flex; align-items: center; gap: 6px; background: #eff6ff; border: 1px solid #bfdbfe; padding: 4px 10px; border-radius: 20px; }
.badge-kelas { color: var(--primary); font-size: 13px; font-weight: 700; }
.class-logo { height: 20px; width: 20px; border-radius: 4px; object-fit: cover; background: #fff; }

.user-pill { display: flex; align-items: center; gap: 8px; background: var(--bg-subtle); border: 1px solid var(--border-light); padding: 4px 10px 4px 6px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }

.nav-tabs { background: var(--bg-card); border-bottom: 1px solid var(--border-light); display: flex; overflow-x: auto; white-space: nowrap; padding: 0 16px; gap: 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab { flex-shrink: 0; padding: 14px 4px; border: none; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; border-bottom: 2px solid transparent; cursor: pointer; }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* CONTENT & CARDS */
.main-content { max-width: 760px; margin: 0 auto; padding: 16px; }
.tab-pane { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 20px; }
.card-header-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* BALANCE CARD */
.balance-card { background: #090d16; color: #fff; border-radius: var(--radius-md); padding: 22px 20px; }
.balance-top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.balance-label { font-size: 12px; font-weight: 600; color: #94a3b8; }
.realtime-pill { background: rgba(29,78,216,0.25); color: #60a5fa; border: 1px solid rgba(96,165,250,0.3); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.balance-amount { font-size: 30px; font-weight: 700; margin-bottom: 10px; }
.balance-details { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; }
.detail-row { font-size: 13.5px; color: #e2e8f0; line-height: 1.4; }
.detail-row.text-muted { font-size: 12.5px; color: #94a3b8; }

/* LISTS & OTHERS */
.logs-list, .members-list, .users-directory-list { display: flex; flex-direction: column; gap: 10px; }
.log-item, .member-row, .user-dir-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); }
.log-left { display: flex; gap: 10px; }
.log-desc { font-weight: 600; font-size: 13.5px; }
.log-time { font-size: 12px; color: var(--text-muted); }
.log-amount.plus { color: var(--success); font-weight: 700; }
.log-amount.minus { color: var(--danger); font-weight: 700; }
.period-selector-group { display: flex; gap: 8px; align-items: center; }
.period-badge { background: var(--bg-subtle); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600; }
.status-paid-badge { background: var(--success-soft); color: var(--success); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 4px; }

/* AVATARS & PROFILE */
.avatar { border-radius: 50%; background: #0f172a; color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; object-fit: cover; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: 11px; }
.avatar-sm { width: 36px; height: 36px; font-size: 14px; }
.avatar-md { width: 48px; height: 48px; font-size: 18px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.profile-summary-box { display: flex; flex-wrap: wrap; gap: 16px; padding: 16px; background: var(--bg-subtle); border: 1px solid var(--border-light); border-radius: var(--radius-sm); margin: 16px 0; }
.profile-avatar-wrapper { display: flex; align-items: center; gap: 14px; }
.profile-photo-controls { display: flex; flex-direction: column; gap: 6px; }
.file-hint { font-size: 11.5px; color: var(--text-muted); }

/* CHAT */
.chat-card { height: 520px; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 4px; display: flex; flex-direction: column; gap: 12px; }
.chat-item { display: flex; gap: 10px; }
.chat-item.mine { flex-direction: row-reverse; }
.chat-bubble { max-width: 78%; background: var(--bg-subtle); border: 1px solid var(--border-light); padding: 10px 12px; border-radius: var(--radius-sm); }
.chat-item.mine .chat-bubble { background: #eff6ff; border-color: #bfdbfe; }
.chat-sender { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.chat-text { font-size: 13.5px; word-break: break-word; }
.chat-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-align: right; }
.chat-input-bar { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border-light); }
.empty-state { text-align: center; color: var(--text-muted); padding: 24px; font-size: 13.5px; }
