:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f9faff;
  --surface-3: #eff1f8;
  --text: #1c2238;
  --muted: #727991;
  --muted-2: #9399ae;
  --line: #e3e6ef;
  --line-strong: #d4d8e5;
  --primary: #5c5ce8;
  --primary-2: #7656d8;
  --primary-soft: #eeedff;
  --success: #15966a;
  --success-soft: #e7f7f1;
  --warning: #be7a0c;
  --warning-soft: #fff4dd;
  --danger: #cb4b58;
  --danger-soft: #ffebed;
  --info: #2876d2;
  --info-soft: #eaf3ff;
  --shadow-sm: 0 1px 2px rgba(25, 32, 56, .05), 0 3px 12px rgba(25, 32, 56, .04);
  --shadow-md: 0 14px 40px rgba(25, 32, 56, .10);
  --shadow-lg: 0 24px 80px rgba(25, 32, 56, .18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar: 244px;
  --topbar: 64px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #10121a;
  --surface: #171a24;
  --surface-2: #1c202c;
  --surface-3: #252a37;
  --text: #f3f4fa;
  --muted: #a0a7bd;
  --muted-2: #777f96;
  --line: #2a2f3d;
  --line-strong: #393f50;
  --primary: #8585ff;
  --primary-2: #9c7cf0;
  --primary-soft: #292945;
  --success: #47c998;
  --success-soft: #19382e;
  --warning: #efb04f;
  --warning-soft: #3a2f1d;
  --danger: #f07a84;
  --danger-soft: #42242a;
  --info: #68a8f1;
  --info-soft: #1f3147;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, .30);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }

.boot-screen { min-height: 100vh; display: grid; place-content: center; gap: 14px; justify-items: center; color: var(--muted); }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: white; font-weight: 800; font-size: 20px; background: linear-gradient(145deg, var(--primary-2), var(--primary)); box-shadow: 0 12px 30px rgba(92, 92, 232, .28); }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--line); z-index: 40; display: flex; flex-direction: column; }
.sidebar-brand { height: var(--topbar); display: flex; align-items: center; gap: 11px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.sidebar-brand .brand-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }
.sidebar-brand strong { font-size: 14px; letter-spacing: -.01em; }
.sidebar-brand small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; margin-top: 1px; }
.project-picker { margin: 14px 12px 8px; padding: 9px 10px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 11px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.project-picker select { width: 100%; border: 0; background: transparent; color: var(--text); outline: none; font-weight: 650; min-width: 0; }
.sidebar-nav { padding: 8px; overflow-y: auto; flex: 1; }
.nav-section { color: var(--muted-2); font-size: 10px; font-weight: 750; letter-spacing: .10em; text-transform: uppercase; padding: 15px 10px 7px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 39px; padding: 0 10px; border-radius: 9px; color: var(--muted); margin: 2px 0; transition: .16s ease; font-weight: 550; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); font-weight: 680; }
.nav-item .icon { width: 18px; height: 18px; }
.nav-item .nav-count { margin-left: auto; min-width: 21px; height: 19px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 10px; }
.nav-section-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: 0; cursor: pointer; font: inherit; }
.nav-section-toggle .icon { width: 13px; height: 13px; transition: transform .16s ease; }
.nav-section-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.nav-advanced-group[hidden] { display: none; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--line); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 31px; height: 31px; border-radius: 50%; background: linear-gradient(145deg, var(--primary-soft), var(--surface-3)); color: var(--primary); display: grid; place-items: center; font-size: 12px; font-weight: 800; border: 1px solid var(--line); }
.user-card strong { display: block; font-size: 12px; }
.user-card small { color: var(--muted); font-size: 10px; }

