@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=DM+Mono&display=swap');

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

/* ── Default theme: Pure White ────────────────────────────── */
:root {
  --bg:       #ffffff;
  --surface:  #ffffff;
  --surface2: #f7f7f7;
  --border:   rgba(0,0,0,0.07);
  --border2:  rgba(0,0,0,0.12);
  --text:     #111111;
  --text2:    #666666;
  --text3:    #aaaaaa;
  --blue:     #2563eb; --blue-bg:  #eff6ff; --blue-text:  #1d4ed8;
  --green:    #16a34a; --green-bg: #f0fdf4; --green-text: #15803d;
  --red:      #dc2626; --red-bg:   #fef2f2; --red-text:   #b91c1c;
  --amber:    #d97706; --amber-bg: #fffbeb; --amber-text: #b45309;
  --radius: 8px; --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

/* ── Theme: Warm White ────────────────────────────────────── */
[data-theme="warm"] {
  --bg:       #fefcf8;
  --surface:  #ffffff;
  --surface2: #faf8f3;
  --border:   rgba(0,0,0,0.07);
  --border2:  rgba(0,0,0,0.12);
  --text:     #1a1814;
  --text2:    #6b6660;
  --text3:    #aaa49e;
}

/* ── Theme: Cool White ────────────────────────────────────── */
[data-theme="cool"] {
  --bg:       #f8fafc;
  --surface:  #ffffff;
  --surface2: #f1f5f9;
  --border:   rgba(0,0,0,0.07);
  --border2:  rgba(0,0,0,0.12);
  --text:     #0f172a;
  --text2:    #64748b;
  --text3:    #94a3b8;
}

/* ── Theme: Soft Gray ─────────────────────────────────────── */
[data-theme="gray"] {
  --bg:       #f4f4f5;
  --surface:  #ffffff;
  --surface2: #ececed;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.14);
  --text:     #18181b;
  --text2:    #71717a;
  --text3:    #a1a1aa;
}

/* ── Theme: Paper ─────────────────────────────────────────── */
[data-theme="paper"] {
  --bg:       #fdf8f0;
  --surface:  #fffef9;
  --surface2: #f5f0e8;
  --border:   rgba(0,0,0,0.07);
  --border2:  rgba(0,0,0,0.12);
  --text:     #1c1a16;
  --text2:    #6b6457;
  --text3:    #a09890;
}

/* ── Theme: Dark ──────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --surface2: #222222;
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.13);
  --text:     #f0f0f0;
  --text2:    #888888;
  --text3:    #555555;
  --blue-bg:  #0c1f3d; --blue-text:  #6ba3e8;
  --green-bg: #0a1f12; --green-text: #4cba85;
  --red-bg:   #1f0a0a; --red-text:   #e88888;
  --amber-bg: #1f1608; --amber-text: #e8b84b;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

/* ── Accent colors ────────────────────────────────────────── */
[data-accent="indigo"] { --blue: #4f46e5; --blue-bg: #eef2ff; --blue-text: #4338ca; }
[data-accent="violet"] { --blue: #7c3aed; --blue-bg: #f5f3ff; --blue-text: #6d28d9; }
[data-accent="rose"]   { --blue: #e11d48; --blue-bg: #fff1f2; --blue-text: #be123c; }
[data-accent="teal"]   { --blue: #0d9488; --blue-bg: #f0fdfa; --blue-text: #0f766e; }
[data-accent="orange"] { --blue: #ea580c; --blue-bg: #fff7ed; --blue-text: #c2410c; }

html, body { height: 100%; background: var(--bg); font-family: 'Inter', 'DM Sans', sans-serif; color: var(--text); -webkit-font-smoothing: antialiased; }
#root { min-height: 100vh; }

.app { max-width: 1140px; margin: 0 auto; padding: 20px 20px 60px; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.topbar h1 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.updated { font-size: 11px; color: var(--text3); }
.btn-icon { background: none; border: 0.5px solid var(--border2); border-radius: 6px; padding: 4px 8px; font-size: 14px; cursor: pointer; color: var(--text2); transition: all .15s; }
.btn-icon:hover { background: var(--surface2); }

/* Site tabs */
.site-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.stab { font-size: 11px; padding: 4px 10px; border-radius: 20px; border: 0.5px solid var(--border2); background: var(--surface2); color: var(--text2); cursor: pointer; transition: all .15s; user-select: none; }
.stab.active { background: var(--blue-bg); color: var(--blue-text); border-color: var(--blue); font-weight: 500; }
.stab:hover:not(.active) { background: var(--surface); border-color: var(--border2); }

/* AI banner */
.ai-banner { background: var(--blue-bg); border: 0.5px solid var(--blue); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.ai-icon { font-size: 14px; color: var(--blue-text); flex-shrink: 0; margin-top: 1px; }

/* Metrics */
.metrics-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-bottom: 14px; }
.metric-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); }
.metric-label { font-size: 11px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.metric-value { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.metric-delta { font-size: 11px; margin-top: 3px; }
.up { color: var(--green-text) !important; }
.dn { color: var(--red-text) !important; }
.info { color: var(--blue-text) !important; }

/* Tab nav */
.tab-nav { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; gap: 2px; }
.ntab { font-size: 12px; padding: 8px 14px; cursor: pointer; color: var(--text2); border-bottom: 2px solid transparent; transition: all .15s; white-space: nowrap; font-weight: 400; }
.ntab.active { color: var(--text); border-bottom-color: var(--blue); font-weight: 500; }
.ntab:hover:not(.active) { color: var(--text); }

/* Panels */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.ptitle { font-size: 11px; font-weight: 600; color: var(--text2); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .06em; }

/* KPI rows */
.kpi-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.kpi-row:last-child { border: none; }
.kpi-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Keyword table */
.kw-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.ksum { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.ksum-lbl { font-size: 10px; color: var(--text2); margin-bottom: 2px; font-weight: 500; }
.ksum-val { font-size: 18px; font-weight: 600; }
.filters { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.fbtn { font-size: 11px; padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border2); background: transparent; color: var(--text2); cursor: pointer; transition: all .12s; }
.fbtn.fup.active { background: var(--green-bg); color: var(--green-text); border-color: var(--green); }
.fbtn.fdn.active { background: var(--red-bg); color: var(--red-text); border-color: var(--red); }
.fbtn.fall.active, .fbtn.fst.active { background: var(--surface2); color: var(--text); border-color: var(--border2); font-weight: 500; }
.kwtable { width: 100%; border-collapse: collapse; table-layout: fixed; }
.kwtable thead th { font-size: 11px; font-weight: 500; color: var(--text2); text-align: left; padding: 0 6px 8px; border-bottom: 1px solid var(--border); }
.kwtable thead th.rc { text-align: center; }
.kwtable thead th.rr { text-align: right; }
.kwtable tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.kwtable tbody tr:last-child { border: none; }
.kwtable tbody tr:hover { background: var(--surface2); }
.kwtable td { padding: 8px 6px; font-size: 12px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kwtable td.rc { text-align: center; }
.kwtable td.rr { text-align: right; }

/* Badges */
.pbadge { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 500; }
.p13   { background: var(--green-bg);  color: var(--green-text); }
.p410  { background: var(--amber-bg);  color: var(--amber-text); }
.p1120 { background: var(--blue-bg);   color: var(--blue-text);  }
.p20p  { background: var(--surface2);  color: var(--text2);      }
.mbadge { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 20px; white-space: nowrap; }
.mup { background: var(--green-bg); color: var(--green-text); }
.mdn { background: var(--red-bg);   color: var(--red-text);   }
.mst { background: var(--surface2); color: var(--text2);      }
.mnw { background: var(--blue-bg);  color: var(--blue-text);  }

/* Tasks */
.tchip { font-size: 11px; padding: 7px 9px; border-radius: 7px; margin-bottom: 5px; border-left: 3px solid; display: flex; align-items: center; gap: 6px; cursor: pointer; transition: opacity .1s; }
.tchip:hover { opacity: .75; }
.tchip.todo   { background: var(--surface2); border-color: var(--border2); color: var(--text2); }
.tchip.inprog { background: var(--blue-bg);  border-color: var(--blue);    color: var(--blue-text); }
.tchip.review { background: var(--amber-bg); border-color: var(--amber);   color: var(--amber-text); }
.tchip.done   { background: var(--green-bg); border-color: var(--green);   color: var(--green-text); }

/* Misc */
.src-footer { font-size: 11px; color: var(--text3); margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.skeleton { background: linear-gradient(90deg, var(--surface2) 25%, var(--surface) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

@media (max-width: 640px) {
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .panels { grid-template-columns: 1fr; }
  .kw-summary { grid-template-columns: repeat(2, 1fr); }
}
