.koas-decision-app,
.koas-decision-manager,
.koas-visual-builder-page {
  --koas-ink: #0f172a;
  --koas-muted: #64748b;
  --koas-line: #d7dee8;
  --koas-paper: #f8fafc;
  --koas-card: #ffffff;
  --koas-blue: #2563eb;
  --koas-blue-soft: #e0f2fe;
  --koas-blue-deep: #075985;
  --koas-amber: #f59e0b;
  --koas-amber-soft: #fef3c7;
  --koas-amber-deep: #92400e;
  --koas-green: #16a34a;
  --koas-green-soft: #dcfce7;
  --koas-purple: #7c3aed;
  --koas-purple-soft: #ede9fe;
  --koas-slate: #475569;
  --koas-slate-soft: #e2e8f0;
  color: var(--koas-ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.koas-decision-app *,
.koas-decision-manager *,
.koas-visual-builder-page * {
  box-sizing: border-box;
}

.koas-visual-builder-page {
  width: min(1440px, calc(100% - 32px));
  margin: 36px auto 72px;
}

.koas-decision-loading,
.koas-decision-message {
  padding: 18px 20px;
  border: 1px solid var(--koas-line, #d7dee8);
  border-radius: 14px;
  background: #fff;
  color: #334155;
}

.koas-decision-shell {
  background: var(--koas-paper);
  border: 1px solid var(--koas-line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

.koas-decision-topbar,
.koas-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  background: #fff;
  border: 1px solid var(--koas-line);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 18px;
}

.koas-kicker,
.koas-decision-kicker {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 800;
  color: var(--koas-muted);
}

.koas-decision-topbar h2,
.koas-manager-header h2 {
  margin: 0;
  color: var(--koas-ink);
  font-size: clamp(27px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: -.025em;
}

.koas-decision-intro {
  margin: 9px 0 0;
  color: var(--koas-muted);
  font-size: 16px;
  max-width: 800px;
}

.koas-decision-actions,
.koas-editor-actions,
.koas-editor-inline-actions,
.koas-manager-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.koas-decision-app button,
.koas-decision-manager button,
.koas-decision-app .koas-button,
.koas-decision-manager .koas-button,
.koas-decision-app .koas-secondary-link,
.koas-decision-manager .koas-secondary-link {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--koas-line);
  background: #fff;
  color: var(--koas-ink);
  border-radius: 10px;
  padding: 10px 13px;
  font: inherit;
  font-size: 14px;
  line-height: 1.15;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
}

.koas-decision-app button:hover,
.koas-decision-manager button:hover,
.koas-decision-app .koas-secondary-link:hover,
.koas-decision-manager .koas-secondary-link:hover {
  background: #f1f5f9;
  color: var(--koas-ink);
}

.koas-decision-app button:focus-visible,
.koas-decision-manager button:focus-visible,
.koas-decision-app input:focus,
.koas-decision-app textarea:focus,
.koas-decision-app select:focus {
  outline: 3px solid rgba(37, 99, 235, .18);
  outline-offset: 2px;
}

.koas-decision-app .koas-primary,
.koas-decision-manager .koas-primary {
  background: var(--koas-blue);
  border-color: var(--koas-blue);
  color: #fff;
}

.koas-decision-app .koas-primary:hover,
.koas-decision-manager .koas-primary:hover {
  background: #1d4ed8;
  color: #fff;
}

.koas-decision-app .koas-danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.koas-decision-app .koas-danger:hover {
  background: #fef2f2;
  color: #991b1b;
}

.koas-decision-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 18px;
}

.koas-decision-mode-note {
  color: var(--koas-muted);
  font-size: 13px;
}

.koas-decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 20px;
  align-items: start;
}

.koas-decision-section {
  --koas-tone: #0ea5e9;
  --koas-tone-soft: #e0f2fe;
  --koas-tone-dark: #075985;
  background: #fff;
  border: 1px solid var(--koas-line);
  border-radius: 20px;
  padding: 18px;
  min-width: 0;
}

.koas-decision-section[data-tone="amber"] { --koas-tone: #f59e0b; --koas-tone-soft: #fef3c7; --koas-tone-dark: #92400e; }
.koas-decision-section[data-tone="green"] { --koas-tone: #16a34a; --koas-tone-soft: #dcfce7; --koas-tone-dark: #166534; }
.koas-decision-section[data-tone="purple"] { --koas-tone: #7c3aed; --koas-tone-soft: #ede9fe; --koas-tone-dark: #5b21b6; }
.koas-decision-section[data-tone="slate"] { --koas-tone: #475569; --koas-tone-soft: #e2e8f0; --koas-tone-dark: #334155; }

.koas-section-heading {
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 12px;
  background: var(--koas-tone-soft);
  border: 1px solid color-mix(in srgb, var(--koas-tone) 35%, white);
}

.koas-section-heading h3 {
  margin: 0;
  color: var(--koas-tone-dark);
  font-size: 20px;
  line-height: 1.2;
}

.koas-section-heading p {
  margin: 6px 0 0;
  color: #526072;
  font-size: 13px;
}

.koas-option-card {
  border: 1px solid var(--koas-line);
  border-radius: 15px;
  margin: 10px 0;
  overflow: hidden;
  background: #fff;
}

.koas-option-card > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 15px;
  color: var(--koas-ink);
}

.koas-option-card > summary::-webkit-details-marker { display: none; }
.koas-option-card > summary::marker { display: none; }

.koas-option-number {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--koas-tone);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.koas-option-summary-title {
  font-weight: 800;
  line-height: 1.25;
}

.koas-option-summary-desc {
  display: block;
  margin-top: 4px;
  color: var(--koas-muted);
  font-size: 13px;
  font-weight: 400;
}

.koas-option-chevron {
  color: var(--koas-muted);
  font-size: 20px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform .15s ease;
}

.koas-option-card[open] .koas-option-chevron { transform: rotate(45deg); }

.koas-option-body {
  border-top: 1px solid #e5eaf0;
  padding: 14px 15px 16px;
}

.koas-org-preferred {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #ecfdf5;
  color: #166534;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.koas-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 11px;
  border-radius: 11px;
  margin: 8px 0;
  border: 1px solid #e5e7eb;
  background: #fafafa;
}

.koas-item-label {
  border-radius: 999px;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.koas-item[data-type="cost"] .koas-item-label { background: #fef3c7; color: #92400e; }
.koas-item[data-type="benefit"] .koas-item-label { background: #dcfce7; color: #166534; }
.koas-item[data-type="risk"] .koas-item-label { background: #fee2e2; color: #991b1b; }
.koas-item[data-type="note"] .koas-item-label { background: #e2e8f0; color: #334155; }

.koas-item-text {
  color: #334155;
  white-space: pre-line;
}

.koas-question-box {
  margin-top: 14px;
  padding: 13px;
  border-radius: 13px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
}

.koas-question-box h4 {
  margin: 0 0 9px;
  font-size: 15px;
  color: #1e3a8a;
}

.koas-answer-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.koas-question-result {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px 11px;
  background: #fff;
  border: 1px solid #bfdbfe;
  color: #334155;
}

.koas-question-path {
  margin: 10px 0 0;
  color: var(--koas-muted);
  font-size: 12px;
}

.koas-preference-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid #e5e7eb;
}

.koas-preference-selected {
  color: #166534;
  font-size: 13px;
  font-weight: 800;
}

.koas-status {
  min-height: 20px;
  margin-top: 12px;
  color: var(--koas-muted);
  font-size: 13px;
}

/* Editor */
.koas-editor-panel {
  border: 2px dashed #93c5fd;
  border-radius: 16px;
  padding: 14px;
  background: #f8fbff;
  margin: 12px 0;
}

.koas-editor-field {
  display: grid;
  gap: 5px;
  margin: 9px 0;
}

.koas-editor-field > label,
.koas-editor-mini-label {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.koas-decision-app input[type="text"],
.koas-decision-app textarea,
.koas-decision-app select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 9px 10px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  line-height: 1.3;
}

.koas-decision-app textarea { min-height: 76px; resize: vertical; }

.koas-editor-top {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, .8fr);
  gap: 16px;
  margin-bottom: 18px;
}

.koas-editor-settings {
  display: grid;
  gap: 8px;
  align-content: start;
}

.koas-editor-section {
  border: 1px solid #93c5fd;
  border-radius: 18px;
  padding: 14px;
  background: #fff;
}

.koas-editor-section-head,
.koas-editor-option-head,
.koas-editor-question-head,
.koas-editor-item-row,
.koas-editor-answer-row {
  display: grid;
  gap: 8px;
  align-items: start;
}

.koas-editor-section-head { grid-template-columns: 1fr 150px auto; }
.koas-editor-option-head { grid-template-columns: 1fr auto; }
.koas-editor-question-head { grid-template-columns: 1fr auto; }
.koas-editor-item-row { grid-template-columns: 110px 1fr auto; margin: 8px 0; }
.koas-editor-answer-row { grid-template-columns: minmax(120px, .7fr) minmax(140px, .8fr) 1fr auto; margin: 8px 0; }

.koas-editor-option {
  border: 1px solid #dbe4ee;
  border-radius: 14px;
  margin: 10px 0;
  padding: 12px;
  background: #fbfdff;
}

.koas-editor-question {
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 11px;
  margin-top: 10px;
  background: #eff6ff;
}

.koas-editor-checks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 9px 0;
  color: #334155;
  font-size: 13px;
}

.koas-add-zone {
  border: 1px dashed #94a3b8;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  margin-top: 10px;
  background: #f8fafc;
}

.koas-editor-savebar {
  position: sticky;
  bottom: 14px;
  z-index: 10;
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 10px 30px rgba(15,23,42,.12);
  backdrop-filter: blur(8px);
}

.koas-editor-unsaved {
  color: #92400e;
  font-size: 13px;
  font-weight: 800;
}

/* Manager */
.koas-decision-manager {
  background: var(--koas-paper);
  border: 1px solid var(--koas-line);
  border-radius: 22px;
  padding: 20px;
}

.koas-manager-header p { margin: 8px 0 0; color: var(--koas-muted); }
.koas-manager-list { display: grid; gap: 10px; }
.koas-manager-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--koas-line);
  border-radius: 14px;
  padding: 15px;
}
.koas-manager-row h3 { margin: 0; font-size: 17px; color: var(--koas-ink); }
.koas-manager-row p { margin: 4px 0 0; color: var(--koas-muted); font-size: 12px; }
.koas-manager-row code { font-size: 12px; padding: 5px 7px; background: #f1f5f9; border-radius: 7px; }
.koas-manager-empty { background: #fff; border: 1px dashed var(--koas-line); border-radius: 14px; padding: 24px; text-align: center; color: var(--koas-muted); }
.koas-manager-status { min-height: 18px; color: var(--koas-muted); font-size: 13px; margin-bottom: 8px; }

@media (max-width: 860px) {
  .koas-decision-topbar,
  .koas-manager-header,
  .koas-manager-row { flex-direction: column; align-items: stretch; }
  .koas-editor-top { grid-template-columns: 1fr; }
  .koas-editor-section-head,
  .koas-editor-option-head,
  .koas-editor-question-head,
  .koas-editor-item-row,
  .koas-editor-answer-row { grid-template-columns: 1fr; }
  .koas-decision-shell { padding: 14px; }
  .koas-manager-row-actions { align-items: stretch; }
}

@media print {
  .koas-decision-shell { border: 0; box-shadow: none; padding: 0; background: #fff; }
  .koas-decision-toolbar,
  .koas-editor-actions,
  .koas-preference-row,
  .koas-decision-topbar .koas-decision-actions { display: none !important; }
  .koas-option-card { break-inside: avoid; }
  .koas-option-card > .koas-option-body { display: block !important; }
  .koas-decision-grid { grid-template-columns: repeat(2, 1fr); }
}
