.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--green); }
.data-workspace { max-width: 1780px; }
.data-heading { align-items: center; }
.legend { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.legend span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.user { background: var(--green); }
.legend-dot.platform { background: var(--blue); }
.legend-dot.external { background: var(--amber); }
.legend-dot.database { background: var(--teal); }

.flow-map { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.flow-map-head { min-height: 68px; padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.flow-map-head > div { display: grid; gap: 3px; }
.flow-map-head > span { color: var(--green); font-weight: 800; }
.flow-step-list { padding: 16px; display: grid; grid-template-columns: repeat(9, minmax(118px, 1fr)); gap: 8px; overflow-x: auto; }
.flow-map-step { position: relative; min-height: 82px; padding: 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); display: grid; align-content: start; gap: 5px; text-align: left; }
.flow-map-step::after { content: ""; position: absolute; top: 26px; left: 100%; width: 9px; height: 1px; background: var(--line-strong); }
.flow-map-step:last-child::after { display: none; }
.flow-map-step span { color: var(--muted); font-size: 10px; font-weight: 700; }
.flow-map-step strong { font-size: 12px; }
.flow-map-step small { font-size: 10px; }
.flow-map-step:hover { border-color: #99c5aa; background: var(--green-soft); }
.flow-map-step.active { color: #fff; background: var(--green); border-color: var(--green); }
.flow-map-step.active span, .flow-map-step.active small { color: #d8eee1; }

.cooperation-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.step-index, .step-detail, .build-section, .matrix-section { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.step-index { position: sticky; top: 82px; overflow: hidden; }
#stepIndex { display: grid; }
.step-index-button { min-height: 55px; padding: 8px 14px; border: 0; border-bottom: 1px solid #edf0ee; background: var(--surface); display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto; gap: 2px 8px; text-align: left; }
.step-index-button:last-child { border-bottom: 0; }
.step-index-button > span { grid-row: 1 / 3; width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: #edf1ee; font-size: 11px; font-weight: 800; }
.step-index-button strong { font-size: 12px; }
.step-index-button small { font-size: 10px; }
.step-index-button:hover { background: var(--surface-soft); }
.step-index-button.active { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.step-index-button.active > span { color: #fff; background: var(--green); }
.step-detail { overflow: hidden; }
.step-detail-head { min-height: 92px; padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.step-detail-head > div { display: grid; gap: 4px; }
.step-code { color: var(--green); font-size: 11px; font-weight: 800; }
.step-detail-head h2 { font-size: 23px; }

.handoff-row { padding: 20px; display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 12px; align-items: stretch; border-bottom: 1px solid var(--line); }
.handoff-column { min-width: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.column-title { min-height: 58px; padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 9px; }
.column-title > span { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; }
.column-title > span svg { width: 16px; }
.column-title div { display: grid; gap: 2px; }
.column-title p { font-size: 10px; }
.frontend-column .column-title { background: var(--green-soft); }
.frontend-column .column-title > span { color: var(--green); background: #d5ecdd; }
.backend-column .column-title { background: var(--blue-soft); }
.backend-column .column-title > span { color: var(--blue); background: #d7e7f6; }
.external-column .column-title { background: var(--amber-soft); }
.external-column .column-title > span { color: var(--amber); background: #f8e5c3; }
.handoff-arrow { align-self: center; width: 17px; color: #a6b1ab; }
.detail-list { padding: 8px 12px; display: grid; }
.detail-item { min-height: 48px; padding: 9px 0; border-bottom: 1px solid #edf0ee; display: grid; gap: 3px; }
.detail-item:last-child { border-bottom: 0; }
.detail-item strong { font-size: 12px; overflow-wrap: anywhere; }
.detail-item small { font-size: 10px; }
.source-label { width: fit-content; padding: 1px 5px; border-radius: 3px; font-size: 9px; font-weight: 800; }
.source-label.user { color: var(--green); background: var(--green-soft); }
.source-label.platform { color: var(--blue); background: var(--blue-soft); }
.source-label.external { color: var(--amber); background: var(--amber-soft); }

.transaction-panel { margin: 20px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.transaction-head { min-height: 62px; padding: 10px 14px; background: var(--teal-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.transaction-head > div { display: flex; align-items: center; gap: 10px; }
.transaction-head > div > svg { color: var(--teal); }
.transaction-head > div > div { display: grid; gap: 2px; }
.transaction-head p { font-size: 10px; }
.transaction-head > span { color: var(--teal); font-size: 11px; font-weight: 800; }
.write-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.write-table th, .parameter-table th, .matrix-table th { height: 38px; padding: 0 12px; color: var(--muted); background: var(--surface-soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; }
.write-table td { min-height: 52px; padding: 10px 12px; border-bottom: 1px solid #edf0ee; vertical-align: top; font-size: 11px; line-height: 1.5; }
.write-table tr:last-child td { border-bottom: 0; }
.table-name { color: var(--teal); font-family: Consolas, monospace; font-weight: 800; }
.write-action { padding: 2px 6px; border-radius: 3px; font-size: 9px; font-weight: 800; white-space: nowrap; }
.write-action.insert { color: var(--green); background: var(--green-soft); }
.write-action.update { color: var(--blue); background: var(--blue-soft); }
.write-action.read { color: var(--muted); background: #edf0ee; }
.state-transition { margin: 0 20px 20px; padding: 15px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); display: grid; grid-template-columns: minmax(220px, 0.7fr) 1.3fr; align-items: center; gap: 20px; }
.state-transition > div:first-child { display: grid; gap: 4px; }
.state-transition p { font-size: 11px; }
.state-chain { display: flex; align-items: center; gap: 7px; overflow-x: auto; }
.state-node { min-width: max-content; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-size: 10px; font-weight: 800; }
.state-node.current { color: var(--green); border-color: #92c4a4; background: var(--green-soft); }
.state-chain > svg { width: 13px; color: #aab4ae; }

.build-section, .matrix-section { margin-top: 18px; padding: 20px; }
.build-section > .section-title, .matrix-section > .section-title { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.build-flow { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: center; gap: 10px; background: var(--surface-soft); }
.build-flow > div { display: grid; gap: 3px; text-align: center; }
.build-flow > div span { color: var(--muted); font-size: 10px; }
.build-flow > div strong { font-size: 12px; }
.build-flow > div small { font-size: 10px; }
.build-flow > svg { width: 15px; color: #aab4ae; }
.build-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.65fr); gap: 16px; align-items: start; }
.parameter-table-wrap { border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; }
.parameter-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.parameter-table td { padding: 10px 12px; border-bottom: 1px solid #edf0ee; vertical-align: top; font-size: 11px; line-height: 1.45; }
.parameter-table tr:last-child td { border-bottom: 0; }
.parameter-source { display: inline-flex; padding: 2px 6px; border-radius: 3px; font-size: 9px; font-weight: 800; }
.parameter-source.user { color: var(--green); background: var(--green-soft); }
.parameter-source.git { color: var(--amber); background: var(--amber-soft); }
.parameter-source.profile { color: var(--blue); background: var(--blue-soft); }
.parameter-source.service { color: var(--teal); background: var(--teal-soft); }
.permission-no { color: var(--red); font-weight: 800; }
.permission-select { color: var(--green); font-weight: 800; }
.build-output { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.build-output-title { padding: 13px; background: var(--teal-soft); display: flex; align-items: center; gap: 10px; }
.build-output-title > svg { color: var(--teal); }
.build-output-title div { display: grid; gap: 2px; }
.build-output dl { margin: 0; padding: 14px; display: grid; gap: 12px; }
.build-output dl div { display: grid; gap: 3px; }
.build-output dt { color: var(--muted); font-size: 10px; }
.build-output dd { margin: 0; overflow-wrap: anywhere; font-size: 11px; font-weight: 700; }
.build-rule { margin: 0 14px 14px; padding: 11px; border-radius: 6px; background: var(--amber-soft); display: flex; gap: 9px; }
.build-rule > svg { color: var(--amber); }
.build-rule p { display: grid; gap: 3px; }
.matrix-filter { min-height: 34px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #edf1ee; display: flex; }
.matrix-filter button { padding: 0 10px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.matrix-filter button.active { color: var(--green); background: var(--surface); }
.matrix-section .table-scroll { margin-top: 16px; border: 1px solid var(--line); border-radius: 6px; }
.matrix-table { width: 100%; min-width: 980px; border-collapse: collapse; }
.matrix-table td { height: 49px; padding: 8px 12px; border-bottom: 1px solid #edf0ee; font-size: 11px; }
.matrix-table tr:last-child td { border-bottom: 0; }
.matrix-table td:not(:nth-child(-n+2)) { text-align: center; }
.matrix-mark { width: 22px; height: 22px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 800; }
.matrix-mark.write { color: var(--green); background: var(--green-soft); }
.matrix-mark.update { color: var(--blue); background: var(--blue-soft); }
.matrix-mark.none { color: #b5beb9; background: #f0f2f1; }
.matrix-table tr[hidden] { display: none; }

body.embedded .data-heading { margin-bottom: 14px; }
body.embedded .data-heading h1 { font-size: 23px; }
body.embedded .legend { display: none; }
body.embedded .step-index { display: none; }
body.embedded .cooperation-layout { grid-template-columns: 1fr; }
body.embedded .flow-step-list { grid-template-columns: repeat(9, 118px); }
body.embedded .build-section, body.embedded .matrix-section { margin-top: 14px; }

@media (max-width: 1260px) {
  .cooperation-layout { grid-template-columns: 220px minmax(0,1fr); }
  .handoff-row { grid-template-columns: 1fr; }
  .handoff-arrow { justify-self: center; transform: rotate(90deg); }
  .build-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .data-heading { align-items: flex-start; }
  .legend { width: 100%; overflow-x: auto; }
  .cooperation-layout { grid-template-columns: 1fr; }
  .step-index { position: static; }
  #stepIndex { grid-template-columns: repeat(3,1fr); }
  .step-index-button { border-right: 1px solid #edf0ee; }
  .state-transition { grid-template-columns: 1fr; }
  .build-flow { overflow-x: auto; grid-template-columns: repeat(7, minmax(110px, auto)); }
}

@media (max-width: 620px) {
  .topbar-actions .tag { display: none; }
  .topbar-actions .btn span { display: none; }
  .flow-map-head { align-items: flex-start; flex-direction: column; }
  .flow-step-list { grid-template-columns: repeat(9, 126px); }
  #stepIndex { grid-template-columns: 1fr 1fr; }
  .step-detail-head { align-items: flex-start; flex-direction: column; }
  .transaction-panel { margin: 14px; }
  .state-transition { margin: 0 14px 14px; }
  .build-section, .matrix-section { padding: 14px; }
  .build-section > .section-title, .matrix-section > .section-title { align-items: flex-start; }
  .matrix-filter { width: 100%; }
  .matrix-filter button { flex: 1; }
}
