:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #172033;
  --muted: #6b778c;
  --line: #d9e1ec;
  --blue: #2f6fed;
  --blue-dark: #1f55bd;
  --blue-soft: #edf4ff;
  --green: #1f8f4d;
  --green-soft: #e8f6ee;
  --red: #c93a3a;
  --red-soft: #fdeaea;
  --yellow-soft: #fff6d7;
  --yellow-text: #755a00;
  --radius: 8px;
  --shadow: 0 12px 32px rgba(22, 34, 55, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

body.page-widget,
body.page-worker {
  background: transparent;
}

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

.shell {
  min-height: 100vh;
}

.page-widget .shell,
.page-worker .shell {
  min-height: 0;
}

.workspace {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background:
    linear-gradient(180deg, #f8fbff 0%, #f4f7fb 100%);
}

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 4px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.workspace-header h1,
.install-panel h1,
.status h1,
.status h2,
.decision-panel h2,
.task-form h2 {
  margin: 0;
  letter-spacing: 0;
}

.workspace-header h1 {
  font-size: 26px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.deal-summary,
.decision-panel,
.task-form,
.settings-panel,
.install-panel,
.status {
  width: 100%;
  border: 1px solid #d6e1ee;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.deal-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
}

.summary-main {
  min-width: 0;
}

.deal-title-link {
  display: inline;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #10233f;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  overflow-wrap: anywhere;
}

.deal-title-link:hover {
  color: var(--blue);
  text-decoration: underline;
}

.meta-row,
.form-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 4px;
  height: 4px;
  align-self: center;
  border-radius: 50%;
  background: var(--line);
}

.facts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid #e7edf5;
}

.facts-grid div {
  min-width: 0;
  padding: 14px 12px 0 0;
}

.facts-grid div + div {
  padding-left: 14px;
  border-left: 1px solid #e7edf5;
}

.facts-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.facts-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  line-height: 1.1;
}

.pill-good {
  background: var(--green-soft);
  color: var(--green);
}

.pill-bad {
  background: var(--red-soft);
  color: var(--red);
}

.decision-panel,
.task-form,
.settings-panel,
.install-panel,
.status {
  padding: 22px;
}

.decision-panel p,
.task-form p,
.settings-panel p,
.install-panel p,
.status p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.actions-stacked {
  align-items: stretch;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  background: #2f6fed;
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(47, 111, 237, 0.18);
}

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

.button-secondary {
  border-color: #c7d5e8;
  background: #f8fbff;
  color: var(--text);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  border-color: #b9c8dc;
  background: #eef4ff;
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button-full {
  width: 100%;
}

.button-small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.disabled-hint {
  color: var(--red) !important;
  font-size: 13px;
}

.system-note {
  color: var(--muted) !important;
  font-size: 13px;
}

.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  line-height: 1.45;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 6px;
}

.notice-warning {
  border: 1px solid #ecd37d;
  background: var(--yellow-soft);
  color: var(--yellow-text);
}

.task-form {
  display: grid;
  gap: 16px;
}

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

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #ffffff;
  color: var(--text);
  line-height: 1.4;
}

.decision-panel label {
  margin-top: 16px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(47, 111, 237, 0.14);
}

.input-error {
  border-color: var(--red);
  outline: 3px solid rgba(201, 58, 58, 0.14);
}

.status {
  display: grid;
  max-width: 560px;
  gap: 8px;
  margin: 24px auto;
  text-align: center;
}

.status .actions {
  justify-content: center;
}

.status-success {
  border-color: #bfe5ce;
}

.status-error {
  border-color: #f1b7b7;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  border: 3px solid #d8e3f3;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

.status-mark {
  display: grid;
  width: 34px;
  height: 34px;
  margin: 0 auto 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 800;
}

.status-mark-success {
  background: var(--green-soft);
  color: var(--green);
}

.error-details {
  overflow: auto;
  max-height: 140px;
  margin: 12px 0 0;
  border-radius: var(--radius);
  background: #2b2f39;
  color: #ffffff;
  padding: 12px;
  text-align: left;
  white-space: pre-wrap;
}

.diagnostics {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.diagnostics summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.diagnostics dl {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.diagnostics div {
  display: grid;
  gap: 3px;
}

.diagnostics dt {
  font-weight: 700;
}

.diagnostics dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.diagnostics ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.diagnostics code {
  color: var(--text);
}

.definition-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.definition-list div {
  display: grid;
  gap: 4px;
}

.definition-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.definition-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.textarea-widget {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 40px;
  padding: 2px;
  background: transparent;
}

.textarea-widget-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  border: 1px solid #cdd8e7;
  border-radius: 10px;
  padding: 0;
  background: #ffffff;
  color: #667181;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(22, 34, 55, 0.08);
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.textarea-widget-button:hover:not(:disabled) {
  border-color: #8fb1ea;
  background: #f5f9ff;
  color: var(--blue);
  transform: translateY(-1px);
}

.textarea-widget-button:active:not(:disabled) {
  transform: translateY(0);
}

.textarea-widget-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.textarea-widget-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  color: currentColor;
  font-size: 18px;
  line-height: 1;
}

.textarea-widget-button.is-opening .textarea-widget-icon {
  width: 18px;
  height: 18px;
  border: 2px solid #d7e0ee;
  border-top-color: var(--blue);
  border-radius: 50%;
  color: transparent;
  animation: spin 850ms linear infinite;
}

.textarea-widget-label {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.connector-workspace {
  gap: 18px;
}

.connector-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.settings-panel {
  display: grid;
  gap: 16px;
}

.settings-panel h2,
.settings-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.settings-panel h2 {
  font-size: 18px;
}

.settings-panel h3 {
  font-size: 16px;
}

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

.field-hint {
  margin-top: -6px !important;
  font-size: 13px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.empty-state {
  border: 1px dashed #b9c8dc;
  border-radius: var(--radius);
  padding: 18px;
  background: #fbfcfe;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #ffffff;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #fbfcfe;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.table-action {
  width: 1%;
  white-space: nowrap;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 14px;
  }

  .workspace-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: stretch;
  }

  .facts-grid {
    grid-template-columns: 1fr;
  }

  .connector-grid,
  .form-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .actions,
  .actions-stacked {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
