:root {
  --ink: #1B2230;
  --slate: #5A6475;
  --rule: #DCE1E8;
  --paper: #F4F6F9;
  --surface: #FFFFFF;
  --danger: #B42318;
  --ok: #1F7A4D;
  --brand: #0F6E6A;            /* replaced by each institute's own colour */
  --brand-ink: #FFFFFF;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, white);
  --display: "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.55 var(--body); }
#spine { position: fixed; inset: 0 auto 0 0; width: 8px; background: var(--brand); z-index: 5; }
#app { min-height: 100vh; padding-left: 8px; }
.loading { padding: 48px; color: var(--slate); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--slate); }
a { color: var(--brand); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, white); outline-offset: 2px; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 32px 28px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .lead { margin: 0 0 24px; color: var(--slate); }

/* ---------- forms ---------- */
label { display: block; font-weight: 500; font-size: 14px; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid #C5CCD6; border-radius: 6px; }
input:focus, select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=color] { width: 56px; height: 40px; padding: 2px; border: 1px solid #C5CCD6; border-radius: 6px; background: white; }
.hint { font-size: 13px; color: var(--slate); margin-top: 4px; }
.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.radio-group label, .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; }
.radio-group input, .check input { margin-top: 4px; accent-color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
  font: 600 14px var(--body); border-radius: 6px; border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: #C5CCD6; }
.btn.ghost { background: transparent; color: var(--brand); padding: 6px 8px; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #E9B8B3; }
.btn.block { width: 100%; margin-top: 20px; }
.form-error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 1em; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- app shell ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 4; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 32px; width: auto; }
.brand-name { font: 700 18px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-tag { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--slate);
  border: 1px solid var(--rule); border-radius: 4px; padding: 2px 6px; }
.topbar .spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 12px; font-size: 14px; margin-left: auto; }
.user .who { text-align: right; line-height: 1.25; }
.user .who small { display: block; color: var(--slate); font-family: var(--mono); font-size: 12px; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 24px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 14px; font: 600 14px var(--body); color: var(--slate);
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tab[aria-selected=true] { color: var(--ink); border-bottom-color: var(--brand); }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.empty { padding: 28px; text-align: center; color: var(--slate); border: 1px dashed #C5CCD6; border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--slate);
  padding: 8px 10px; border-bottom: 1px solid var(--rule); }
td { padding: 11px 10px; border-bottom: 1px solid #ECEFF3; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #EEF1F5; color: var(--slate); }
.pill.on { background: var(--brand-soft); color: var(--brand); }
.pill.warn { background: #FEF0C7; color: #93370D; }
.pill.off { background: #FDE3E1; color: var(--danger); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid #C5CCD6; background: var(--surface); border-radius: 999px; padding: 5px 12px;
  font: 500 13px var(--body); cursor: pointer; color: var(--ink); }
.chip[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; }
.card h3 { margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 12px 0; }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; }
.checklist { max-height: 260px; overflow-y: auto; border: 1px solid var(--rule); border-radius: 6px; padding: 4px 12px; }
.notice { background: var(--brand-soft); border-left: 4px solid var(--brand); padding: 12px 14px; border-radius: 4px; margin: 12px 0; font-size: 14px; }
.notice .mono { font-size: 15px; background: white; padding: 2px 6px; border-radius: 4px; user-select: all; }
.workspace-list { display: grid; gap: 10px; margin-top: 16px; }
.workspace { display: flex; justify-content: space-between; align-items: center; text-align: left; width: 100%;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--rule); border-left: 6px solid var(--ws, var(--brand));
  border-radius: var(--radius); cursor: pointer; font: inherit; color: var(--ink); }
.workspace:hover { border-color: #B7C0CC; border-left-color: var(--ws, var(--brand)); }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: white; padding: 10px 16px; border-radius: 6px; font-size: 14px; transition: .2s; z-index: 10; pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .user .who { display: none; }
  .page { padding: 20px 16px; }
  .auth-card { padding: 24px 18px; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
