* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #242836;
  --border: #2a2e3d;
  --text: #e4e4e7;
  --text-dim: #8b8d98;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --sidebar-w: 240px;
}

/* LIGHT THEME */
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-card: #ffffff;
  --bg-hover: #f0f1f3;
  --border: #e2e4e9;
  --text: #1a1d27;
  --text-dim: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --orange: #ea580c;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* LOGIN PAGE */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
[data-theme="light"] .login-box {
  border-color: var(--border);
}

.login-box h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.login-box p {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
[data-theme="light"] .form-group input,
[data-theme="light"] .form-group textarea,
[data-theme="light"] .form-group select {
  border-color: var(--border);
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
  justify-content: center;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

/* LAYOUT */
.layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: background 0.2s;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h2 {
  font-size: 18px;
  font-weight: 600;
}

.sidebar-logo span {
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent);
  color: white;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* MAIN CONTENT */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px 32px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-dim);
  font-size: 14px;
}

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: background 0.2s;
}

.stat-card.clickable {
  cursor: pointer;
}

.stat-card.clickable:hover {
  background: var(--bg-hover);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 600;
}

.stat-card .sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* PROGRESS BAR */
.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.fill-blue { background: var(--accent); }
.fill-green { background: var(--green); }
.fill-yellow { background: var(--yellow); }
.fill-red { background: var(--red); }

/* CARDS / PANELS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 24px;
  transition: background 0.2s;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* TABLE */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px 16px;
  font-size: 14px;
}

th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-hover);
}

/* STATUS BADGES */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-yellow { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent); }

/* FILE MANAGER */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb .sep { color: var(--text-dim); }

.file-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.file-entry:hover { background: var(--bg-hover); }
.file-entry:last-child { border-bottom: none; }

.file-icon { font-size: 18px; width: 24px; text-align: center; }
.file-name { flex: 1; font-size: 14px; }
.file-size { font-size: 13px; color: var(--text-dim); min-width: 80px; text-align: right; }
.file-date { font-size: 13px; color: var(--text-dim); min-width: 140px; text-align: right; }

/* EDITOR */
.editor-wrap {
  display: none;
}

.editor-wrap.active {
  display: block;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}

.editor-toolbar .filename {
  font-size: 14px;
  font-weight: 500;
}

#file-editor {
  width: 100%;
  min-height: 400px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  tab-size: 2;
}

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
}

.modal.modal-wide {
  max-width: 640px;
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* SITE PREVIEW MODAL */
#site-preview-modal {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-preview {
  max-width: 95vw;
  width: 95vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #ffffff;
  border: 1px solid #e2e4e9;
  box-shadow: 0 24px 80px rgba(0,0,0,0.15), 0 0 0 1px rgba(255,255,255,0.1);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e2e4e9;
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
}

.preview-header h3 {
  font-size: 15px;
  margin: 0;
  color: #1a1d27;
  font-weight: 600;
}

.preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

.preview-body iframe {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  border-radius: 0 0 0 12px;
  background: #fff;
}

/* When admin panel is hidden, iframe gets full rounded bottom */
.preview-body.panel-hidden iframe {
  border-radius: 0 0 12px 12px;
}

/* ADMIN SIDE PANEL */
.preview-admin-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  border-radius: 0 0 12px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pap-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pap-tab {
  flex: 1;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pap-tab:hover {
  color: var(--text);
}

.pap-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.pap-tab-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  padding: 1px 5px;
  font-weight: 700;
  line-height: 1.4;
}

.pap-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pap-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.pap-empty {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 24px 12px;
}

/* Message items */
.pap-msg {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.pap-msg.unread {
  border-left: 3px solid var(--accent);
}

.pap-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 6px;
}

.pap-msg-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pap-msg-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.pap-msg-page {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.pap-msg-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

.pap-msg-actions {
  margin-top: 7px;
  display: flex;
  gap: 6px;
}

.pap-msg-actions button {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-dim);
  cursor: pointer;
}

.pap-msg-actions button:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Note items inside panel */
.pap-note {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 7px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.pap-note.done .pap-note-text {
  text-decoration: line-through;
  color: var(--text-dim);
}

.pap-note-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--green);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.pap-note-check:hover {
  border-color: var(--green);
}

.pap-note-body {
  flex: 1;
  min-width: 0;
}

