/* ============================================================
   VigyanLLM CMS Design System v1.0
   Inter type system · Slate token scale · WCAG 2.1 AA
   Shared by: cms-login.html · cms-admin.html · cms-editor.html
   ============================================================ */

/* ------------------------------------------------------------
   1. Design Tokens
   ------------------------------------------------------------ */
:root {
  /* Color — brand */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;

  /* Color — slate scale */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Color — semantic */
  --success-50: #ecfdf5;
  --success-600: #059669;
  --success-700: #047857;
  --warning-50: #fffbeb;
  --warning-600: #d97706;
  --warning-700: #b45309;
  --danger-50: #fef2f2;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;

  /* Role mapping (light) */
  --bg: var(--slate-100);
  --bg-subtle: var(--slate-50);
  --surface: #ffffff;
  --surface-hover: var(--slate-50);
  --surface-active: var(--slate-100);
  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --text: var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-muted: var(--slate-400);
  --text-inverse: #ffffff;
  --text-on-primary: #ffffff;
  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --primary-subtle: var(--blue-50);
  --primary-strong: var(--blue-800);
  --sidebar-bg: var(--slate-900);
  --sidebar-text: rgba(255, 255, 255, 0.6);
  --sidebar-text-hover: #ffffff;
  --sidebar-item-hover: rgba(255, 255, 255, 0.06);
  --sidebar-item-active: rgba(255, 255, 255, 0.1);
  --sidebar-border: rgba(255, 255, 255, 0.08);

  /* Compatibility aliases — legacy inline styles in CMS JS-generated HTML */
  --muted: var(--slate-400);
  --text2: var(--slate-600);
  --white: #ffffff;
  --slate: var(--slate-100);
  --slate-border: var(--slate-200);
  --navy: var(--slate-900);
  --bio: var(--success-600);
  --success: var(--success-600);
  --warning: var(--warning-600);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  /* Type scale */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.8125rem;    /* 13px */
  --text-base: 0.875rem;   /* 14px */
  --text-md: 0.9375rem;    /* 15px */
  --text-lg: 1.0625rem;    /* 17px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* Spacing (4px grid) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Radius */
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-full: 9999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.1), 0 1px 2px -1px rgb(15 23 42 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.1), 0 2px 4px -2px rgb(15 23 42 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.1), 0 4px 6px -4px rgb(15 23 42 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(15 23 42 / 0.1), 0 8px 10px -6px rgb(15 23 42 / 0.1);

  /* Focus ring */
  --ring-width: 3px;
  --ring-color: rgba(37, 99, 235, 0.35);
  --ring-offset: 2px;

  /* Motion — easing */
  --ease-standard: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-enter: cubic-bezier(0.21, 1.02, 0.73, 1);
  --ease-exit: cubic-bezier(0.06, 0.89, 0.38, 0.99);

  /* Motion — duration */
  --dur-fast: 100ms;
  --dur-base: 200ms;
  --dur-med: 300ms;
  --dur-slow: 500ms;

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 68px;
  --topbar-height: 56px;
  --content-max: 1440px;
}

/* ------------------------------------------------------------
   2. Dark Mode (token remap — enabled via [data-theme="dark"] or media query)
   ------------------------------------------------------------ */
