:root {
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --bg-hover: #eef2ff;
  --border: #e5e7eb;
  --text: #111827;
  --text-sub: #4b5563;
  --text-muted: #9ca3af;
  --primary: #111827;
  --primary-h: #030712;
  --primary-light: rgba(17, 24, 39, 0.08);
  --cyan: #22d3ee;
  --red: #f43f5e;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --sidebar-w: 228px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 12px 30px rgba(17, 24, 39, 0.08);
  --font: 'Space Grotesk', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font); background: radial-gradient(circle at top left, rgba(34,211,238,.09), transparent 28%), radial-gradient(circle at top right, rgba(244,63,94,.08), transparent 24%), var(--bg); color: var(--text); min-height: 100vh; display: flex; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 20px 16px; font-size: 15px; font-weight: 700; border-bottom: 1px solid var(--border); }
.brand-mark { width: 28px; height: 28px; position: relative; }
.brand-dot { position: absolute; width: 18px; height: 18px; border-radius: 50%; mix-blend-mode: multiply; }
.brand-dot--cyan { left: 0; top: 6px; background: var(--cyan); }
.brand-dot--red { right: 0; top: 0; background: var(--red); }
.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-sub); font-size: 13.5px; font-weight: 500; transition: all .15s;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(34,211,238,.14), rgba(244,63,94,.10)); color: var(--primary); }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.webhook-url { background: var(--bg-input); border-radius: var(--radius-sm); padding: 10px 12px; }
.wh-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.wh-value { font-size: 11px; color: var(--text-sub); word-break: break-all; margin-bottom: 6px; }
.mode-pill { font-size: 11px; padding: 8px 10px; border-radius: 999px; background: #e5e7eb; color: var(--text-sub); text-align: center; }
.mode-pill--sandbox { background: rgba(244,63,94,.10); color: #9f1239; border: 1px solid rgba(244,63,94,.18); }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; max-width: calc(100vw - var(--sidebar-w)); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { font-size: 13px; color: var(--text-sub); margin-top: 4px; }

.flash-container { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; animation: slideIn .2s ease; }
.alert button { background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: 14px; margin-left: 12px; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.alert-danger { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-warning { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; }
.alert-info { background: #dbeafe; border: 1px solid #93c5fd; color: #1d4ed8; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); text-decoration: none; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-sub); }
.btn-outline:hover { border-color: var(--red); color: var(--red); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.copy-btn { font-size: 11px; padding: 3px 10px; background: var(--primary); color: #fff; border: none; border-radius: 5px; cursor: pointer; }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-section-title { font-size: 16px; font-weight: 600; padding: 20px 24px 0; margin-bottom: 20px; }

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group label, .code-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-sub); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 7px; }
.required { color: var(--danger); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font); font-size: 13.5px; padding: 10px 13px; outline: none; transition: border-color .15s; resize: vertical;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,.12); }
.hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }
.input-with-eye { position: relative; }
.input-with-eye input { padding-right: 40px; }
.eye-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 16px; }
.config-form { padding: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 16px; border-left: 3px solid var(--accent, var(--primary)); box-shadow: var(--shadow); transition: transform .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { font-size: 28px; }
.stat-num { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

.page-list { padding: 8px 20px; }
.page-item { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.page-item:last-child { border-bottom: none; }
.page-avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--red)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; color: #fff; flex-shrink: 0; }
.page-avatar--image { object-fit: cover; }
.page-detail { flex: 1; min-width: 0; }
.page-name { font-size: 14px; font-weight: 600; }
.page-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.guide-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.guide-step { display: flex; gap: 14px; margin-bottom: 24px; }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--red)); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-content h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.step-content p { font-size: 13px; color: var(--text-sub); line-height: 1.6; }
.code-block { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.code-block code { font-size: 12px; color: var(--primary); flex: 1; word-break: break-all; }
.code-block button { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 11px; }
.code-group { margin-bottom: 18px; }

.tab-bar { display: flex; gap: 0; margin-bottom: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; width: fit-content; box-shadow: var(--shadow); }
.tab-btn { padding: 8px 20px; border-radius: var(--radius-sm); background: transparent; border: none; color: var(--text-sub); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .15s; }
.tab-btn.active { background: var(--primary); color: #fff; }
.tab-btn:not(.active):hover { background: var(--bg-hover); color: var(--text); }
.post-card { padding: 24px; }

.file-drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 20px; text-align: center; cursor: pointer; transition: all .15s; }
.file-drop:hover, .file-drop.has-file { border-color: var(--cyan); background: rgba(34,211,238,.06); }
.file-drop-icon { font-size: 36px; margin-bottom: 10px; }
.file-drop-text { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.file-drop-hint { font-size: 12px; color: var(--text-muted); }
.file-name { margin-top: 10px; font-size: 13px; color: var(--success); }

.creator-box { margin-bottom: 18px; padding: 14px 16px; background: linear-gradient(135deg, rgba(34,211,238,.08), rgba(244,63,94,.08)); border: 1px solid rgba(34,211,238,.18); border-radius: var(--radius-sm); }
.creator-chip { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.creator-meta-list { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-sub); }
.toggle-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.toggle-grid--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.toggle-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text-sub); cursor: pointer; }
.toggle-item input { width: auto; }
.toggle-item--disabled { opacity: .55; cursor: not-allowed; }
.commercial-box { margin-bottom: 18px; }
.commercial-sub { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.consent-box { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 13px; color: #9a3412; line-height: 1.5; }
.consent-box input { margin-top: 2px; width: auto; }
.media-preview { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #0f172a; overflow: hidden; }
.media-preview--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; padding: 8px; background: #f8fafc; }
.media-preview__video { display: block; width: 100%; max-height: 420px; background: #000; }
.media-preview__image { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; }

.toast { position: fixed; bottom: 28px; right: 28px; padding: 14px 22px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; z-index: 9999; max-width: 360px; opacity: 0; transform: translateY(16px); transition: all .25s; box-shadow: var(--shadow-md); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-info { background: #1e293b; color: #fff; }
.toast-success { background: #166534; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px 16px; background: var(--bg-input); color: var(--text-muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text-sub); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.text-muted { color: var(--text-muted); }
code { font-family: 'Menlo','Consolas',monospace; font-size: 12px; background: var(--bg-input); padding: 2px 6px; border-radius: 4px; color: var(--primary); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11.5px; font-weight: 500; }
.tag-photo { background: rgba(34,211,238,.10); color: #0f766e; }
.tag-video { background: rgba(244,63,94,.10); color: #be123c; }

.status-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.status-pill--processing-upload, .status-pill--processing-download, .status-pill--init { background: #e0f2fe; color: #0369a1; }
.status-pill--publish-complete { background: #dcfce7; color: #166534; }
.status-pill--failed { background: #fee2e2; color: #991b1b; }
.status-pill--send-to-user-inbox, .status-pill--no-longer-publicly-available, .status-pill--no-longer-publicaly-available { background: #fef3c7; color: #92400e; }

.filter-bar { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-item { display: flex; align-items: center; gap: 8px; }
.filter-item label { font-size: 12.5px; color: var(--text-sub); white-space: nowrap; }
.filter-item select { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 7px 12px; font-size: 13px; outline: none; cursor: pointer; }
.page-banner { display: flex; align-items: center; gap: 16px; padding: 18px 20px; }
.page-pic { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.page-pic-placeholder { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--red)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 24px; color: #fff; }
.page-banner-info { flex: 1; }
.page-banner-name { font-size: 17px; font-weight: 700; }
.page-banner-meta { font-size: 12.5px; color: var(--text-sub); margin-top: 4px; }
.page-banner-id { font-size: 11px; color: var(--text-muted); }
.insight-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.insight-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); transition: transform .15s; }
.insight-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.insight-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.insight-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-container { padding: 20px 24px 24px; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.video-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video-card__cover { aspect-ratio: 9 / 14; background: linear-gradient(135deg, rgba(34,211,238,.12), rgba(244,63,94,.12)); }
.video-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-card__placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-weight: 700; letter-spacing: .08em; }
.video-card__body { padding: 16px; }
.video-card__body h3 { font-size: 14px; margin-bottom: 8px; line-height: 1.5; }
.video-card__body p { font-size: 12px; color: var(--text-sub); line-height: 1.6; min-height: 38px; }
.video-card__meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); margin-top: 12px; }
.video-card__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .toggle-grid, .commercial-sub { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo span, .nav-item span, .sidebar-footer { display: none; }
  .main-content { margin-left: 60px; padding: 20px 16px; max-width: calc(100vw - 60px); }
  .stat-grid, .form-row, .video-grid { grid-template-columns: 1fr; }
}
