/* ===== Taiyue CMS — Admin Panel Styles ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --sidebar-bg: #0a0a0a;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f0f0f2;
  --accent: #000000;
  --accent-hover: #222;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --sidebar-w: 250px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
}

body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; line-height: 1.5; }

/* ===== Login ===== */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); padding: 24px; }
.login-card { background: var(--surface); border-radius: 24px; padding: 48px 40px; max-width: 400px; width: 100%; box-shadow: 0 24px 64px rgba(0,0,0,0.3); }
.login-logo { font-size: 24px; font-weight: 800; letter-spacing: 0.15em; color: var(--accent); margin-bottom: 32px; }
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.login-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 20px; }

/* ===== Forms ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input, .form-group textarea, .form-group select,
.select-input {
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  transition: border-color 0.2s; outline: none;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus,
.select-input:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; line-height: 1.6; }
.form-hint { font-size: 12px; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.success-msg { color: var(--success); font-size: 13px; min-height: 18px; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-label input { width: 18px; height: 18px; cursor: pointer; }

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-danger, .btn-text {
  padding: 10px 20px; border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; border: 1.5px solid transparent; transition: all 0.2s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f3f3f3; border-color: var(--text-light); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-text { background: none; border: none; color: var(--text-muted); font-size: 13px; padding: 4px 8px; }
.btn-text:hover { color: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface); cursor: pointer; }
.btn-icon:hover { background: #f3f3f3; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 4px; color: var(--text); display: flex; align-items: center; }

/* ===== App Layout ===== */
.app-view { display: flex; min-height: 100vh; }