[data-theme="dark"] {
  --bg: var(--slate-900);
  --bg-subtle: var(--slate-800);
  --surface: var(--slate-800);
  --surface-hover: var(--slate-700);
  --surface-active: var(--slate-700);
  --border: var(--slate-700);
  --border-strong: var(--slate-600);
  --text: var(--slate-100);
  --text-secondary: var(--slate-300);
  --text-muted: var(--slate-400);
  --sidebar-bg: var(--slate-950, #020617);
  --sidebar-text: rgba(255, 255, 255, 0.55);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
  --ring-color: rgba(96, 165, 250, 0.4);
}

/* ------------------------------------------------------------
   3. Reset + Base
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img, svg, video { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
a { color: var(--primary); }
button { font-family: inherit; }
input, select, textarea, button { font-family: inherit; }

::selection { background: var(--blue-100); color: var(--slate-900); }

/* ------------------------------------------------------------
   4. Accessibility — focus visible (WCAG 2.4.7 / 2.4.11)
   ------------------------------------------------------------ */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: var(--ring-offset);
  border-radius: var(--radius-sm);
}
.sidebar-nav a:focus-visible,
.btn:focus-visible,
.btn-icon:focus-visible,
.filter-btn:focus-visible,
.pagination button:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}
[data-theme="dark"] :focus-visible { outline-color: #60a5fa; }

/* ------------------------------------------------------------
   5. Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: var(--shadow-md); }

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--slate-400); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-danger {
  background: var(--danger-50);
  border-color: #fecaca;
  color: var(--danger-700);
}
.btn-danger:hover:not(:disabled) { background: #fee2e2; border-color: var(--danger-600); color: var(--danger-700); }

.btn-success { background: var(--success-600); color: var(--text-inverse); box-shadow: var(--shadow-sm); }
.btn-success:hover:not(:disabled) { background: var(--success-700); }

.btn-white { background: var(--surface); color: var(--slate-900); box-shadow: var(--shadow-sm); }
.btn-white:hover:not(:disabled) { background: var(--slate-100); }

.btn-outline-light { background: transparent; border-color: rgba(255, 255, 255, 0.25); color: rgba(255, 255, 255, 0.85); }
.btn-outline-light:hover:not(:disabled) { border-color: #fff; color: #fff; background: rgba(255, 255, 255, 0.08); }

.btn-sm { padding: 5px 12px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 24px; font-size: var(--text-md); border-radius: var(--radius-md); }

.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--border);
  cursor: pointer; color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-standard);
  font-size: var(--text-sm);
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }
.btn-icon.is-active { background: var(--primary); color: var(--text-on-primary); border-color: var(--primary); }
.btn-icon-group { display: flex; gap: 1px; align-items: center; }
.toolbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* ------------------------------------------------------------
   6. Forms
   ------------------------------------------------------------ */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.form-group > label, .form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.form-input, .form-textarea, .form-select,
.modal input, .modal select, .modal textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.form-textarea, .modal textarea { resize: vertical; min-height: 52px; }
.form-input::placeholder, .form-textarea::placeholder, .modal input::placeholder { color: var(--text-muted); }
.form-input:focus, .form-textarea:focus, .form-select:focus,
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 var(--ring-width) var(--ring-color);
}
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.form-group .preview-thumb { width: 60px; height: 60px; border-radius: var(--radius-md); object-fit: cover; margin-top: 6px; border: 1px solid var(--border); }
.code-textarea textarea { font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.6; min-height: 120px; }

.inline-edit input { width: 100%; padding: 4px 8px; border: 1px solid var(--primary); border-radius: var(--radius-sm); font-size: var(--text-xs); outline: none; }

/* ------------------------------------------------------------
   7. Badges & Tags
   ------------------------------------------------------------ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-draft { background: var(--warning-50); color: var(--warning-700); }
.badge-pending_review { background: var(--blue-100); color: var(--blue-800); }
.badge-published { background: var(--success-50); color: var(--success-700); }
.badge-archived { background: var(--slate-100); color: var(--slate-600); }
.badge-admin { background: var(--danger-50); color: var(--danger-700); }
.badge-editor { background: var(--blue-100); color: var(--blue-800); }

/* ------------------------------------------------------------
   8. Cards & Surfaces
   ------------------------------------------------------------ */
.stat-card, .page-card, .block-card, .recent-item, .media-item, .editor-card,
.meta-section, .settings-section, .users-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.stat-card, .page-card, .block-card, .recent-item, .media-item {
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}
.stat-card:hover, .page-card:hover, .block-card:hover, .recent-item:hover { border-color: var(--slate-300); box-shadow: var(--shadow-md); }

