:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2e38;
  --text: #e8eaed;
  --muted: #9aa1ac;
  --accent: #4f8cff;
  --ok: #35b06b;
  --warn: #d9a441;
  --danger: #e0555f;
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f5f6f8; --panel:#ffffff; --border:#e2e4e8; --text:#1c1f26; --muted:#666f7d; }
}
:root[data-theme="light"] { --bg:#f5f6f8; --panel:#ffffff; --border:#e2e4e8; --text:#1c1f26; --muted:#666f7d; }
:root[data-theme="dark"] { --bg:#0f1115; --panel:#171a21; --border:#2a2e38; --text:#e8eaed; --muted:#9aa1ac; }

/* dataviz categorical palette (validated against this app's light/dark surfaces) */
:root {
  --series-1: #2a78d6; /* blue */
  --series-2: #1baf7a; /* aqua */
  --series-3: #eda100; /* yellow */
  --series-4: #4a3aa7; /* violet */
  --series-5: #eb6834; /* orange */
  --series-6: #e34948; /* red */
  --series-7: #e87ba4; /* magenta */
  --series-8: #008300; /* green */
  --grid-line: #e1e0d9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --series-1: #3987e5; --series-2: #199e70; --series-3: #c98500; --series-4: #9085e9;
    --series-5: #d95926; --series-6: #e66767; --series-7: #d55181; --series-8: #008300;
    --grid-line: #2c2c2a;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #199e70; --series-3: #c98500; --series-4: #9085e9;
  --series-5: #d95926; --series-6: #e66767; --series-7: #d55181; --series-8: #008300;
  --grid-line: #2c2c2a;
}
:root[data-theme="light"] {
  --series-1: #2a78d6; --series-2: #1baf7a; --series-3: #eda100; --series-4: #4a3aa7;
  --series-5: #eb6834; --series-6: #e34948; --series-7: #e87ba4; --series-8: #008300;
  --grid-line: #e1e0d9;
}

* { box-sizing: border-box; }
body { margin:0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }

.auth-body { display:flex; align-items:center; justify-content:center; min-height:100vh; }
.auth-card { background: var(--panel); border:1px solid var(--border); border-radius:12px; padding:32px; width:320px; display:flex; flex-direction:column; gap:10px; }
.auth-card h1 { margin:0; font-size:1.4rem; }
.auth-card .sub { margin:0 0 10px; color: var(--muted); font-size:0.9rem; }
.auth-card input { padding:10px; border-radius:8px; border:1px solid var(--border); background: var(--bg); color: var(--text); }
.auth-card button { margin-top:6px; padding:10px; border-radius:8px; border:none; background: var(--accent); color:#fff; font-weight:600; cursor:pointer; }
.auth-card .error { color: var(--danger); min-height:1.2em; font-size:0.85rem; margin:0; }

.topbar { display:flex; align-items:center; justify-content:space-between; padding:12px 20px; border-bottom:1px solid var(--border); background: var(--panel); }
.brand { font-weight:700; }
.brand span { font-weight:400; color: var(--muted); margin-left:6px; font-size:0.85rem; }
.brand .home-link { color: var(--text); text-decoration:none; font-weight:700; }
.brand .home-link:hover { color: var(--accent); }

.home-layout { padding:32px 24px; max-width:1000px; margin:0 auto; }
.card-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap:16px; }
.module-card { position:relative; display:block; background: var(--panel); border:1px solid var(--border); border-radius:14px; padding:22px; text-decoration:none; color: var(--text); transition: border-color .15s, transform .15s; }
.module-card:not(.disabled):hover { border-color: var(--accent); transform: translateY(-2px); }
.module-card.disabled { opacity:0.55; cursor:default; }
.module-icon { font-size:1.8rem; margin-bottom:10px; }
.module-card h3 { margin:0 0 6px; font-size:1.05rem; }
.module-card p { margin:0; color: var(--muted); font-size:0.85rem; line-height:1.4; }
.module-badge { position:absolute; top:16px; right:16px; font-size:0.7rem; font-weight:700; padding:3px 8px; border-radius:999px; text-transform:uppercase; letter-spacing:0.02em; }
.module-badge.live { background: rgba(53,176,107,0.18); color: var(--ok); }
.module-badge.soon { background: rgba(154,161,172,0.18); color: var(--muted); }
.topbar-actions { display:flex; align-items:center; gap:10px; }
.me-info { color: var(--muted); font-size:0.85rem; }

.btn { padding:8px 12px; border-radius:8px; border:1px solid var(--border); background:transparent; color: var(--text); cursor:pointer; font-size:0.85rem; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color:#fff; border-color: var(--accent); }

.layout { display:flex; height: calc(100vh - 57px); }
.orders-panel { flex:1; padding:16px 20px; overflow-y:auto; }
.filters { display:flex; gap:10px; margin-bottom:14px; }
.filters input, .filters select { padding:8px 10px; border-radius:8px; border:1px solid var(--border); background: var(--panel); color: var(--text); }
.filters input { flex:1; }

.orders-table { width:100%; border-collapse: collapse; background: var(--panel); border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.orders-table th, .orders-table td { text-align:left; padding:10px 12px; border-bottom:1px solid var(--border); font-size:0.88rem; }
.orders-table tr:last-child td { border-bottom:none; }
.orders-table tbody tr { cursor:pointer; }
.orders-table tbody tr:hover { background: rgba(79,140,255,0.08); }

.status-pill { padding:3px 9px; border-radius:999px; font-size:0.75rem; font-weight:600; text-transform:capitalize; display:inline-block; }
.status-pending, .status-on-hold { background: rgba(217,164,65,0.18); color: var(--warn); }
.status-processing { background: rgba(79,140,255,0.18); color: var(--accent); }
.status-completed { background: rgba(53,176,107,0.18); color: var(--ok); }
.status-cancelled, .status-failed { background: rgba(224,85,95,0.18); color: var(--danger); }
.status-refunded { background: rgba(154,161,172,0.18); color: var(--muted); }

.detail-panel { width:400px; border-left:1px solid var(--border); background: var(--panel); padding:18px; overflow-y:auto; position:relative; }
.close-btn { position:absolute; top:12px; right:12px; }
.detail-panel h2 { margin-top:0; }
.line-item { display:flex; justify-content:space-between; font-size:0.85rem; padding:6px 0; border-bottom:1px solid var(--border); }
.status-select { padding:8px; border-radius:8px; border:1px solid var(--border); background: var(--bg); color: var(--text); width:100%; margin-top:6px; }
.status-save-row { display:flex; align-items:center; gap:10px; margin-top:8px; }
.status-save-msg { font-size:0.78rem; color: var(--ok); }
.detail-section { margin-top:14px; }
.detail-section h3 { font-size:0.85rem; color: var(--muted); text-transform:uppercase; letter-spacing:0.03em; margin:0 0 6px; }
.address-block { font-size:0.85rem; line-height:1.5; }

.comments { margin-top:16px; }
.comment { background: var(--bg); border:1px solid var(--border); border-radius:8px; padding:8px 10px; margin-bottom:8px; font-size:0.85rem; }
.comment .meta { color: var(--muted); font-size:0.75rem; margin-bottom:4px; }
.comment-input { display:flex; gap:6px; margin-top:8px; }
.comment-input textarea { flex:1; padding:8px; border-radius:8px; border:1px solid var(--border); background: var(--bg); color: var(--text); resize:vertical; min-height:36px; }

.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.5); display:flex; align-items:center; justify-content:center; z-index:50; }
.modal { background: var(--panel); border-radius:12px; padding:24px; width:360px; border:1px solid var(--border); }
.modal label { display:block; margin:10px 0 4px; font-size:0.85rem; color: var(--muted); }
.modal input, .modal select { width:100%; padding:8px; border-radius:8px; border:1px solid var(--border); background: var(--bg); color: var(--text); }
.modal .actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }

/* analytics page */
.analytics-layout { padding:24px; max-width:1100px; margin:0 auto; }
.stat-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap:14px; margin-bottom:20px; }
.stat-tile { background: var(--panel); border:1px solid var(--border); border-radius:12px; padding:16px 18px; }
.stat-tile .stat-label { color: var(--muted); font-size:0.8rem; margin-bottom:6px; }
.stat-tile .stat-value { font-size:1.7rem; font-weight:700; }
.stat-tile .stat-delta { font-size:0.8rem; margin-top:4px; display:inline-flex; align-items:center; gap:4px; }
.stat-delta.up { color:#0ca30c; }
.stat-delta.down { color:#d03b3b; }
.stat-delta.flat { color: var(--muted); }

.chart-card { background: var(--panel); border:1px solid var(--border); border-radius:12px; padding:18px; margin-bottom:20px; }
.chart-card h3 { margin:0 0 4px; font-size:0.95rem; }
.chart-card .chart-sub { color: var(--muted); font-size:0.78rem; margin:0 0 14px; }
.chart-legend { display:flex; gap:16px; margin-bottom:10px; font-size:0.8rem; }
.chart-legend span { display:inline-flex; align-items:center; gap:6px; color: var(--text); }
.legend-dot { width:10px; height:10px; border-radius:50%; display:inline-block; }

.two-col { display:grid; grid-template-columns: 1.3fr 1fr; gap:20px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.bar-row { display:flex; align-items:center; gap:10px; margin-bottom:10px; font-size:0.82rem; }
.bar-row .bar-label { width:120px; flex-shrink:0; color: var(--text); }
.bar-track { flex:1; background: var(--bg); border-radius:6px; height:16px; overflow:hidden; }
.bar-fill { height:100%; border-radius:6px; }
.bar-value { width:44px; text-align:right; color: var(--muted); flex-shrink:0; }

.pages-table { width:100%; border-collapse:collapse; font-size:0.85rem; }
.pages-table th, .pages-table td { text-align:left; padding:7px 4px; border-bottom:1px solid var(--border); }
.pages-table td.views { text-align:right; font-variant-numeric: tabular-nums; }

.chart-tooltip { position:absolute; background: var(--panel); border:1px solid var(--border); border-radius:8px; padding:8px 10px; font-size:0.78rem; pointer-events:none; box-shadow:0 4px 12px rgba(0,0,0,0.15); white-space:nowrap; }

/* social content page */
.content-row { display:flex; align-items:flex-start; gap:12px; padding:12px 0; border-bottom:1px solid var(--border); }
.content-row:last-child { border-bottom:none; }
.content-rank { font-weight:700; color: var(--muted); width:22px; flex-shrink:0; }
.content-platform { flex-shrink:0; font-size:1.1rem; }
.content-body { flex:1; min-width:0; }
.content-caption { font-size:0.85rem; color: var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.content-caption a { color: inherit; text-decoration:none; }
.content-caption a:hover { color: var(--accent); }
.content-stats { display:flex; gap:14px; margin-top:4px; font-size:0.78rem; color: var(--muted); }
.content-stats strong { color: var(--text); }

/* SEO report page */
.seo-group { margin-bottom: 18px; }
.seo-group-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin-bottom: 8px; }
.seo-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.seo-item:last-child { border-bottom: none; }
.seo-status-badge { flex-shrink: 0; font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.02em; width: 62px; text-align: center; }
.seo-status-done { background: rgba(12,163,12,0.15); color: #0ca30c; }
.seo-status-pending { background: rgba(79,140,255,0.15); color: var(--accent); }
.seo-status-blocked { background: rgba(224,85,95,0.15); color: var(--danger); }
.seo-status-flagged { background: rgba(154,161,172,0.18); color: var(--muted); }
.seo-item-body { flex: 1; }
.seo-item-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.seo-item-detail { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
