:root {
  --primary: #059669;
  --primary-dark: #047857;
  --primary-light: #d1fae5;
  --secondary: #1e40af;
  --accent: #f59e0b;
  --danger: #dc2626;
  --bg: #f8fafc;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #059669;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
}

[data-theme="blue"] { --primary:#1e40af; --primary-dark:#1e3a8a; --primary-light:#dbeafe; --sidebar-active:#1e40af; }
[data-theme="red"]  { --primary:#dc2626; --primary-dark:#b91c1c; --primary-light:#fee2e2; --sidebar-active:#dc2626; }
[data-theme="purple"]{ --primary:#7c3aed; --primary-dark:#6d28d9; --primary-light:#ede9fe; --sidebar-active:#7c3aed; }
[data-theme="teal"] { --primary:#0d9488; --primary-dark:#0f766e; --primary-light:#ccfbf1; --sidebar-active:#0d9488; }

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

body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

/* Sidebar */
.sidebar { width: 260px; background: var(--sidebar-bg); min-height: 100vh; position: fixed; left: 0; top: 0; z-index: 100; display: flex; flex-direction: column; transition: width 0.3s; }
.sidebar.collapsed { width: 60px; }
.sidebar-logo { padding: 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.sidebar-logo .app-name { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-logo .app-sub { color: var(--sidebar-text); font-size: 11px; }
.sidebar.collapsed .app-name, .sidebar.collapsed .app-sub { display: none; }

.sidebar-menu { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-menu a { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--sidebar-text); text-decoration: none; font-size: 13.5px; transition: all 0.2s; border-radius: 0; }
.sidebar-menu a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-menu a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-menu a .icon { width: 20px; text-align: center; flex-shrink: 0; font-size: 16px; }
.sidebar-menu .label { white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .label { display: none; }
.sidebar-menu .section-title { padding: 8px 16px 4px; color: #475569; font-size: 10px; text-transform: uppercase; font-weight: 600; letter-spacing: 1px; }
.sidebar.collapsed .section-title { display: none; }
.submenu { display: none; }
.submenu.open { display: block; }
.submenu a { padding-left: 48px; font-size: 13px; }

/* Main Content */
.main-content { margin-left: 260px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left 0.3s; }
.sidebar.collapsed ~ .main-content { margin-left: 60px; }

/* Topbar */
.topbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.btn-toggle { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; padding: 6px; border-radius: 6px; }
.btn-toggle:hover { background: var(--bg); }
.page-title { font-weight: 600; font-size: 16px; color: var(--text); }

/* Avatar & dropdown */
.user-info { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-muted); }
.user-dropdown { position: absolute; top: 100%; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px 0; min-width: 180px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); display: none; z-index: 200; }
.user-dropdown.open { display: block; }
.user-dropdown a { display: flex; align-items: center; gap: 8px; padding: 8px 16px; color: var(--text); text-decoration: none; font-size: 13px; }
.user-dropdown a:hover { background: var(--bg); }
.user-dropdown .divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* Content area */
.content { padding: 24px; flex: 1; }

/* Cards */
.card { background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: 12px; padding: 20px; border: 1px solid var(--border); display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.blue  { background: #dbeafe; color: #1e40af; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red   { background: #fee2e2; color: #dc2626; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: all 0.2s; white-space: nowrap; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-warning { background: #fef3c7; color: #d97706; }
.btn-warning:hover { background: #fde68a; }
.btn-success { background: #d1fae5; color: #059669; }
.btn-success:hover { background: #a7f3d0; }
.btn-info { background: #dbeafe; color: #1e40af; }
.btn-info:hover { background: #bfdbfe; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* Forms */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  background: #fff; color: var(--text); transition: border-color 0.2s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5,150,105,0.1); }
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: auto; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d1fae5; color: #059669; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e2e8f0; color: #64748b; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid #059669; }
.alert-danger  { background: #fee2e2; color: #7f1d1d; border-left: 4px solid #dc2626; }
.alert-warning { background: #fef3c7; color: #78350f; border-left: 4px solid #d97706; }
.alert-info    { background: #dbeafe; color: #1e3a8a; border-left: 4px solid #3b82f6; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: 6px; font-size: 13px; border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.pagination a:hover { background: var(--primary-light); border-color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--text-muted); cursor: not-allowed; }

/* Search + filter bar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input { padding-left: 36px; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }
.per-page { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.per-page select { width: auto; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }

/* Instrument scoring */
.instrumen-table { width: 100%; }
.instrumen-komp { background: var(--primary); color: #fff; padding: 10px 14px; font-weight: 600; font-size: 13px; }
.instrumen-sub { background: var(--primary-light); padding: 8px 14px; font-weight: 600; font-size: 13px; color: var(--primary-dark); }
.instrumen-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--border); align-items: start; }
.instrumen-row:hover { background: #f8fafc; }
.instrumen-ind { font-size: 13px; }
.instrumen-ind .ind-no { font-weight: 600; color: var(--primary); margin-right: 6px; }
.instrumen-ind .bukti { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.skor-radio { display: flex; gap: 8px; }
.skor-radio label { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.skor-radio label span { width: 36px; height: 36px; border-radius: 8px; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; transition: all 0.2s; }
.skor-radio input { display: none; }
.skor-radio input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.skor-radio label small { font-size: 10px; color: var(--text-muted); }

/* Progress bar */
.progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-item { padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Announcement box */
.announcement { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #fff; border-radius: 12px; padding: 20px 24px; margin-bottom: 24px; }
.announcement h3 { font-size: 16px; margin-bottom: 6px; }
.announcement p { font-size: 13px; opacity: 0.9; }

/* Login page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--sidebar-bg) 0%, #0f172a 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; }
.login-logo h1 { font-size: 20px; font-weight: 700; margin-top: 12px; }
.login-logo p { font-size: 13px; color: var(--text-muted); }

/* Utility */
.gap-2 { gap: 8px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-danger { color: var(--danger); }
.text-success { color: #059669; }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* Spinner */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1e293b; color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 13px; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); min-width: 260px; animation: toastIn 0.3s ease; }
.toast.success { border-left: 4px solid #059669; }
.toast.error   { border-left: 4px solid #dc2626; }
.toast.warning { border-left: 4px solid #d97706; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* Activity log */
.log-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-item:last-child { border-bottom: none; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 4px; }
.log-meta { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

/* Charts placeholder */
.chart-wrapper { position: relative; }
canvas { max-width: 100%; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .label, .sidebar .section-title, .sidebar .app-name, .sidebar .app-sub { display: none; }
  .main-content { margin-left: 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .modal { max-width: 100%; }
}

@media print {
  .sidebar, .topbar, .btn, .modal-overlay { display: none !important; }
  .main-content { margin-left: 0; }
  .content { padding: 0; }
}

/* ── Instrumen row status indicators ──────────────────────────────────── */
.instrumen-row {
  transition: background 0.2s;
  border-left: 4px solid transparent;
}
.instrumen-row.row-answered {
  background: #f0fdf4 !important;
  border-left: 4px solid #059669;
}
.instrumen-row.row-answered .ind-no {
  background: #059669;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
}
.instrumen-row.row-unanswered {
  background: #fff7ed !important;
  border-left: 4px solid #f59e0b;
}
.instrumen-row.row-unanswered .ind-no {
  background: #f59e0b;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
}

/* Skor radio enhanced */
.skor-radio { display: flex; gap: 10px; align-items: flex-start; }
.skor-radio label {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; cursor: pointer; user-select: none;
}
.skor-radio label .skor-box {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px;
  transition: all 0.15s;
  background: #f8fafc;
  color: #94a3b8;
  position: relative;
}
.skor-radio label:hover .skor-box { transform: scale(1.08); }
.skor-radio label small {
  font-size: 9px; color: #94a3b8; white-space: nowrap; text-align: center;
}
/* 0 = Tidak ada */
.skor-radio.sel-0 label[data-val="0"] .skor-box,
.skor-radio label[data-val="0"] input:checked ~ .skor-box {
  background: #fee2e2; border-color: #fca5a5; color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.2);
}
/* 1 = Sebagian */
.skor-radio.sel-1 label[data-val="1"] .skor-box,
.skor-radio label[data-val="1"] input:checked ~ .skor-box {
  background: #fef3c7; border-color: #fde68a; color: #d97706;
  box-shadow: 0 0 0 3px rgba(217,119,6,0.2);
}
/* 2 = Seluruhnya */
.skor-radio.sel-2 label[data-val="2"] .skor-box,
.skor-radio label[data-val="2"] input:checked ~ .skor-box {
  background: #d1fae5; border-color: #6ee7b7; color: #059669;
  box-shadow: 0 0 0 3px rgba(5,150,105,0.2);
}
/* Checkmark overlay when selected */
.skor-radio label input:checked ~ .skor-box::after {
  content: '✓';
  position: absolute;
  top: -7px; right: -7px;
  width: 16px; height: 16px;
  background: currentColor;
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
}