/* ------------------------------------------------------------
   9. Skeleton Loading (spec §9 — preferred over spinners)
   ------------------------------------------------------------ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--slate-200);
  border-radius: var(--radius-md);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: shimmer 1.5s infinite;
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }

.skeleton-row { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); }
.skeleton-line { height: 12px; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-card { height: 72px; }
.skeleton-stat { height: 96px; }
.skeleton-thumb { height: 140px; border-radius: var(--radius-lg); }

/* Fallback spinner (kept for compat; skeleton is preferred) */
.spinner { display: flex; align-items: center; justify-content: center; padding: 60px; }
.spinner::after {
  content: '';
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm::after { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------
   10. Empty / Error / Success States (spec §9)
   ------------------------------------------------------------ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.35; }
.empty-state p { font-size: var(--text-md); margin-bottom: 4px; color: var(--text-secondary); font-weight: 600; }
.empty-state .sub { font-size: var(--text-sm); color: var(--text-muted); }
.empty-state .empty-action { margin-top: var(--space-4); }

.state-banner { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-lg); margin-bottom: var(--space-4); font-size: var(--text-sm); }
.state-banner.error { background: var(--danger-50); border: 1px solid #fecaca; color: var(--danger-700); }
.state-banner.success { background: var(--success-50); border: 1px solid #a7f3d0; color: var(--success-700); }
.state-banner.info { background: var(--blue-50); border: 1px solid var(--blue-200); color: var(--blue-800); }

/* ------------------------------------------------------------
   11. Toast
   ------------------------------------------------------------ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: var(--slate-800);
  color: var(--text-inverse);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity var(--dur-med) var(--ease-enter), transform var(--dur-med) var(--ease-enter);
  pointer-events: auto;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast.error { background: var(--danger-700); }
.toast.success { background: var(--success-700); }
.toast.slide-out { opacity: 0; transform: translateY(12px) scale(0.96); }

/* Editor standalone toast (kept for compat) */
#toast { position: fixed; bottom: 24px; right: 24px; background: var(--slate-800); color: #fff; padding: 14px 22px; border-radius: var(--radius-lg); font-size: var(--text-sm); z-index: 9999; opacity: 0; transform: translateY(8px); transition: all var(--dur-med) var(--ease-standard); pointer-events: none; max-width: 360px; box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--danger-600); }
#toast.success { background: var(--success-600); }

/* ------------------------------------------------------------
   12. Modal
   ------------------------------------------------------------ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  display: none; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard);
  backdrop-filter: blur(2px);
}
.modal-overlay.show, .modal-overlay.open {
  display: flex; opacity: 1; pointer-events: auto;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 520px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto; padding: 28px;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--dur-base) var(--ease-enter);
}
/* Editor-style modals (header/body/footer structure) are full-bleed */
.modal:has(.modal-header) {
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
}
.modal.modal-sm { max-width: 480px; }
.modal h2 { font-size: var(--text-lg); font-weight: 700; margin-bottom: var(--space-5); }
.modal-close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal .modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: var(--space-5); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: var(--text-md); font-weight: 700; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes modalIn { from { transform: scale(0.95) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

/* ------------------------------------------------------------
   13. Dropdowns
   ------------------------------------------------------------ */
.insert-block-dropdown { position: relative; }
.insert-block-dropdown .dropdown-menu {
  position: absolute; top: 100%; left: 0; margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 50; min-width: 200px;
  display: none; overflow: hidden;
  animation: dropdownIn var(--dur-fast) var(--ease-enter);
}
.insert-block-dropdown .dropdown-menu.open { display: block; }
@keyframes dropdownIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.dropdown-item { padding: 10px 16px; font-size: var(--text-sm); cursor: pointer; color: var(--text); transition: background var(--dur-fast); display: flex; align-items: center; gap: 8px; }
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item-icon { font-size: var(--text-md); width: 20px; text-align: center; }

/* ------------------------------------------------------------
   14. Pagination, Filters, Tabs
   ------------------------------------------------------------ */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 20px; }
.pagination button {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-xs); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-standard);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.pagination button:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button.active { background: var(--primary); color: var(--text-on-primary); border-color: var(--primary); }

.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 5px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--text-xs); font-weight: 600; cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--dur-fast) var(--ease-standard);
}
.filter-btn:hover { border-color: var(--slate-400); color: var(--text); }
.filter-btn.active { background: var(--primary); color: var(--text-on-primary); border-color: var(--primary); }

