/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

.admin-only { display: none !important; }

:root {
  /* ── Core palette ── */
  --primary: #6366f1;
  --primary-light: rgba(99,102,241,.12);
  --primary-glow: rgba(99,102,241,.3);
  --gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-cool: linear-gradient(135deg, #06b6d4, #6366f1);

  /* ── Surfaces ── */
  --bg: #0f0f1a;
  --bg-elevated: rgba(255,255,255,.04);
  --card: rgba(255,255,255,.05);
  --card-hover: rgba(255,255,255,.08);
  --card-border: rgba(255,255,255,.08);
  --card-border-hover: rgba(255,255,255,.15);
  --nav-bg: rgba(15,15,30,.85);
  --overlay: rgba(0,0,0,.6);

  /* ── Text ── */
  --text: #f1f3f5;
  --text-secondary: #9092a8;
  --muted: #5c5e75;

  /* ── Semantic ── */
  --success: #22c55e;
  --success-light: rgba(34,197,94,.12);
  --danger: #ef4444;
  --danger-light: rgba(239,68,68,.12);
  --warning: #f59e0b;
  --warning-light: rgba(245,158,11,.12);
  --info: #6366f1;
  --info-light: rgba(99,102,241,.12);

  /* ── Geometry ── */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.4);
  --shadow-glow: 0 0 20px var(--primary-glow);
}

/* ── Light mode overrides ── */
.light-mode {
  --bg: #f6f7fb;
  --bg-elevated: rgba(0,0,0,.02);
  --card: #ffffff;
  --card-hover: #f8f9ff;
  --card-border: #e8eaf0;
  --card-border-hover: #c7cbd8;
  --nav-bg: rgba(255,255,255,.85);
  --overlay: rgba(0,0,0,.3);
  --text: #1a1a2e;
  --text-secondary: #6b6f8a;
  --muted: #a0a3b8;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.1);
}

body {
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Subtle background grain / pattern ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(168,85,247,.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(6,182,212,.03) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}

#app {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ═══════════════════════════
   TOP NAVIGATION
   ═══════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center;
  padding: 0 24px;
  height: 60px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--card-border);
  gap: 8px;
}

.topbar-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700;
  color: var(--text);
  margin-right: 24px;
  flex-shrink: 0;
}
.topbar-logo svg {
  width: 26px; height: 26px;
}

.topbar-nav {
  display: flex; align-items: center; gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }

.topbar-item {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
  white-space: nowrap;
  transition: all .2s;
  border: 1px solid transparent;
  background: transparent;
}
.topbar-item:hover {
  color: var(--text);
  background: var(--bg-elevated);
}
.topbar-item.active {
  color: #fff;
  background: var(--gradient);
  border-color: transparent;
  box-shadow: 0 2px 12px var(--primary-glow);
}
.topbar-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.topbar-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Theme toggle ── */
.theme-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
}
.theme-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--card-border-hover);
}
.theme-btn svg { width: 18px; height: 18px; }

/* ═══════════════════════════
   MAIN CONTENT
   ═══════════════════════════ */
.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.page { display: none; }
.page.active-page { display: block; animation: fadeSlideIn .3s ease; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h2 {
  font-size: 22px; font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══════════════════════════
   CARDS
   ═══════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(12px);
  transition: all .25s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.card:hover {
  background: var(--card-hover);
  border-color: var(--card-border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; line-height: 1.4; }
.card-time { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.card-preview { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 8px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.card-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.card-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ── Glass card variant ── */
.glass-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(16px);
  transition: all .25s cubic-bezier(.4,0,.2,1);
}
.glass-card:hover {
  border-color: var(--card-border-hover);
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════
   ACCOUNTS
   ═══════════════════════════ */
.acc-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(12px);
  transition: all .25s cubic-bezier(.4,0,.2,1);
}
.acc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--card-border-hover);
}
.acc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; gap: 12px; }
.acc-name { font-size: 17px; font-weight: 700; }
.acc-id { color: var(--muted); font-size: 12px; font-family: 'SF Mono', 'Fira Code', monospace; margin-top: 4px; word-break: break-all; }
.acc-actions { display: flex; gap: 8px; margin-top: 16px; }

.acc-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 500;
}
.acc-status.ok { color: var(--success); background: var(--success-light); }
.acc-status.err { color: var(--danger); background: var(--danger-light); }

