:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --text: #20242c;
  --muted: #737984;
  --line: #e6e8ed;
  --primary: #e66043;
  --primary-dark: #c94a30;
  --primary-soft: #fff0eb;
  --green: #32846a;
  --green-soft: #eaf6f1;
  --amber: #a57425;
  --amber-soft: #fff6e5;
  --danger: #c54444;
  --danger-soft: #fff0f0;
  --sidebar: #202a2d;
  --radius: 14px;
  --shadow: 0 12px 36px rgba(28, 34, 42, .07);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 24px; letter-spacing: -.5px; }
h2 { margin-bottom: 8px; font-size: 19px; }
h3 { margin-bottom: 8px; font-size: 15px; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 224px; padding: 28px 18px 20px; color: #dce3e3; background: var(--sidebar); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 34px; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; color: #fff; background: var(--primary); font-size: 19px; font-weight: 700; }
.brand strong { display: block; color: #fff; font-size: 18px; letter-spacing: 1px; }
.brand small { display: block; margin-top: 3px; color: #91a0a2; font-size: 11px; }
.nav-list { display: grid; gap: 7px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 9px 12px; border-radius: 10px; color: #aebabc; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.active { color: #fff; background: rgba(230,96,67,.18); }
.nav-icon { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 7px; font-size: 12px; opacity: .85; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 8px; color: #899799; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #62b899; }
.main-area { min-height: 100vh; margin-left: 224px; }
.topbar { min-height: 96px; padding: 22px 34px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.85); }
.eyebrow { margin-bottom: 7px; color: var(--primary); font-size: 10px; font-weight: 700; letter-spacing: 1.8px; }
.account { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.account form { margin-left: 6px; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--primary-dark); background: var(--primary-soft); font-size: 12px; }
.page-content { padding: 30px 34px 50px; max-width: 1600px; margin: 0 auto; }
.button { min-height: 38px; padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: var(--text); border-color: var(--line); background: #fff; }
.button-secondary:hover { border-color: #c8ccd3; background: var(--surface-soft); }
.button-ghost { color: var(--muted); background: transparent; }
.button-danger { color: var(--danger); border-color: #f0cccc; background: var(--danger-soft); }
.button-small { min-height: 31px; padding: 5px 10px; font-size: 12px; }
.button-block { width: 100%; min-height: 45px; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.text-link { color: var(--primary); font-weight: 600; font-size: 13px; }
.muted { color: var(--muted); }
.welcome-panel { padding: 28px 30px; display: flex; align-items: center; justify-content: space-between; gap: 24px; color: #fff; border-radius: var(--radius); background: #293a3d; }
.welcome-panel h2 { font-size: 24px; }
.welcome-panel p:not(.eyebrow) { margin-bottom: 0; color: #b7c3c4; }
.stats-grid { margin: 22px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stat-card { padding: 22px; display: grid; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat-card strong { font-size: 34px; line-height: 1; }
.stat-card > span:last-child { color: var(--muted); font-size: 12px; }
.stat-label { color: var(--muted); font-weight: 600; }
.stat-published strong { color: var(--green); }
.stat-draft strong { color: var(--amber); }
.section-block { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.section-heading { margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.recent-list { display: grid; }
.recent-item { min-height: 72px; padding: 10px 4px; display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--line); }
.recent-item:hover { background: var(--surface-soft); }
.recent-item img { width: 42px; height: 52px; object-fit: cover; border-radius: 6px; background: var(--surface-soft); }
.recent-info { flex: 1; display: grid; gap: 5px; }
.recent-info small { color: var(--muted); }
.recent-arrow { color: var(--muted); font-size: 18px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-published { color: var(--green); background: var(--green-soft); }
.badge-draft { color: var(--amber); background: var(--amber-soft); }
.badge-archived { color: var(--muted); background: #eef0f2; }
.flow-strip { margin-top: 22px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.flow-strip > div { padding: 20px; display: grid; gap: 6px; background: var(--surface); }
.flow-strip span { color: var(--primary); font-size: 11px; font-weight: 700; }
.flow-strip small { color: var(--muted); }
.empty-state { padding: 52px 20px; text-align: center; border: 1px dashed #d7dae0; border-radius: 12px; background: var(--surface-soft); }
.empty-state strong { font-size: 17px; }
.empty-state p { margin: 8px 0 20px; color: var(--muted); }
.toast { position: fixed; z-index: 100; right: 28px; bottom: 28px; max-width: 420px; padding: 13px 18px; color: #fff; border-radius: 10px; background: #293a3d; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.alert { padding: 12px 14px; border-radius: 9px; font-size: 13px; }
.alert-danger { color: var(--danger); background: var(--danger-soft); }
.form-stack { display: grid; gap: 18px; }
.form-field { display: grid; gap: 7px; color: #4f555f; font-size: 12px; font-weight: 600; }
.form-field input, .form-field select, .form-field textarea, .input { width: 100%; min-height: 40px; padding: 9px 11px; color: var(--text); border: 1px solid #dfe2e7; outline: none; border-radius: 8px; background: #fff; transition: .15s ease; }
.form-field textarea { min-height: 84px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(230,96,67,.1); }
.form-field small { color: var(--muted); font-weight: 400; }
.checkbox-field { display: flex; align-items: center; gap: 8px; color: #4f555f; font-size: 13px; }
.checkbox-field input { accent-color: var(--primary); }
.login-body { min-height: 100vh; background: #f4f1ed; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr); }
.login-intro { padding: 9vw; display: flex; flex-direction: column; justify-content: center; color: #fff; background: #26373a; }
.brand-mark-large { width: 52px; height: 52px; margin-bottom: 44px; font-size: 24px; }
.login-intro h1 { margin: 10px 0 24px; font-size: clamp(34px, 4vw, 58px); line-height: 1.25; letter-spacing: -2px; }
.login-intro > p:not(.eyebrow) { max-width: 480px; color: #b6c2c3; font-size: 16px; line-height: 1.9; }
.login-feature-list { margin-top: 38px; display: flex; flex-wrap: wrap; gap: 10px; }
.login-feature-list span { padding: 8px 12px; color: #d8e0e0; border: 1px solid #46575a; border-radius: 20px; font-size: 12px; }
.login-card { width: min(420px, calc(100% - 48px)); margin: auto; padding: 38px; display: grid; gap: 26px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.login-card h2 { font-size: 26px; }
.login-hint { margin: 0; color: var(--muted); text-align: center; font-size: 11px; }
.filter-bar { margin-bottom: 20px; padding: 14px 16px; display: flex; align-items: end; flex-wrap: wrap; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.filter-bar .form-field { min-width: 170px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.template-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: .18s ease; }
.template-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.template-cover { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: #eceef1; }
.template-cover img { width: 100%; height: 100%; object-fit: contain; }
.template-cover .badge { position: absolute; top: 12px; right: 12px; }
.template-body { padding: 16px; }
.template-body h3 { margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-meta { margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.template-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table th { color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 600; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table code { padding: 3px 6px; color: #526069; border-radius: 5px; background: #f0f2f4; }
.dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 24px 80px rgba(20,28,32,.22); }
.dialog::backdrop { background: rgba(25,32,35,.48); }
.dialog-head { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 22px; }
.dialog-close { border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 22px; }
.upload-box { padding: 18px; border: 1px dashed #ccd1d8; border-radius: 10px; background: var(--surface-soft); }
.upload-box input { padding: 7px; background: #fff; }
.new-template-layout { max-width: 860px; margin: 0 auto; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-footer { margin-top: 24px; padding-top: 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
@media (max-width: 1000px) {
  .sidebar { width: 76px; padding-inline: 12px; }
  .brand { padding-inline: 6px; }
  .brand > span:last-child, .nav-item > span:last-child, .sidebar-foot span:last-child { display: none; }
  .nav-item { justify-content: center; padding-inline: 0; }
  .main-area { margin-left: 76px; }
  .flow-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { position: static; width: 100%; height: auto; padding: 12px 16px; flex-direction: row; align-items: center; }
  .brand { padding: 0; }
  .brand > span:last-child { display: block; }
  .brand small, .sidebar-foot { display: none; }
  .nav-list { margin-left: auto; display: flex; gap: 4px; }
  .nav-item { min-height: 38px; padding: 6px; }
  .main-area { margin-left: 0; }
  .topbar { padding: 18px; }
  .account > span:not(.avatar) { display: none; }
  .page-content { padding: 20px 16px 40px; }
  .welcome-panel { padding: 22px; align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .flow-strip { grid-template-columns: 1fr; }
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { display: none; }
  .login-card { padding: 28px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