.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: var(--space-4); }
.tab { flex: 1; padding: 10px 16px; text-align: center; font-size: var(--text-sm); font-weight: 600; cursor: pointer; color: var(--text-secondary); border-bottom: 2px solid transparent; transition: all var(--dur-fast) var(--ease-standard); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ------------------------------------------------------------
   15. Tables
   ------------------------------------------------------------ */
.users-table { width: 100%; border-collapse: collapse; overflow: hidden; }
.users-table th { text-align: left; padding: 10px 14px; font-size: var(--text-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.users-table td { padding: 10px 14px; font-size: var(--text-sm); border-bottom: 1px solid var(--border); }
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: var(--surface-hover); }

/* ------------------------------------------------------------
   16. Upload Zones
   ------------------------------------------------------------ */
.upload-zone, .drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-standard);
  background: var(--bg-subtle);
}
.upload-zone:hover, .upload-zone.dragover, .drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}
.upload-zone svg { width: 36px; height: 36px; color: var(--text-muted); margin: 0 auto 8px; }
.upload-zone p { font-size: var(--text-sm); color: var(--text-secondary); }
.upload-zone .hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; }
.drop-zone-icon { font-size: 36px; margin-bottom: 8px; color: var(--text-muted); }
.drop-zone-text { font-size: var(--text-sm); color: var(--text-secondary); }
.drop-zone-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; }

/* ------------------------------------------------------------
   17. Media Grid
   ------------------------------------------------------------ */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.media-item { overflow: hidden; position: relative; }