.pap-note-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.pap-note-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.pap-note-del {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.pap-note-del:hover {
  color: var(--red);
}

.pap-note-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.pap-note-input input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.pap-note-input input:focus {
  border-color: var(--accent);
}

/* SERVICES LIST */
.service-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.service-item:last-child { border-bottom: none; }

.service-name {
  font-size: 14px;
  font-weight: 500;
}

.service-desc {
  font-size: 13px;
  color: var(--text-dim);
}

/* SERVICES TOGGLE */
.services-toggle {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.services-toggle:hover {
  background: var(--bg-hover);
}

/* THEME TOGGLE */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* PROCESS BAR */
.process-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}

.process-bar .fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  .sidebar-logo span, .nav-item span, .sidebar-footer .btn span, .theme-toggle span {
    display: none;
  }
  .sidebar-logo h2 { font-size: 14px; }
  .nav-item { justify-content: center; padding: 10px; }
  .theme-toggle { justify-content: center; padding: 10px; }
  .main { margin-left: 60px; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* LOADING SPINNER */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pinDrop {
  from { transform: translate(-50%, -200%) scale(0.5); opacity: 0; }
  to { transform: translate(-50%, -100%) scale(1); opacity: 1; }
}

.loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 12px;
  color: var(--text-dim);
}

/* ========== ANALYTICS ========== */

.analytics-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.analytics-range-btns {
  display: flex;
  gap: 4px;
}

.analytics-range.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.analytics-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* Bar chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 200px;
  padding: 0 4px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
}

.bar-value {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
  white-space: nowrap;
}

.bar {
  width: 100%;
  max-width: 32px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
  min-height: 2px;
}

.bar-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chart-legend {
  text-align: center;
  margin-top: 8px;
}

/* Horizontal bar rows */
.h-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.h-bar-label {
  min-width: 80px;
  font-size: 13px;
  color: var(--text);
}

.h-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.h-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.h-bar-value {
  min-width: 40px;
  text-align: right;
  font-size: 13px;
  color: var(--text-dim);
}

/* Status code bar */
.status-bar-container {
  padding: 8px 0;
}

