/* style.css — tema lembut, ramah di mata. Gelap default + mode terang. */
:root {
  --bg: #0e1217;
  --bg-soft: #151a21;
  --card: #1a2029;
  --card-2: #20272f;
  --border: #2a323d;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #67727d;
  --accent: #5b9dff;
  --accent-soft: rgba(91,157,255,.14);
  --ok: #3fb98a;
  --ok-soft: rgba(63,185,138,.14);
  --warn: #e0a93c;
  --warn-soft: rgba(224,169,60,.14);
  --crit: #e5605e;
  --crit-soft: rgba(229,96,94,.14);
  --shadow: 0 6px 24px rgba(0,0,0,.28);
  --radius: 14px;
  --radius-sm: 9px;
}
[data-theme="light"] {
  --bg: #f4f6f9;
  --bg-soft: #eef1f6;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --border: #e2e7ef;
  --text: #1c2530;
  --text-dim: #5a6573;
  --text-faint: #8a95a3;
  --accent: #2f6fed;
  --accent-soft: rgba(47,111,237,.10);
  --ok: #1f9d6b;
  --ok-soft: rgba(31,157,107,.12);
  --warn: #c4881f;
  --warn-soft: rgba(196,136,31,.12);
  --crit: #d8413f;
  --crit-soft: rgba(216,65,63,.12);
  --shadow: 0 6px 24px rgba(40,60,90,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- Gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.gate-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 36px 32px; width: 340px;
  text-align: center; box-shadow: var(--shadow);
}
.gate-box h1 { font-size: 20px; margin: 8px 0 4px; }
.gate-box p { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.gate-box input {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  font-size: 14px; margin-bottom: 12px;
}
.gate-box input:focus { outline: none; border-color: var(--accent); }
.gate-err { color: var(--crit); font-size: 12px; min-height: 16px; margin-bottom: 8px; }
.btn-primary {
  width: 100%; padding: 11px; border: none; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.07); }

/* ---------- Layout ---------- */
.app { max-width: 1320px; margin: 0 auto; padding: 18px 22px 60px; }
header.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #8b5bff);
  display: grid; place-items: center; font-size: 18px;
}
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.brand small { display: block; color: var(--text-faint); font-size: 11px; font-weight: 500; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctrl {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px;
}
.ctrl:focus { outline: none; border-color: var(--accent); }
.icon-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  width: 36px; height: 36px; border-radius: var(--radius-sm); font-size: 15px;
  display: grid; place-items: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Token banner ---------- */
.token-banner {
  background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px;
}
.token-banner h3 { margin: 0 0 6px; font-size: 14px; color: var(--warn); }
.token-banner p { margin: 0 0 12px; color: var(--text-dim); font-size: 13px; }
.token-row { display: flex; gap: 8px; }
.token-row input {
  flex: 1; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 12px;
}

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow);
}
.kpi .label { color: var(--text-faint); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 23px; font-weight: 700; margin-top: 5px; letter-spacing: -.4px; }
.kpi .sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.kpi.alert-crit { border-color: var(--crit); }
.kpi.alert-crit .value { color: var(--crit); }
.kpi.alert-warn .value { color: var(--warn); }

/* ---------- Panels ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 14px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .count { font-size: 11px; color: var(--text-faint); font-weight: 500; }

/* alerts list */
.alert-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.alert-dot.critical { background: var(--crit); }
.alert-dot.warn { background: var(--warn); }
.alert-main { flex: 1; min-width: 0; }
.alert-main .a-name { font-weight: 600; font-size: 13px; }
.alert-main .a-detail { color: var(--text-dim); font-size: 12px; }
.alert-main .a-advice { color: var(--text-faint); font-size: 11.5px; margin-top: 2px; }
.empty-state { color: var(--text-faint); font-size: 13px; text-align: center; padding: 24px 0; }

/* ---------- Table ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.table-head h2 { font-size: 14px; margin: 0; }
.table-search { background: var(--bg-soft); border: 1px solid var(--border); color: var(--text); padding: 7px 11px; border-radius: var(--radius-sm); font-size: 13px; width: 200px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 10px 12px; font-size: 13px; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; }
th {
  color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .3px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
  background: var(--card);
}
th:hover { color: var(--text); }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
tbody tr:hover { background: var(--card-2); }
tbody tr:last-child { border-bottom: none; }
td .acc-name { font-weight: 600; }
td .acc-biz { color: var(--text-faint); font-size: 11px; }
.num-dim { color: var(--text-dim); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.critical { background: var(--crit-soft); color: var(--crit); }
.badge.idle { background: var(--bg-soft); color: var(--text-faint); }

.cell-bad { color: var(--crit); font-weight: 600; }
.cell-warn { color: var(--warn); font-weight: 600; }
.cell-good { color: var(--ok); font-weight: 600; }

/* ---------- Drawer (settings) ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: none; }
.drawer-overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: -460px; width: 440px; max-width: 92vw; height: 100%;
  background: var(--bg-soft); border-left: 1px solid var(--border); z-index: 201;
  transition: right .25s ease; overflow-y: auto; padding: 22px;
}
.drawer.open { right: 0; }
.drawer h2 { font-size: 16px; margin: 0 0 4px; }
.drawer .hint { color: var(--text-dim); font-size: 12px; margin-bottom: 18px; }
.drawer h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); margin: 22px 0 10px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.field label { font-size: 13px; color: var(--text); flex: 1; }
.field label small { display: block; color: var(--text-faint); font-size: 11px; }
.field input[type="number"] {
  width: 120px; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--text); text-align: right; font-size: 13px;
}
.rule-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.rule-row .r-label { flex: 1; font-size: 13px; }
.rule-row .r-sev { font-size: 11px; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--border); border-radius: 20px; transition: .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track + .thumb { left: 19px; }
.drawer-actions { display: flex; gap: 8px; margin-top: 22px; }
.btn-ghost { flex: 1; padding: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: var(--radius-sm); font-weight: 600; }

/* ---------- Drill modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 1100px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; margin: 0; margin-right: auto; }
.seg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: none; border: none; color: var(--text-dim); padding: 7px 13px; font-size: 12.5px; font-weight: 600; }
.seg button.active { background: var(--accent); color: #fff; }
.modal-body { padding: 6px 10px 16px; overflow-x: auto; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { text-align: center; color: var(--text-faint); padding: 30px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 11px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 300; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
