* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2ef;
  color: #1f2826;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid #d4ddd8;
  background: #f7f8f5;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  color: #5b6a63;
  text-decoration: none;
  font-size: 24px;
  line-height: 1;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 20px;
}

.side-note {
  color: #68746f;
  font-size: 13px;
  line-height: 1.45;
}

.profile-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.profile-card {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  border: 1px solid #d4ddd8;
  border-radius: 8px;
  background: #fff;
  color: #1f2826;
  padding: 11px 12px;
}

.profile-card.active {
  border-color: #3f6f68;
  background: #edf7f4;
}

.profile-card strong {
  font-size: 14px;
}

.profile-card span {
  color: #69766f;
  font-size: 12px;
}

.workspace {
  padding: 22px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.workflow-strip {
  border: 1px solid #d4ddd8;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.workflow-text {
  margin-top: 4px;
  color: #42504b;
  font-size: 14px;
  font-weight: 700;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tab-button {
  min-height: 36px;
  border: 1px solid #d4ddd8;
  border-radius: 6px;
  background: #f4f7f5;
  color: #2d3834;
  padding: 0 12px;
  font-weight: 700;
}

.tab-button.active {
  border-color: #3f6f68;
  background: #3f6f68;
  color: #fff;
}

.panel {
  border: 1px solid #d4ddd8;
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.tab-panel {
  display: none;
}

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

.section-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #e1e7e3;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  color: #68746f;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.save-status {
  min-height: 18px;
  color: #3f6f68;
  font-size: 13px;
  text-align: right;
}

.profile-form,
.source-form {
  display: grid;
  gap: 14px;
}

.channel-import-form {
  border: 1px solid #e1e8e4;
  border-radius: 8px;
  background: #f8faf8;
  padding: 14px;
  margin-bottom: 14px;
}

.section-subtitle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.section-subtitle span {
  color: #68746f;
  font-size: 13px;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.divider {
  border-top: 1px solid #e1e7e3;
  margin: 14px 0;
}

.recommend-panel {
  border: 1px solid #e1e8e4;
  border-radius: 8px;
  background: #f8faf8;
  padding: 14px;
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #42504b;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d4cf;
  border-radius: 6px;
  background: #fbfcfa;
  color: #1f2826;
  padding: 10px 11px;
  font-size: 14px;
}

textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

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

.compile-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  margin-top: 14px;
}

.wide-field {
  grid-column: span 2;
}

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

.checkbox-label input {
  width: 18px;
  height: 18px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  background: #3f6f68;
  color: #fff;
}

.secondary-button {
  background: #e2e8e4;
  color: #26302d;
}

.danger-button {
  background: #895a58;
  color: #fff;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-grid div {
  border: 1px solid #dce4df;
  border-radius: 8px;
  padding: 12px;
  background: #f8faf8;
  display: grid;
  gap: 4px;
}

.summary-grid strong {
  font-size: 22px;
}

.summary-grid span {
  color: #68746f;
  font-size: 12px;
  font-weight: 700;
}

.segment-table-wrap {
  overflow: auto;
  border: 1px solid #dce4df;
  border-radius: 8px;
  max-height: 300px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #e5ebe7;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f5f8f6;
  color: #4d5a55;
  font-size: 12px;
  position: sticky;
  top: 0;
}

td:last-child {
  min-width: 320px;
  color: #2e3835;
}

.compiled-output {
  margin-top: 14px;
  min-height: 260px;
  background: #f8faf8;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 13px;
}

.compact-output {
  min-height: 160px;
  margin-top: 0;
}

.blend-grid {
  margin-top: 14px;
  align-items: end;
}

.assignment-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.assignment-item,
.source-item {
  border: 1px solid #dce4df;
  border-radius: 8px;
  background: #f8faf8;
  padding: 10px 12px;
  color: #42504b;
  font-size: 13px;
}

.source-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.source-item {
  display: grid;
  gap: 5px;
}

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

.source-delete-button {
  min-height: 28px;
  border-radius: 6px;
  padding: 0 10px;
  background: #e2e8e4;
  color: #26302d;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.source-item.failed .source-delete-button {
  background: #d9b1aa;
  color: #4d241f;
}

.source-item.failed {
  border-color: #d9b1aa;
  background: #fff7f5;
}

.source-item strong {
  color: #1f2826;
}

.source-meta {
  color: #68746f;
  font-size: 12px;
}

.source-error {
  color: #a23b2a;
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #d4ddd8;
  }

  .workspace {
    padding: 14px;
  }

  .workflow-strip {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    justify-content: stretch;
  }

  .tab-button {
    flex: 1 1 130px;
  }

  .field-grid,
  .compile-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }
}