/* Mobile topbar */
.mobile-topbar { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 200; background: var(--sidebar-bg); color: #fff; padding: 12px 16px; align-items: center; gap: 12px; }
.mobile-topbar-title { font-size: 16px; font-weight: 700; letter-spacing: 0.08em; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
.sidebar-overlay.show { display: block; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; overflow-y: auto; }
.sidebar-header { padding: 24px 24px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo { font-size: 18px; font-weight: 800; letter-spacing: 0.12em; }
.sidebar-logo span { font-size: 11px; font-weight: 500; opacity: 0.4; margin-left: 6px; letter-spacing: 0.2em; }
.current-user { margin-top: 12px; font-size: 12px; color: rgba(255,255,255,0.5); display: flex; align-items: center; gap: 6px; }
.current-user .user-avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }
.current-user .user-info { display: flex; flex-direction: column; gap: 1px; }
.current-user .user-name { color: rgba(255,255,255,0.9); font-weight: 600; font-size: 13px; }
.current-user .user-role { font-size: 11px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.05em; }

.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(255,255,255,0.3); padding: 16px 16px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: var(--radius-sm); color: rgba(255,255,255,0.6); text-decoration: none; font-size: 14px; font-weight: 500; transition: all 0.2s; position: relative; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-item.active { color: #fff; background: rgba(255,255,255,0.12); }
.nav-badge { position: absolute; right: 12px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.nav-badge:empty { display: none; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; gap: 4px; }
.sidebar-link { display: block; padding: 8px 16px; border-radius: var(--radius-sm); color: rgba(255,255,255,0.5); text-decoration: none; font-size: 13px; font-weight: 500; background: none; border: none; cursor: pointer; text-align: left; font-family: inherit; transition: color 0.2s; }
.sidebar-link:hover { color: #fff; }

/* Main Content */
.main-content { flex: 1; margin-left: var(--sidebar-w); padding: 32px 40px; max-width: 100%; overflow-x: hidden; }

/* Views */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.view-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.page-subtitle { font-size: 14px; color: var(--text-muted); }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-grid.stats-mini { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin-bottom: 20px; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 20px 24px; border: 1px solid var(--border); transition: box-shadow 0.2s; }
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.stat-icon.icon-blue { background: var(--info-bg); color: var(--info); }
.stat-icon.icon-green { background: var(--success-bg); color: var(--success); }
.stat-icon.icon-orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.icon-purple { background: #f3e8ff; color: #7c3aed; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-change { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Dashboard Row */
.dashboard-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); margin-bottom: 16px; }
.card.no-pad { padding: 0; overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; }

/* Bar Chart */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-item { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 100px; font-size: 13px; color: var(--text-muted); text-transform: capitalize; flex-shrink: 0; }
.bar-track { flex: 1; height: 24px; background: var(--bg); border-radius: var(--radius-xs); overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: var(--radius-xs); transition: width 0.6s ease; min-width: 2px; }
.bar-fill.fill-blue { background: #3b82f6; }
.bar-fill.fill-green { background: #22c55e; }
.bar-fill.fill-orange { background: #f59e0b; }
.bar-fill.fill-purple { background: #a855f7; }
.bar-fill.fill-red { background: #ef4444; }
.bar-fill.fill-gray { background: #6b7280; }
.bar-value { font-size: 13px; font-weight: 600; min-width: 30px; text-align: right; }

/* Activity List */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.activity-dot.dot-blue { background: var(--info); }
.activity-dot.dot-green { background: var(--success); }
.activity-dot.dot-orange { background: var(--warning); }
.activity-dot.dot-red { background: var(--danger); }
.activity-text { font-size: 13px; flex: 1; }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* Quick Actions */
.quick-actions { display: flex; flex-direction: column; gap: 8px; }
.quick-btn { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-align: left; transition: all 0.2s; color: var(--text); }
.quick-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.quick-btn svg { opacity: 0.6; }
.quick-btn:hover svg { opacity: 1; }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; align-items: center; }
.batch-info { font-size: 13px; color: var(--text-muted); font-weight: 600; padding: 6px 10px; background: var(--warning-bg); border-radius: var(--radius-xs); }

/* Search Box */
.search-box { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); min-width: 260px; }
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input { border: none; outline: none; font-family: inherit; font-size: 14px; color: var(--text); flex: 1; background: none; }

/* Data Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table th.col-check { width: 40px; }
.data-table td { padding: 14px 16px; font-size: 13px; border-bottom: 1px solid var(--border-light); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr.selected { background: var(--info-bg); }
.col-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 9999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-core { background: #f3f3f3; color: var(--text); }
.badge-custom { background: var(--info-bg); color: var(--info); }
.badge-published { background: var(--success-bg); color: var(--success); }
.badge-draft { background: var(--warning-bg); color: var(--warning); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--danger-bg); color: var(--danger); }
.badge-admin { background: #f3e8ff; color: #7c3aed; }
.badge-editor { background: var(--info-bg); color: var(--info); }
.badge-viewer { background: #f3f3f3; color: var(--text-muted); }
.badge-category { background: #f0f9ff; color: #0369a1; }

/* Action badge */
.activity-action { display: inline-block; padding: 3px 10px; border-radius: 9999px; font-size: 11px; font-weight: 700; }
.action-image\.replace { background: var(--warning-bg); color: #92400e; }
.action-image\.reset, .action-image\.batch_reset { background: var(--danger-bg); color: #991b1b; }
.action-page\.create, .action-content\.create { background: var(--success-bg); color: #065f46; }
.action-page\.update, .action-content\.update { background: var(--info-bg); color: #1e40af; }
.action-page\.delete, .action-content\.delete { background: var(--danger-bg); color: #991b1b; }
.action-auth\.login { background: #e0e7ff; color: #3730a3; }
.action-auth\.password_change { background: #f3e8ff; color: #6b21a8; }
.action-user\.create, .action-user\.status_change { background: #f3e8ff; color: #6b21a8; }
.action-content\.batch { background: var(--warning-bg); color: #92400e; }
.action-settings\.update { background: #f3f3f3; color: var(--text); }

/* Action buttons in table */
.table-actions { display: flex; gap: 4px; }
.table-actions button { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-xs); }

/* Page Tabs */
.page-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.page-tab { padding: 8px 18px; border-radius: 9999px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1.5px solid var(--border); background: var(--surface); color: var(--text-muted); transition: all 0.2s; }
.page-tab:hover { border-color: var(--accent); color: var(--text); }
.page-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Image Grid */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.image-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); transition: box-shadow 0.2s; }
.image-card:hover { box-shadow: var(--shadow-md); }
.image-card-thumb { width: 100%; aspect-ratio: 16/10; background: #f3f3f3; overflow: hidden; position: relative; }
.image-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.image-card-badge { position: absolute; top: 10px; left: 10px; padding: 4px 10px; border-radius: 9999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.image-card-badge.original { background: rgba(0,0,0,0.7); color: #fff; }
.image-card-badge.replaced { background: var(--success); color: #fff; }
.image-card-dim { position: absolute; bottom: 10px; right: 10px; padding: 3px 8px; border-radius: var(--radius-xs); font-size: 11px; font-weight: 600; background: rgba(0,0,0,0.65); color: #fff; backdrop-filter: blur(4px); letter-spacing: 0.02em; }
.image-card-body { padding: 14px 16px; }
.image-card-alt { font-size: 13px; font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-card-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.image-card-actions { display: flex; gap: 8px; }
.image-card-actions button { flex: 1; padding: 8px 12px; font-size: 12px; border-radius: var(--radius-xs); }

/* Page List */
.page-list { display: flex; flex-direction: column; gap: 12px; }
.page-list-item { display: flex; align-items: center; gap: 16px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: box-shadow 0.2s; }
.page-list-item:hover { box-shadow: var(--shadow-sm); }
.page-list-info { flex: 1; }
.page-list-title { font-size: 15px; font-weight: 700; }
.page-list-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.page-list-actions { display: flex; gap: 8px; }
.page-list-actions button, .page-list-actions a { padding: 8px 14px; font-size: 13px; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state p { font-size: 14px; }

/* ===== Settings Layout ===== */
.settings-layout { display: flex; gap: 24px; align-items: flex-start; }
.settings-tabs { display: flex; flex-direction: column; gap: 4px; width: 180px; flex-shrink: 0; position: sticky; top: 20px; }
.settings-tab { padding: 10px 16px; text-align: left; border: none; background: none; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-sm); transition: all 0.2s; }
.settings-tab:hover { background: var(--surface); color: var(--text); }
.settings-tab.active { background: var(--accent); color: #fff; }
.settings-panels { flex: 1; min-width: 0; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeIn 0.2s ease; }
.settings-form { display: flex; flex-direction: column; gap: 16px; max-width: 600px; }

/* ===== Modals ===== */
.modal-overlay { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); padding: 24px; }
.modal-overlay.show { display: flex; animation: fadeIn 0.15s ease; }
.modal { background: var(--surface); border-radius: 20px; padding: 32px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-wide { max-width: 680px; }
.modal-confirm { max-width: 400px; }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.modal-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }

/* Image Modal */
.modal-preview { width: 100%; aspect-ratio: 16/10; border-radius: var(--radius-sm); overflow: hidden; background: #f3f3f3; margin-bottom: 20px; position: relative; }
.modal-preview img { width: 100%; height: 100%; object-fit: cover; }
.modal-badge { position: absolute; top: 10px; left: 10px; padding: 4px 12px; border-radius: 9999px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.modal-badge.original { background: rgba(0,0,0,0.7); color: #fff; }
.modal-badge.replaced { background: var(--success); color: #fff; }
.modal-dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 20px; text-align: center; cursor: pointer; transition: all 0.2s; margin-bottom: 16px; }
.modal-dropzone:hover, .modal-dropzone.dragover { border-color: var(--accent); background: #fafafa; }
.dropzone-icon { width: 48px; height: 48px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; background: #f3f3f3; border-radius: 50%; color: var(--text-muted); }
.dropzone-text { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.dropzone-hint { font-size: 12px; color: var(--text-muted); }
.modal-file-info { font-size: 12px; color: var(--text); text-align: center; margin-bottom: 16px; padding: 8px 12px; background: #f3f3f3; border-radius: var(--radius-sm); display: none; }
.modal-file-info.show { display: block; }
.modal-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Page Form */
.page-form { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--accent); color: #fff; padding: 12px 24px; border-radius: 9999px; font-size: 14px; font-weight: 500; z-index: 2000; opacity: 0; transition: all 0.3s; pointer-events: none; box-shadow: var(--shadow-md); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .dashboard-row { grid-template-columns: 1fr; }
  .settings-layout { flex-direction: column; }
  .settings-tabs { flex-direction: row; width: 100%; position: static; overflow-x: auto; }
  .settings-tab { white-space: nowrap; }
}

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; z-index: 200; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 64px 20px 24px; }
  .view-header { flex-direction: column; align-items: stretch; }
  .form-row { grid-template-columns: 1fr; }
  .image-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 10px 10px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-direction: column; }
  .search-box { min-width: 0; }
  .select-input { width: 100%; }
  .modal { padding: 24px 20px; border-radius: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ===== Extra-wide modal ===== */
.modal-xl { max-width: 900px; }

/* ===== Rich Text Editor ===== */
.rte-wrapper { border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: visible; }
.rte-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 10px; background: #f9f9fb; border-bottom: 1px solid var(--border); flex-wrap: wrap; position: relative; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.rte-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 4px 8px; border: 1px solid transparent; border-radius: var(--radius-xs); background: none; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); transition: all 0.15s; }
.rte-btn:hover { background: var(--surface); border-color: var(--border); }
.rte-btn:active { background: #e8e8ec; }
.rte-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.rte-editor { min-height: 300px; max-height: 500px; overflow-y: auto; padding: 20px 24px; font-size: 14px; line-height: 1.7; outline: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.rte-editor:empty::before { content: attr(data-placeholder); color: var(--text-light); }
.rte-editor h2 { font-size: 1.5em; font-weight: 700; margin: 1em 0 0.5em; }
.rte-editor h3 { font-size: 1.2em; font-weight: 600; margin: 0.8em 0 0.4em; }
.rte-editor p { margin-bottom: 0.8em; }
.rte-editor ul, .rte-editor ol { padding-left: 1.5em; margin-bottom: 0.8em; }
.rte-editor ul { list-style: disc; }
.rte-editor ol { list-style: decimal; }
.rte-editor li { margin-bottom: 0.3em; }
.rte-editor img { border-radius: 8px; margin: 10px 0; max-width: 100%; }
.rte-editor img.align-left { float: left; margin-right: 16px; max-width: 50%; }
.rte-editor img.align-right { float: right; margin-left: 16px; max-width: 50%; }
.rte-editor img.align-center { display: block; margin-left: auto; margin-right: auto; }
.rte-editor img.size-small { width: 25%; }
.rte-editor img.size-medium { width: 50%; }
.rte-editor img.size-large { width: 75%; }
.rte-editor img.size-full { width: 100%; }
.rte-editor video { border-radius: 8px; margin: 10px 0; max-width: 100%; }
.rte-editor .video-embed { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 8px; margin: 10px 0; }
.rte-editor .video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.rte-editor a { color: var(--info); text-decoration: underline; }

/* RTE Popover — position:fixed to escape modal overflow clipping */
.rte-popover { display: none; position: fixed; z-index: 10000; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 16px; min-width: 340px; max-width: 420px; }
.rte-popover.show { display: block; animation: fadeIn 0.15s ease; }
.rte-upload-preview { margin-top: 10px; border-radius: var(--radius-xs); overflow: hidden; }
.rte-upload-preview img { width: 100%; max-height: 120px; object-fit: cover; border-radius: var(--radius-xs); }
.rte-popover-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.rte-popover-tab { padding: 6px 14px; border: none; background: none; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: var(--radius-xs); }
.rte-popover-tab.active { background: var(--accent); color: #fff; }
.rte-popover-content { margin-bottom: 12px; }
.rte-popover-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; }
.rte-popover-row label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }
.rte-popover-row select { padding: 6px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-xs); font-family: inherit; font-size: 13px; }
.rte-input { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-xs); font-family: inherit; font-size: 13px; width: 100%; }
.rte-input:focus { border-color: var(--accent); outline: none; }
.rte-popover-actions { display: flex; justify-content: flex-end; }
.rte-dropzone { border: 2px dashed var(--border); border-radius: var(--radius-sm); padding: 20px 16px; text-align: center; cursor: pointer; transition: all 0.2s; }
.rte-dropzone:hover, .rte-dropzone.dragover { border-color: var(--accent); background: #fafafa; }
.rte-upload-info { font-size: 12px; color: var(--text); padding: 8px 12px; background: #f3f3f3; border-radius: var(--radius-xs); }

/* Product sub-page table specifics */
.pp-summary-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.sort-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; border-radius: 8px; background: #f3f3f3; font-size: 13px; font-weight: 700; color: var(--text); }