.status-bar {
  display: flex;
  height: 24px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

.status-segment {
  transition: width 0.3s ease;
  min-width: 2px;
}

.status-legend {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Journeys */
.journey-summary {
  display: flex;
  gap: 24px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.journey-section h4 {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.journey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.journey-row:last-child {
  border-bottom: none;
}

.journey-rank {
  color: var(--text-dim);
  min-width: 24px;
}

.journey-path {
  flex: 1;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

.journey-count {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 12px;
  white-space: nowrap;
}

/* Signup funnel */
.signup-funnel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.funnel-step {
  text-align: center;
  padding: 12px 20px;
  background: var(--bg);
  border-radius: 8px;
  min-width: 90px;
}

.funnel-step-highlight {
  background: color-mix(in srgb, var(--green) 15%, var(--bg));
  border: 1px solid var(--green);
}

.funnel-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.funnel-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.funnel-pct {
  font-size: 11px;
  color: var(--accent);
  margin-top: 4px;
}

.funnel-arrow {
  color: var(--text-dim);
  font-size: 18px;
}

/* ========== SECRET RHYTHMS EMBED ========== */

.sr-nav-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 0;
  overflow-x: auto;
  padding-bottom: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 8px 8px 0;
}

.sr-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.15s;
  white-space: nowrap;
}

.sr-tab:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sr-tab.active {
  color: var(--accent);
  background: var(--bg);
  border-bottom: 2px solid var(--accent);
}

.sr-frame-wrap {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  background: #0f1117;
}

.sr-frame-wrap iframe {
  width: 100%;
  height: calc(100vh - 200px);
  min-height: 600px;
  border: none;
  background: #0f1117;
}

/* ========== DOMAINS (FTP TREE) ========== */

.domains-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.domains-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.domain-filter.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* FTP tree row */
.domain-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  font-size: 13px;
}

.domain-row:last-child { border-bottom: none; }
.domain-row:hover { background: var(--bg-hover); }

.domain-star {
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  padding: 12px 0;
  flex-shrink: 0;
  opacity: 0.3;
  transition: opacity 0.15s;
}

.domain-star:hover { opacity: 0.7; }
.domain-star.starred { opacity: 1; color: var(--yellow); }

.domain-icon {
  width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  color: var(--text-dim);
}

.domain-name {
  flex: 1;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  padding: 12px 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.domain-category {
  min-width: 120px;
  padding: 12px 8px;
}

.domain-action {
  flex: 1.2;
  padding: 12px 8px;
  color: var(--text-dim);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.domain-action:not(:empty) {
  color: var(--orange);
}

.domain-actions {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  flex-shrink: 0;
}

/* Tree branch lines */
.domain-tree-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 500;
  background: var(--bg);
}

.domain-tree-header > span:nth-child(1) { width: 40px; text-align: center; }
.domain-tree-header > span:nth-child(2) { width: 28px; }
.domain-tree-header > span:nth-child(3) { flex: 1; }
.domain-tree-header > span:nth-child(4) { min-width: 120px; }
.domain-tree-header > span:nth-child(5) { flex: 1.2; }
.domain-tree-header > span:nth-child(6) { min-width: 100px; }

/* Category badge variants */
.badge-orange { background: rgba(249,115,22,0.15); color: var(--orange); }
.badge-dim { background: var(--bg-hover); color: var(--text-dim); }

/* ========== Page Notes Widget ========== */
.pn-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: inherit;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.pn-toggle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.15s, background 0.15s;
  position: relative;
}
.pn-toggle:hover { transform: scale(1.1); background: var(--accent-hover, #2563eb); }

.pn-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.pn-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 360px;
  height: 100vh;
  background: var(--bg-card, #1a1a2e);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  animation: pnSlideIn 0.2s ease-out;
}
@keyframes pnSlideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.pn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.pn-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.pn-close:hover { color: var(--text); }

.pn-list {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
  min-height: 0;
}

.pn-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.pn-note {
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.pn-note:last-child { border-bottom: none; }

.pn-note.done { opacity: 0.45; }
.pn-note.done .pn-note-text { text-decoration: line-through; }

.pn-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--green);
  padding: 0;
}

.pn-note-text {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.pn-note-time {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  margin-top: 2px;
}

.pn-del {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}
.pn-del:hover { color: var(--red); }

.pn-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
  flex-shrink: 0;
}

.pn-input-row input {
  flex: 1;
  position: relative;
  z-index: 2;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
.pn-input-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

/* Rhythm Rules - Today + Session layout */
@media (max-width: 900px) {
  #rr-main-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Analytics responsive */
@media (max-width: 768px) {
  .analytics-grid-2 {
    grid-template-columns: 1fr;
  }
  .bar-chart {
    height: 150px;
  }
  .bar-value {
    display: none;
  }
}

/* ===== MERCH PIPELINE ===== */

.merch-phase-col {
  flex: 1;
  min-width: 180px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.merch-phase-col:last-child {
  border-right: none;
}

.merch-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-size: 12px;
}

.merch-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.merch-card-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
}

.merch-card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.merch-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  text-transform: capitalize;
}

.merch-badge-cat {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.merch-badge-high { background: #e55; color: #fff; }
.merch-badge-medium { background: #f0ad4e; color: #fff; }
.merch-badge-low { background: rgba(255,255,255,0.1); color: var(--muted); }

.merch-card-img {
  width: 100%;
  height: 80px;
  border-radius: 6px;
  object-fit: cover;
  margin-bottom: 8px;
}

.merch-card-move {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.merch-card-move button {
  flex: 1;
  padding: 3px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s;
}

.merch-card-move button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

/* Site Cards */
.site-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}
.site-card {
  background: var(--card-bg, var(--input-bg));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.site-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.site-card-disabled {
  opacity: 0.5;
}
.site-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.site-card-favicon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.site-card-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.site-card-title strong {
  font-size: 14px;
}
.site-card-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.site-card-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.site-card-stat-val {
  font-size: 18px;
  font-weight: 700;
}
.site-card-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.site-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Preview panel message items */
.pap-msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.pap-msg-body {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.pap-msg-read {
  opacity: 0.5;
}

/* Markup Overlay */
#pn-markup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.15);
}
#pn-markup-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
#pn-markup-toolbar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card-bg, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 10001;
}
.pn-mk-tool {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim, #aaa);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.pn-mk-tool:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text, #fff);
}
.pn-mk-tool.active {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-color: var(--accent, #3b82f6);
}
.pn-mk-save {
  background: #22c55e !important;
  color: #fff !important;
  font-size: 12px !important;
  font-weight: 600;
  padding: 4px 12px !important;
}
.pn-mk-save:hover { background: #16a34a !important; }
.pn-mk-cancel {
  font-size: 12px !important;
  color: #f87171 !important;
}
.pn-mk-cancel:hover { color: #ef4444 !important; }
.pn-mk-sep {
  width: 1px;
  height: 20px;
  background: var(--border, #333);
  margin: 0 4px;
}

/* Markup viewer - above everything */
#pn-markup-viewer {
  z-index: 20000 !important;
}

/* Markup toggle button */
.pn-markup-toggle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e55;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.15s, background 0.15s;
  font-size: 20px;
}
.pn-markup-toggle:hover { transform: scale(1.1); background: #d44; }

/* Note flash animation */
@keyframes pnFlash {
  0% { background: var(--accent); }
  100% { background: transparent; }
}
.pn-note-flash {
  animation: pnFlash 1s ease-out;
}

/* Markup thumbnails in notes */
.pn-markup-thumb {
  display: block;
  max-width: 100%;
  height: 60px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  margin-top: 4px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.pn-markup-thumb:hover {
  opacity: 0.8;
}

/* Rhythm Rules Section Toggle Buttons */
/* Rhythm Rules Sidebar */
.rr-sidebar {
  width: 180px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: sticky;
  top: 16px;
}
.rr-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.rr-sidebar-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.rr-sidebar-close:hover { color: var(--accent, #f5c842); }
.rr-sidebar-tab {
  position: sticky;
  top: 16px;
  width: 24px;
  height: 48px;
  background: var(--card-bg, #111);
  border: 1px solid var(--border);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rr-sidebar-tab:hover { color: var(--text); border-color: var(--accent); }
.rr-sidebar-group {
  margin-bottom: 12px;
}
.rr-sidebar-group:last-child { margin-bottom: 0; }
.rr-sidebar-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent, #f5c842);
  margin-bottom: 6px;
  font-weight: 700;
}
.rr-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  padding: 5px 0;
  transition: color 0.2s;
}
.rr-toggle:hover { color: var(--accent, #f5c842); }
.rr-toggle input { display: none; }
.rr-toggle-switch {
  width: 28px;
  height: 16px;
  background: var(--border);
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.rr-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.rr-toggle input:checked + .rr-toggle-switch {
  background: var(--accent, #f5c842);
}
.rr-toggle input:checked + .rr-toggle-switch::after {
  transform: translateX(12px);
  background: #fff;
}
@media (max-width: 768px) {
  .rr-sidebar { width: 100%; position: static; }
}

/* Rhythm Rules theme-aware containers */
.rr-themed-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card-bg, var(--bg));
}
.rr-text { color: var(--text); }
.rr-text-secondary { color: var(--text-secondary); }

/* Legacy pill buttons (keep for backwards compat) */
.rr-section-btn {
  padding: 3px 10px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.rr-section-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.rr-section-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Rhythm Rules Accordion */
.rr-acc-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 4px; overflow: hidden; }
.rr-acc-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; user-select: none; background: var(--bg-card); transition: background 0.15s; min-height: 40px; }
.rr-acc-header:hover { background: var(--bg-hover); }
.rr-grip { cursor: grab; font-size: 14px; opacity: 0.3; padding: 0 4px; flex-shrink: 0; }
.rr-grip:hover { opacity: 0.7; }
.rr-acc-num { font-size: 11px; font-weight: 700; color: var(--accent); min-width: 20px; flex-shrink: 0; }
.rr-acc-title { flex: 1; font-size: 13px; font-weight: 600; }
.rr-acc-chevron { font-size: 12px; color: var(--text-dim); transition: transform 0.2s; flex-shrink: 0; }
.rr-acc-item.open .rr-acc-chevron { transform: rotate(90deg); }
.rr-acc-body { padding: 12px 16px; border-top: 1px solid var(--border); }
.rr-acc-item.rr-dragging { opacity: 0.5; }

/* Priorities page */
@keyframes priFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.pri-toggle-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.pri-pill:hover {
  transform: translateY(-1px);
}
.pri-pill-active {
  font-weight: 600 !important;
}
.pri-group {
  animation: priFadeIn 0.3s ease;
}
