:root {
  --red: #d83931;
  --red-dark: #ad2923;
  --red-soft: #fff3f2;
  --ink: #202124;
  --muted: #6f7378;
  --line: #e4e6e8;
  --surface: #ffffff;
  --page: #f5f6f7;
  --sidebar: #191a1c;
  --success: #16794b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1080px; background: var(--page); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; background: #f1f2f3; }
.login-panel { width: 390px; padding: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 50px rgb(0 0 0 / 8%); }
.login-panel h1 { margin: 18px 0 6px; font-size: 26px; }
.login-panel > p { margin: 0 0 28px; color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 62px; height: 62px; color: white; background: var(--red); border-radius: 8px; font-size: 19px; font-weight: 750; }
.brand-mark.small { width: 44px; height: 44px; font-size: 14px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; color: #fff; background: var(--sidebar); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 24px; border-bottom: 1px solid #303236; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 16px; }
.sidebar-brand span { margin-top: 4px; color: #979ba1; font-size: 12px; }
.main-nav { display: grid; gap: 4px; margin-top: 20px; }
.main-nav button { height: 44px; padding: 0 14px; border: 0; border-radius: 6px; color: #b9bdc3; background: transparent; text-align: left; }
.main-nav button:hover { color: white; background: #25272a; }
.main-nav button.active { color: white; background: var(--red); font-weight: 650; }
.sidebar-user { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding: 18px 8px 2px; border-top: 1px solid #303236; font-size: 13px; }
.text-button { padding: 0; border: 0; color: #aeb2b7; background: none; }
.text-button:hover { color: white; }

.workspace { min-width: 0; }
.topbar { height: 86px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0 0 5px; font-size: 22px; }
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }
.content { padding: 26px 30px 50px; }
.loading, .empty-state { padding: 70px 20px; color: var(--muted); text-align: center; background: var(--surface); border: 1px solid var(--line); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 16px; }
.metric { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 12px; font-size: 32px; line-height: 1; }
.overview-band { margin-top: 22px; padding: 24px; background: var(--surface); border: 1px solid var(--line); }
.overview-band h3 { margin: 0 0 16px; font-size: 17px; }
.workflow { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); }
.workflow div { min-height: 96px; padding: 18px; border-right: 1px solid var(--line); }
.workflow div:last-child { border-right: 0; }
.workflow b { display: block; margin-bottom: 8px; color: var(--red); }
.workflow span { color: var(--muted); font-size: 13px; line-height: 1.6; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar input[type="search"] { width: 300px; }
.toolbar .result-count { margin-left: auto; color: var(--muted); font-size: 13px; }
input, textarea, select { width: 100%; border: 1px solid #cfd2d5; border-radius: 5px; color: var(--ink); background: white; outline: none; }
input, select { height: 38px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--red); box-shadow: 0 0 0 2px rgb(216 57 49 / 10%); }

.button { min-height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 5px; font-weight: 620; }
.button.primary { color: white; background: var(--red); }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { color: #333; background: white; border-color: #cfd2d5; }
.button.secondary:hover { border-color: #999da2; }
.button.compact { min-height: 32px; padding: 0 11px; font-size: 12px; }
.button.full { width: 100%; }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
.data-table th { height: 44px; padding: 0 14px; color: #555a60; background: #fafafa; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; white-space: nowrap; }
.data-table td { padding: 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fcfcfc; }
.title-cell { max-width: 420px; }
.title-cell strong { display: block; margin-bottom: 5px; font-size: 14px; }
.title-cell span { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 12px; white-space: nowrap; }
.row-actions button { padding: 0; border: 0; color: var(--red-dark); background: none; }
.row-actions button:hover { text-decoration: underline; }
.status, .tag { display: inline-flex; align-items: center; min-height: 24px; width: auto; padding: 0 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.status.published, .status.active { color: var(--success); background: #eaf7f0; }
.status.draft, .status.inactive { color: #6b7076; background: #f0f1f2; }
.status.offline, .status.revoked, .status.expired { color: #a23934; background: var(--red-soft); }
.tag { margin-right: 5px; color: var(--red-dark); background: var(--red-soft); border: 1px solid #f2cbc8; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: 13px; }

.stack-form, .modal-form { display: grid; gap: 16px; }
label > span { display: block; margin-bottom: 7px; color: #555a60; font-size: 12px; font-weight: 600; }
.form-error { min-height: 20px; margin-top: 14px !important; color: var(--red); font-size: 13px; }
.form-help { margin: -3px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.6; }

dialog { padding: 0; border: 0; }
dialog::backdrop { background: rgb(20 22 24 / 48%); }
.editor-dialog { width: calc(100vw - 40px); height: calc(100vh - 40px); max-width: none; max-height: none; border-radius: 7px; overflow: hidden; }
.editor-shell { height: 100%; display: grid; grid-template-rows: 70px minmax(0, 1fr); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0 0 4px; font-size: 20px; }
.dialog-header p { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; gap: 10px; }
.editor-columns { min-height: 0; display: grid; grid-template-columns: minmax(620px, 1fr) 430px; }
.editor-form { padding: 22px; overflow: auto; background: #f7f7f8; }
.form-section { margin-bottom: 18px; padding: 20px; background: white; border: 1px solid var(--line); }
.form-section h3 { margin: 0 0 18px; font-size: 16px; }
.form-section label { display: block; margin-bottom: 14px; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.upload-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.section-heading h3 { margin-bottom: 5px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.add-block-menu { display: flex; gap: 6px; }
.add-block-menu button { height: 30px; padding: 0 10px; border: 1px solid #d5d7da; border-radius: 4px; background: white; font-size: 12px; }
.add-block-menu button:hover { color: var(--red); border-color: var(--red); }
.block-list { display: grid; gap: 10px; }
.block-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.block-index { display: grid; place-items: center; width: 30px; height: 30px; color: var(--muted); background: #f0f1f2; border-radius: 4px; font-size: 12px; }
.block-fields { min-width: 0; }
.block-fields .block-type { margin-bottom: 8px; color: var(--red-dark); font-size: 12px; font-weight: 650; }
.block-fields input, .block-fields textarea { margin-bottom: 7px; }
.block-actions { display: flex; flex-direction: column; gap: 5px; }
.block-actions button { width: 30px; height: 28px; padding: 0; border: 1px solid #d9dbde; border-radius: 4px; background: white; }
.block-actions button:hover { color: var(--red); border-color: var(--red); }

.article-preview-wrap { min-height: 0; overflow: auto; background: #e9eaec; border-left: 1px solid var(--line); }
.preview-toolbar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; padding: 13px 20px; background: #fff; border-bottom: 1px solid var(--line); font-size: 12px; }
.preview-toolbar span { color: var(--muted); }
.article-preview { width: 375px; min-height: 700px; margin: 20px auto; padding: 30px 22px 80px; background: white; box-shadow: 0 2px 12px rgb(0 0 0 / 7%); }
.article-preview h1 { margin: 0 0 18px; font-size: 26px; line-height: 1.35; }
.preview-author { margin-bottom: 28px; padding-bottom: 18px; color: var(--muted); border-bottom: 1px solid #eee; font-size: 13px; line-height: 1.6; }
.article-preview p { margin: 0 0 20px; font-size: 19px; line-height: 1.85; }
.preview-heading { display: grid; grid-template-columns: 44px 1fr; gap: 10px; margin: 32px 0 20px; }
.preview-heading b { color: var(--red); font-family: Georgia, serif; font-size: 28px; font-style: italic; }
.preview-heading strong { font-size: 21px; line-height: 1.45; }
.preview-insight { margin: 20px 0; padding: 16px; color: #3c2725; background: var(--red-soft); font-size: 17px; line-height: 1.75; }
.article-preview img, .article-preview video { display: block; width: 100%; margin: 20px 0; background: #111; }
.preview-lock { margin-top: 24px; padding: 22px; color: var(--red-dark); background: var(--red-soft); border: 1px solid #f0c8c5; text-align: center; font-weight: 700; }

.small-dialog { width: 520px; border-radius: 7px; }
.modal-form { padding: 24px; }
.modal-form header { display: flex; align-items: flex-start; justify-content: space-between; }
.modal-form h2 { margin: 0; font-size: 20px; }
.modal-form header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.close-symbol { border: 0; color: var(--muted); background: none; font-size: 24px; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 5px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 400px; padding: 12px 16px; color: white; background: #292b2e; border-radius: 5px; box-shadow: 0 8px 24px rgb(0 0 0 / 20%); opacity: 0; transform: translateY(10px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9f2f2a; }

@media (max-width: 1240px) {
  .editor-columns { grid-template-columns: minmax(600px, 1fr) 390px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}
