:root {
  --primary: #1677ff;
  --primary-strong: #0958d9;
  --text: #1f2733;
  --muted: #788598;
  --border: #e7ebf0;
  --surface: #ffffff;
  --canvas: #f5f7fa;
  --success: #35a66f;
  --warning: #c88b1c;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: var(--canvas);
  font-size: 14px;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; min-width: 1180px; height: 100%; margin: 0; }
body { overflow: auto; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; background: var(--canvas); }
.topbar { height: 64px; display: flex; align-items: center; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; min-width: 210px; color: #0768bd; font-weight: 700; letter-spacing: .02em; }
.brand-mark { font-size: 20px; font-style: italic; margin-right: 8px; }
.brand-name { font-size: 15px; }
.global-nav { display: flex; align-self: stretch; gap: 12px; }
.global-nav button { position: relative; border: 0; background: transparent; padding: 0 15px; color: #556273; }
.global-nav button.active { color: var(--primary); font-weight: 600; }
.global-nav button.active::after { content: ""; position: absolute; left: 15px; right: 15px; bottom: 0; height: 2px; background: var(--primary); }
.account { margin-left: auto; color: #6b7788; }

.workspace { display: flex; min-height: calc(100vh - 64px); }
.domain-sidebar { width: 228px; flex: 0 0 228px; background: #fff; border-right: 1px solid var(--border); }
.side-head { height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 18px; color: #3b70b5; border-bottom: 1px solid var(--border); font-weight: 600; }
.side-search { margin: 14px 14px 10px; }
.side-list { padding: 0 8px; }
.side-item { padding: 11px 14px; border-radius: 4px; color: #566273; }
.side-item.active { background: #eaf3ff; color: var(--primary); font-weight: 600; }

.main { flex: 1; min-width: 0; background: #fff; }
.local-tabs { height: 54px; display: flex; align-items: flex-end; gap: 30px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.local-tabs button { height: 54px; position: relative; border: 0; background: transparent; color: #596678; }
.local-tabs button.active { color: var(--primary); font-weight: 600; }
.local-tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--primary); }
.breadcrumb { height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 24px; border-bottom: 1px solid var(--border); color: #7f8a99; }
.dataset-breadcrumb { height: 62px; display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid #eef1f5; color: #7aa8e8; background: #fff; font-size: 18px; }
.crumb-link { border: 0; background: transparent; color: #4e78ad; padding: 0; }
.content { padding: 22px 24px 28px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.toolbar-spacer { flex: 1; }
.field { height: 34px; min-width: 210px; padding: 0 11px; border: 1px solid #d9dfe7; border-radius: 3px; color: #445064; background: #fff; outline: none; }
.field:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgb(22 119 255 / 10%); }
.select { min-width: 150px; }
.btn { height: 34px; border-radius: 3px; border: 1px solid #d8dee7; background: #fff; color: #415066; padding: 0 15px; }
.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn.danger { border-color: #ef4d57; background: #ef4d57; color: #fff; }
.btn.primary:hover { background: var(--primary-strong); }
.btn.link { border: 0; padding: 0 4px; background: transparent; color: var(--primary); height: auto; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.panel-title { display: flex; align-items: center; min-height: 42px; font-weight: 600; }
.table-wrap { border-top: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 44px; text-align: left; padding: 0 12px; color: #6d7888; background: #fafbfc; font-weight: 500; border-bottom: 1px solid var(--border); }
td { min-height: 52px; padding: 13px 12px; border-bottom: 1px solid #eef1f4; color: #4c5869; vertical-align: middle; word-break: break-word; }
tr:hover td { background: #fbfdff; }
.name-main { color: #2f3b4b; font-weight: 500; margin-bottom: 4px; }
.name-sub { color: #8792a2; font-size: 12px; }
.entity-link { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tag { display: inline-flex; height: 22px; align-items: center; border-radius: 10px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
.tag.blue { color: #3d6dba; background: #edf4ff; border: 1px solid #d7e5fb; }
.tag.green { color: #23855a; background: #eaf8f2; border: 1px solid #cfeee0; }
.tag.gold { color: #a86d0a; background: #fff7e6; border: 1px solid #f8e4bb; }
.tag.gray { color: #6f7886; background: #f4f5f6; border: 1px solid #e4e7eb; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 18px; color: #7a8594; }
.page-box { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #dfe4ea; border-radius: 3px; color: #526071; background: #fff; }
.page-box.active { border-color: var(--primary); color: var(--primary); }
.empty { padding: 100px 20px; text-align: center; color: #9aa4b1; }

.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgb(15 27 45 / 48%); }
.modal { width: 800px; max-height: 84vh; overflow: auto; background: #fff; border-radius: 5px; box-shadow: 0 18px 50px rgb(16 32 54 / 22%); }
.modal.wide { width: 1180px; }
.modal.model-edit-modal { width: 800px; max-height: 84vh; border-radius: 6px; }
.modal-head { height: 58px; display: flex; align-items: center; padding: 0 22px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600; }
.modal-head .close { margin-left: auto; border: 0; background: transparent; color: #8994a3; font-size: 18px; }
.modal-body { padding: 24px 28px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 26px; }
.form-row { display: flex; flex-direction: column; gap: 8px; }
.form-row.full { grid-column: 1 / -1; }
.form-row label { color: #455164; }
.required::before { content: "*"; color: #ef4d57; margin-right: 4px; }
.help { color: #929cac; font-size: 12px; }
.steps { display: flex; align-items: center; margin-bottom: 24px; }
.step { display: flex; align-items: center; gap: 8px; color: #8994a2; }
.step-dot { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #eef1f5; color: #7b8796; }
.step.active { color: #355f9f; }
.step.active .step-dot { background: var(--primary); color: #fff; }
.step-line { flex: 1; height: 1px; margin: 0 12px; background: #dfe4ea; }
.toast { position: fixed; top: 82px; left: 50%; z-index: 40; transform: translateX(-50%); background: #fff; border: 1px solid #cfe9dc; box-shadow: 0 8px 24px rgb(16 32 54 / 12%); color: #277c55; padding: 12px 18px; border-radius: 4px; }
.assistant-fab { position: fixed; right: 28px; bottom: 30px; width: 44px; height: 44px; border-radius: 50%; border: 4px solid #e7efff; background: #315fdc; color: #fff; font-weight: 700; }

.status-card { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 4px; border: 1px solid var(--border); background: #fafcff; }
.status-card.success { border-color: #cfe9dc; background: #f1fbf6; color: #277c55; }
.status-card.error { border-color: #f4cdd0; background: #fff6f6; color: #b7353f; }
.field-table { max-height: 460px; overflow: auto; border: 1px solid var(--border); }
.dual-list { display: grid; grid-template-columns: 1fr 48px 1fr; gap: 12px; min-height: 430px; }
.list-box { border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.list-head { padding: 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.list-search { margin: 12px; width: calc(100% - 24px); }
.list-item { padding: 11px 14px; display: flex; align-items: center; gap: 8px; border-top: 1px solid #f0f2f4; }
.transfer-controls { display: flex; flex-direction: column; justify-content: center; gap: 8px; }

.drawer-wrap { position: fixed; inset: 0; z-index: 20; background: rgb(15 27 45 / 38%); }
.drawer { position: absolute; right: 0; top: 0; width: 560px; height: 100%; background: #fff; box-shadow: -12px 0 40px rgb(15 27 45 / 14%); }
.drawer-body { padding: 24px; }
.detail-row { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 13px 0; border-bottom: 1px solid #eef1f4; }
.detail-label { color: #8792a1; }

.entity-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: calc(100vh - 112px); background: #fff; }
.entity-sidebar { position: relative; border-right: 1px solid var(--border); padding: 20px 16px; }
.entity-heading { display: flex; gap: 10px; align-items: flex-start; padding: 0 4px 20px; }
.entity-star { color: #c99827; font-size: 20px; }
.entity-title { font-size: 16px; font-weight: 600; margin-bottom: 5px; }
.entity-menu { width: 100%; height: 40px; display: flex; align-items: center; padding: 0 14px; margin-bottom: 4px; border: 0; border-radius: 3px; color: #576476; background: transparent; text-align: left; }
.entity-menu.active { background: #eaf3ff; color: var(--primary); font-weight: 600; }
.entity-meta { position: absolute; left: 20px; right: 20px; bottom: 26px; color: #697587; font-size: 12px; }
.entity-meta > strong { display: block; margin-bottom: 10px; color: #4d5968; }
.entity-meta .detail-row { display: grid; grid-template-columns: 72px 1fr; padding: 7px 0; border: 0; gap: 4px; }
.entity-editor { padding: 0 24px 32px; }
.editor-head { height: 58px; display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.editor-head .btn { margin-left: auto; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; padding: 20px 0; }
.editor-grid.one-column { grid-template-columns: 1fr; }
.editor-textarea { min-height: 150px; padding-top: 10px; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field .field { flex: 1; }
.editor-grid .form-row > .btn { align-self: flex-end; }

.dataset-detail-page { display: grid; grid-template-columns: 328px minmax(0, 1fr); gap: 14px; min-height: calc(100vh - 126px); padding: 14px 12px 18px; background: #f7f9fc; }
.dataset-detail-sidebar, .dataset-editor-panel { border: 1px solid #e2e8f0; border-radius: 4px; background: #fff; }
.dataset-detail-sidebar { position: relative; min-height: calc(100vh - 158px); padding: 28px 12px 22px; }
.dataset-card-head { padding: 0 26px 14px; border-bottom: 1px solid #edf0f4; }
.dataset-card-head strong { display: block; margin-bottom: 6px; color: #334766; font-size: 20px; }
.dataset-card-head span { color: #8a95aa; font-size: 15px; }
.dataset-menu-list { padding: 18px 0; }
.dataset-menu { width: 100%; height: 48px; display: flex; align-items: center; gap: 12px; border: 0; background: transparent; padding: 0 18px; color: #314562; font-size: 18px; font-weight: 600; text-align: left; }
.dataset-menu.active { background: #eef5ff; color: #1677ff; }
.dataset-menu span { width: 20px; color: inherit; font-size: 14px; }
.dataset-create-info { position: absolute; left: 28px; right: 20px; bottom: 34px; color: #667792; }
.dataset-create-info strong { display: block; margin-bottom: 22px; color: #314562; font-size: 16px; }
.dataset-create-info div { display: flex; gap: 8px; margin: 18px 0; }
.dataset-create-info b { color: #425672; }
.dataset-create-info span { color: #929db2; }
.dataset-editor-panel { min-height: calc(100vh - 158px); overflow: hidden; }
.dataset-editor-head { height: 68px; display: flex; align-items: center; padding: 0 22px; border-bottom: 1px solid #e5eaf1; }
.dataset-editor-head strong { font-size: 18px; color: #1f2733; }
.dataset-editor-head .btn { margin-left: auto; height: 36px; padding: 0 20px; font-size: 16px; border-radius: 5px; }
.dataset-form { padding: 26px 22px; }
.dataset-form .form-row { margin-bottom: 28px; gap: 10px; }
.dataset-form label { color: #637086; font-size: 15px; font-weight: 600; }
.dataset-form .field { width: 100%; height: 34px; min-width: 0; border-radius: 6px; color: #2f3744; }
.dataset-form select.field { color: #c1c7d0; }
.dataset-description { min-height: 56px; padding-top: 10px; resize: vertical; }
.dataset-relations { display: grid; grid-template-columns: minmax(430px, 520px) 32px minmax(430px, 520px); gap: 10px; justify-content: center; padding: 22px 22px 0; }
.relation-list { height: 640px; border: 1px solid #dfe3e8; border-radius: 8px; overflow: hidden; background: #fff; }
.relation-list-head { height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; color: #303946; border-bottom: 1px solid #edf0f4; }
.relation-list-head label { display: flex; align-items: center; gap: 6px; }
.switch-model { display: flex; align-items: center; gap: 8px; }
.switch-model .field { height: 34px; min-width: 150px; }
.relation-search { padding: 12px 14px; border-bottom: 1px solid #edf0f4; }
.relation-search .field { width: 100%; min-width: 0; border-radius: 6px; color: #adb5c0; }
.relation-table-head, .relation-row { display: grid; grid-template-columns: 34px 1fr 160px 160px; align-items: center; min-height: 42px; padding: 0 10px; border-bottom: 1px solid #edf0f4; }
.relation-table-head { color: #66738a; background: #f6f7f9; font-weight: 600; }
.relation-row { color: #414b5b; }
.relation-row:hover { background: #fbfdff; }
.relation-tag { display: inline-flex; height: 24px; align-items: center; padding: 0 9px; border: 1px solid #ffc777; border-radius: 5px; color: #f08a00; background: #fff9ef; font-style: normal; }
.relation-tag.blue { color: #1677ff; border-color: #9cc7ff; background: #eef6ff; }
.relation-transfer { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.relation-transfer .btn { width: 28px; height: 28px; padding: 0; color: #b7bec9; background: #fafafa; }
.relation-empty { height: 160px; display: grid; place-items: center; align-content: center; color: #9ca3ad; }
.empty-box-icon { width: 42px; height: 30px; margin-bottom: 10px; border: 1px solid #e0e3e7; border-radius: 8px; background: linear-gradient(#fff, #f7f7f8); box-shadow: 0 10px 0 rgb(0 0 0 / 3%); }

.toolbar.compact { margin-bottom: 12px; }
.operation-summary { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid #d7e5fb; border-radius: 4px; background: #f5f9ff; color: #49627d; }
.operation-summary span { color: #788598; font-size: 12px; }
.code-area { min-height: 96px; padding-top: 10px; font-family: "SFMono-Regular", Consolas, monospace; line-height: 1.55; }
.formula-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; padding: 20px 0; }
.formula-card, .formula-panel, .rule-card { border: 1px solid var(--border); border-radius: 5px; background: #fff; padding: 18px; }
.formula-card label { display: block; margin-bottom: 10px; color: #455164; }
.formula-panel { display: flex; flex-direction: column; gap: 10px; }
.formula-panel strong { margin-bottom: 2px; }
.field-chip { display: flex; justify-content: space-between; gap: 12px; width: 100%; min-height: 34px; align-items: center; border: 1px solid #dce3ec; border-radius: 3px; background: #fafcff; color: #405065; padding: 0 10px; text-align: left; }
.field-chip span { color: #8b96a5; font-size: 12px; }
.lineage-board { display: flex; align-items: center; gap: 16px; margin: 28px 0 18px; padding: 26px; border: 1px solid var(--border); border-radius: 6px; background: linear-gradient(180deg, #fbfdff, #f6f9fc); }
.lineage-node { min-width: 150px; padding: 18px 14px; border-radius: 6px; text-align: center; border: 1px solid #dbe4ef; background: #fff; color: #344154; box-shadow: 0 6px 18px rgb(16 32 54 / 5%); }
.lineage-node span { display: block; margin-top: 6px; color: #8590a0; font-size: 12px; }
.lineage-node.source { border-color: #bfe4d3; }
.lineage-node.model { border-color: #bad5ff; }
.lineage-node.metric { border-color: #f5d79d; }
.lineage-node.app { border-color: #d6c7fb; }
.lineage-arrow { color: #9aa4b1; font-size: 24px; }
.impact-note { margin-left: 4px; }
.rule-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.confirm-box { display: grid; grid-template-columns: 46px 1fr; gap: 14px; align-items: start; }
.confirm-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #fff7e6; color: #c27a09; font-weight: 700; }
.confirm-box p { margin: 8px 0 12px; color: #788598; }
.confirm-target { display: inline-flex; align-items: center; max-width: 100%; padding: 7px 10px; border-radius: 4px; background: #f4f6f8; color: #4d5968; }
.wide-drawer { width: 720px; }

.model-edit-modal .modal-body { padding: 16px 24px 20px; }
.model-edit-steps { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 18px; }
.model-step { display: flex; align-items: center; gap: 8px; color: #788598; white-space: nowrap; }
.model-step span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #eef1f5; color: #7f8a99; font-size: 12px; }
.model-step.active { color: #1f2733; font-weight: 500; }
.model-step.active span { background: var(--primary); color: #fff; }
.model-step.done span { background: #eaf4ff; color: var(--primary); }
.model-step-line { height: 1px; background: var(--primary); opacity: .75; }
.model-edit-form { display: flex; flex-direction: column; gap: 18px; }
.model-edit-form .form-row { gap: 8px; }
.model-edit-form .field { width: 100%; min-width: 0; border-radius: 6px; color: #3d4654; }
.model-edit-form label { color: #4b596c; font-weight: 600; }
.drill-help { margin: -2px 0 2px; line-height: 1.4; }
.model-edit-textarea { min-height: 58px; padding-top: 10px; resize: vertical; }
.model-field-step { position: relative; }
.model-field-search { display: flex; width: 250px; margin-bottom: 12px; }
.model-field-search .field { min-width: 0; border-radius: 4px 0 0 4px; }
.model-field-search .btn { width: 34px; padding: 0; border-left: 0; border-radius: 0 4px 4px 0; color: #7f8a99; }
.model-field-table { max-height: 520px; overflow: auto; border-radius: 6px; background: #fff; }
.model-field-head, .model-field-row { display: grid; grid-template-columns: 210px 130px 250px 1fr 180px; align-items: start; gap: 14px; padding: 0 16px; border-bottom: 1px solid #eef1f4; }
.model-field-head { min-height: 48px; align-items: center; color: #69778b; background: #fafbfc; font-weight: 600; }
.model-field-row { min-height: 64px; padding-top: 16px; color: #2f3b4b; }
.model-field-row.expanded { min-height: 104px; }
.semantic-selects { display: flex; gap: 8px; }
.semantic-selects .field, .field-ext .field { height: 32px; min-width: 88px; border-radius: 6px; }
.field-ext { display: grid; grid-template-columns: 70px minmax(150px, 1fr) 20px; gap: 8px 6px; align-items: center; color: #4f5c6f; }
.field-ext label:nth-of-type(2) { grid-column: 1; }
.field-ext .disabled { color: #c1c7d0; }
.quick-create { display: flex; align-items: center; gap: 8px; }
.quick-create .field { min-width: 0; width: 120px; height: 32px; border-radius: 6px; }
.filter-sql-label { margin: 22px 0 8px; color: #4a596d; font-weight: 600; }
.sql-editor { height: 150px; display: grid; grid-template-columns: 42px 1fr; border: 1px solid #2b302a; background: #1e241d; color: #9aa58f; font-family: "SFMono-Regular", Consolas, monospace; }
.sql-line { padding-top: 8px; text-align: center; background: #2b302a; color: #b9c0b2; }
.sql-body { background: #1f251e; }
.fullscreen-link { float: right; margin-top: 6px; }

@media (max-width: 1300px) {
  .topbar { padding: 0 18px; }
  .brand { min-width: 180px; }
  .global-nav { gap: 0; }
  .global-nav button { padding: 0 10px; }
}