.topbar { position: fixed; top: 0; right: 0; left: var(--sidebar); height: var(--topbar); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); z-index: 35; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; }
.breadcrumbs { min-width: 0; display: flex; align-items: center; gap: 7px; color: var(--muted); }
.breadcrumbs strong { color: var(--text); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.reindex-pending { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.reindex-pending svg { width: 14px; height: 14px; }
.reindex-pending:hover { filter: brightness(0.95); }
.search-trigger { width: min(320px, 28vw); height: 36px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); border-radius: 10px; display: flex; align-items: center; gap: 8px; padding: 0 10px; cursor: pointer; }
.search-trigger kbd { margin-left: auto; border: 1px solid var(--line); border-bottom-color: var(--line-strong); background: var(--surface); border-radius: 5px; padding: 1px 5px; font-size: 10px; color: var(--muted-2); }
.main { margin-left: var(--sidebar); padding-top: var(--topbar); min-height: 100vh; }
.page { padding: 28px clamp(18px, 3vw, 40px) 52px; max-width: 1660px; margin: 0 auto; animation: page-in .22s ease; }
.page.wide { max-width: none; padding-left: 18px; padding-right: 18px; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-title h1 { margin: 0; font-size: clamp(24px, 2vw, 31px); letter-spacing: -.035em; line-height: 1.15; }
.page-title p { margin: 7px 0 0; color: var(--muted); max-width: 760px; line-height: 1.55; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn { min-height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font-weight: 650; font-size: 12px; transition: .15s ease; box-shadow: var(--shadow-sm); white-space: nowrap; }
.btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 7px 20px color-mix(in srgb, var(--primary) 26%, transparent); }
.btn.primary:hover { filter: brightness(1.04); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); }
.btn.success { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, var(--line)); background: var(--success-soft); }
.btn.icon-only { width: 36px; padding: 0; }
.btn.small { min-height: 30px; padding: 0 9px; border-radius: 8px; font-size: 11px; }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.icon { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { min-height: 54px; padding: 0 17px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h2, .card-header h3 { margin: 0; font-size: 13px; letter-spacing: -.01em; }
.card-body { padding: 17px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { padding: 17px; min-height: 126px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 100px; height: 100px; right: -48px; top: -48px; border-radius: 50%; background: var(--primary-soft); opacity: .65; }
.metric-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.metric-value { font-size: 27px; font-weight: 780; letter-spacing: -.04em; line-height: 1; }
.metric-label { margin-top: 7px; color: var(--muted); font-size: 11px; font-weight: 600; }
.metric-delta { position: absolute; right: 13px; bottom: 13px; z-index: 2; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 16px; margin-top: 16px; }
.stack { display: grid; gap: 16px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 750; background: var(--surface-3); color: var(--muted); border: 1px solid transparent; }
.badge.primary { color: var(--primary); background: var(--primary-soft); }
.badge.success { color: var(--success); background: var(--success-soft); }
.badge.warning { color: var(--warning); background: var(--warning-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.info { color: var(--info); background: var(--info-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.list { display: grid; }
.list-row { min-height: 56px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row strong { display: block; font-size: 12px; }
.list-row small { display: block; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.activity-icon { width: 31px; height: 31px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: 0 0 auto; }
.list-row.with-icon { grid-template-columns: auto minmax(0, 1fr) auto; }

.progress { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary-2), var(--primary)); border-radius: inherit; }
.health-ring { width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--success) calc(var(--value) * 1%), var(--surface-3) 0); position: relative; }
.health-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.health-ring strong { position: relative; z-index: 1; font-size: 23px; }

.toolbar { min-height: 48px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 9px; outline: none; transition: .15s ease; }
.input, .select { height: 37px; padding: 0 11px; }
.textarea { min-height: 100px; padding: 10px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.input-group { position: relative; min-width: 210px; flex: 1; }
.input-group .icon { position: absolute; left: 11px; top: 10px; color: var(--muted); pointer-events: none; }
.input-group .input { padding-left: 36px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; color: var(--muted); font-weight: 700; }
.field-hint { font-size: 10px; color: var(--muted-2); line-height: 1.45; }

.screen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.screen-card { overflow: hidden; transition: .18s ease; cursor: pointer; }
.screen-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.screen-preview { height: 186px; background: linear-gradient(145deg, var(--surface-2), var(--surface-3)); overflow: hidden; position: relative; border-bottom: 1px solid var(--line); }
.screen-preview iframe { width: 1440px; height: 900px; border: 0; transform: scale(.205); transform-origin: 0 0; pointer-events: none; background: white; }
.screen-preview img { width: 100%; height: 100%; object-fit: cover; }
.screen-preview::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.025); pointer-events: none; }
.screen-preview-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.screen-preview-placeholder svg { width: 36px; height: 36px; }
.screen-preview-pending { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted-2); background: var(--surface-2); }
.screen-preview-pending svg { width: 28px; height: 28px; opacity: .6; }
.screen-preview-pending span { font-size: 11px; }
.screen-preview-funnel { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px; background: linear-gradient(160deg, var(--primary-soft), var(--surface-2)); text-align: center; overflow: hidden; }
.screen-preview-funnel-image { max-width: 44%; max-height: 40%; object-fit: contain; }
.screen-preview-funnel-bubble { background: var(--surface); border-radius: 10px; padding: 7px 10px; box-shadow: var(--shadow-sm); max-width: 100%; }
.screen-preview-funnel-heading { font-weight: 700; font-size: 11px; margin-bottom: 2px; }
.screen-preview-funnel-body { font-size: 10px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.screen-preview-funnel-button { background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.screen-card-body { padding: 14px 15px 15px; }
#screen-category-filter { margin-bottom: 16px; }
.funnel-editor-layout { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.funnel-preview { width: 320px; flex-shrink: 0; padding: 28px 20px; border-radius: 16px; background: linear-gradient(160deg, var(--primary-soft), var(--surface-2)); display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.funnel-preview-image { max-width: 140px; max-height: 140px; object-fit: contain; }
.funnel-preview-bubble { background: var(--surface); border-radius: 14px; padding: 16px; box-shadow: var(--shadow-sm); width: 100%; min-height: 40px; }
.funnel-preview-heading { font-weight: 700; font-size: 15px; margin-bottom: 6px; word-break: break-word; }
.funnel-preview-body { font-size: 13px; color: var(--muted); word-break: break-word; }
.funnel-preview-body:not(:last-child) { margin-bottom: 6px; }
.funnel-preview-button { width: 100%; justify-content: center; }
.simple-editor-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; padding: 0 24px 24px; }
.simple-editor-preview { flex: 1 1 560px; min-width: 320px; height: 640px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.simple-editor-preview iframe { width: 100%; height: 100%; border: 0; background: white; }
.simple-editor-preview img { width: 100%; height: 100%; object-fit: contain; background: white; }
.simple-editor-side { width: 340px; flex-shrink: 0; }
.ai-edit-preview { margin-top: 14px; height: 420px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.ai-edit-preview iframe { width: 100%; height: 100%; border: 0; background: white; }
.screen-card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.screen-card-title strong { font-size: 13px; }
.screen-route { margin-top: 5px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; }
.screen-meta { margin-top: 12px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 15px; }
.project-card { padding: 17px; cursor: pointer; transition: .18s ease; }
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.project-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.project-card-head .icon { width: 22px; height: 22px; color: var(--primary); }
.project-card h3 { margin: 0; font-size: 14px; letter-spacing: -.01em; }
.project-card p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; min-height: 18px; }
.project-card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 13px; }
.project-card-branch { margin-top: 11px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; border-radius: 8px; background: var(--surface-2); }
.project-card-branch .mono { font-size: 11px; color: var(--muted); }
.project-card-foot { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 13px; border-top: 1px solid var(--line); }
.project-card-foot small { color: var(--muted-2); font-size: 10px; }

.data-table-wrap { overflow: auto; border-radius: var(--radius-lg); }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th { height: 42px; text-align: left; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 0 13px; position: sticky; top: 0; z-index: 1; }
.data-table td { min-height: 50px; padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td strong + small, .data-table td span + small { display: block; margin-top: 4px; color: var(--muted); }
.code-path { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); font-size: 10px; }

.resource-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.resource-card { padding: 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.resource-thumb { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--primary); overflow: hidden; }
.resource-thumb img { width: 100%; height: 100%; object-fit: cover; }
.resource-card strong { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-card small { display: block; margin-top: 5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.editor-page { height: calc(100vh - var(--topbar)); padding: 0; overflow: hidden; }
.editor-shell { height: 100%; display: grid; grid-template-rows: 50px minmax(0, 1fr); background: var(--surface); }
.editor-toolbar { border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 7px; padding: 0 11px; overflow-x: auto; }
.editor-toolbar .spacer { flex: 1; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: var(--surface-2); }
.segmented button { height: 29px; border: 0; background: transparent; border-radius: 7px; padding: 0 10px; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 650; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.editor-grid { min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr) 292px; }
.editor-panel { min-height: 0; background: var(--surface); overflow: auto; }
.editor-panel.left { border-right: 1px solid var(--line); }
.editor-panel.right { border-left: 1px solid var(--line); }
.panel-title { min-height: 42px; position: sticky; top: 0; z-index: 2; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 750; }
.tree { padding: 7px; }
.tree-node { min-height: 32px; display: flex; align-items: center; gap: 7px; padding: 0 8px; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 11px; }
.tree-node:hover { background: var(--surface-2); color: var(--text); }
.tree-node.active { background: var(--primary-soft); color: var(--primary); }
.tree-node code { margin-left: auto; font-size: 9px; color: var(--muted-2); }
.canvas-area { min-height: 0; overflow: auto; background-color: #d9dce5; background-image: linear-gradient(45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.35) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.35) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.35) 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; padding: 34px; }
:root[data-theme="dark"] .canvas-area { background-color: #282c36; background-image: linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.025) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.025) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.025) 75%); }
.device-stage { margin: 0 auto; background: white; border: 1px solid rgba(0,0,0,.14); border-radius: 10px; box-shadow: 0 18px 55px rgba(15,18,32,.24); overflow: hidden; transition: width .22s ease, height .22s ease, transform .18s ease; transform-origin: top center; }
.device-stage iframe { width: 100%; height: 100%; border: 0; display: block; background: white; }
.multi-device-grid { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 28px; }
.multi-device-item { display: grid; gap: 8px; justify-items: center; }
.multi-device-item > span { font-size: 10px; color: #444a5c; background: rgba(255,255,255,.82); padding: 4px 8px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.inspector { padding: 12px; display: grid; gap: 13px; }
.inspector-section { border-bottom: 1px solid var(--line); padding-bottom: 13px; }
.inspector-section:last-child { border-bottom: 0; }
.inspector-section h4 { margin: 0 0 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.inspector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.selected-node { padding: 10px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); }
.selected-node strong { display: block; font-size: 11px; }
.selected-node small { display: block; margin-top: 4px; opacity: .76; }
.code-workspace { height: 100%; display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 0; }
.file-explorer { border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
.code-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: 36px minmax(0,1fr); }
.code-tabs { display: flex; align-items: end; overflow-x: auto; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.code-tab { height: 35px; padding: 0 11px; display: flex; align-items: center; gap: 7px; border-right: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: 10px; }
.code-tab.active { background: var(--surface); color: var(--text); border-top: 2px solid var(--primary); }
.monaco-host, .fallback-editor { width: 100%; height: 100%; min-height: 0; border: 0; background: var(--surface); color: var(--text); }
.fallback-editor { resize: none; padding: 16px; outline: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.55; tab-size: 2; }

.diff-view { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.diff-pane { background: var(--surface); min-width: 0; }
.diff-title { height: 38px; padding: 0 12px; display: flex; align-items: center; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 700; }
.diff-code { margin: 0; padding: 13px; max-height: 520px; overflow: auto; white-space: pre; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); }
.unified-diff { margin: 0; padding: 15px; max-height: 560px; overflow: auto; white-space: pre; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #11141d; color: #d9dfef; border-radius: 12px; }

.ai-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.chat-card { min-height: 620px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-messages { padding: 20px; overflow: auto; display: grid; align-content: start; gap: 14px; }
.message { max-width: 82%; padding: 12px 14px; border-radius: 14px; line-height: 1.55; }
.message.user { margin-left: auto; background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.message.assistant { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-input { padding: 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.prompt-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 10px; cursor: pointer; color: var(--muted); font-size: 10px; transition: .15s; }
.prompt-chip:hover { border-color: var(--primary); color: var(--primary); }
.operation { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--surface-2); margin-top: 8px; }
.operation code { font-size: 10px; word-break: break-all; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: var(--surface); }
.login-visual { position: relative; overflow: hidden; padding: clamp(36px, 7vw, 96px); display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(circle at 20% 20%, rgba(118,86,216,.52), transparent 42%), radial-gradient(circle at 80% 70%, rgba(63,109,246,.52), transparent 42%), #17182b; color: white; }
.login-visual::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent); }
.login-visual > * { position: relative; z-index: 1; }
.login-visual h1 { font-size: clamp(38px, 5vw, 72px); max-width: 820px; line-height: .99; letter-spacing: -.055em; margin: 0; }
.login-visual p { max-width: 620px; color: rgba(255,255,255,.70); line-height: 1.7; font-size: 15px; }
.login-features { display: flex; flex-wrap: wrap; gap: 8px; }
.login-features span { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); backdrop-filter: blur(10px); border-radius: 999px; padding: 8px 12px; font-size: 11px; }
.login-form-wrap { display: grid; place-items: center; padding: 34px; background: var(--bg); }
.login-form { width: min(410px, 100%); }
.login-form .brand-mark { margin-bottom: 28px; }
.login-form h2 { font-size: 30px; letter-spacing: -.04em; margin: 0; }
.login-form > p { color: var(--muted); line-height: 1.55; margin: 8px 0 28px; }
.login-form .field { margin-bottom: 14px; }
.login-form .btn.primary { width: 100%; height: 43px; margin-top: 6px; }
.login-hint { margin-top: 18px; padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.6; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(12,14,24,.52); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 24px; animation: fade-in .14s ease; }
.modal { width: min(660px, 100%); max-height: min(820px, calc(100vh - 48px)); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); animation: modal-in .18s ease; }
.modal.wide { width: min(1040px, 100%); }
.modal-header { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px; }
.modal-footer { min-height: 60px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 0 18px; border-top: 1px solid var(--line); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.toast-root { position: fixed; top: 76px; right: 16px; z-index: 200; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 280px; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: 11px 13px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; animation: toast-in .2s ease; pointer-events: auto; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast strong { font-size: 11px; }
.toast p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } }

.command-modal { width: min(720px, calc(100vw - 32px)); position: fixed; top: 11vh; left: 50%; transform: translateX(-50%); z-index: 110; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow-lg); overflow: hidden; }
.command-input { height: 58px; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); padding: 0 18px; outline: none; font-size: 16px; }
.command-results { max-height: 58vh; overflow: auto; padding: 7px; }
.command-result { min-height: 48px; padding: 7px 10px; border-radius: 9px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; cursor: pointer; }
.command-result:hover, .command-result.active { background: var(--primary-soft); }
.command-result strong { display: block; font-size: 11px; }
.command-result small { display: block; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { min-height: 220px; display: grid; place-content: center; justify-items: center; text-align: center; padding: 30px; color: var(--muted); }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-3); margin-bottom: 12px; }
.empty strong { color: var(--text); }
.empty p { max-width: 420px; margin: 7px 0 0; font-size: 11px; line-height: 1.5; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 220% 100%; animation: shimmer 1.25s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -220% 0; } }
.error-state { padding: 18px; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); background: var(--danger-soft); color: var(--danger); border-radius: 12px; line-height: 1.5; }
.callout { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; }
.callout svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.callout.warning { background: var(--warning-soft); color: var(--warning); }
.callout.danger { background: var(--danger-soft); color: var(--danger); }
.callout strong { color: inherit; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .editor-grid { grid-template-columns: 220px minmax(0,1fr) 265px; }
  .ai-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar: 72px; }
  .sidebar-brand strong, .sidebar-brand small, .project-picker select, .nav-item span, .nav-section, .user-card > div, .nav-count { display: none; }
  .sidebar-brand, .project-picker, .nav-item, .user-card { justify-content: center; }
  .project-picker { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .two-col { grid-template-columns: 1fr; }
  .editor-grid { grid-template-columns: 190px minmax(0,1fr); }
  .editor-panel.right { position: fixed; right: 0; top: calc(var(--topbar) + 50px); bottom: 0; width: 290px; z-index: 20; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: .2s; }
  .editor-panel.right.open { transform: none; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}
@media (max-width: 640px) {
  :root { --sidebar: 0px; }
  .sidebar { transform: translateX(-100%); }
  .topbar { left: 0; padding: 0 12px; }
  .main { margin-left: 0; }
  .search-trigger { width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .page { padding: 20px 13px 40px; }
  .page-header { display: grid; }
  .header-actions { justify-content: flex-start; }
  .metric-grid, .three-col, .form-grid { grid-template-columns: 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-panel.left { display: none; }
  .canvas-area { padding: 18px; }
  .diff-view { grid-template-columns: 1fr; }
  .login-form-wrap { padding: 22px; }
}
