:root {
  color-scheme: light;
  --bg: #eef6f1;
  --panel: #ffffff;
  --line: #cfe2d6;
  --ink: #133325;
  --muted: #64756b;
  --brand: #287a52;
  --brand-strong: #155d3b;
  --danger: #c53232;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  min-height: 34px;
  padding: 0 12px;
}

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

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(24, 64, 44, 0.12);
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
}

.login-card p,
.topbar p,
.modal-header p {
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.login-card h1,
.topbar h1,
.section-title h2,
.modal-header h2 {
  margin: 0;
}

.login-card label,
.control-row label,
.task-form label {
  display: grid;
  gap: 7px;
}

.login-card label span,
.control-row label span,
.task-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.login-card input,
.control-row select,
.task-form input,
.task-form select,
.task-form textarea,
table textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  width: 100%;
}

.login-card input,
.control-row select,
.task-form input,
.task-form select {
  min-height: 38px;
  padding: 0 10px;
}

.task-form textarea,
table textarea {
  line-height: 1.5;
  padding: 9px 10px;
  resize: vertical;
}

.login-card button,
.primary-button,
#openTaskButton {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.login-card small,
#pageStatus,
#userLabel,
.section-title span,
.account-summary span,
.muted,
.run-item small,
.run-item span,
#formMessage {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.app-view {
  display: grid;
  gap: 14px;
  padding: 14px;
}

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

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

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

.panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.section-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.control-row {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 320px) auto minmax(0, 1fr);
}

.account-summary {
  background: #f6fbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 1420px;
  width: 100%;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #e4f1e9;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 900;
}

td strong {
  color: var(--ink);
}

table textarea {
  min-height: 62px;
  width: 220px;
}

.empty {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.status-pill {
  background: #e9f5ee;
  border-radius: 999px;
  color: var(--brand-strong);
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 8px;
  padding: 5px 10px;
}

.status-pill.running,
.status-pill.pausing {
  background: #fff4d8;
  color: #8c5b0b;
}

.status-pill.failed,
.status-pill.no_material,
.status-pill.insufficient_material {
  background: #fff0ed;
  color: var(--danger);
}

.status-pill.archived,
.status-pill.paused {
  background: #edf0ee;
  color: var(--muted);
}

.row-actions,
.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.action-stack {
  min-width: 120px;
}

.row-actions button,
.action-stack button,
#newTaskButton,
.icon-button {
  background: #f5faf7;
  color: var(--brand-strong);
}

.danger-button {
  background: #fff0ed !important;
  border-color: #f2b6ad;
  color: var(--danger) !important;
}

.task-error {
  color: var(--danger);
  display: block;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  max-width: 220px;
}

.run-list {
  display: grid;
  gap: 10px;
}

.run-item {
  background: #f6fbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.run-item header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.modal-backdrop {
  background: rgba(12, 42, 27, 0.28);
  display: grid;
  inset: 0;
  padding: 24px;
  place-items: center;
  position: fixed;
  z-index: 20;
}

.task-modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(24, 64, 44, 0.24);
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
  padding: 18px;
  width: min(920px, calc(100vw - 48px));
}

.modal-header {
  align-items: start;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.icon-button {
  min-width: 34px;
  padding: 0;
}

.task-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.check-line,
.radio-row {
  align-items: center;
  background: #f6fbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex !important;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
}

.radio-row label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.modal-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .topbar,
  .section-title,
  .control-row,
  .task-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: start;
  }
}
