:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --panel-3: #eef4fb;
  --line: #d4dce8;
  --text: #172033;
  --muted: #657389;
  --green: #1f8f3a;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c9352b;
  --violet: #7c3aed;
  --cyan: #0e7490;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(219, 234, 254, 0.82), rgba(240, 253, 244, 0.75) 42%, rgba(254, 243, 199, 0.62)),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef4fb;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  background: #dbeafe;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #ffffff 0%, #eef6ff 48%, #fff7ed 100%);
}

.back-link {
  display: inline-block;
  color: var(--blue);
  font-size: 0.82rem;
  text-decoration: none;
  margin-bottom: 0.35rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 0.88rem;
}

.subtitle {
  max-width: 760px;
  color: var(--muted);
  font-size: 0.95rem;
}

.clock-panel {
  min-width: 170px;
  align-self: stretch;
  display: grid;
  align-content: center;
  gap: 0.15rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(160deg, #eef6ff, #ffffff);
}

.clock-label,
.daemon-state {
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(540px, 1fr) minmax(260px, 330px);
  gap: 1rem;
  padding: 1rem;
}

.submit-panel,
.cluster-panel,
.inspect-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 1rem;
  box-shadow: 0 12px 34px rgba(30, 64, 175, 0.08);
}

.cluster-panel {
  background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.submit-panel {
  border-top: 5px solid #22c55e;
}

.cluster-panel {
  border-top: 5px solid #3b82f6;
}

.inspect-panel {
  border-top: 5px solid #a855f7;
}

.section-head,
.cluster-toolbar,
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.badge {
  flex: 0 0 auto;
  border: 1px solid #9fd1aa;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  color: #166534;
  background: #dcfce7;
  font-size: 0.72rem;
}

.badge.info {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #dbeafe;
}

.badge.accent {
  border-color: #c4b5fd;
  color: #6d28d9;
  background: #ede9fe;
}

.job-form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.85rem;
}

label {
  display: grid;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.78rem;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0.45rem 0.55rem;
}

input[type="range"] {
  min-height: 22px;
  padding: 0;
  accent-color: var(--green);
}

.range-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.inline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.primary-action {
  background: #1f8f3a;
  border-color: #1b7f34;
  color: white;
}

.primary-action:hover {
  background: #18742f;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.script-box,
.detail-box {
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}

.script-title {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.script-box pre,
.command-output {
  min-height: 150px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #1f2937;
  padding: 0.75rem;
  font-size: 0.78rem;
}

.sim-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sim-controls button {
  min-width: 58px;
  padding-inline: 0.75rem;
}

.speed-control {
  width: 132px;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 0.65rem;
}

.metrics div:nth-child(1) {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.metrics div:nth-child(2) {
  border-color: #fde68a;
  background: #fffbeb;
}

.metrics div:nth-child(3) {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.metrics div:nth-child(4) {
  border-color: #ddd6fe;
  background: #f5f3ff;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.metrics strong {
  display: block;
  margin-top: 0.1rem;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.node-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(135px, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.node {
  min-height: 138px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 0.65rem;
}

.node-cpu {
  border-color: #bbf7d0;
  background: linear-gradient(180deg, #f0fdf4, #ffffff);
}

.node-gpu {
  border-color: #ddd6fe;
  background: linear-gradient(180deg, #f5f3ff, #ffffff);
}

.node-highmem {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #eff6ff, #ffffff);
}

.node.maintenance {
  border-color: #d7aa43;
  background: #fff8e6;
}

.node-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.node-name {
  font-weight: 700;
  font-size: 0.86rem;
}

.node-partition {
  color: var(--muted);
  font-size: 0.74rem;
}

.node-bars {
  display: grid;
  gap: 0.4rem;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: #e6edf5;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar.mem span {
  background: var(--blue);
}

.bar.gpu span {
  background: var(--violet);
}

.bar-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
}

.job-chip {
  display: inline-block;
  max-width: 100%;
  margin-top: 0.45rem;
  border-radius: 5px;
  padding: 0.22rem 0.42rem;
  background: #dbeafe;
  color: #174a7c;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tables {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 0.9rem;
  margin-top: 1rem;
}

.tables > div {
  min-width: 0;
}

.table-head {
  margin-bottom: 0.45rem;
}

.table-head span {
  color: var(--muted);
  font-size: 0.74rem;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 0.78rem;
}

th,
td {
  padding: 0.48rem 0.55rem;
  border-bottom: 1px solid #e6edf5;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #eef4fb;
  font-weight: 600;
}

td {
  font-variant-numeric: tabular-nums;
}

tr.selected {
  background: #eaf2ff;
}

.state-r {
  color: #166534;
}

.state-pd {
  color: #8a5d0a;
}

.state-cd {
  color: #1d4ed8;
}

.log {
  min-height: 238px;
  max-height: 238px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
}

.log-line {
  color: #1f2937;
  padding-bottom: 0.28rem;
}

.log-line strong {
  color: var(--cyan);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-top: 0.85rem;
  margin-bottom: 0.55rem;
}

.tab {
  min-height: 32px;
  font-size: 0.78rem;
}

.tab.active {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.command-output {
  min-height: 220px;
}

.detail-box h3 {
  margin-bottom: 0.35rem;
}

.detail-box p {
  color: var(--muted);
  font-size: 0.86rem;
}

.concept-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.concept-list div {
  border-left: 3px solid var(--line);
  padding-left: 0.65rem;
}

.concept-list strong {
  display: block;
  font-size: 0.84rem;
}

.concept-list span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(250px, 320px) 1fr;
  }

  .inspect-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 840px) {
  .topbar,
  .workspace,
  .tables,
  .cluster-toolbar {
    grid-template-columns: 1fr;
  }

  .topbar,
  .cluster-toolbar {
    display: grid;
  }

  .workspace {
    padding: 0.7rem;
  }

  .node-grid,
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .inline-grid,
  .button-row,
  .node-grid,
  .metrics,
  .sim-controls {
    grid-template-columns: 1fr;
    display: grid;
  }

  .speed-control {
    width: 100%;
  }
}
