/* DPM — tema gelap konsisten (CSS vars sesuai konvensi platform). */
:root {
  --bg: #0f1420;
  --surface: #161d2e;
  --surface-2: #1d2740;
  --border: #28324a;
  --text: #e2e8f0;
  --text-muted: #8b93a7;
  --accent: #3b82f6;
  --success: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  font-family: system-ui, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.boot-splash { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; color: var(--text-muted); gap: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout utama */
.layout { display: flex; height: 100vh; }
.sidebar { width: 230px; flex: 0 0 230px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar .logo { padding: 18px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
.sidebar .logo .sub { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text-muted); margin-bottom: 2px; font-weight: 500; }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.sidebar nav a.active { background: var(--surface-2); color: var(--text); }
.sidebar .foot { padding: 12px 16px; border-top: 1px solid var(--border); }
.role-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--accent); border: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; flex: 0 0 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 14px; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-muted); font-size: 12px; }
.content { flex: 1; overflow-y: auto; padding: 20px; }

/* Komponen umum */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 550; }
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

.input, select.input, textarea.input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; }
textarea.input { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; resize: vertical; }
label.fld { display: block; margin-bottom: 10px; font-size: 12px; color: var(--text-muted); }
label.fld > span { display: block; margin-bottom: 4px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; user-select: none; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table tr:hover td { background: rgba(59, 130, 246, 0.06); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-green { background: rgba(22, 163, 74, 0.16); color: #4ade80; }
.badge-gray { background: rgba(139, 147, 167, 0.16); color: var(--text-muted); }
.badge-yellow { background: rgba(217, 119, 6, 0.16); color: #fbbf24; }
.badge-red { background: rgba(220, 38, 38, 0.16); color: #f87171; }
.badge-blue { background: rgba(59, 130, 246, 0.16); color: #7db1f9; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 8, 15, 0.72); display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: min(720px, 94vw); max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

#toast-wrap { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 11px 16px; border-radius: 8px; font-size: 13px; max-width: 380px; animation: slidein 0.18s ease; }
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .title { font-weight: 650; margin-right: 6px; }
.pill { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.hintbar { background: rgba(59, 130, 246, 0.1); border: 1px dashed var(--accent); border-radius: 8px; padding: 8px 14px; font-size: 12.5px; color: #9ec2f7; margin-bottom: 10px; display: none; }

/* ── Canvas-lite ───────────────────────────────────────────────── */
.canvas-layout { display: flex; gap: 14px; height: calc(100vh - 160px); min-height: 480px; }
.canvas-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.canvas-wrap { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; position: relative; }
svg.canvas { width: 100%; height: 100%; display: block; cursor: default; background: #0c111c; }
svg.canvas.panning { cursor: grabbing; }
svg.canvas.edge-mode { cursor: crosshair; }

.dnode { cursor: grab; }
.dnode rect.box { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.6; rx: 8; }
.dnode.status-active rect.box { stroke: #2f9e5f; }
.dnode.status-deprecated rect.box { stroke: #566077; fill: #141a2a; }
.dnode.status-draft rect.box { stroke: var(--warn); }
.dnode.is-group rect.box { stroke-width: 3.4; }
.dnode text.nlabel { fill: var(--text); font-size: 12px; font-weight: 600; }
.dnode text.nsub { fill: var(--text-muted); font-size: 9.5px; }
.dnode.status-deprecated text.nlabel { fill: var(--text-muted); text-decoration: line-through; }
.dnode.selected rect.box { stroke: var(--accent); stroke-width: 2.6; filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.55)); }
.dnode.edge-src rect.box { stroke: #f59e0b; stroke-width: 2.6; stroke-dasharray: 5 3; }
.dnode:hover rect.box { filter: brightness(1.22); }

path.edge { stroke: #4d5a78; stroke-width: 1.8; fill: none; pointer-events: stroke; cursor: pointer; }
path.edge:hover { stroke: var(--accent); stroke-width: 2.4; }
.edge-selected { stroke: var(--accent) !important; stroke-width: 2.4 !important; }
.qtype-tag { font-size: 9px; font-weight: 700; letter-spacing: 0.4px; fill: #9ec2f7; }

/* Panel detail kanan */
.detail-panel { width: 400px; flex: 0 0 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow-y: auto; }
.detail-panel h3 { margin: 0 0 4px; font-size: 15px; word-break: break-all; }
.detail-panel .meta { color: var(--text-muted); font-size: 11.5px; margin-bottom: 12px; }
.detail-panel .section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.detail-panel .section h4 { margin: 0 0 8px; font-size: 12.5px; color: var(--text-muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.5px; }
.sql-edit { min-height: 220px; tab-size: 2; font-size: 12.5px; line-height: 1.5; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Diff viewer */
.diffbox { font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.55; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 340px; overflow: auto; white-space: pre; }
.diffbox .add { color: #4ade80; background: rgba(22, 163, 74, 0.10); display: block; }
.diffbox .del { color: #f87171; background: rgba(220, 38, 38, 0.10); display: block; }
.diffbox .ctx { color: var(--text-muted); display: block; }
.diffbox .hdr { color: #9ec2f7; display: block; }

.commits-list { max-height: 300px; overflow-y: auto; }
.commit-item { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.commit-item .sha { font-family: ui-monospace, monospace; color: #7db1f9; }
.commit-item .msg { color: var(--text-muted); flex: 1; }

.empty { color: var(--text-muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.changes-list .chg { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }

.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card .sub { color: var(--text-muted); font-size: 12px; margin-bottom: 20px; }
.kv { display: flex; gap: 10px; font-size: 12.5px; padding: 3px 0; }
.kv .k { color: var(--text-muted); width: 130px; flex: 0 0 130px; }
