:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #d9dee3;
  --text: #1f2933;
  --muted: #6b7280;
  --accent: #1f6feb;
  --accent-dark: #1550b3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 600; font-size: 16px; }
.topbar .spacer { flex: 1; }
.topbar-link { color: var(--accent); text-decoration: none; font-size: 14px; }
.topbar-link:hover { text-decoration: underline; }
.lang-switch select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.logout button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}
.logout button:hover { background: #f0f2f4; }

/* ---- Workspace layout ---- */
.workspace {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 53px);
}
.tree-pane {
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 12px;
}
.content-pane { overflow: auto; padding: 20px; }
.placeholder, .tree-loading { color: var(--muted); padding: 12px; }

/* ---- Tree ---- */
.tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree > ul { padding-left: 0; }
.tree-node > .tree-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.tree-node > .tree-label:hover { background: #eef2f7; }
.tree-node.selected > .tree-label { background: #e1ecff; color: var(--accent-dark); font-weight: 600; }
.tree-toggle {
  width: 14px;
  display: inline-block;
  text-align: center;
  color: var(--muted);
}
.tree-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}
.tree-children.collapsed { display: none; }

/* ---- Report ---- */
.report-title { margin: 0 0 12px; font-size: 18px; }
.report-empty, .report-error { color: var(--muted); padding: 16px; }
.plot { width: 100%; height: 460px; }

/* ---- Login ---- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f6feb 0%, #14315f 100%);
}
.login-card {
  width: 340px;
  background: #fff;
  border-radius: 12px;
  padding: 28px 26px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-title { margin: 0 0 4px; font-size: 20px; }
.login-subtitle { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login-error {
  background: #fdecea;
  color: #b3261e;
  border: 1px solid #f6c8c3;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
  font-size: 14px;
}
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,235,.15); }
.btn-primary {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dark); }
