:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --text: #171a24;
  --muted: #748096;
  --line: #e9ebf0;
  --brand: #e83e8c;
  --brand-dark: #c72978;
  --purple: #7c3aed;
  --shadow: 0 14px 38px rgba(20, 27, 45, 0.045);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--text); background: #f8f9fb; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: grid; grid-template-columns: 72px minmax(0, 1fr); width: 100%; height: 100%; }

.rail { position: relative; display: flex; flex-direction: column; align-items: center; padding: 18px 7px 12px; background: #f8f9fb; border-right: 1px solid #eceef2; }
.logo-wrap { display: grid; place-items: center; width: 54px; height: 48px; margin-bottom: 24px; }
.logo-wrap img { width: 46px; height: auto; }
.rail nav { display: grid; gap: 8px; width: 100%; }
.rail-secondary { display: grid; gap: 8px; width: 100%; margin-top: 8px; padding-top: 8px; border-top: 1px solid #eef0f4; }
.nav-item { position: relative; display: grid; place-items: center; gap: 5px; width: 58px; min-height: 58px; padding: 8px 3px; color: #858b98; background: transparent; border: 0; border-radius: 7px; font-size: 11px; font-weight: 600; }
.nav-item span { line-height: 1.45; text-align: center; }
.nav-item svg { width: 20px; height: 20px; stroke-width: 1.7; }
.nav-item:hover { color: #252936; background: #f0f1f4; }
.nav-item.active { color: #1f232c; background: #fff; box-shadow: 0 5px 16px rgba(18, 24, 38, .07); }
.nav-item.active::before { position: absolute; top: 12px; bottom: 12px; left: -7px; width: 3px; content: ""; background: var(--brand); border-radius: 0 3px 3px 0; }
.rail-account { display: grid; justify-items: center; gap: 3px; width: 58px; margin-top: auto; padding: 7px 2px 8px; color: #68707f; background: transparent; border: 1px solid transparent; border-radius: 7px; }
.rail-account:hover { color: #252936; border-color: #cdd2da; background: #e4e6eb; }
.account-avatar { position: relative; display: grid; place-items: center; width: 27px; height: 27px; color: #4c5361; background: #e0e3e8; border-radius: 50%; }
.account-avatar svg { width: 14px; stroke-width: 1.7; }
.account-vip-badge { position: absolute; right: -12px; top: -5px; display: inline-grid; place-items: center; min-width: 24px; height: 13px; padding: 0 5px; color: #7a3f00; background: linear-gradient(180deg, #fff4c7, #ffd66b); border: 1px solid rgba(205, 136, 23, .22); border-radius: 999px; box-shadow: 0 2px 6px rgba(177, 110, 12, .16); font-size: 7px; font-weight: 850; line-height: 1; letter-spacing: .02em; }
.account-vip-badge[hidden] { display: none; }
.account-vip-badge.is-admin { min-width: 30px; color: #4c1d95; background: linear-gradient(180deg, #ede9fe, #ddd6fe); border-color: rgba(124, 58, 237, .18); box-shadow: 0 2px 6px rgba(124, 58, 237, .12); }
.account-vip-badge.is-expired { color: #7a8495; background: linear-gradient(180deg, #f3f4f6, #e6e8ee); border-color: rgba(148, 163, 184, .22); box-shadow: none; }
.account-phone { max-width: 54px; overflow: hidden; color: #757c89; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.account-vip-days { max-width: 56px; overflow: hidden; color: #a06012; font-size: 8px; font-weight: 750; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.account-vip-days.is-admin { color: #6d4fd1; }
.account-vip-days.is-expired { color: #9aa1ad; }
.account-popover { position: absolute; z-index: 12; bottom: 10px; left: 64px; width: 280px; padding: 10px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 16px 40px rgba(22, 28, 45, .14); }
.account-popover[hidden] { display: none; }
.account-popover [hidden] { display: none !important; }
.account-popover-head { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; padding: 7px 8px 12px; border-bottom: 1px solid #eceef2; }
.popover-avatar { display: grid; place-items: center; width: 34px; height: 34px; color: #4f5664; background: #f1f2f5; border-radius: 50%; }
.popover-avatar svg { width: 17px; }
.account-popover-head > div { display: grid; gap: 3px; }
.account-popover-head strong { font-size: 13px; }
.account-popover-head span { color: var(--muted); font-size: 10px; }
.account-action { display: grid; grid-template-columns: 28px minmax(0, 1fr) 16px; gap: 9px; align-items: center; width: 100%; min-height: 54px; margin-top: 5px; padding: 8px; color: #424957; text-align: left; background: transparent; border: 0; border-radius: 6px; }
.account-action:hover { background: #f5f6f8; }
.account-action > svg:first-child { width: 18px; }
.account-action > svg:last-child { width: 14px; color: #a2a8b2; }
.account-action > span { display: grid; gap: 3px; }
.account-action strong { font-size: 12px; }
.account-action small { color: var(--muted); font-size: 10px; }
.account-action small b { color: #9b1c62; }
.logout-action { color: #555d6a; }
.tool-flyout { position: absolute; z-index: 10; top: 74px; left: 64px; width: 320px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 20px 50px rgba(22, 28, 45, .15); }
.tool-flyout[hidden] { display: none; }
.flyout-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 5px 6px 12px; }
.flyout-heading > div { display: grid; gap: 4px; }
.flyout-heading strong { font-size: 15px; }
.flyout-heading span { color: var(--muted); font-size: 11px; }
.flyout-heading > button { display: grid; place-items: center; width: 30px; height: 30px; color: #697386; background: transparent; border: 0; border-radius: 6px; }
.flyout-heading > button:hover { background: #f3f4f6; }
.flyout-heading svg { width: 17px; }
.flyout-list { display: grid; gap: 5px; }
.flyout-list[hidden] { display: none; }
.flyout-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) 18px; gap: 11px; align-items: center; width: 100%; min-height: 64px; padding: 10px; color: #343a48; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 7px; }
.flyout-item:hover { background: #f7f8fa; border-color: #eceff3; }
.flyout-item.active { color: #8f1d60; background: #fff3f8; border-color: #ffd5e6; }
.flyout-item > svg:first-child { width: 20px; height: 20px; }
.flyout-item > svg:last-child { width: 15px; height: 15px; color: #a3aab7; }
.flyout-item span { display: grid; gap: 4px; }
.flyout-item strong { font-size: 13px; }
.flyout-item small { color: var(--muted); font-size: 11px; line-height: 1.4; }

.tool-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #f8f9fb; }
#tool-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.tool-loading { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); background: rgba(243, 245, 248, 0.94); font-size: 13px; }
.tool-loading.hidden { display: none; }
.loader { width: 28px; height: 28px; border: 3px solid #e1e5ec; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-main { display: grid; grid-template-rows: 70px 82px minmax(0, 1fr); min-width: 0; min-height: 0; padding: 0 28px 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-width: 0; border-bottom: 1px solid var(--line); }
.product-name { display: flex; align-items: baseline; gap: 12px; }
.product-name strong { font-size: 16px; }
.product-name span { color: var(--muted); font-size: 12px; }

.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
h1, h2, h3, p { margin: 0; }
.workspace-head h1 { font-size: 25px; letter-spacing: -.01em; line-height: 1.25; }
.workspace-head p, .panel-heading p, .result-toolbar p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.new-button { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 15px; color: #fff; background: #17181d; border: 0; border-radius: 7px; font-weight: 650; }
.new-button svg { width: 17px; }

.workspace-grid { display: grid; grid-template-columns: minmax(350px, 420px) minmax(0, 1fr); gap: 14px; min-height: 0; }
.form-panel, .result-panel { min-height: 0; overflow: hidden; background: var(--surface); border: 1px solid #eceef2; border-radius: 12px; box-shadow: var(--shadow); }
.form-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.panel-heading, .result-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .result-toolbar h2 { font-size: 17px; }
.step { color: #c7ccd6; font-size: 22px; font-weight: 750; }
.form-scroll { display: grid; align-content: start; gap: 16px; padding: 18px 20px 26px; overflow-y: auto; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { position: relative; display: grid; gap: 8px; color: #343b4a; font-size: 12px; font-weight: 650; }
label > span, label > em { position: absolute; top: -1px; right: 0; padding: 2px 6px; color: #e11d48; background: #fff1f3; border-radius: 999px; font-size: 10px; font-style: normal; font-weight: 600; }
label > em { color: #667085; background: #f2f4f7; }
select, textarea { width: 100%; color: #252a35; background: #fff; border: 1px solid #d8dee8; border-radius: 7px; outline: none; }
select { height: 42px; padding: 0 11px; font-weight: 600; }
textarea { min-height: 72px; padding: 11px 12px; resize: vertical; line-height: 1.5; }
select:focus, textarea:focus { border-color: #a855f7; box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.09); }
textarea::placeholder { color: #b2bac8; }
.form-action { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; background: var(--surface-soft); border-top: 1px solid var(--line); }
.form-action button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 20px; color: #fff; background: var(--brand); border: 0; border-radius: 7px; font-weight: 700; }
.form-action button:hover { background: var(--brand-dark); }
.form-action button svg { width: 16px; }
.form-action small { color: var(--muted); font-size: 11px; }

.result-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.toolbar-actions { display: flex; gap: 8px; }
.toolbar-actions button { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; color: #9ca3af; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 7px; }
.toolbar-actions svg { width: 15px; }
.empty-state { display: grid; place-content: center; justify-items: center; padding: 34px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 18px; color: #fff; background: linear-gradient(135deg, var(--brand), var(--purple)); border-radius: 8px; box-shadow: 0 10px 24px rgba(190, 36, 137, 0.2); }
.empty-icon svg { width: 24px; }
.empty-state h3 { font-size: 20px; }
.empty-state > p { margin-top: 9px; color: var(--muted); font-size: 13px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: min(760px, 100%); margin-top: 30px; text-align: left; }
.steps article { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; min-height: 118px; padding: 18px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; }
.steps article > span { display: grid; place-items: center; width: 26px; height: 26px; color: var(--brand-dark); background: #ffe9f2; border-radius: 50%; font-size: 12px; font-weight: 800; }
.steps strong { font-size: 13px; }
.steps p { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.55; }

@media (max-width: 1100px) {
  .workspace-grid { grid-template-columns: minmax(320px, 370px) minmax(0, 1fr); }
  .steps { grid-template-columns: 1fr; width: 420px; }
  .steps article { min-height: 0; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 64px minmax(0, 1fr); }
  .rail { padding-inline: 3px; }
  .nav-item, .rail-account { width: 58px; }
  .workspace-grid { grid-template-columns: 1fr; overflow-y: auto; }
  .form-panel, .result-panel { min-height: 620px; }
}
