/*
 * OEM dashboard.
 *
 * Palet chart & status memakai nilai referensi data-viz apa adanya
 * (surface gelap #1a1a19; series slot 1-3 dark; status good/warning/critical).
 */

:root {
  color-scheme: dark;

  --plane: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222221;

  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;

  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;

  --radius: 10px;
}

* { box-sizing: border-box; }

/*
 * Aturan [hidden] bawaan browser hanya `display:none` tanpa kelas, sehingga
 * KALAH spesifisitas dari `.layout{display:flex}` dan sejenisnya. Tanpa
 * baris ini, elemen yang di-set hidden lewat JS tetap tampil -- modal tidak
 * bisa ditutup dan layout aplikasi ikut terlihat di balik layar login.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--text-primary);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- layout ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand { padding: 0 8px 22px; }
.brand-mark { display: block; font-size: 20px; font-weight: 700; letter-spacing: .04em; }
.brand-sub { display: block; font-size: 12px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding: 0 8px; font-size: 12px; }
.collector-state { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.doc-link { display: inline-block; margin-top: 10px; color: var(--series-1); text-decoration: none; }
.doc-link:hover { text-decoration: underline; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.dot.on { background: var(--good); }
.dot.off { background: var(--critical); }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 21px; }
.subtitle { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.updated { color: var(--text-muted); font-size: 12px; }

/* ---------- cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.card-value { font-size: 26px; font-weight: 600; margin-top: 6px; }
.card-value.good { color: var(--good); }
.card-value.warning { color: var(--warning); }
.card-value.critical { color: var(--critical); }
.card-unit { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-left: 3px; }

/* ---------- panel & table ---------- */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  margin-bottom: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.note { margin: 0 0 12px; color: var(--text-muted); font-size: 12.5px; }
.note code { color: var(--text-secondary); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: left; white-space: nowrap; }
th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--axis);
  font-weight: 600;
}
td { border-bottom: 1px solid var(--grid); color: var(--text-secondary); }
tbody tr:hover td { background: var(--surface-2); }
td.name { color: var(--text-primary); font-weight: 600; }
td.num { text-align: right; }
th.num { text-align: right; }

.link-cell { color: var(--series-1); cursor: pointer; text-decoration: none; }
.link-cell:hover { text-decoration: underline; }

/* ---------- status ---------- */

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; }
.status .glyph { font-size: 12px; }
.status-UP { color: var(--good); }
.status-DEGRADED { color: var(--warning); }
.status-DOWN { color: var(--critical); }
.status-UNKNOWN { color: var(--text-muted); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.pill.on { color: var(--good); border-color: rgba(12, 163, 12, .45); }
.pill.off { color: var(--text-muted); }

/* ---------- meter ---------- */

.meter { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.meter-track { width: 62px; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 3px; background: var(--series-1); }
.meter-fill.warning { background: var(--warning); }
.meter-fill.critical { background: var(--critical); }

/* ---------- buttons ---------- */

.btn {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { border-color: rgba(255, 255, 255, .25); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 600; }
.btn-danger { color: var(--critical); }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.icon-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.icon-btn:hover { color: var(--text-primary); }

/* ---------- states ---------- */

.state { padding: 30px 10px; text-align: center; color: var(--text-muted); }
.state strong { display: block; color: var(--text-secondary); margin-bottom: 4px; }

.banner {
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid;
}
.banner.error { color: var(--critical); border-color: rgba(208, 59, 59, .5); background: rgba(208, 59, 59, .08); }
.banner.ok { color: var(--good); border-color: rgba(12, 163, 12, .5); background: rgba(12, 163, 12, .08); }

/* ---------- form ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--text-muted); }
.field input, .field select, .field textarea {
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
}
.field textarea { resize: vertical; min-height: 62px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--series-1); outline-offset: -1px;
}
.field-wide { grid-column: 1 / -1; }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.field.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field.checkbox input { width: 16px; height: 16px; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
}
.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(680px, 100%);
  max-height: 88vh;
  display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border); }

/* ---------- detail & charts ---------- */

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kv { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kv .k { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.kv .v { font-size: 15px; margin-top: 4px; word-break: break-all; }

.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.chart-title { font-size: 13px; font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

.chart { width: 100%; display: block; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-size: 10.5px; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end-label { font-size: 11px; font-weight: 600; }

.detail-cell {
  max-width: 380px;
  white-space: normal;
  word-break: break-word;
  font-size: 12px;
  color: var(--text-muted);
}

.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions select { min-width: 220px; }

.type-badge {
  display: inline-block;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ---------- rencana DNS ---------- */

.dns-plan { display: flex; flex-direction: column; gap: 1px; }
.dns-row {
  display: flex; gap: 14px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--grid);
}
.dns-row .k { flex: 0 0 148px; color: var(--text-muted); font-size: 12px; }
.dns-row .v { color: var(--text-secondary); word-break: break-all; }
.dns-row .v.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.dns-row .v.strong { color: var(--text-primary); font-weight: 600; }

/* ---------- auth ---------- */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(380px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-brand { text-align: center; margin-bottom: 4px; }
.auth-submit { width: 100%; padding: 10px; margin-top: 4px; }
.auth-foot { margin: 6px 0 0; text-align: center; font-size: 11.5px; color: var(--text-muted); }

.auth-error {
  color: var(--critical);
  background: rgba(208, 59, 59, .08);
  border: 1px solid rgba(208, 59, 59, .5);
  border-radius: 7px;
  padding: 8px 11px;
  font-size: 12.5px;
}
.auth-note {
  color: var(--warning);
  background: rgba(250, 178, 25, .08);
  border: 1px solid rgba(250, 178, 25, .45);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.55;
}
.auth-note code { display: block; margin-top: 5px; color: var(--text-secondary); word-break: break-all; }

.auth-notice {
  color: var(--text-secondary);
  background: rgba(57, 135, 229, .08);
  border: 1px solid rgba(57, 135, 229, .4);
  border-left-width: 3px;
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 30vh;
  overflow-y: auto;
}

.account { margin: 14px 0 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.account-name { color: var(--text-primary); font-weight: 600; font-size: 13px; }
.account-role { color: var(--text-muted); font-size: 11.5px; margin-top: 1px; }
.account-actions { display: flex; gap: 10px; margin-top: 7px; flex-wrap: wrap; }

.linkish {
  background: none; border: none; padding: 0;
  color: var(--series-1); font: inherit; font-size: 12px;
  cursor: pointer; text-decoration: none;
}
.linkish:hover { text-decoration: underline; }

/* Disembunyikan untuk role userview; server tetap menolak walau dipaksa. */
body[data-role="userview"] .admin-only { display: none !important; }

.role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid var(--border);
}
.role-admin { color: var(--series-2); border-color: rgba(217, 89, 38, .5); }
.role-userview { color: var(--text-secondary); }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; flex: none; flex-direction: row; align-items: center; gap: 16px; padding: 12px 14px; }
  .brand { padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; margin-left: auto; }
  .main { padding: 16px 14px 30px; }
}
