:root {
  --ink: #1d2528;
  --muted: #6d7a7e;
  --line: #dfe5e3;
  --paper: #f5f3ee;
  --card: #ffffff;
  --brand: #d75b32;
  --brand-dark: #a94324;
  --brand-soft: #f7e5dd;
  --green: #2b7a5a;
  --shadow: 0 18px 45px rgba(29, 37, 40, 0.08);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.hidden, [hidden] { display: none !important; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 32px; background:
  radial-gradient(circle at 15% 20%, rgba(215, 91, 50, .16), transparent 34%),
  radial-gradient(circle at 90% 85%, rgba(43, 122, 90, .12), transparent 30%), var(--paper); }
.login-shell { width: min(1080px, 100%); min-height: 560px; display: grid; grid-template-columns: 1.2fr .8fr; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 26px; overflow: hidden; }
.login-brand { padding: 58px 54px; color: #fdf9f3; background: #1d2528; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; width: 420px; height: 420px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; right: -150px; bottom: -160px; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 16px; background: var(--brand); color: white; font-size: 28px; font-weight: 800; letter-spacing: -.06em; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; font-size: 21px; }
.brand-eyebrow { margin-top: 46px; font: 12px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: #ed9b78; }
.login-brand h1 { margin-top: 14px; font-size: clamp(42px, 5vw, 72px); letter-spacing: .06em; line-height: 1.05; }
.brand-lead { margin-top: 22px; font-size: 18px; color: #c8d0ca; }
.brand-points { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 34px; max-width: 440px; }
.brand-points span { border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 7px 13px; color: #e9ece7; font-size: 13px; }
.brand-foot { margin-top: 78px; color: #8d9b96; font-size: 13px; line-height: 1.8; }
.login-panel { padding: 68px 52px; display: flex; flex-direction: column; justify-content: center; }
.panel-head h2 { font-size: 30px; letter-spacing: -.04em; }
.panel-head p { margin-top: 9px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
#login-form { margin-top: 32px; }
.field { display: grid; gap: 8px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 650; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); background: #fbfcfa; border-radius: 10px; padding: 11px 12px; color: var(--ink); outline: none; transition: .15s border, .15s box-shadow; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(215,91,50,.13); }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
.button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 650; background: #eef1ee; color: var(--ink); }
.button:hover { filter: brightness(.97); }
.button.primary { background: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); }
.button.ghost { background: transparent; border: 1px solid var(--line); }
.button.danger { background: #fbe8e4; color: #9b2f1b; }
.button.block { width: 100%; padding: 13px; margin-top: 6px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 0; font-size: 13px; }
.text-button:hover { color: var(--brand); }
.form-error { color: #a3311b; background: #fbece8; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.login-note { margin-top: 28px; color: #9aa4a1; font-size: 12px; line-height: 1.8; text-align: center; }

.app-page { min-height: 100vh; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { background: #1d2528; color: #f7f4ed; padding: 22px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 26px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand div:last-child { display: grid; gap: 3px; }
.sidebar-brand strong { font-size: 16px; letter-spacing: .08em; }
.sidebar-brand span { color: #90a09a; font: 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
.nav { margin-top: 22px; display: grid; gap: 5px; }
.nav-label { margin: 22px 10px 9px; color: #e3ece7; font: 13px/1.4 var(--mono); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.nav-item { width: 100%; text-align: left; border: 0; background: transparent; color: #c2ccc6; padding: 11px 12px; border-radius: 9px; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.active { background: var(--brand); color: white; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 16px 8px 0; display: grid; gap: 10px; }
.side-user { display: grid; gap: 4px; font-size: 13px; color: #d8dfda; }
.side-user small { color: #84948e; font-size: 11px; }
.sidebar .text-button { color: #e3ece7; text-align: left; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 9px 12px; background: rgba(255,255,255,.04); }
.sidebar .text-button:hover { color: white; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.08); }
.main { min-width: 0; padding: 30px clamp(22px, 4vw, 54px) 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.kicker { color: var(--brand); font: 10px/1 var(--mono); letter-spacing: .18em; }
.topbar h1 { margin-top: 7px; font-size: 32px; line-height: 1.15; letter-spacing: .02em; }
.context-chip { max-width: 320px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 13px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view-head h2 { font-size: 21px; letter-spacing: -.035em; }
.muted { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.cat-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 5px 18px rgba(29,37,40,.035); }
.cat-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 15px; }
.cat-title { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cat-title input { width: min(280px, 60vw); border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: 18px; font-weight: 700; padding: 4px 2px; }
.cat-title input:focus { outline: none; border-color: var(--brand); }
.pill { display: inline-flex; border-radius: 999px; padding: 4px 9px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; font-weight: 700; }
.pill.green { background: #e5f1ea; color: var(--green); }
.grid-2 { display: grid; grid-template-columns: 1.35fr .65fr; gap: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.section { margin-top: 17px; padding-top: 16px; border-top: 1px dashed var(--line); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.section-head h3 { font-size: 14px; }
.rule-table, .data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rule-table th, .data-table th, .rule-table td, .data-table td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: middle; }
.rule-table th, .data-table th { color: var(--muted); font-size: 11px; font-weight: 650; }
.rule-table input, .rule-table select { max-width: 160px; }
.rule-table .rule-check { max-width: none; width: 100%; }
.sub-card { border: 1px solid var(--line); border-radius: 11px; padding: 13px; margin-top: 10px; background: #fbfcfa; }
.sub-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; }
.sub-head input { border: 0; background: transparent; font-weight: 650; font-size: 14px; padding: 3px 0; border-bottom: 1px solid var(--line); flex: 1; }
.sub-head input:focus { outline: none; border-color: var(--brand); }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.empty { color: var(--muted); text-align: center; padding: 42px 20px; border: 1px dashed var(--line); border-radius: 12px; font-size: 13px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.data-table { min-width: 680px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table a { color: var(--brand-dark); font-weight: 650; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.split-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.28fr); gap: 18px; align-items: start; }
.form-panel { display: grid; gap: 13px; }
.form-panel h3, .panel h3 { font-size: 15px; margin-bottom: 4px; }
.panel-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.list-stack { display: grid; gap: 8px; }
.list-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: center; font-size: 13px; }
.list-row > div:first-child { min-width: 0; flex: 1; }
.list-row .inline-actions { flex-wrap: nowrap; flex-shrink: 0; }
.list-row small { display: block; color: var(--muted); margin-top: 4px; font-family: var(--mono); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.json-box { margin-top: 9px; background: #f4f6f3; border: 1px solid var(--line); border-radius: 9px; padding: 11px; overflow: auto; max-height: 300px; font: 11px/1.6 var(--mono); white-space: pre-wrap; }
.toast { position: fixed; right: 24px; bottom: 24px; background: #1d2528; color: white; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; z-index: 20; max-width: min(420px, calc(100vw - 32px)); }
.toast.error { background: #9b2f1b; }
@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; min-height: auto; }
  .login-brand { padding: 38px 32px; }
  .brand-foot { margin-top: 35px; }
  .login-panel { padding: 38px 32px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; padding: 15px; }
  .sidebar-brand { padding-bottom: 13px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
  .nav-label { display: none; }
  .sidebar-foot { margin-top: 15px; }
  .main { padding: 22px 16px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .context-chip { max-width: 100%; }
  .grid-2, .split-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
  .view-head { flex-direction: column; }
  .cat-head { align-items: flex-start; flex-direction: column; }
  .rule-table { display: block; overflow-x: auto; }
}

.topic-workbench { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.main-tree { padding: 16px; }
.tree-list { display: grid; gap: 6px; margin-top: 10px; }
.tree-item { width: 100%; text-align: left; border: 1px solid transparent; background: #f7f8f5; border-radius: 10px; padding: 11px 12px; display: grid; gap: 5px; }
.tree-item:hover { border-color: #e7b6a1; background: #fff8f4; }
.tree-item.active { border-color: var(--brand); background: var(--brand-soft); }
.tree-item strong { font-size: 13px; }
.tree-item small { color: var(--muted); font: 11px var(--mono); }
.topic-panel { min-height: 360px; padding: 20px; }
.workspace-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; padding-bottom: 15px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.workspace-head h3 { font-size: 20px; letter-spacing: -.03em; }
.workspace-head .muted { margin-top: 5px; }
.sub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sub-item { border: 1px solid var(--line); background: #fbfcfa; border-radius: 11px; padding: 12px; text-align: left; display: grid; gap: 6px; }
.sub-item:hover { border-color: #e7b6a1; background: #fff8f4; }
.sub-item.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(215,91,50,.1); }
.sub-item strong { font-size: 14px; }
.sub-item small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.sub-editor { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.sub-editor h3 { margin-bottom: 12px; }
.sub-editor .form-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal { position: fixed; inset: 0; background: rgba(29,37,40,.55); display: grid; place-items: center; z-index: 30; padding: 20px; }
.modal-card { width: min(430px, 100%); background: white; border-radius: 15px; padding: 20px; box-shadow: var(--shadow); }
.modal-card .panel-head-row { margin-bottom: 8px; }
.empty-panel { padding: 30px; }
@media (max-width: 900px) {
  .topic-workbench { grid-template-columns: 1fr; }
  .sub-grid { grid-template-columns: 1fr; }
}

.scope-editor { margin-top: 14px; padding: 14px; border: 1px solid #efd4c8; background: #fff9f5; border-radius: 12px; }
.scope-editor h3 { margin-bottom: 10px; }
.scope-editor .rule-table textarea { min-height: 40px; }
.doc-card { width: min(860px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.doc-body { overflow: auto; line-height: 1.8; font-size: 15px; padding: 8px 4px 24px; }
.doc-body h1 { font-size: 26px; margin: 8px 0 16px; letter-spacing: -.03em; }
.doc-body h2 { font-size: 19px; margin: 22px 0 9px; }
.doc-body h3 { font-size: 16px; margin: 18px 0 8px; }
.doc-body p { margin: 8px 0; }
.doc-body ul { padding-left: 22px; }
.doc-body li { margin: 4px 0; }
.doc-body blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--brand); background: #fff7f3; color: #5b6662; }
.doc-body img { max-width: 100%; height: auto; border-radius: 8px; margin: 10px 0; }
.doc-body code { font-family: var(--mono); background: #f2f4f1; padding: 2px 4px; border-radius: 4px; font-size: 12px; }
.doc-body pre { overflow: auto; background: #1d2528; color: #f5f3ee; padding: 12px; border-radius: 8px; }

.log-job { padding: 16px; }
.log-job-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.log-job-head h3 { font-size: 16px; }
.log-job-head small { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.timeline { display: grid; gap: 8px; border-left: 2px solid var(--line); padding-left: 14px; }
.log-event { position: relative; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fbfcfa; }
.log-event::before { content: ""; position: absolute; left: -19px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.log-event.failed::before { background: #a3311b; }
.log-event-top { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; font-family: var(--mono); }
.log-event p { margin-top: 6px; font-size: 13px; line-height: 1.6; }
.log-event ul { margin: 5px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }

.label-help { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: #e7ece8; color: #4c655b; font: 700 11px/1 var(--mono); cursor: help; vertical-align: 1px; }

.workspace-title { min-width: 0; flex: 1; }
.workspace-title .field { max-width: 420px; }
.workspace-title .field input { font-size: 18px; font-weight: 700; }

.plan-weeks { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 10px; }
.plan-week { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fbfcfa; }
.plan-week h4 { font-size: 14px; margin-bottom: 8px; }
.plan-week h4 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.plan-week ol { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.plan-week li strong { display: block; font-size: 13px; }
.plan-week li small { color: var(--muted); font-size: 11px; }

.shortvideo-card h3 { font-size: 16px; }
.shortvideo-card .panel-head-row { align-items: center; }
.shortvideo-card .panel-head-row p { margin-top: 4px; }
.shortvideo-actions { margin-top: 12px; flex-wrap: wrap; }
.json-view { margin: 0; max-height: 62vh; }

.doc-actions { display: flex; justify-content: flex-end; margin: 0 0 10px; }
.doc-actions[hidden] { display: none; }
.doc-body pre code { background: transparent; color: inherit; padding: 0; font: 12px/1.7 var(--mono); white-space: pre-wrap; word-break: break-word; }

.balance-warning { color: #ffb199; background: rgba(196, 69, 40, .18); border: 1px solid rgba(255, 137, 105, .35); border-radius: 8px; padding: 8px 10px; font-size: 12px; text-align: center; }
.cost-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 14px; }
.cost-summary div { background: #f6f8f5; border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.cost-summary small { display: block; color: var(--muted); font-size: 11px; }
.cost-summary strong { display: block; margin-top: 4px; font-size: 18px; }
.cost-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.cost-row small { color: var(--muted); display: block; margin-top: 2px; }

.log-table td { padding-top: 13px; padding-bottom: 13px; vertical-align: middle; }
.log-table .mono { font-family: var(--mono); font-size: 11px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }

#cost-modal .modal-card { height: min(90vh, 920px); max-height: 90vh; overflow: hidden; }
#cost-modal .cost-summary { flex: 0 0 auto; }
#cost-modal #cost-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 6px; }
#cost-modal #cost-pagination { flex: 0 0 auto; padding-top: 12px; border-top: 1px solid var(--line); background: var(--card); }

.login-page { gap: 24px; align-content: center; }
.login-intro { width: min(1080px, 100%); background: rgba(255, 252, 247, .88); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 28px 32px 30px; }
.login-intro-head h2 { margin-top: 8px; font-size: 24px; letter-spacing: -.03em; }
.login-intro-head > p:last-child { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-intro-grid { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 22px; margin-top: 22px; }
.login-intro-card { border-top: 2px solid var(--line); padding-top: 13px; }
.login-intro-card h3 { font-size: 15px; margin-bottom: 8px; }
.login-intro-card p, .login-intro-card li { color: var(--muted); font-size: 12px; line-height: 1.75; }
.login-intro-card p + p { margin-top: 6px; }
.login-intro-card ul { margin: 0; padding-left: 17px; }
.intro-steps { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; margin: 0; padding: 0; }
.intro-steps li { display: grid; gap: 2px; }
.intro-steps strong { color: var(--ink); font-size: 12px; }
.intro-steps span { color: var(--muted); font-size: 11px; line-height: 1.5; }
@media (max-width: 980px) {
  .login-intro { padding: 22px; }
  .login-intro-grid { grid-template-columns: 1fr; }
}

.login-contact { color: #26302d; font-weight: 650; }

.login-footer { width: min(1080px, 100%); padding: 2px 0 6px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.7; }

.icp-link { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-decoration: none; }
.icp-link img { width: 14px; height: 14px; object-fit: contain; }
.icp-link:hover { color: var(--brand-dark); text-decoration: underline; }
