:root {
  --primary: #c43543;
  --primary-hover: #a92c39;
  --primary-soft: #fff1f3;
  --accent: #0f9f9a;
  --accent-soft: #eaf9f7;
  --background: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --info: #2563eb;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(15, 23, 42, .05);
  color-scheme: light;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; min-width: 320px; background: var(--background); }
button, input, textarea, select { font: inherit; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }

.app-layout { min-height: 100vh; }
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: 220px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar-brand { min-height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 9px; color: #fff; background: var(--primary); font-size: 13px; }
.sidebar-nav { display: grid; gap: 4px; padding: 16px 12px; }
.sidebar-nav a { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border-radius: 8px; color: #536176; text-decoration: none; transition: color .16s ease, background .16s ease; }
.sidebar-nav a:hover { color: var(--primary); background: #fff7f8; }
.sidebar-nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.sidebar-nav svg, .sidebar-toggle svg { width: 18px; height: 18px; flex: 0 0 18px; }

.app-workspace { min-height: 100vh; margin-left: 220px; }
.accountbar { position: sticky; top: 0; z-index: 25; height: 56px; display: flex; align-items: center; justify-content: flex-end; padding: 0 24px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--border); }
.account-actions { display: flex; align-items: center; gap: 14px; }
.identity { color: #536176; font-size: 14px; white-space: nowrap; }
.sidebar-toggle { display: none; align-items: center; gap: 7px; border: 0; padding: 8px 10px; color: #475569; background: transparent; cursor: pointer; }
.sidebar-backdrop { display: none; }

.shell { max-width: 1200px; margin: 0 auto; padding: 30px 24px 56px; }
.auth-shell { min-height: 100vh; padding-top: 1px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 2px 0 6px; font-size: 28px; line-height: 1.25; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.7; }
.page-eyebrow { color: var(--primary); font-size: 12px; font-weight: 700; }

.surface-card, .form-band, .preview, .table-wrap, .advanced-panel, .history-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.surface-card, .form-band, .preview, .table-wrap { padding: 20px; margin-bottom: 18px; }
.surface-card h2, .section-block h2 { font-size: 18px; }
.compact-card { padding: 18px 20px; }
.section-block { margin-bottom: 24px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 0 0 4px; }
.section-heading p, .form-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.compact-heading { margin-bottom: 12px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 8px 15px; cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 600; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.button:hover { transform: translateY(-1px); }
.button svg { width: 18px; height: 18px; }
.button.primary, .primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.secondary, .secondary { background: #1d4f72; color: #fff; border-color: #1d4f72; }
.button.quiet, .quiet { background: #fff; color: #34445c; border-color: var(--border-strong); }
.button.danger, .danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.large-button { min-height: 44px; padding-inline: 22px; }
.text-link { color: #17678e; font-size: 13px; text-decoration: none; }
.form-actions { display: flex; align-items: center; gap: 10px; }
.form-actions.end { justify-content: flex-end; }

label, legend { display: grid; gap: 6px; color: #354258; font-size: 14px; }
input, textarea, select { width: 100%; min-height: 40px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 11px; color: var(--text); background: #fff; outline: none; transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 159, 154, .12); }
textarea { min-height: 92px; resize: vertical; line-height: 1.65; }
.large-textarea { min-height: 140px; }
.stack-form { display: grid; gap: 15px; }
.rule-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)) auto; gap: 12px; align-items: end; }
.account-create-grid { grid-template-columns: 1.2fr .7fr .8fr 1.1fr auto; }
.submit-rule-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
.inline-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.wide-filters { grid-template-columns: repeat(5, minmax(135px, 1fr)) auto; }
.two-column, .composer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

.alert { margin: 0 0 16px; padding: 12px 14px; color: #991b1b; background: #fff1f2; border: 1px solid #fecdd3; border-radius: 8px; }
.status-badge, .badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 999px; color: #1e5577; background: #e8f2f8; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-badge.success { color: #047857; background: #dff7ed; }
.status-badge.warning { color: #b45309; background: #fff4dc; }
.status-badge.danger { color: #be123c; background: #ffe4e8; }
.status-badge.neutral { color: #526174; background: #edf1f5; }
.status-badge.info { color: #1d4ed8; background: #e7efff; }
.state-text.success { color: var(--success); }
.state-text.warning { color: var(--warning); }
.state-text.danger { color: var(--danger); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-card { min-height: 118px; display: flex; align-items: center; gap: 14px; padding: 18px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; box-shadow: var(--shadow); }
.metric-card:hover { border-color: var(--border-strong); }
.metric-icon { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 44px; border-radius: 10px; }
.metric-icon svg { width: 24px; height: 24px; }
.tone-warning .metric-icon { color: #d97706; background: #fff4dc; }
.tone-info .metric-icon { color: #2563eb; background: #e8f0ff; }
.tone-success .metric-icon { color: #059669; background: #dff7ed; }
.tone-danger .metric-icon { color: #dc2626; background: #ffe5e8; }
.metric-card > span:last-child { min-width: 0; display: grid; gap: 2px; }
.metric-card small, .metric-card em { color: var(--muted); font-size: 12px; font-style: normal; }
.metric-card strong { font-size: 25px; line-height: 1.2; }
.panel-health { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; }
.health-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 10px; }
.health-icon svg { width: 23px; height: 23px; }
.panel-health h2 { margin: 0 0 4px; }
.panel-health p { margin: 0; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.quick-entry { min-height: 90px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.quick-entry:hover { border-color: #f3b1ba; background: #fffbfb; }
.quick-entry span:nth-child(2) { min-width: 0; display: grid; gap: 4px; }
.quick-entry small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.quick-entry b { color: var(--muted); font-size: 20px; }
.quick-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 9px; }
.quick-icon svg { width: 20px; height: 20px; }

.mini-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.mini-metrics div { display: grid; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.mini-metrics span { color: var(--muted); font-size: 12px; }
.mini-metrics strong { font-size: 20px; }
.advanced-panel, .history-panel { margin-bottom: 18px; overflow: hidden; }
.advanced-panel > summary, .history-panel > summary { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 18px; cursor: pointer; list-style: none; }
.advanced-panel > summary::-webkit-details-marker, .history-panel > summary::-webkit-details-marker { display: none; }
.advanced-panel summary span { display: grid; gap: 3px; }
.advanced-panel summary small { color: var(--muted); font-size: 12px; font-weight: 400; }
.advanced-panel summary b { color: var(--muted); font-size: 12px; }
.advanced-panel[open] summary b { color: var(--primary); }
.advanced-body { padding: 18px; border-top: 1px solid var(--border); background: var(--surface-muted); }
.advanced-body .form-note { margin-top: 12px; }
.inner-panel { box-shadow: none; margin: 0; }
.filter-panel { box-shadow: none; }

.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.account-card { display: grid; gap: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.account-card header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; }
.account-card h3 { margin: 0 0 3px; font-size: 16px; }
.account-card header p { margin: 0; color: var(--muted); font-size: 12px; }
.account-avatar { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; background: #1d4f72; border-radius: 50%; font-weight: 700; }
.account-state-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.account-state-grid div { display: grid; gap: 3px; }
.account-state-grid span { color: var(--muted); font-size: 11px; }
.account-state-grid strong { font-size: 13px; }
.account-card footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.actions form { display: inline-flex; }

.workflow-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 0 18px; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.workflow-steps li { min-height: 74px; display: flex; align-items: center; gap: 11px; padding: 14px 18px; color: var(--muted); border-right: 1px solid var(--border); }
.workflow-steps li:last-child { border-right: 0; }
.workflow-steps li.is-current { color: var(--text); background: #fffafb; }
.workflow-steps li b { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 28px; color: var(--muted); background: #edf1f5; border-radius: 50%; font-size: 12px; }
.workflow-steps li.is-current b { color: #fff; background: var(--primary); }
.workflow-steps li span { display: grid; gap: 2px; font-weight: 600; }
.workflow-steps small { color: var(--muted); font-size: 11px; font-weight: 400; }
.link-preview-list { display: grid; gap: 8px; }
.link-preview-item { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; background: var(--surface-muted); border-radius: 8px; }
.link-preview-item > span:last-child { overflow: hidden; color: #40506a; text-overflow: ellipsis; white-space: nowrap; }
.rule-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 16px; padding: 11px 13px; color: #536176; background: var(--accent-soft); border: 1px solid #c6ece8; border-radius: 8px; font-size: 13px; }
.rule-summary strong { color: var(--text); }
.choice-fieldset { margin: 0; padding: 0; border: 0; }
.choice-fieldset legend { margin-bottom: 8px; font-weight: 700; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice-card { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 11px 13px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.choice-card:has(input:checked) { border-color: #7fd0cb; background: var(--accent-soft); }
.choice-card input { width: 17px; min-height: 17px; flex: 0 0 17px; accent-color: var(--accent); }
.choice-card span { display: grid; gap: 2px; }
.choice-card small { color: var(--muted); font-size: 11px; }

.work-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.work-card { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.work-card img, .work-placeholder { width: 100%; aspect-ratio: 16 / 10; display: grid; place-items: center; object-fit: cover; color: var(--muted); background: var(--surface-muted); }
.work-card > div { display: grid; gap: 8px; padding: 13px; }
.work-card h3 { min-height: 42px; display: -webkit-box; overflow: hidden; margin: 0; font-size: 14px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.work-card time { color: var(--muted); font-size: 12px; }
.work-card a { color: #17678e; font-size: 13px; text-decoration: none; }
.history-panel > summary { font-weight: 700; }
.history-panel > summary span { color: var(--muted); font-size: 12px; font-weight: 400; }
.history-list { display: grid; padding: 0 18px 16px; }
.history-list > a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border); text-decoration: none; }

.composer-grid { margin-bottom: 24px; }
.composer-grid .surface-card { margin-bottom: 0; }
.template-list { display: grid; gap: 8px; }
.template-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 14px; padding: 13px 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.template-copy { min-width: 0; }
.template-copy p { display: -webkit-box; overflow: hidden; margin: 0 0 5px; line-height: 1.55; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.template-copy span { color: var(--muted); font-size: 12px; }

.status-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 14px; padding: 5px; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.status-tabs a { min-height: 34px; display: inline-flex; align-items: center; padding: 0 13px; border-radius: 7px; color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.status-tabs a.is-current { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.task-list { display: grid; gap: 12px; }
.task-card { overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.task-main { display: grid; grid-template-columns: 76px 1fr; gap: 14px; padding: 17px; }
.task-cover { width: 76px; height: 76px; overflow: hidden; border-radius: 9px; background: var(--surface-muted); }
.task-cover img { width: 100%; height: 100%; object-fit: cover; }
.task-cover span { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.task-cover svg { width: 25px; height: 25px; }
.task-content { min-width: 0; }
.task-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-title-row > div { min-width: 0; display: grid; gap: 3px; }
.task-title-row a { overflow: hidden; font-weight: 700; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.task-title-row > div > span { color: var(--muted); font-size: 12px; }
.comment-preview { display: -webkit-box; overflow: hidden; margin: 9px 0; color: #40506a; font-size: 13px; line-height: 1.55; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 11px; }
.task-progress { display: grid; grid-template-columns: repeat(4, 1fr); padding: 13px 18px; background: var(--surface-muted); border-top: 1px solid var(--border); }
.task-progress span { position: relative; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.task-progress span::after { content: ""; position: absolute; top: 11px; right: 10px; left: 34px; height: 1px; background: var(--border-strong); }
.task-progress span:last-child::after { display: none; }
.task-progress i { width: 23px; height: 23px; display: grid; place-items: center; z-index: 1; color: var(--muted); background: #fff; border: 1px solid var(--border-strong); border-radius: 50%; font-style: normal; }
.task-progress .done i { color: #fff; background: var(--success); border-color: var(--success); }
.task-progress .current i { color: #fff; background: var(--primary); border-color: var(--primary); }
.task-progress .done b, .task-progress .current b { color: var(--text); }
.task-progress b { font-weight: 600; }
.task-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 17px; border-top: 1px solid var(--border); }
.task-footer p { margin: 0; color: var(--muted); font-size: 12px; }

.timeline { position: relative; display: grid; gap: 0; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; top: 9px; bottom: 9px; left: 6px; width: 1px; background: var(--border-strong); }
.timeline-item { position: relative; padding: 0 0 14px 16px; }
.timeline-dot { position: absolute; top: 17px; left: -17px; width: 9px; height: 9px; z-index: 1; background: var(--accent); border: 2px solid var(--background); border-radius: 50%; }
.timeline-card { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.timeline-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.timeline-card header div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.timeline-card header span, .timeline-card time { color: var(--muted); font-size: 12px; }
.timeline-card p { margin: 7px 0 0; color: #40506a; line-height: 1.65; }

.empty-state { grid-column: 1 / -1; min-height: 150px; display: grid; place-items: center; align-content: center; gap: 6px; padding: 28px; color: var(--muted); text-align: center; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-state h3, .empty-state p { margin: 0; }
.empty-state h3 { color: var(--text); font-size: 15px; }
.empty-state p { font-size: 13px; }
.small-empty { min-height: 96px; box-shadow: none; }
.empty-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 50%; font-size: 20px; }
.inline-empty { padding: 12px 14px; color: #8a5a00; background: #fff8e8; border: 1px solid #fde3a7; border-radius: 8px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); background: var(--surface-muted); font-size: 13px; font-weight: 600; }
.auth-panel { max-width: 400px; margin: 72px auto; padding: 26px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-panel h1 { margin-top: 0; font-size: 22px; }

@media (max-width: 1040px) {
  .metric-grid, .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-grid, .account-create-grid, .wide-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule-grid .button { align-self: end; }
  .account-state-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 16px 0 32px rgba(15, 23, 42, .12); }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-workspace { margin-left: 0; }
  .accountbar { justify-content: space-between; padding: 0 14px; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(15, 23, 42, .38); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .identity { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .shell { padding: 22px 14px 42px; }
  .page-heading { display: block; }
  .page-heading .button { margin-top: 14px; }
  .page-heading h1 { font-size: 24px; }
  .composer-grid, .account-grid, .two-column, .work-grid { grid-template-columns: 1fr; }
  .inline-form, .rule-grid, .account-create-grid, .submit-rule-grid, .wide-filters { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-progress b { display: none; }
  .task-progress span::after { left: 30px; right: 4px; }
  .account-card footer, .task-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .metric-grid, .quick-grid, .mini-metrics { grid-template-columns: 1fr; }
  .metric-card { min-height: 94px; }
  .panel-health { grid-template-columns: auto 1fr; }
  .panel-health .status-badge { grid-column: 2; justify-self: start; }
  .workflow-steps li { min-height: 62px; padding: 10px; }
  .workflow-steps small { display: none; }
  .choice-grid { grid-template-columns: 1fr; }
  .task-main { grid-template-columns: 54px 1fr; gap: 10px; padding: 14px; }
  .task-cover { width: 54px; height: 54px; }
  .task-title-row { display: grid; }
  .task-title-row .status-badge { justify-self: start; }
  .task-progress { padding: 12px 14px; }
  .timeline { padding-left: 12px; }
  .template-row { grid-template-columns: 1fr auto; }
  .template-row .template-copy { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .accountbar { height: 52px; }
  .identity { display: none; }
  .sidebar-brand { min-height: 58px; }
}

/* Douyin-parity application shell. Kept in the Xiaohongshu stylesheet so the two systems stay independent. */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 220px; height: 100vh; padding: 18px 14px; overflow-y: auto; background: #fff; border-right: 1px solid var(--border); }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 20px; font-size: 17px; font-weight: 800; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; background: var(--primary); color: #fff; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 8px; color: #475569; font-weight: 600; text-decoration: none; }
.nav a:hover, .nav a.is-current { color: var(--primary-hover); background: var(--primary-soft); }
.nav svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; }
.nav svg path { stroke-linecap: round; stroke-linejoin: round; }
.content-shell { grid-column: 2; min-width: 0; }
.topbar { height: 56px; display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--border); }
.topbar form { margin: 0; }
.sidebar-toggle { display: none; min-height: 36px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #334155; font-weight: 700; }
.sidebar-backdrop { display: none; }
.main { width: auto; max-width: 1200px; margin: 0 auto; padding: 26px 24px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-head h1 { margin: 0 0 6px; font-size: 26px; }
.page-head p, .muted, .form-note { margin: 0; color: var(--muted); }
.panel { min-width: 0; margin-bottom: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 23, 42, .035); }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.stat strong { display: block; margin-top: 8px; font-size: 26px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.generation-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
.generation-grid + .form-note { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.profile-channel-setting { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.profile-channel-setting label { min-width: min(280px, 100%); }
.profile-channel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); }
.profile-channel span { color: var(--muted); font-size: 13px; }
.profile-channel strong + span { margin-left: 12px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1.2fr 1fr auto auto; gap: 10px; align-items: end; }
.compact-filter { grid-template-columns: 1fr 1.5fr 1fr auto auto; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h2 { margin-bottom: 5px; }
.section-head p { margin: 0; color: var(--muted); line-height: 1.65; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #334155; cursor: pointer; font-weight: 700; text-decoration: none; }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn-primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #edf2f7; color: #475569; }
.badge.success { background: #e8f8f1; color: #087f5b; }
.badge.warning { background: #fff7e8; color: #b45309; }
.badge.danger { background: #fef0f2; color: #c81e3a; }
.badge.info, .badge-primary { background: var(--primary-soft); color: var(--primary-hover); }
.badge.neutral { background: #edf2f7; color: #475569; }
.alert { margin-bottom: 14px; padding: 11px 13px; border: 1px solid #f4c7ce; border-radius: 8px; background: #fff5f6; color: var(--primary-hover); }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-warning { background: #fff7e8; border-color: #fed7aa; color: #9a5605; }
.notice-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notice-banner button { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: currentColor; cursor: pointer; font-size: 20px; line-height: 1; }
.notice-banner button:hover { background: rgba(15, 23, 42, .06); }
.help-details { margin: -4px 0 16px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--muted); font-size: 13px; }
.help-details summary { cursor: pointer; color: #475569; font-weight: 700; }
.help-details p { margin: 9px 0 0; line-height: 1.7; }
.table-wrap { width: 100%; overflow-x: auto; }
.table-wrap table { min-width: 760px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: #f8fafc; color: #475569; text-align: left; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
td.summary { max-width: 360px; line-height: 1.5; overflow-wrap: anywhere; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); border: 1px dashed #cbd5e1; border-radius: 8px; }
.checkbox-list { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-item { display: flex; align-items: center; gap: 7px; min-width: 150px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-weight: 500; }
.checkbox-item input { width: 16px; height: 16px; }
.link-list { margin: 10px 0 0; padding-left: 20px; color: #475569; line-height: 1.8; overflow-wrap: anywhere; }
.profile-submit-panel { padding-bottom: 16px; }
.profile-scan-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.profile-scan-form textarea { min-height: 82px; }
.profile-scan-form .btn { min-width: 150px; }
.profile-rule-strip { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.default-rule { display:flex; flex-wrap:wrap; align-items:center; gap:8px 18px; margin-bottom:16px; padding:12px 14px; border-radius:8px; background:#fff6f7; color:#7f1d2d; }
.default-rule span { color:var(--muted); }
.profile-url { max-width: 720px; margin: 0; overflow-wrap: anywhere; }
.profile-preview-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.profile-preview-summary > div { padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
.profile-preview-summary span { display: block; color: var(--muted); font-size: 12px; }
.profile-preview-summary strong { display: block; margin-top: 4px; font-size: 21px; }
.profile-work-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.profile-work-card { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.profile-work-cover { aspect-ratio: 16 / 10; overflow: hidden; background: #edf4f6; }
.profile-work-cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
.cover-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.profile-work-body { padding: 13px; min-width: 0; }
.profile-work-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.profile-work-title-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-work-body p { margin: 10px 0; color: var(--muted); }
.profile-work-body a { color: var(--primary-hover); font-weight: 700; }
.profile-scan-list { display: grid; }
.profile-scan-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.profile-scan-row:last-child { border-bottom: 0; }
.profile-scan-row strong, .profile-scan-row small { display: block; }
.profile-scan-row small { margin-top: 4px; color: var(--muted); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #fff4f5, #f5f7fa 55%, #fff); }
.login-card { width: min(420px, 100%); padding: 30px; border: 1px solid rgba(255,255,255,.7); border-radius: 14px; background: rgba(255,255,255,.9); box-shadow: 0 24px 60px rgba(196,53,67,.12); }
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card form { display: grid; gap: 14px; margin-top: 22px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .content-shell { grid-column: 1; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 12px 0 30px rgba(15,23,42,.12); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; margin-right: auto; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 30; border: 0; background: rgba(15,23,42,.28); }
  .sidebar-open .sidebar-backdrop { display: block; }
  .stats, .form-grid, .generation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid, .compact-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  body { overflow-x: hidden; }
  .topbar { padding: 0 14px; }
  .main { padding: 20px 14px 36px; }
  .page-head, .grid-2 { display: grid; grid-template-columns: 1fr; }
  .stats, .stats-3, .form-grid, .generation-grid, .filter-grid, .compact-filter { grid-template-columns: 1fr; }
  .profile-scan-form, .profile-work-grid { grid-template-columns: 1fr; }
  .profile-scan-form .btn { width: 100%; }
  .profile-work-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); }
  .profile-work-cover { aspect-ratio: 1; }
  .panel { width: 100%; min-width: 0; padding: 16px; }
}
