:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-track: #cde2fb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --critical-text: #b42e2e;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-track: #184f95;
    --series-1: #3987e5;
    --series-2: #d95926;
    --critical-text: #e66767;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

button, input { font: inherit; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-small { padding: 3px 10px; font-size: 13px; }

/* --- Login --------------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { margin: 0 0 20px; color: var(--text-2); }
.login-card label { display: block; font-weight: 600; margin-bottom: 6px; }
.login-card input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--axis);
  border-radius: 8px;
  background: var(--page);
  color: var(--text);
  margin-bottom: 16px;
}
.login-card .btn { width: 100%; padding: 9px; }
.error { color: var(--critical-text); margin: 0 0 12px; }
.error:empty { display: none; }

/* --- Dashboard ----------------------------------------------------------- */

/* --- Shell: sidebar + content ------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: 216px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  padding: 8px 10px 16px;
  color: var(--text);
}
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
}
.nav-item svg { flex: none; opacity: 0.85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.sidebar-spacer { flex: 1; }
.sidebar form { display: contents; }

.content {
  padding: 24px 24px 48px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tab[hidden] { display: none; }
.tab { display: flex; flex-direction: column; gap: 12px; }

/* --- Status card ---------------------------------------------------------- */

.status-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.status-card-head h1 { font-size: 20px; margin: 0 0 8px; }
.status-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.pill.offline .pill-dot { background: var(--critical); }
.pill.offline { color: var(--critical-text); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 0;
}

/* --- Console -------------------------------------------------------------- */

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.console-head h2 { margin: 0; }
.console-controls { display: flex; align-items: center; gap: 12px; }
.console-controls select {
  border: 1px solid var(--axis);
  border-radius: 6px;
  background: var(--page);
  color: var(--text);
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
}
.live-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }

/* --- Instellingen ----------------------------------------------------------- */

.card.narrow { max-width: 420px; }

#password-form { display: flex; flex-direction: column; margin-top: 16px; }
#password-form label { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
#password-form input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--axis);
  border-radius: 8px;
  background: var(--page);
  color: var(--text);
  margin-bottom: 14px;
}
.form-msg { margin: -4px 0 12px; font-size: 13px; }
.form-msg:empty { display: none; }
.form-msg.ok { color: var(--good); }
.form-msg.error { color: var(--critical-text); }

.console-box {
  margin: 0;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  height: 260px;
  overflow: auto;
  font: 12px/1.6 var(--mono);
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }
  .brand { padding: 4px 10px 4px 0; }
  .sidebar-spacer { display: none; }
  .nav-item { white-space: nowrap; }
  .content { padding: 16px 16px 40px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
}
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }

/* --- Inklapbare kaarten (Systeem-tabblad) --------------------------------- */

.card.collapsible { padding: 0; }
.card.collapsible > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card.collapsible > summary::-webkit-details-marker { display: none; }
.card.collapsible > summary h2 { margin: 0; }
.card.collapsible > summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin-left: 12px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.card.collapsible[open] > summary::after { transform: rotate(45deg); }
.card.collapsible > summary:hover::after { border-color: var(--text); }
.card.collapsible > *:not(summary) { padding: 0 18px 16px; }
.card.collapsible > summary { border-radius: var(--radius); }
.card.collapsible[open] > summary { border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--grid); }

.tile-label { color: var(--text-2); font-size: 14px; }
.tile-value { font-size: 28px; font-weight: 600; margin: 2px 0 2px; }
.tile-sub { color: var(--muted); font-size: 13px; }

.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--accent-track);
  overflow: hidden;
  margin-top: 10px;
}
.meter > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.meter.warn > span { background: var(--warning); }
.meter.crit > span { background: var(--critical); }

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.chart-box { position: relative; height: 220px; }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin: -4px 0 8px; }
.legend span::before {
  content: "";
  display: inline-block;
  width: 12px; height: 2px;
  vertical-align: middle;
  margin-right: 6px;
  background: var(--key);
}
.legend .k1 { --key: var(--series-1); }
.legend .k2 { --key: var(--series-2); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
}
td { padding: 9px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td .meter { margin-top: 0; min-width: 80px; }
.table-scroll { overflow-x: auto; }

.status { white-space: nowrap; }
.status::before { margin-right: 6px; }
.status.running::before { content: "●"; color: var(--good); }
.status.exited::before, .status.created::before, .status.dead::before { content: "■"; color: var(--muted); }
.status.restarting::before, .status.paused::before { content: "▲"; color: var(--warning); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mono { font-family: var(--mono); font-size: 13px; color: var(--text-2); }
.empty { color: var(--text-2); margin: 0; }

.stack { display: grid; gap: 12px; }

dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--grid);
}
.dialog-head h2 { margin: 0; font-size: 16px; }
dialog pre {
  margin: 0;
  padding: 16px;
  max-height: calc(100vh - 160px);
  overflow: auto;
  font: 12px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- Database-dialoog ------------------------------------------------------ */

#db-dialog { width: min(1100px, calc(100vw - 32px)); }
.db-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  max-height: calc(100vh - 120px);
}
.db-tables-panel {
  border-right: 1px solid var(--grid);
  padding: 14px;
  overflow-y: auto;
}
.db-tables-panel h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.db-tables-panel h3:not(:first-child) { margin-top: 18px; }
.db-table-list, .db-backup-list { display: flex; flex-direction: column; gap: 2px; }
.db-table-btn {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.db-table-btn:hover { background: var(--surface-2); }
.db-table-btn.active { background: var(--accent-track); color: var(--text); font-weight: 600; }
.db-table-btn .count { color: var(--muted); font-variant-numeric: tabular-nums; }

.db-backup-list { font-size: 13px; }
.db-backup-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; gap: 8px; }
.db-backup-item a { color: var(--accent); text-decoration: none; }
.db-backup-item a:hover { text-decoration: underline; }
.db-backup-item .meta { color: var(--muted); font-size: 12px; }

.db-preview-panel { padding: 14px; overflow: auto; min-width: 0; }
.db-preview-panel h3 { margin: 0 0 10px; font-size: 14px; }
#db-preview-table { font-size: 13px; }
#db-preview-table td { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 760px) {
  .db-body { grid-template-columns: 1fr; }
  .db-tables-panel { border-right: none; border-bottom: 1px solid var(--grid); max-height: 220px; }
}

/* --- Bestandsbeheer ---------------------------------------------------------- */

.files-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 14px; }
.files-actions { display: flex; gap: 8px; }
.file-upload-label { cursor: pointer; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 2px 4px; font: inherit; }
.link-btn:hover { text-decoration: underline; }
#fm-editor { width: min(960px, calc(100vw - 32px)); }
#fm-editor textarea {
  width: 100%;
  height: min(60vh, 520px);
  padding: 12px;
  border: none;
  background: var(--page);
  color: var(--text);
  font: 13px/1.5 var(--mono);
  resize: vertical;
  outline: none;
}

/* --- Goedkeuren van inlogverzoeken ------------------------------------------- */

.approvals { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.approvals[hidden] { display: none; }
.approval-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-color: var(--accent); }
.approval-text { font-size: 14px; }
