:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --ink: #17201b;
  --muted: #637067;
  --line: #d8ded8;
  --accent: #0f7d6a;
  --blue: #1e8be8;
  --danger: #bb3e35;
  --good: #287a3d;
  --warn: #9b6a13;
  --shadow: 0 10px 28px rgba(20, 35, 29, 0.07);
}

* {
  box-sizing: border-box;
}

[hidden],
.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
output,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.96);
}

.ghost-button,
.tab-button {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.danger-button {
  background: #ffffff;
  border-color: #e5b5af;
  color: var(--danger);
}

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

h1 {
  font-size: clamp(21px, 2.2vw, 28px);
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 42px 14px;
}

.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.login-card h1 {
  margin-bottom: 6px;
}

.login-card p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.login-card label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.login-card input,
.login-card button {
  width: 100%;
}

.login-message {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 10px;
}

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

.topbar p,
.toolbar-title span,
.muted-line {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.top-actions,
.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.toolbar-title {
  display: grid;
  gap: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.form-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 8px;
}

.compact-band {
  padding: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.defaults-grid {
  grid-template-columns: 130px 106px 105px 106px auto;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
output {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 5px 7px;
  font-size: 13px;
}

output {
  display: flex;
  align-items: center;
  font-weight: 700;
  color: var(--ink);
}

.action-row {
  margin-top: 12px;
}

.inline-actions {
  display: flex;
  gap: 6px;
  align-items: end;
}

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

.injection-results-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr);
  gap: 8px;
}

.phase-grid {
  display: grid;
  grid-template-columns: 70px repeat(4, minmax(130px, 1fr));
  gap: 8px;
  align-items: center;
  overflow-x: auto;
}

.phase-head,
.phase-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.phase-name {
  color: var(--ink);
}

.result-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.result-list div {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.table-wrap.no-scroll {
  overflow-x: visible;
}

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

th,
td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: right;
  font-size: 13px;
}

.compact-table {
  min-width: 0;
  table-layout: fixed;
}

.compact-table th,
.compact-table td {
  padding: 4px 5px;
  font-size: 12px;
  line-height: 1.15;
}

.compact-table input,
.compact-table output {
  min-height: 28px;
  padding: 3px 5px;
  font-size: 12px;
  text-align: right;
}

.compact-table output {
  border: 0;
  background: transparent;
  justify-content: flex-end;
  white-space: nowrap;
}

.phase-table th:nth-child(1),
.phase-table td:nth-child(1) {
  width: 38px;
}

.phase-table th:nth-child(2),
.phase-table td:nth-child(2),
.phase-table th:nth-child(5),
.phase-table td:nth-child(5) {
  width: 72px;
}

.phase-table th:nth-child(3),
.phase-table td:nth-child(3),
.phase-table th:nth-child(6),
.phase-table td:nth-child(6) {
  width: 68px;
}

.phase-table th:nth-child(4),
.phase-table td:nth-child(4),
.phase-table th:nth-child(7),
.phase-table td:nth-child(7) {
  width: 88px;
}

.sequence-table th:nth-child(1),
.sequence-table td:nth-child(1) {
  width: 46px;
}

.sequence-table th:nth-child(2),
.sequence-table td:nth-child(2),
.sequence-table th:nth-child(3),
.sequence-table td:nth-child(3) {
  width: 142px;
}

.power-table th:nth-child(1),
.power-table td:nth-child(1) {
  width: 48px;
}

.power-table th:nth-child(2),
.power-table td:nth-child(2),
.power-table th:nth-child(3),
.power-table td:nth-child(3),
.power-table th:nth-child(4),
.power-table td:nth-child(4) {
  width: 72px;
}

.power-table th:nth-child(5),
.power-table td:nth-child(5) {
  width: 126px;
}

th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 800;
}

td {
  background: #ffffff;
  color: var(--ink);
}

tbody th,
thead th:first-child {
  text-align: left;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #17201b;
  color: #ffffff;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  max-width: min(420px, calc(100vw - 32px));
  z-index: 20;
}

@media (max-width: 900px) {
  .topbar,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .form-grid.compact,
  .grid-two,
  .defaults-grid,
  .injection-results-grid {
    grid-template-columns: 1fr;
  }

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

  .result-list {
    grid-template-columns: 1fr;
  }
}