.acc-perm-tags { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.acc-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.acc-tag-draft { background: rgba(6,182,212,.12); color: #22d3ee; }
.acc-tag-publish { background: rgba(34,197,94,.12); color: #4ade80; }
.acc-tag-unauth { background: rgba(239,68,68,.12); color: #f87171; }

.light-mode .acc-tag-draft { background: #e0f2fe; color: #0369a1; }
.light-mode .acc-tag-publish { background: #dcfce7; color: #15803d; }
.light-mode .acc-tag-unauth { background: #fef2f2; color: #dc2626; }

/* ── Account hint ── */
.account-hint {
  font-size: 12px; line-height: 1.5;
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 600px; text-align: right;
  padding: 6px 12px; border-radius: 6px;
  background: var(--warning-light);
  border: 1px solid rgba(245,158,11,.2);
  color: #fbbf24;
}
.light-mode .account-hint { color: #92400e; }

/* ═══════════════════════════
   BUTTONS
   ═══════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  cursor: pointer; font-size: 13px;
  font-weight: 500;
  transition: all .2s;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}
.btn:hover {
  background: var(--card-hover);
  border-color: var(--card-border-hover);
}
.btn-primary {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover {
  box-shadow: 0 2px 16px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-lg { padding: 12px 24px; font-size: 14px; border-radius: var(--radius); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.btn-danger { color: var(--danger); border-color: rgba(239,68,68,.2); background: transparent; }
.btn-danger:hover { background: var(--danger-light); border-color: rgba(239,68,68,.3); }
.btn-primary.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); border-color: transparent; color: #fff; }
.btn-primary.btn-danger:hover { box-shadow: 0 2px 16px rgba(239,68,68,.3); }

.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Publish button in history ── */
.btn-publish {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 1px 8px; border-radius: 8px;
  border: 1px solid var(--success);
  background: var(--success-light);
  color: var(--success);
  cursor: pointer; font-size: 11px; font-weight: 600;
  transition: all .2s; margin-left: 4px; vertical-align: middle;
}
.btn-publish:hover { background: var(--success); color: #fff; }

/* ── Tag published ── */
.tag-published { font-size: 11px; font-weight: 600; margin-left: 4px; }
.tag-published-fail { color: var(--danger); }

/* ═══════════════════════════
   FORMS
   ═══════════════════════════ */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-row { display: flex; gap: 16px; }
.flex-1 { flex: 1; }

input, textarea, select {
  width: 100%; padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--bg-elevated);
  color: var(--text); font-size: 14px;
  outline: none; font-family: inherit;
  transition: all .2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
textarea {
  resize: vertical;
  font-family: 'SF Mono', 'Fira Code', monospace;
  line-height: 1.6; font-size: 13px;
}
select { cursor: pointer; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.form-tip { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

/* ═══════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════ */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; flex-shrink: 0; }
.toggle input { display: none; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--card-border);
  border-radius: 22px;
  transition: .25s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: .25s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--gradient); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ═══════════════════════════
   TAGS
   ═══════════════════════════ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.tag-success { color: var(--success); background: var(--success-light); }
.tag-fail { color: var(--danger); background: var(--danger-light); }
.tag-drafting { color: var(--warning); background: var(--warning-light); }
.tag-cron { color: #a78bfa; background: rgba(167,139,250,.12); }
.tag-manual { color: var(--text-secondary); background: var(--card-border); }
.tag-image { background: rgba(167,139,250,.12); color: #a78bfa; }
.tag-doc { background: rgba(56,189,248,.12); color: #38bdf8; }
.tag-sheet { background: rgba(52,211,153,.12); color: #34d399; }
.tag-all { background: rgba(99,102,241,.12); color: #818cf8; }

.light-mode .tag-cron { color: var(--primary); background: var(--primary-light); }
.light-mode .tag-all { color: #1a73e8; background: #e8f4fd; }

/* ═══════════════════════════
   FILTER TABS
   ═══════════════════════════ */
.filter-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.filter-tab {
  padding: 7px 18px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all .2s;
  user-select: none; border: 1px solid transparent;
}
.filter-tab:hover { color: var(--text); background: var(--bg-elevated); }
.filter-tab.active {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
}

/* ═══════════════════════════
   TASK CARD
   ═══════════════════════════ */
.task-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.task-header .card-title { font-size: 16px; }
.task-meta { display: grid; gap: 10px; }
.task-meta-item { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.task-meta-item code { font-size: 12px; color: var(--muted); }
.task-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ═══════════════════════════
   STATUS DOT
   ═══════════════════════════ */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.success { background: var(--success); }
.status-dot.fail { background: var(--danger); }
.status-dot.drafting { background: var(--warning); animation: pulse 1.5s ease infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ═══════════════════════════
   HISTORY
   ═══════════════════════════ */
.history-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
  transition: all .2s;
}
.history-item:hover {
  border-color: var(--card-border-hover);
  box-shadow: var(--shadow-md);
}
.history-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; gap: 12px;
}
.history-header > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.history-title {
  font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-time { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.history-targets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.history-summary { font-size: 13px; color: var(--text-secondary); margin: 4px 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 14px; }

.history-filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius);
}
.history-filters .filter-group { display: flex; align-items: center; gap: 6px; }
.history-filters label { font-size: 12px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.history-filters input[type="date"] { width: auto; padding: 6px 10px; font-size: 13px; }
.history-filters input[type="text"] { width: 200px; padding: 6px 12px; font-size: 13px; }
.history-filters .filter-tabs-compact { display: flex; gap: 4px; flex-wrap: wrap; }
.history-filters .filter-tab { padding: 5px 12px; font-size: 12px; }

/* ═══════════════════════════
   DASHBOARD
   ═══════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px; margin-bottom: 32px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(12px);
  transition: all .25s cubic-bezier(.4,0,.2,1);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient);
  opacity: .6;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--card-border-hover);
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  background: var(--primary-light);
  color: #818cf8;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1.2; color: var(--text); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.dashboard-section { margin-bottom: 28px; }
.dashboard-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 14px; color: var(--text); }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-action-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all .2s;
  backdrop-filter: blur(8px);
}
.quick-action-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: #818cf8;
  transform: translateY(-1px);
}
.quick-action-btn svg { width: 18px; height: 18px; }

/* ═══════════════════════════
   MODAL
   ═══════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-lg { width: 720px; }
.modal h3 { margin-bottom: 24px; font-size: 18px; font-weight: 700; }

/* ═══════════════════════════
   TOAST
   ═══════════════════════════ */
.toast-container {
  position: fixed; top: 72px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-lg);
  font-size: 14px; max-width: 380px;
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .3s ease;
  line-height: 1.5;
  backdrop-filter: blur(16px);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.fail { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
.toast-out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }

/* ═══════════════════════════
   LOADING / SPINNER
   ═══════════════════════════ */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--card-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════
   SKELETON
   ═══════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--card-border) 25%, var(--card-hover) 50%, var(--card-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 140px; margin-bottom: 20px; }
.skeleton-line { height: 14px; margin-bottom: 10px; }
.skeleton-line-sm { height: 10px; width: 60%; }
.skeleton-block { height: 80px; }

/* ═══════════════════════════
   ICON BUTTON
   ═══════════════════════════ */
.btn-icon {
  padding: 6px; border: none; background: transparent;
  color: var(--text-secondary); cursor: pointer; border-radius: 6px;
  transition: all .2s;
}
.btn-icon:hover { background: var(--primary-light); color: #818cf8; }
.btn-icon svg { width: 18px; height: 18px; display: block; }

/* ═══════════════════════════
   RADIO & CHECKBOX GROUPS
   ═══════════════════════════ */
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-label {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s; font-size: 13px; font-weight: 500;
  background: var(--bg-elevated);
}
.radio-label:hover { border-color: var(--primary); }
.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: #818cf8;
}
.radio-label input { width: auto; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-label {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s; font-size: 13px;
  background: var(--bg-elevated);
}
.checkbox-label:hover { border-color: var(--primary); }
.checkbox-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.checkbox-label input { width: auto; }

/* ═══════════════════════════
   PREVIEW CONTENT
   ═══════════════════════════ */
.preview-content {
  font-size: 15px; line-height: 1.8; color: var(--text);
  padding: 4px 0;
}
.preview-content h1, .preview-content h2, .preview-content h3 {
  margin: 20px 0 12px; font-weight: 700; line-height: 1.4;
}
.preview-content h1 { font-size: 2em; }
.preview-content h2 { font-size: 1.5em; }
.preview-content h3 { font-size: 1.17em; }
.preview-content p { margin-bottom: 12px; }
.preview-content p:empty { display: none; }
.preview-content li { margin-bottom: 4px; margin-left: 20px; list-style: disc; }
.preview-content a { color: #818cf8; text-decoration: underline; }
.preview-content strong { font-weight: 700; }
.preview-content img { max-width: 100%; border-radius: var(--radius-sm); margin: 12px 0; }
.preview-content p > code, .preview-content li > code {
  font-size: 13px; padding: 2px 6px;
  background: var(--bg-elevated); border-radius: 4px;
}

/* ═══════════════════════════
   ARTICLE OPTIMIZE
   ═══════════════════════════ */
.optimize-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
}
.optimize-topbar-left { display: flex; align-items: center; gap: 12px; }
.optimize-topbar-right { display: flex; align-items: center; gap: 10px; }
.optimize-body { display: flex; gap: 20px; min-height: calc(100vh - 220px); align-items: flex-start; }
.optimize-panel { display: flex; flex-direction: column; }
.optimize-panel-left { flex: 1; min-width: 0; max-width: 50%; }
.optimize-panel-right { flex: 1; min-width: 0; }
.optimize-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(8px);
}
.optimize-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; font-size: 14px; font-weight: 600; color: var(--text);
}
.optimize-card-hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.optimize-publish-mode {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 8px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.optimize-textarea {
  width: 100%; min-height: 380px; padding: 14px;
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.7;
  font-family: 'SF Mono', 'Fira Code', monospace;
  resize: vertical; outline: none;
  transition: all .2s;
  background: var(--bg-elevated); color: var(--text);
}
.optimize-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.optimize-textarea-sm { min-height: 70px; font-family: inherit; font-size: 13px; }
.optimize-preview-card { height: 100%; display: flex; flex-direction: column; }
.optimize-preview-content {
  flex: 1; overflow-y: auto; padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  min-height: 200px; max-height: 60vh;
}
.optimize-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px; color: var(--muted);
}
.optimize-placeholder p { font-size: 14px; text-align: center; }

/* ── Quill overrides ── */
.ql-container { font-size: 14px; line-height: 1.7; }
.ql-editor {
  min-height: 340px; max-height: 50vh; overflow-y: auto;
  font-size: 15px; line-height: 1.8; color: var(--text);
  font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.ql-editor h1, .ql-editor h2, .ql-editor h3 { margin: 20px 0 12px; font-weight: 700; line-height: 1.4; }
.ql-editor h1 { font-size: 2em; }
.ql-editor h2 { font-size: 1.5em; }
.ql-editor h3 { font-size: 1.17em; }
.ql-editor p { margin-bottom: 12px; }
.ql-toolbar {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border) !important;
  border-bottom: none !important;
}
.ql-container {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
  border: 1px solid var(--card-border) !important;
  border-top: none !important;
  background: var(--bg-elevated);
}
.ql-toolbar .ql-stroke { stroke: var(--text-secondary); }
.ql-toolbar .ql-fill { fill: var(--text-secondary); }
.ql-toolbar button:hover .ql-stroke { stroke: var(--primary); }
.ql-toolbar button:hover .ql-fill { fill: var(--primary); }

@media (max-width: 900px) {
  .optimize-body { flex-direction: column; }
  .optimize-panel-left { max-width: 100%; }
}

/* ═══════════════════════════
   MEDIA LIBRARY
   ═══════════════════════════ */
.media-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px;
  backdrop-filter: blur(8px);
  transition: all .2s;
}
.media-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--card-border-hover); }
.media-preview { margin-bottom: 8px; }
.media-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.media-size { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.media-actions { display: flex; gap: 6px; }

/* ═══════════════════════════
   RESULT BOX
   ═══════════════════════════ */
.result-box { margin-top: 16px; padding: 16px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--card-border); }
.result-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--card-border); }
.result-item:last-child { border-bottom: none; }
.result-item.success { color: var(--success); }
.result-item.fail { color: var(--danger); }

/* ═══════════════════════════
   TUTORIAL
   ═══════════════════════════ */
.tutorial-content { background: transparent; padding: 0; max-width: 960px; }
.tutorial-content h1, .tutorial-content h2, .tutorial-content h3 { color: var(--text); margin: 24px 0 12px; }
.tutorial-content p { color: var(--text-secondary); line-height: 1.8; margin-bottom: 12px; }
.tutorial-content code { background: var(--bg-elevated); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ═══════════════════════════
   AI CONFIG
   ═══════════════════════════ */
.ai-section { display: none; }
.ai-section.visible { display: block; }

/* ═══════════════════════════
   EXECUTING BUTTON ANIMATION
   ═══════════════════════════ */
.btn-executing {
  pointer-events: none;
  background: var(--card) !important;
  border-color: transparent !important;
  color: var(--primary) !important;
  animation: borderFlow 1.6s linear infinite;
}
@keyframes borderFlow {
  0%   { box-shadow: 0 0 0 2px #6366f1, 0 0 8px rgba(99,102,241,.35); }
  16%  { box-shadow: 0 0 0 2px #a855f7, 0 0 8px rgba(168,85,247,.35); }
  33%  { box-shadow: 0 0 0 2px #ec4899, 0 0 8px rgba(236,72,153,.35); }
  50%  { box-shadow: 0 0 0 2px #f59e0b, 0 0 8px rgba(245,158,11,.35); }
  66%  { box-shadow: 0 0 0 2px #22c55e, 0 0 8px rgba(34,197,94,.35); }
  83%  { box-shadow: 0 0 0 2px #06b6d4, 0 0 8px rgba(6,182,212,.35); }
  100% { box-shadow: 0 0 0 2px #6366f1, 0 0 8px rgba(99,102,241,.35); }
}

.brain-thinking {
  display: inline-flex; align-items: center;
  animation: brainPulse 1.8s ease-in-out infinite;
}
@keyframes brainPulse {
  0%, 100% { transform: scale(1); opacity: .7; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* ═══════════════════════════
   ACTIVATION OVERLAY
   ═══════════════════════════ */
.activation-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  justify-content: center; align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.activation-overlay::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(99,102,241,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(168,85,247,.1) 0%, transparent 50%);
  pointer-events: none;
}
.activation-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px; padding: 48px 40px;
  max-width: 480px; width: 90%;
  box-shadow: var(--shadow-lg), 0 0 60px var(--primary-glow);
  backdrop-filter: blur(20px);
  text-align: center;
  position: relative;
}
.activation-lock { width: 48px; height: 48px; color: #818cf8; margin-bottom: 12px; }
.activation-header h1 { font-size: 24px; font-weight: 800; color: var(--text); margin: 0 0 8px; }
.activation-subtitle { color: var(--text-secondary); font-size: 14px; margin: 0 0 32px; }
.activation-body { text-align: left; }
.activation-hint { font-size: 13px; color: var(--text-secondary); margin: 0 0 16px; text-align: center; line-height: 1.5; }
.machine-fingerprint {
  display: flex; gap: 6px; align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 20px;
}
.fingerprint-label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}
.fingerprint-value {
  flex: 1; font-size: 12px; color: var(--text); word-break: break-all;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.activation-input-area { margin-bottom: 16px; }
.activation-input-area label { font-size: 13px; font-weight: 600; color: var(--text-secondary); display: block; margin-bottom: 6px; }
.activation-input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 14px; outline: none; box-sizing: border-box; margin-bottom: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--bg-elevated);
  color: var(--text);
}
.activation-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.activate-btn { width: 100%; padding: 12px; font-size: 16px; font-weight: 700; }
.activate-btn:disabled { opacity: .6; cursor: not-allowed; }
.activation-status { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; display: none; }
.activation-status.error { display: block; background: var(--danger-light); color: #f87171; border: 1px solid rgba(239,68,68,.2); }
.activation-status.success { display: block; background: var(--success-light); color: #4ade80; border: 1px solid rgba(34,197,94,.2); }
.activation-footer { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--card-border); }
.activation-footer p { font-size: 13px; color: var(--muted); margin: 0; }

.light-mode .activation-status.error { color: #dc2626; }
.light-mode .activation-status.success { color: #16a34a; }

/* ═══════════════════════════
   LICENSE ADMIN
   ═══════════════════════════ */
.license-tab-content { margin-top: 20px; }
.license-result {
  margin-top: 20px; padding: 20px; border-radius: var(--radius);
  background: var(--success-light);
  border: 1px solid rgba(34,197,94,.2);
}
.license-result-header {
  font-size: 15px; font-weight: 700;
  color: #4ade80; margin-bottom: 12px;
}
.light-mode .license-result-header { color: #16a34a; }
.license-result-body { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.license-code {
  flex: 1; font-size: 13px; font-family: 'SF Mono', 'Fira Code', monospace;
  word-break: break-all; padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: var(--radius-sm);
  color: #4ade80; line-height: 1.6;
}
.light-mode .license-code { color: #15803d; }
.license-payload {
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-elevated); padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  font-family: 'SF Mono', 'Fira Code', monospace;
  white-space: pre-wrap; word-break: break-all;
}
.license-error {
  margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--danger-light); color: #f87171;
  font-size: 14px; border: 1px solid rgba(239,68,68,.2);
}
.light-mode .license-error { color: #dc2626; }

.license-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.license-table th {
  text-align: left; padding: 10px 12px; font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--card-border);
  white-space: nowrap;
}
.license-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
}
.license-table td:first-child { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; color: var(--muted); }
.license-table .lic-machine-id {
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.license-status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}
.license-status-badge.active { background: var(--success-light); color: #4ade80; }
.license-status-badge.expired { background: var(--danger-light); color: #f87171; }
.light-mode .license-status-badge.active { color: #15803d; }
.light-mode .license-status-badge.expired { color: #dc2626; }
.license-table .btn-sm { font-size: 12px; padding: 4px 10px; }
.license-table .btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.license-table .btn-danger:hover { background: #dc2626; }

/* ═══════════════════════════
   SCROLLBAR
   ═══════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ═══════════════════════════
   RESPONSIVE
   ═══════════════════════════ */
@media (max-width: 768px) {
  .topbar { padding: 0 12px; gap: 4px; }
  .topbar-logo { margin-right: 8px; }
  .topbar-logo span { display: none; }
  .topbar-item { padding: 6px 10px; font-size: 12px; }
  .topbar-item svg { width: 14px; height: 14px; }
  .main { padding: 20px 16px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 24px 20px; }
}
