/* AQM — Agent Quality Management. Tema gelap konsisten (CSS vars sesuai konvensi). */

:root {
  --bg: #0f1420;
  --surface: #161d2e;
  --surface-2: #1d2740;
  --border: #28324a;
  --text: #e2e8f0;
  --text-muted: #8b93a7;
  --accent: #3b82f6;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
pre.wrap { white-space: pre-wrap; word-break: break-word; font-family: inherit; }

/* ---------- layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.logo {
  width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; color: #fff;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-muted); }
.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--text-muted); font-weight: 500; display: block;
}
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; gap: 10px; align-items: center; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.user-name { font-weight: 600; font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 17px; font-weight: 650; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.content { padding: 22px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- komponen ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
}
.card + .card { margin-top: 14px; }
.card h2, .card h3 { font-size: 15px; font-weight: 650; margin-bottom: 10px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) { .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid-2, .grid-4, .grid-6 { grid-template-columns: 1fr; } }

.stat-card .stat-value { font-size: 24px; font-weight: 700; }
.stat-card .stat-label { color: var(--text-muted); font-size: 12px; }

.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 550;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2f6fe0; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

.input, select.input, textarea.input {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit;
}
textarea.input { min-height: 74px; resize: vertical; }
.input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--accent); }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
table.table th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; cursor: pointer; user-select: none; white-space: nowrap; }
table.table th.sorted-asc::after { content: ' ↑'; }
table.table th.sorted-desc::after { content: ' ↓'; }
table.table tbody tr:hover { background: var(--surface-2); }
table.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge.ok { background: rgba(22, 163, 74, 0.15); color: #4ade80; border-color: rgba(22, 163, 74, 0.4); }
.badge.err { background: rgba(220, 38, 38, 0.15); color: #f87171; border-color: rgba(220, 38, 38, 0.4); }
.badge.warn { background: rgba(217, 119, 6, 0.15); color: #fbbf24; border-color: rgba(217, 119, 6, 0.4); }
.badge.info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border-color: rgba(59, 130, 246, 0.4); }
.badge.mute { opacity: 0.7; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; }

.toast-container { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--success);
  border-radius: 8px; padding: 10px 14px; min-width: 260px; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slideIn .18s ease-out;
}
.toast.err { border-left-color: var(--danger); }
.toast-title { font-weight: 650; font-size: 13px; }
.toast-msg { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 10, 18, 0.72); z-index: 500;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 560px; max-width: 100%;
  padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal.wide { width: 880px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.empty-state { padding: 30px; text-align: center; color: var(--text-muted); }
.es-icon { font-size: 30px; margin-bottom: 6px; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

.detail-grid { display: grid; grid-template-columns: 170px 1fr; row-gap: 6px; column-gap: 12px; font-size: 13px; }
.detail-grid dt { color: var(--text-muted); }
.detail-grid dd { word-break: break-word; }

.audio-player { width: 100%; }
.hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.kv-list { font-size: 13px; }
.kv-list > div { display: flex; gap: 8px; padding: 3px 0; }
.kv-list .k { color: var(--text-muted); min-width: 130px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at top, #16213c, var(--bg)); }
.login-box { width: 380px; max-width: 92vw; }
.login-logo { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 18px; }

.chart-box { width: 100%; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input { width: 220px; }
.toolbar select.input { width: auto; }

.clickable { cursor: pointer; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.uplot { font-family: inherit; }
