:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7f9;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

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

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

.wide-view .app-shell {
  width: calc(100vw - 32px);
  max-width: none;
}

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

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
}

p {
  margin-top: 6px;
  color: #5f6c7a;
}

.panel {
  background: #ffffff;
  border: 1px solid #dfe5eb;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.download-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 180px) minmax(150px, 180px) auto;
  align-items: end;
  gap: 14px;
}

.analysis-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  align-items: end;
  gap: 14px;
}

.profile-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px) minmax(180px, 260px) minmax(180px, 260px);
  align-items: end;
  gap: 14px;
}

.profile-config-field {
  grid-column: 1 / -1;
}

textarea {
  width: 100%;
  min-height: 260px;
  border: 1px solid #ccd6e0;
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
  color: #17202a;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.frame-fieldset,
.indicator-fieldset {
  grid-column: 1 / -1;
  border: 1px solid #dfe5eb;
  border-radius: 8px;
  padding: 12px;
  margin: 0;
}

.frame-fieldset legend,
.indicator-fieldset legend {
  padding: 0 6px;
  color: #4b5968;
  font-size: 13px;
  font-weight: 700;
}

.frame-rows {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.frame-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(120px, 160px) auto;
  align-items: end;
  gap: 10px;
}

.indicator-rows {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.indicator-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(90px, 120px) auto;
  align-items: end;
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  color: #4b5968;
  font-size: 13px;
  font-weight: 600;
}

.disabled-field {
  opacity: 0.42;
}

.disabled-field input,
.disabled-field select {
  cursor: not-allowed;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid #ccd6e0;
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  color: #17202a;
}

button {
  height: 42px;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  padding: 0 16px;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  padding: 0 16px;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

#layoutToggle,
.button-link.secondary,
.secondary-button {
  background: #ffffff;
  color: #1d4ed8;
}

.danger {
  border-color: #b42318;
  background: #b42318;
}

.status {
  min-height: 24px;
  margin-top: 14px;
  color: #4b5968;
  white-space: pre-wrap;
}

.status.error {
  color: #b42318;
}

.status.success {
  color: #027a48;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

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

.indicator-table {
  min-width: 1200px;
}

.indicator-table-wrap {
  max-height: min(620px, calc(100vh - 220px));
  overflow: auto;
  border: 1px solid #e8edf2;
  border-radius: 6px;
}

.indicator-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #ffffff;
}

th,
td {
  border-bottom: 1px solid #e8edf2;
  padding: 11px 10px;
  text-align: center;
  white-space: nowrap;
}

th {
  color: #5f6c7a;
  font-size: 12px;
  text-transform: uppercase;
  text-align: center;
}

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

.job-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 0.8fr) minmax(180px, 1fr) minmax(150px, 0.8fr);
  align-items: end;
  gap: 14px;
}

.interval-fieldset {
  grid-column: 1 / -1;
  border: 1px solid #dfe5eb;
  border-radius: 8px;
  padding: 12px;
  margin: 0;
}

.interval-fieldset legend {
  padding: 0 6px;
  color: #4b5968;
  font-size: 13px;
  font-weight: 700;
}

.interval-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.checkbox-chip,
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-chip {
  height: 38px;
  border: 1px solid #ccd6e0;
  border-radius: 6px;
  padding: 0 10px;
  background: #f8fafc;
}

.checkbox-chip input,
.toggle-row input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.toggle-row {
  height: 42px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-head,
.status-cell {
  width: 34px;
  min-width: 34px;
  text-align: center;
}

.status-led {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(102, 112, 133, 0.12);
  vertical-align: middle;
}

.status-led.enabled {
  background: #12b76a;
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.15);
}

.status-led.disabled {
  background: #f04438;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.15);
}

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

.row-actions button {
  height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.copy-frame-button {
  height: 34px;
  padding: 0 12px;
}

.analysis-result {
  display: block;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding: 18px 0;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .download-form {
    grid-template-columns: 1fr;
  }

  .analysis-form,
  .profile-form,
  .frame-row,
  .indicator-row {
    grid-template-columns: 1fr;
  }

  .job-form {
    grid-template-columns: 1fr;
  }
}
