:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #657385;
  --line: #d7dee8;
  --accent: #176b5b;
  --accent-dark: #0e4f43;
  --warn: #a15c00;
  --field: #ffffff;
  --drop: #f9fbfc;
  --hover: #f8fafb;
  --row-alt: #f7f9fb;
  --log-bg: #111820;
  --log-ink: #d9efe8;
}

:root.dark {
  --bg: #101418;
  --panel: #171d23;
  --ink: #e9eef3;
  --muted: #a5b3c2;
  --line: #33404d;
  --accent: #28a184;
  --accent-dark: #45b99e;
  --field: #11171d;
  --drop: #141b22;
  --hover: #1e2730;
  --row-alt: #151b22;
  --log-bg: #080c10;
  --log-ink: #d8fff2;
}

:root[data-theme="dark"] {
  --bg: #101418;
  --panel: #171d23;
  --ink: #e9eef3;
  --muted: #a5b3c2;
  --line: #33404d;
  --accent: #28a184;
  --accent-dark: #45b99e;
  --field: #11171d;
  --drop: #141b22;
  --hover: #1e2730;
  --row-alt: #151b22;
  --log-bg: #080c10;
  --log-ink: #d8fff2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

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

button.primary {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

button.primary:not(:disabled):hover {
  background: var(--accent-dark);
}

.shell {
  width: min(1360px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.topbar p,
.program-header p,
.note {
  color: var(--muted);
}

.status {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 8px 12px;
  min-width: 180px;
  text-align: center;
}

.status.ready {
  border-color: #b9d7ce;
  color: var(--accent-dark);
}

.workspace {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
}

.controls {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dropzone {
  display: grid;
  place-content: center;
  min-height: 160px;
  border: 2px dashed #b7c1cf;
  background: var(--drop);
  text-align: center;
  cursor: pointer;
  padding: 16px;
}

.dropzone.compact {
  min-height: 112px;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(40, 161, 132, 0.12);
}

.dropzone input {
  display: none;
}

.drop-title {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.drop-copy {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 700;
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  min-height: 38px;
  padding: 0 10px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 8px 10px;
  font-size: 13px;
  user-select: none;
}

.theme-toggle input {
  width: 16px;
  height: 16px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.single-program-loader {
  border: 1px solid var(--line);
  background: var(--drop);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.or-label {
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}

.file-button {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--field);
  cursor: pointer;
  font-weight: 700;
}

.file-button input {
  display: none;
}

.program-panel {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.program-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.legend {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  border: 1px solid var(--line);
  padding: 4px 7px;
}

.program-list {
  overflow: auto;
  max-height: 620px;
}

.program-list.empty {
  display: grid;
  place-items: center;
  min-height: 440px;
}

.empty-state {
  color: var(--muted);
}

.program-row {
  display: grid;
  grid-template-columns: 34px 92px 120px minmax(180px, 1fr) 168px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 6px solid var(--machine-color, var(--accent));
}

.program-row:nth-child(even) {
  background: var(--row-alt);
}

.program-row:hover {
  background: var(--hover);
}

.program-row input {
  width: 18px;
  height: 18px;
}

.program-code {
  font-weight: 700;
}

.program-machine {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 3px 8px;
  background: var(--machine-color, var(--accent));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.program-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-meta {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.program-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-panel {
  margin-top: 16px;
  padding: 14px;
}

.log-panel h2 {
  margin-bottom: 8px;
}

pre {
  margin: 0;
  min-height: 90px;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  background: var(--log-bg);
  color: var(--log-ink);
  white-space: pre-wrap;
}

.note {
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 860px) {
  .topbar,
  .workspace {
    display: block;
  }

  .status,
  .program-panel,
  .log-panel {
    margin-top: 16px;
  }

  .program-row {
    grid-template-columns: 34px 76px 1fr;
  }

  .program-machine,
  .program-meta {
    grid-column: 2 / 4;
    text-align: left;
    justify-self: start;
  }
}