.media-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.media-thumb { width: 100%; height: 140px; background: var(--bg-subtle); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .video-icon { width: 40px; height: 40px; background: rgba(0, 0, 0, 0.6); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.media-info { padding: 10px 12px; }
.media-info .mi-name { font-size: var(--text-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-info .mi-detail { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.media-actions { display: flex; gap: 4px; padding: 6px 12px 10px; }
.media-actions button { font-size: 11px; padding: 3px 8px; border-radius: var(--radius-sm); }

/* Editor media picker grid (smaller tiles) */
#mediaGrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 16px; }
#mediaGrid .media-item img, #mediaGrid .media-item video { width: 100%; height: 110px; object-fit: cover; display: block; }
#mediaGrid .media-item-info { padding: 6px 8px; font-size: 10px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mediaGrid .media-item { position: relative; cursor: pointer; }
.media-item-del { position: absolute; top: 6px; right: 6px; z-index: 5; width: 22px; height: 22px; border: none; border-radius: 50%; background: rgba(15,23,42,.78); color: #fff; font-size: 12px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s, background .15s; }
.media-item:hover .media-item-del { opacity: 1; }
.media-item-del:hover { background: #dc2626; }
.media-pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; font-size: var(--text-xs); color: var(--text-secondary); }

/* ------------------------------------------------------------
   18. Blocks & List Rows
   ------------------------------------------------------------ */
.block-card { padding: 16px 20px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.block-info { flex: 1; min-width: 0; }
.block-info .bi-name { font-size: var(--text-md); font-weight: 700; }
.block-info .bi-slug { font-size: var(--text-xs); color: var(--text-muted); }
.block-info .bi-desc { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }
.block-info .bi-cat { font-size: 10px; padding: 2px 7px; border-radius: var(--radius-full); background: var(--slate-100); color: var(--slate-600); display: inline-block; margin-top: 4px; font-weight: 600; }
.block-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: 12px; }

.recent-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; margin-bottom: 6px; }
.recent-item .ri-title { font-size: var(--text-sm); font-weight: 600; }
.recent-item .ri-meta { font-size: var(--text-xs); color: var(--text-secondary); display: flex; gap: 10px; align-items: center; margin-top: 2px; }

.page-card { padding: 14px 18px; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; }
.page-info { flex: 1; min-width: 0; }
.page-info .title { font-size: var(--text-sm); font-weight: 700; margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
.page-info .slug { font-size: var(--text-xs); color: var(--text-muted); }
.page-info .meta { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 4px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.page-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: 12px; }

/* ------------------------------------------------------------
   19. Stats Grid
   ------------------------------------------------------------ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { padding: 20px; }
.stat-card .num { font-size: var(--text-2xl); font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.stat-card .label { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-card .icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-card .icon svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------
   20. Section titles & toolbars
   ------------------------------------------------------------ */
.section-title { font-size: var(--text-md); font-weight: 700; margin-bottom: 12px; color: var(--text); }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.search-input { padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); font-size: var(--text-xs); width: 220px; outline: none; background: var(--surface); color: var(--text); transition: border-color var(--dur-fast), box-shadow var(--dur-fast); }
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 var(--ring-width) var(--ring-color); }

.settings-section { padding: 24px; margin-bottom: 16px; }
.settings-section h3 { font-size: var(--text-md); font-weight: 700; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

/* ------------------------------------------------------------
   21. Sidebar (spec §7.3 — responsive collapse)
   ------------------------------------------------------------ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed; left: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: width var(--dur-med) var(--ease-standard);
}
.sidebar-brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-brand a { display: flex; align-items: center; gap: 10px; color: var(--text-inverse); font-size: var(--text-lg); font-weight: 700; text-decoration: none; letter-spacing: -0.02em; }
.sidebar-brand img { width: 32px; height: 32px; border-radius: var(--radius-md); }
.sidebar-nav { padding: 8px 0; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: var(--text-sm); font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: var(--sidebar-text-hover); background: var(--sidebar-item-hover); }
.sidebar-nav a.active { color: var(--sidebar-text-hover); background: var(--sidebar-item-active); border-left-color: var(--primary); }
.sidebar-nav a svg { width: 16px; height: 16px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--sidebar-border); }
.sidebar-user { color: var(--sidebar-text); font-size: var(--text-xs); }
.sidebar-user strong { color: rgba(255, 255, 255, 0.85); display: block; font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout { color: #fca5a5; font-size: var(--text-xs); cursor: pointer; margin-top: 6px; display: inline-block; text-decoration: none; }
.sidebar-logout:hover { color: #fee2e2; }

/* ------------------------------------------------------------
   22. Main layout
   ------------------------------------------------------------ */
.main { margin-left: var(--sidebar-width); flex: 1; padding: 24px 32px; min-height: 100vh; max-width: var(--content-max); transition: margin-left var(--dur-med) var(--ease-standard); }
.tab-content { display: none; animation: fadeIn var(--dur-base) var(--ease-standard); }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.header h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }
.header-actions { display: flex; gap: 10px; }

/* ------------------------------------------------------------
   23. Editor page (cms-editor.html)
   ------------------------------------------------------------ */
body.editor-body { display: flex; flex-direction: column; }
.topbar {
  background: var(--slate-900);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: var(--topbar-height);
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.topbar-back { color: rgba(255, 255, 255, 0.6); text-decoration: none; font-size: var(--text-sm); display: flex; align-items: center; gap: 4px; }
.topbar-back:hover { color: #fff; }
.topbar-title { color: #fff; font-size: var(--text-md); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.two-col { display: flex; flex: 1; overflow: hidden; }
.editor-col { flex: 2; min-width: 0; overflow-y: auto; padding: 24px 32px 120px; }
.editor-col.preview-open { flex: 2; }
.preview-col { width: 0; overflow: hidden; background: var(--surface); border-left: 1px solid var(--border); transition: width var(--dur-med) var(--ease-standard), opacity var(--dur-med) var(--ease-standard); opacity: 0; }
.preview-col.open { width: 45%; opacity: 1; overflow-y: auto; display: flex; flex-direction: column; }

.meta-section { overflow: hidden; margin-bottom: 16px; }
.meta-summary { padding: 14px 18px; cursor: pointer; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); display: flex; align-items: center; justify-content: space-between; user-select: none; }
.meta-summary:hover { background: var(--surface-hover); }
.meta-body { padding: 0 18px 18px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.editor-card { overflow: hidden; }
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.editor-content { padding: 28px 32px; min-height: 420px; outline: none; font-size: var(--text-md); line-height: var(--leading-relaxed); caret-color: var(--primary); }
.editor-content:focus { outline: none; }
.editor-content h1 { font-size: var(--text-3xl); margin: 20px 0 8px; line-height: var(--leading-tight); font-weight: 700; }
.editor-content h2 { font-size: var(--text-2xl); margin: 18px 0 6px; line-height: var(--leading-tight); font-weight: 700; }
.editor-content h3 { font-size: var(--text-lg); margin: 14px 0 4px; line-height: var(--leading-tight); font-weight: 600; }
.editor-content p { margin-bottom: 14px; }
.editor-content ul, .editor-content ol { padding-left: 26px; margin-bottom: 14px; }
.editor-content li { margin-bottom: 4px; }
.editor-content blockquote { border-left: 4px solid var(--primary); padding: 10px 20px; margin: 14px 0; background: var(--bg-subtle); border-radius: 0 var(--radius-md) var(--radius-md) 0; color: var(--text-secondary); font-style: italic; }
.editor-content pre { background: var(--slate-800); color: var(--slate-200); padding: 18px 20px; border-radius: var(--radius-md); overflow-x: auto; font-size: var(--text-xs); line-height: 1.6; margin: 14px 0; font-family: var(--font-mono); }
.editor-content code { background: var(--bg-subtle); padding: 2px 6px; border-radius: var(--radius-sm); font-size: 0.9em; font-family: var(--font-mono); }
.editor-content pre code { background: none; padding: 0; border-radius: 0; color: inherit; }
.editor-content img { max-width: 100%; border-radius: var(--radius-md); margin: 14px 0; display: block; }
.editor-content img.ProseMirror-selectednode { outline: 2px solid var(--primary); outline-offset: 2px; }

.image-float-toolbar { position: absolute; z-index: 60; display: flex; align-items: center; gap: 2px; padding: 4px 6px; background: var(--slate-800, #1e293b); border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,.18); font-family: var(--font-sans); }
.image-float-toolbar .ift-label { font-size: 11px; font-weight: 700; color: #e2e8f0; padding: 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.image-float-toolbar .ift-divider { width: 1px; height: 16px; background: rgba(255,255,255,.2); margin: 0 4px; }
.image-float-toolbar .ift-btn { border: none; background: transparent; color: #cbd5e1; font-size: 11px; font-weight: 600; padding: 5px 8px; border-radius: 6px; cursor: pointer; line-height: 1; }
.image-float-toolbar .ift-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.image-float-toolbar .ift-btn.is-active { background: var(--primary); color: #fff; }
.image-float-toolbar .ift-btn.ift-danger:hover { background: #dc2626; color: #fff; }
.image-float-toolbar .ift-btn.ift-settings:hover { background: var(--primary); color: #fff; }
.editor-content figure { margin: 16px 0; text-align: center; }
.editor-content figure figcaption { font-size: 13px; color: var(--text-secondary); margin-top: 8px; font-style: italic; }
.editor-content figure.vl-align-left { float: left; margin-right: 20px; max-width: 50%; }
.editor-content figure.vl-align-right { float: right; margin-left: 20px; max-width: 50%; }
.editor-content img[vl-align="left"], .editor-content img[align="left"] { float: left; margin-right: 20px; }
.editor-content img[vl-align="right"], .editor-content img[align="right"] { float: right; margin-left: 20px; }
.editor-content img[vl-align="center"], .editor-content img[align="center"] { margin-left: auto; margin-right: auto; display: block; }
.img-align-picker { display: flex; gap: 6px; }
.img-align-opt, .img-width-opt { flex: 1; padding: 9px 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-secondary); font-size: var(--text-sm); font-weight: 600; cursor: pointer; transition: all var(--dur-fast); }
.img-align-opt:hover, .img-width-opt:hover { border-color: var(--primary); color: var(--primary); }
.img-align-opt.is-active, .img-width-opt.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.img-width-row { display: flex; gap: 6px; }
.editor-content .vl-figure img { margin: 0 auto; }
.editor-content .vl-figure.vl-align-left, .editor-content .vl-figure.vl-align-right { display: inline-block; margin: 0 0 16px; }
.editor-content a { color: var(--primary); text-decoration: underline; cursor: pointer; }
.editor-content a:hover { color: var(--primary-hover); }
.editor-content hr { border: none; border-top: 2px solid var(--border); margin: 24px 0; }
.editor-content table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: var(--text-sm); }
.editor-content th { background: var(--bg-subtle); padding: 10px 14px; border: 1px solid var(--border); font-weight: 700; text-align: left; }
.editor-content td { padding: 10px 14px; border: 1px solid var(--border); }
.editor-content p.is-editor-empty:first-child::before { color: var(--text-muted); content: attr(data-placeholder); float: left; height: 0; pointer-events: none; }
.editor-content .ProseMirror { outline: none; }
.editor-content .ProseMirror p.is-empty::before { color: var(--text-muted); content: attr(data-placeholder); float: left; height: 0; pointer-events: none; }

.status-bar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 16px; font-size: var(--text-xs); color: var(--text-secondary); }

/* Preview panel */
.preview-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); flex-shrink: 0; }
.preview-toolbar span { font-size: var(--text-xs); font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-right: auto; }
.preview-viewport { display: flex; gap: 4px; }
.preview-viewport button { padding: 4px 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; color: var(--text-secondary); transition: all var(--dur-fast); }
.preview-viewport button:hover { background: var(--surface-hover); }
.preview-viewport button.is-active { background: var(--primary); color: var(--text-on-primary); border-color: var(--primary); }
.preview-iframe-wrap { flex: 1; overflow: hidden; display: flex; justify-content: center; padding: 16px; background: var(--slate-200); }
.preview-iframe-wrap iframe { background: var(--surface); border: none; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); transition: width var(--dur-base) var(--ease-standard); width: 100%; height: 100%; }
.preview-meta { padding: 16px; border-top: 1px solid var(--border); flex-shrink: 0; display: flex; flex-direction: column; gap: 12px; }
.preview-meta-card { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; font-size: var(--text-xs); line-height: 1.6; }
.preview-serp-link { color: var(--success-600); font-size: var(--text-xs); text-decoration: none; display: block; margin-bottom: 2px; word-break: break-all; }
.preview-serp-title { color: #1a0dab; font-size: var(--text-md); font-weight: 600; text-decoration: none; display: block; margin-bottom: 2px; cursor: pointer; }
.preview-serp-title:hover { text-decoration: underline; }
.preview-serp-desc { color: var(--slate-600); font-size: var(--text-xs); line-height: 1.4; word-break: break-word; }
.preview-stat { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.preview-stat-label { color: var(--text-secondary); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; }
.preview-stat-value { font-weight: 700; font-size: var(--text-sm); }

.highlight-flash { animation: highlightFade 1.2s ease; }
@keyframes highlightFade { 0% { background: var(--warning-50); } 50% { background: var(--warning-50); } 100% { background: transparent; } }

/* ------------------------------------------------------------
   24. Login page (cms-login.html)
   ------------------------------------------------------------ */
body.login-body {
  background: var(--slate-900);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--dur-base) var(--ease-enter);
}
.login-card h1 { font-size: var(--text-xl); font-weight: 700; margin-bottom: 4px; text-align: center; letter-spacing: -0.02em; }
.login-card p { font-size: var(--text-sm); color: var(--text-muted); text-align: center; margin-bottom: 24px; }
.login-card .btn { width: 100%; padding: 12px; }
.error { color: var(--danger-600); font-size: var(--text-xs); text-align: center; margin-top: 8px; display: none; }
.cms-badge { text-align: center; margin-bottom: 20px; }
.cms-badge span { display: inline-block; background: var(--primary-subtle); color: var(--primary-strong); font-size: var(--text-xs); font-weight: 700; padding: 4px 12px; border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.1em; }

/* ------------------------------------------------------------
   25. Reduced motion (WCAG 2.3.3)
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------
   26. Responsive (spec §10)
   ------------------------------------------------------------ */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .media-grid { grid-template-columns: repeat(3, 1fr); }
  .editor-col { padding: 16px; }
  .preview-col.open { width: 100%; position: fixed; top: var(--topbar-height); left: 0; right: 0; bottom: 0; z-index: 50; }
  .topbar { padding: 0 12px; }
  .topbar-title { font-size: var(--text-sm); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .meta-grid { grid-template-columns: 1fr; }
  .modal { width: 95vw; max-height: 90vh; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  .header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: 1fr; }
  .editor-col { padding: 12px; }
  .topbar-actions .btn span.btn-label { display: none; }
}

/* ── Advanced Analytics ─────────────────────────────────────────────────── */
.analytics-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.analytics-range { display: flex; gap: 6px; }
.analytics-range .btn { padding: 6px 12px; font-size: var(--text-xs); }
.analytics-range .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.analytics-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 24px; }
.analytics-card { padding: 18px 20px; }
.analytics-card .num { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.analytics-card .label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; margin-top: 4px; }
.analytics-card .trend { font-size: var(--text-xs); font-weight: 600; margin-top: 6px; }
.analytics-card .trend.up { color: var(--success, #059669); }
.analytics-card .trend.down { color: var(--danger, #DC2626); }
.analytics-card .icon { width: 34px; height: 34px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.analytics-card .icon svg { width: 17px; height: 17px; }

.chart-card { padding: 20px; margin-bottom: 24px; }
.chart-title { font-size: var(--text-md); font-weight: 700; margin-bottom: 16px; color: var(--text); }
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-tooltip { position: absolute; pointer-events: none; background: var(--slate-800); color: #fff; font-size: var(--text-xs); padding: 6px 10px; border-radius: var(--radius-sm); opacity: 0; transition: opacity 0.15s; z-index: 5; white-space: nowrap; }
.chart-tooltip.visible { opacity: 1; }
.chart-axis-label { font-size: 9px; fill: var(--text-muted, #94A3B8); }

.analytics-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 24px; }
.analytics-cols.two-thirds { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1080px) { .analytics-cols, .analytics-cols.two-thirds { grid-template-columns: 1fr; } }
@media (max-width: 1000px) { .analytics-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .analytics-grid { grid-template-columns: repeat(2, 1fr); } }

.analytics-table { width: 100%; border-collapse: collapse; }
.analytics-table th { text-align: left; padding: 10px 12px; font-size: var(--text-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.analytics-table td { padding: 10px 12px; font-size: var(--text-sm); border-bottom: 1px solid var(--border); vertical-align: top; }
.analytics-table tr:hover td { background: var(--surface-hover); }
.analytics-table .views-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--primary); }
.analytics-table .views-pill .bar { width: 40px; height: 6px; background: var(--bg-subtle); border-radius: 3px; overflow: hidden; display: inline-block; }
.analytics-table .views-pill .bar span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }

.recent-views-list { display: flex; flex-direction: column; }
.recent-view { display: flex; align-items: flex-start; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.recent-view:last-child { border-bottom: none; }
.recent-view .rv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.recent-view .rv-title { font-size: var(--text-sm); font-weight: 600; }
.recent-view .rv-meta { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.recent-view .rv-time { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; margin-left: auto; }

.analytics-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.analytics-empty .sub { color: var(--text-secondary); margin-top: 4px; font-size: var(--text-xs); }
