:root {
  --bg: #f4f6f8;
  --fg: #1f2933;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #d7dde5;
  --accent: #0b5fa5;
  --ok: #136f3b;
  --error: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.container.wide { max-width: 1800px; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin-top: 0; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

nav.tabs a {
  padding: 0.45rem 0.95rem;
  text-decoration: none;
  color: var(--fg);
  background: #eef1f4;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

nav.tabs a:hover {
  background: #dfe6ee;
  color: var(--accent);
  box-shadow: 0 -2px 6px rgba(15, 23, 42, 0.1);
}

nav.tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 -2px 6px rgba(11, 95, 165, 0.35);
}

.tabs .tab-label {
  padding: 0.5rem 0.35rem 0.5rem 0.2rem;
  margin-left: 1.5rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  align-self: center;
}

.tabs .tab-label:first-child { margin-left: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

form label {
  display: block;
  margin-bottom: 0.85rem;
  font-weight: 600;
}

form input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-weight: 400;
}

form input:disabled { background: #eef1f4; color: var(--muted); }

button, .button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .button:hover { filter: brightness(1.08); }

.alert {
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert.error { background: #fdecea; color: var(--error); border-color: #f5c6c2; }
.alert.ok { background: #e8f5ec; color: var(--ok); border-color: #bfe3cb; }

/* My Students: prominent warning above the archived/deleted table. */
.ms-warning {
  background: #fdecea;
  border: 1px solid #f5c6c2;
  border-left: 5px solid var(--error);
  color: var(--error);
  padding: 0.9rem 1.1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.35;
}

.muted { color: var(--muted); font-size: 0.92rem; }
.muted a, .container a { color: var(--accent); }

/* Keep link-buttons readable (the generic ".container a" colour must not win). */
.container a.button,
.container a.button:hover { color: #fff; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
}

.pill-user { background: #e3ecf5; color: #0b5fa5; }
.pill-promotor { background: #e3f4e8; color: #136f3b; }
.pill-admin { background: #fdecea; color: #b3261e; }
.pill-active { background: #e3f4e8; color: #136f3b; }
.pill-disabled { background: #eef1f4; color: #6b7280; }
/* Cluster account statuses (active/protected/archived/deleted). */
.pill-protected { background: #bbdefb; color: #0d47a1; }
.pill-archived { background: #fff3e0; color: #e65100; }
.pill-deleted { background: #ffcdd2; color: #c62828; }

/* Admin user table: column-set toggles + sortable headers. */
.admin-cols {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin: 0.6rem 0;
}
.admin-cols label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: normal;
  font-size: 0.9rem;
  margin: 0;
}
.admin-cols input { width: auto; margin: 0; }
/* Dates + Storage are hidden until enabled by admin.js. */
#admin-table .colset-dates,
#admin-table .colset-storage { display: none; }
#admin-table th[data-col] { cursor: pointer; user-select: none; white-space: nowrap; }
#admin-table th.admin-asc::after { content: ' \25B2'; color: #1f2933; }
#admin-table th.admin-desc::after { content: ' \25BE'; color: #1f2933; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

/* Welcome header (replaces the per-page h1) */
.page-head { margin-bottom: 0.85rem; }
.page-head .welcome { font-size: 1.5rem; margin: 0; }

/* About page */
.about-logos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  align-items: stretch;
}
.about-logos.about-logos-2 { grid-template-columns: repeat(2, 1fr); }
.about-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  min-height: 88px;
  text-decoration: none;
}
.about-logo img { max-height: 46px; max-width: 100%; object-fit: contain; }
.about-logo:hover { border-color: var(--accent); }
@media (max-width: 560px) {
  .about-logos { grid-template-columns: repeat(2, 1fr); }
}
.exp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.exp-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  min-height: 96px;
  text-decoration: none;
  color: inherit;
}
.exp-card:hover { border-color: var(--accent); }
.exp-card img { max-height: 40px; max-width: 100%; object-fit: contain; }
.exp-card .name { font-size: 0.9rem; font-weight: 600; margin-top: 0.4rem; text-align: center; }

.banner {
  background: #fff4d6;
  border: 1px solid #e8c877;
  color: #7a5a00;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

form select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-weight: 400;
  background: #fff;
}

form label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}

form label.checkbox input { width: auto; margin: 0; }

.button.small, button.small {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

button.secondary, .button.secondary {
  background: #5b6b7b;
}

form.inline { display: inline-block; margin: 0; }

table.users {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.95rem;
}

table.users th, table.users td {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.users th { background: #eef1f4; font-size: 0.9rem; }

table.users td.actions { white-space: nowrap; }

table.users td.actions a, table.users td.actions form { margin-right: 0.25rem; }


/* ── Cluster status banner (top strip, site-wide) ── */
.cs-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 0.9rem;
  background: #1e2a38;
  position: relative;
  z-index: 50;
}

.cs-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
  color: #e8edf3;
}
.cs-brand-link { display: block; text-decoration: none; }
.cs-brand-link:hover { text-decoration: none; }
.cs-logo { height: 48px; width: auto; display: block; }

.cs-live { flex: 1; position: relative; }

.cs-refresh { font-size: 0.68rem; color: #aab7c4; white-space: nowrap; }

.cs-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.15rem 0;
}

/* State is shown by a thick edge + a big glowing dot, not just a small pill. */
.cs-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 10rem;
  min-width: 9rem;
  text-align: center;
  background: #26374a;
  color: #e8edf3;
  border: 1px solid #35485e;
  border-left: 5px solid #546e7a;
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.cs-box:hover { background: #2f4560; }
.cs-box:focus-visible { outline: 2px solid #7fb3e8; outline-offset: 2px; }
.cs-box.active { background: #34506e; box-shadow: inset 0 0 0 1px #7fb3e8; }

.cs-box.cs-ok { border-left-color: #7ac47f; }
.cs-box.cs-warn { border-left-color: #ffcc80; background: #3a3320; }
.cs-box.cs-crit { border-left-color: #ef5350; background: #3d2323; }
.cs-box.cs-unknown, .cs-box.cs-stale { border-left-color: #6b7a89; opacity: 0.75; }

.cs-head { display: flex; align-items: center; justify-content: center; gap: 0.45rem; }
.cs-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #dbe6f0;
}

.cs-dot { width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0; }
.cs-dot.cs-ok { background: #8bd48f; box-shadow: 0 0 10px 2px rgba(139, 212, 143, 0.8); }
.cs-dot.cs-warn { background: #ffd54f; box-shadow: 0 0 10px 2px rgba(255, 213, 79, 0.8); }
.cs-dot.cs-crit { background: #ff6b6b; box-shadow: 0 0 10px 2px rgba(255, 107, 107, 0.85); }
.cs-dot.cs-unknown { background: #6b7a89; }

.cs-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem; }
.cs-pill { display: inline-flex; align-items: center; padding: 1px 8px;
  border-radius: 10px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.cs-pill.cs-ok { background: #1b5e20; color: #a5d6a7; }
.cs-pill.cs-warn { background: #4a3000; color: #ffe082; }
.cs-pill.cs-crit { background: #5c1a00; color: #ef9a9a; }
.cs-pill.cs-muted { background: #37474f; color: #cfd8dc; }

/* Floating detail panel, attached under the strip. */
.cs-panel-layer {
  position: absolute;
  top: 100%;
  left: 0;
  width: 30rem;
  max-width: 100%;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
  max-height: 72vh;
  overflow: auto;
  padding: 1rem 1.25rem 1.25rem;
}
.cs-panel-layer[hidden] { display: none; }
.cs-panel[hidden] { display: none; }

.cs-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.cs-panel-head h2 { margin: 0; font-size: 1.05rem; }
.cs-close {
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0 0.3rem;
  cursor: pointer;
  font-weight: 400;
}
.cs-close:hover { color: var(--fg); filter: none; }

.cs-list { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.cs-list li { margin: 0.2rem 0; }
.cs-note { margin: 0.35rem 0 0; color: var(--muted); }

/* Storage warning: generic line, exact check text behind a click. */
.cs-details { margin: 0.6rem 0 0; }
.cs-details > summary { cursor: pointer; }
.cs-details[open] > summary { margin-bottom: 0.2rem; }

/* Status panel: one row per system + messages with threads. */
.cs-sub { margin: 1rem 0 0.4rem; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); }
.cs-sys { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0;
  border-bottom: 1px solid #eef1f4; }
.cs-flag { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cs-flag.cs-ok { background: #2e7d32; }
.cs-flag.cs-warn { background: #f9a825; }
.cs-flag.cs-crit { background: #c62828; }
.cs-sys-name { flex: 1; font-weight: 600; }
.cs-sys-state { font-weight: 700; }
.cs-sys-state.cs-ok { color: var(--ok); }
.cs-sys-state.cs-warn { color: #a06a00; }
.cs-sys-state.cs-crit { color: var(--error); }

.cs-msgs { display: flex; flex-direction: column; gap: 0.8rem; }
.cs-msg { border: 1px solid var(--border); border-left: 4px solid #f9a825;
  border-radius: 0 8px 8px 0; padding: 0.6rem 0.8rem; background: #fffdf7; }
.cs-msg-resolved { border-left-color: #9e9e9e; background: #fafafa; opacity: 0.85; }
/* Message colour follows its Cachet state: fixed green, watching/identified
   amber/orange, investigating red, scheduled blue. */
.cs-msg-fixed { border-left-color: #2e7d32; background: #eef8f0; }
.cs-msg-watching { border-left-color: #f9a825; background: #fffdf7; }
.cs-msg-identified { border-left-color: #ef6c00; background: #fff4ea; }
.cs-msg-investigating { border-left-color: #c62828; background: #fdecea; }
.cs-msg-scheduled { border-left-color: #3b6ea5; background: #eef4fb; }
.cs-msg-head { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; align-items: baseline; }
.cs-msg-title { font-weight: 700; }
.cs-msg-meta { font-size: 0.85rem; }
.cs-msg-body { margin-top: 0.4rem; white-space: normal; }
.cs-thread { margin-top: 0.5rem; padding-left: 0.7rem; border-left: 2px solid #e0e6ef; }
.cs-thread-meta { font-size: 0.82rem; }
.cs-thread-body { margin-top: 0.15rem; }

/* ── My History table ── */
.hist-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.6rem 0;
}
.hist-controls input[type="search"] {
  padding: 5px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 5px;
}
.hist-btn {
  padding: 5px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #eef3f8;
  color: var(--fg);
  cursor: pointer;
}
.hist-btn:hover { background: #e2ebf5; }
.hist-btn[disabled] { opacity: 0.6; cursor: default; }
.hist-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.hist-summary-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 0.8rem 1rem;
  margin: 0.6rem 0;
}
.hist-summary-title {
  text-align: center;
  font-size: 1.1rem;
  margin: 0.2rem 0 0.4rem;
}

/* ── Column pickers (My Jobs / Finished tables) ── */
.colpick { position: relative; }
.colpick-btn {
  padding: 5px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #eef3f8;
  color: var(--fg);
  cursor: pointer;
}
.colpick-btn:hover { background: #e2ebf5; }
.colpick-btn.open { background: var(--accent); color: #fff; border-color: var(--accent); }
.colpick-panel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 30;
  min-width: 150px;
  margin-top: 4px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  text-align: left;
}
.colpick-panel label {
  display: block;
  padding: 2px 0;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}
.colpick-panel input { margin-right: 6px; }
/* The Finished table mirrors the "My Jobs" (running) table: inline-styled
   cells, #ddd header, #fff/#f5f5f5 rows, CPU and memory group tints. */
#hist-table th { white-space: nowrap; }
.hist-flag { font-weight: 700; }
.hist-flag.hist-ok { color: var(--ok); }
.hist-flag.hist-bad { color: var(--error); }
.hist-flag.hist-warn { color: #b26a00; }
.hist-flag.hist-muted { color: var(--muted); }
.hist-more { text-align: center; margin: 0.7rem 0; }

/* Log out sits at the right end of the tab line. */
nav.tabs a.tab-logout {
  margin-left: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--muted);
  font-weight: 500;
  align-self: center;
  padding: 0.5rem 0.3rem;
}
nav.tabs a.tab-logout:hover { color: var(--accent); background: transparent; box-shadow: none; }

/* Filled colored detail rows — a whole green/amber/red row, not just a pill */
.cs-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem;
  margin: 0.3rem 0;
  border: 1px solid transparent;
  border-left-width: 4px;
  border-left-style: solid;
  border-radius: 6px;
}
.cs-row.cs-ok { background: #e9f6ec; border-color: #c3e6cb; border-left-color: #2e7d32; }
.cs-row.cs-warn { background: #fff6e0; border-color: #f2dfa8; border-left-color: #f9a825; }
.cs-row.cs-crit { background: #fdecea; border-color: #f5c6c2; border-left-color: #c62828; }
.cs-row-name { font-weight: 700; }
.cs-row-value { flex: 1; }
.cs-row.cs-ok .cs-row-value { color: var(--ok); }
.cs-row.cs-warn .cs-row-value { color: #8a5a00; }
.cs-row.cs-crit .cs-row-value { color: var(--error); }

/* Batch-jobs capacity bar: free + running + draining + idle = total */
.cs-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin: 0.45rem 0 0.3rem;
  background: #eef1f4;
}
.cs-seg { height: 100%; }
.cs-seg-free { background: #7ac47f; }
.cs-seg-running { background: #3b6ea5; }
.cs-seg-draining { background: #e6a23c; }
.cs-seg-idle { background: #c9d0d8; }
.cs-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.cs-bar-legend b { color: var(--fg); }
.cs-bar-legend .cs-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.3rem;
}
.cs-bar-total { margin-left: auto; }
