:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-input: #0b0f14;
  --border: #30363d;
  --border-strong: #484f58;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-strong: #1f6feb;
  --success: #3fb950;
  --warn: #d29922;
  --error: #f85149;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

html { color-scheme: dark; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* The whole page is one viewport-tall column: header, then a workspace that
     takes the rest. That is what lets the log grow to whatever height is left
     instead of sitting at a fixed 260px. */
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* The <use> icon library is markup, not layout. Taken out of flow at zero size
   rather than display:none, which is the sprite pattern every browser resolves
   <use> references against without argument. */
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex: 0 0 auto;
}
.topbar-left { display: flex; align-items: center; justify-self: start; }
.topbar-left label { margin-right: 0; }
.topbar-title {
  justify-self: center;
  margin: 0;
  font-size: 16px; font-weight: 600; letter-spacing: 0.4px;
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 14px; justify-self: end; }

/* Green while a job is running, red while nothing is. The colour is driven
   only by .active/.inactive so app.js never has to know a hex value. */
.status-dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex: 0 0 auto;
  transition: background 0.2s, box-shadow 0.2s;
}
.status-dot.active { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-dot.inactive { background: var(--error); box-shadow: 0 0 10px rgba(248, 81, 73, 0.45); }

.env-status { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.env-status.ok { color: var(--success); }
.env-status.bad { color: var(--error); }

/* Three columns rather than "main then rail": the middle column is centred on
   the viewport, so the main box sits at true screen centre instead of centre-
   of-whatever-the-rail-left-over. The side columns never drop below the rail's
   own width, so the rail always has somewhere to sit on the right. */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(152px, 1fr) minmax(0, 900px) minmax(152px, 1fr);
  align-items: stretch;
  gap: 20px;
  padding: 20px 24px;
}

#tabs.tile-rail {
  grid-column: 3;
  justify-self: end;
  width: 132px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px;
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 12px;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.tile-icon {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile:hover:not(.active) { color: var(--text); border-color: var(--border-strong); }
.tile:active { transform: translateY(1px); }
.tile.active {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
  font-weight: 600;
}

main {
  grid-column: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}
/* The panels scroll inside their own box (a Browse table can be very tall) so
   they never push the log off the bottom of the screen. */
.panel-wrap {
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 900px;
  overflow-y: auto;
}
.panel { width: 100%; }
.panel.hidden { display: none; }
/* main's gap already separates the panel column from the log, and only one
   panel is ever visible, so a card margin here would just double that gap. */
.panel-wrap > .card { margin-bottom: 0; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin: 0 0 16px; font-weight: 600; }
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); margin: 16px 0 8px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
label { display: inline-flex; gap: 6px; align-items: center; margin-right: 16px; color: var(--text-muted); font-size: 13px; }
fieldset { border: 1px solid var(--border); border-radius: 6px; margin: 12px 0; padding: 8px 12px; background: var(--bg-input); }
legend { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; padding: 0 6px; }

input[type="text"], input[type="date"], input[type="time"], select {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus, input[type="date"]:focus, input[type="time"]:focus, select:focus { border-color: var(--accent); }

.save-to { margin-left: 16px; }
.folder-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.folder-row input[type="text"] { flex: 1; min-width: 240px; }

button {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}
button.primary {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.1); }
button.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
button.ghost:hover { color: var(--text); border-color: var(--border-strong); }
button.danger {
  background: #c0392b;
  color: #fff;
  border: none;
  font-weight: 600;
}
button.danger:hover { background: #a93226; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

table { border-collapse: collapse; margin: 12px 0; width: 100%; font-family: var(--mono); font-size: 12px; }
th, td { border-bottom: 1px solid var(--border); padding: 5px 8px; text-align: left; font-variant-numeric: tabular-nums; }
th { color: var(--text-muted); font-weight: 600; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.pager[hidden] { display: none; }

/* flex-basis 220px with grow:1 means the log fills the space the open panel
   leaves and never collapses below a readable height. */
.log-card {
  display: flex; flex-direction: column;
  flex: 1 1 220px;
  min-height: 160px;
  width: 100%;
  max-width: 900px;
  margin-bottom: 0;
}
.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex: 0 0 auto; }
.log-hint { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.log-header h2 { margin: 0; }
.log {
  margin: 0;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.log .ok { color: var(--success); }
.log .bad { color: var(--error); }

.muted { color: var(--text-muted); }
.bad { color: var(--error); }
.ok { color: var(--success); }

/* Below the width where a 132px rail and a usable panel both fit, the rail
   becomes a scrolling strip above the panels rather than squeezing them. */
@media (max-width: 720px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px; padding: 14px;
  }
  #tabs.tile-rail {
    grid-column: 1; grid-row: 1;
    justify-self: stretch; width: auto;
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
  }
  main { grid-column: 1; grid-row: 2; }
  .tile { flex: 1 0 88px; }
  .topbar { grid-template-columns: 1fr; justify-items: center; gap: 10px; }
  .topbar-left, .topbar-right { justify-self: center; }
}

