:root {
  --bg: #f3f5fb;
  --panel: #ffffff;
  --border: #e6eaf2;
  --text: #101828;
  --muted: #667085;
  --primary: #4f6ef7;
  --primary-2: #7a5cf0;
  --primary-3: #38bdf8;
  --primary-dark: #3b5bdb;
  --primary-soft: #eef1fe;
  --success: #12a150;
  --success-soft: #e6f7ee;
  --danger: #e03131;
  --danger-soft: #fdeaea;
  --warn: #e8770c;
  --warn-soft: #fff3e4;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 8px 30px rgba(16,24,40,.14);
  --sidebar-w: 244px;
  --grad: linear-gradient(135deg, #4f6ef7 0%, #7a5cf0 60%, #38bdf8 120%);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
::selection { background: var(--primary-soft); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4d9e4; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: linear-gradient(180deg, #111a30 0%, #0d1428 100%); color: #aab4cc; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30; }
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

/* ---------------- sidebar ---------------- */
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 18px 18px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; color: #fff; box-shadow: 0 6px 16px rgba(79,110,247,.45); }
.brand-name { font-weight: 700; font-size: 15.5px; color: #fff; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: #7c88a8; margin-top: 2px; }
.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-group-label { font-size: 10.5px; color: #5d6a8c; text-transform: uppercase; letter-spacing: 1.2px; padding: 10px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10.5px 12px; border-radius: 10px; color: #aab4cc; text-decoration: none; margin-bottom: 3px; font-size: 13.5px; transition: all .15s; position: relative; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(79,110,247,.35), rgba(122,92,240,.22)); color: #fff; font-weight: 600; }
.nav a.active::before { content: ''; position: absolute; left: 0; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--grad); }
.nav a .ico { width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 13px; background: rgba(255,255,255,.08); }
.nav a.active .ico { background: rgba(255,255,255,.16); }
.side-foot { padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,.07); }
.plan-box { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.plan-badge { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 700; background: rgba(79,110,247,.22); color: #a5b4ff; }
.plan-badge.pro { background: rgba(232,119,12,.2); color: #ffb56b; }
.plan-badge.agency { background: rgba(18,161,80,.2); color: #5fd08f; }
.plan-hint { font-size: 11px; color: #7c88a8; }
.tenant-name { font-size: 12px; color: #8a94ad; word-break: break-all; }

/* ---------------- topbar ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 30px 16px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.page-title { font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.page-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-email { color: var(--muted); font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* ---------------- view ---------------- */
.view { padding: 26px 30px 60px; animation: fadeUp .3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 800px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; transition: box-shadow .2s; }
.card:hover { box-shadow: var(--shadow-lg); }
.card h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card h3 .hint { font-size: 12px; color: var(--muted); font-weight: 400; }

/* KPI */
.kpi { display: flex; align-items: flex-start; gap: 14px; position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, rgba(79,110,247,.08), transparent 70%); }
.kpi .kpi-ico { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.kpi .kpi-ico.blue { background: var(--primary-soft); }
.kpi .kpi-ico.green { background: var(--success-soft); }
.kpi .kpi-ico.orange { background: var(--warn-soft); }
.kpi .kpi-ico.purple { background: #f3eefe; }
.kpi .kpi-ico.red { background: var(--danger-soft); }
.kpi .kpi-body { min-width: 0; }
.kpi .kpi-num { font-size: 26px; font-weight: 800; line-height: 1.15; letter-spacing: -.5px; }
.kpi .kpi-lbl { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi .kpi-sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.kpi .kpi-trend { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-top: 5px; }
.kpi .kpi-trend.up { background: var(--success-soft); color: var(--success); }
.kpi .kpi-trend.down { background: var(--danger-soft); color: var(--danger); }
.kpi .kpi-trend.flat { background: #eef0f4; color: var(--muted); }

.chart-box { position: relative; height: 240px; }
.chart-box.sm { height: 200px; }
.section-title { font-size: 14.5px; font-weight: 800; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .ico { font-size: 16px; }

/* ---------------- buttons ---------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8.5px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; }
.btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.btn-primary { background: var(--grad); border: none; color: #fff; box-shadow: 0 4px 12px rgba(79,110,247,.35); }
.btn-primary:hover { color: #fff; box-shadow: 0 6px 18px rgba(79,110,247,.45); }
.btn-success { background: var(--success); border: none; color: #fff; box-shadow: 0 4px 12px rgba(18,161,80,.3); }
.btn-success:hover { color: #fff; opacity: .92; }
.btn-danger { background: var(--danger); border: none; color: #fff; }
.btn-danger:hover { color: #fff; opacity: .9; }
.btn-sm { padding: 5.5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-ghost { border: none; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--danger); background: transparent; transform: none; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------------- forms ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea { width: 100%; padding: 9.5px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text); outline: none; transition: border .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.13); }
.textarea { min-height: 84px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 13px; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); white-space: nowrap; background: #fafbfe; }
td { padding: 11px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8faff; }
.badge { display: inline-block; padding: 2.5px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.purple { background: #f3eefe; color: #7a5cf0; }
.badge.gray { background: #eef0f4; color: var(--muted); }
.badge.cyan { background: #e0f6ff; color: #0c8cc4; }

/* status pills for article flow */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.idea { background: #eef0f4; color: #667085; }
.pill.drafting, .pill.draft { background: var(--warn-soft); color: var(--warn); }
.pill.review { background: var(--primary-soft); color: var(--primary); }
.pill.approved { background: #f3eefe; color: #7a5cf0; }
.pill.published { background: var(--success-soft); color: var(--success); }
.pill.rejected, .pill.archived { background: var(--danger-soft); color: var(--danger); }

/* ---------------- auth ---------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e2a52 50%, #3b5bdb 130%); padding: 20px; position: relative; overflow: hidden; }
.auth-wrap::before, .auth-wrap::after { content: ''; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; }
.auth-wrap::before { width: 420px; height: 420px; background: #4f6ef7; top: -120px; left: -100px; }
.auth-wrap::after { width: 360px; height: 360px; background: #7a5cf0; bottom: -120px; right: -80px; }
.auth-card { width: 420px; max-width: 100%; background: #fff; border-radius: 18px; padding: 38px 36px; box-shadow: 0 24px 80px rgba(0,0,0,.4); position: relative; z-index: 2; animation: fadeUp .4s ease; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.auth-card h1 { font-size: 23px; letter-spacing: .3px; }
.auth-card .auth-sub { color: var(--muted); margin-bottom: 26px; font-size: 13.5px; }
.auth-foot { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.auth-foot a { color: var(--primary); cursor: pointer; text-decoration: none; font-weight: 700; }
.auth-error { background: var(--danger-soft); color: var(--danger); border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px; }

/* ---------------- toast ---------------- */
.toast { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 200; background: #1c2438; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 90vw; animation: fadeUp .25s ease; }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* ---------------- drawer ---------------- */
.drawer { position: fixed; inset: 0; z-index: 100; }
.drawer-mask { position: absolute; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 94vw); background: #fff; box-shadow: -12px 0 40px rgba(15,23,42,.2); overflow-y: auto; animation: slideIn .28s ease; }
@keyframes slideIn { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; background: #fff; padding: 20px 26px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; z-index: 2; }
.drawer-body { padding: 22px 26px 60px; }
.drawer-close { background: #f3f5fb; border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 15px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.drawer-close:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------------- modal ---------------- */
.modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); }
.modal-panel { position: relative; background: #fff; border-radius: 16px; box-shadow: 0 24px 80px rgba(0,0,0,.3); width: min(560px, 92vw); max-height: 88vh; overflow-y: auto; padding: 26px 28px; animation: fadeUp .25s ease; }

/* ---------------- article preview ---------------- */
.preview-frame { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; min-height: 420px; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.article-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ---------------- misc ---------------- */
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 12.5px; font-weight: 700; padding: 3px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--primary-soft); }
.link-btn.danger { color: var(--danger); }
.link-btn.danger:hover { background: var(--danger-soft); }
.engine-chip { display: inline-block; padding: 4px 10px; border-radius: 8px; font-size: 11.5px; font-weight: 600; margin: 2px; background: #eef0f4; color: var(--muted); }
.engine-chip.on { background: var(--success-soft); color: var(--success); }
.engine-chip.off { opacity: .55; }
.empty { color: var(--muted); text-align: center; padding: 34px 0; font-size: 13px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spin.dark { border-color: rgba(79,110,247,.25); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.kv { display: grid; grid-template-columns: 108px 1fr; gap: 8px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.progress-wrap { height: 8px; background: #eef0f4; border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--grad); border-radius: 10px; transition: width .5s; }
.stat-line { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.stat-line:last-child { border-bottom: none; }
.stat-line .v { font-weight: 700; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.step-flow { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 10px 0 16px; }
.step-flow .st { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; background: #eef0f4; color: var(--muted); }
.step-flow .st.done { background: var(--success-soft); color: var(--success); }
.step-flow .st.now { background: var(--primary-soft); color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.15); }
.step-flow .arr { color: #c8cede; font-size: 11px; }
