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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #1e2230;
  --bg-surface: #141620;
  --text: #e4e7ec;
  --text-secondary: #8b92a5;
  --text-muted: #5c6478;
  --accent: #6366f1;
  --accent-glow: rgba(99,102,241,0.15);
  --green: #10b981;
  --green-glow: rgba(16,185,129,0.15);
  --red: #ef4444;
  --red-glow: rgba(239,68,68,0.15);
  --yellow: #f59e0b;
  --yellow-glow: rgba(245,158,11,0.15);
  --blue: #3b82f6;
  --border: #252836;
  --border-light: #2d3147;
  --sidebar-w: 240px;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100dvh; -webkit-font-smoothing: antialiased; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(99,102,241,0.08), transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(16,185,129,0.05), transparent 50%),
              var(--bg);
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 24px;
  padding: 48px 40px; text-align: center; width: 90%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-logo { font-size: 60px; margin-bottom: 12px; filter: drop-shadow(0 0 20px rgba(99,102,241,0.3)); }
.login-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-card input {
  width: 100%; padding: 16px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 18px; text-align: center;
  letter-spacing: 8px; outline: none; margin-bottom: 16px; font-family: var(--mono);
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.login-card button {
  width: 100%; padding: 14px; background: var(--accent); color: white; border: none;
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all var(--transition);
}
.login-card button:hover { filter: brightness(1.1); box-shadow: 0 4px 20px rgba(99,102,241,0.3); }
.error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* ===== LAYOUT ===== */
#app { display: flex; min-height: 100dvh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
}
.sidebar-header { padding: 24px 20px 20px; display: flex; align-items: center; gap: 10px; }
.logo { font-size: 28px; }
.logo-text { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.sidebar-nav { flex: 1; padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: none;
  background: transparent; color: var(--text-secondary); font-size: 13px; font-weight: 600;
  border-radius: var(--radius-xs); cursor: pointer; transition: all var(--transition);
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.version { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

/* ===== MAIN ===== */
.main { flex: 1; margin-left: var(--sidebar-w); padding: 28px 32px 80px; overflow-x: hidden; }
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== VIEW HEADER ===== */
.view-header { margin-bottom: 24px; }
.view-header h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.view-header p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

/* ===== METRIC CARDS ===== */
.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; position: relative; overflow: hidden;
}
.metric-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.metric-card.purple::before { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.metric-card.green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.metric-card.blue::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.metric-card.yellow::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.metric-card.red::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.metric-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.metric-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; }
.metric-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }
.metric-value.purple { color: #818cf8; }
.metric-value.green { color: #34d399; }
.metric-value.blue { color: #60a5fa; }
.metric-value.yellow { color: #fbbf24; }
.metric-value.red { color: #f87171; }

/* ===== TABLE ===== */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px;
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table .mono { font-family: var(--mono); font-size: 12px; }

/* ===== CARDS / PANELS ===== */
.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px; overflow: hidden;
}
.panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-title { font-size: 14px; font-weight: 700; }
.panel-body { padding: 16px 20px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.badge.ok { background: var(--green-glow); color: var(--green); }
.badge.error { background: var(--red-glow); color: var(--red); }
.badge.warn { background: var(--yellow-glow); color: var(--yellow); }
.badge.info { background: var(--accent-glow); color: var(--accent); }
.badge.muted { background: rgba(92,100,120,0.15); color: var(--text-muted); }

/* ===== AGENT CARDS ===== */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; transition: all var(--transition); position: relative;
}
.agent-card:hover { border-color: var(--border-light); box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.agent-emoji { font-size: 36px; margin-bottom: 12px; }
.agent-name { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.agent-model { font-size: 12px; color: var(--text-secondary); font-family: var(--mono); }
.agent-meta { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== CRON CARDS ===== */
.cron-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 10px; transition: all var(--transition);
}
.cron-card:hover { border-color: var(--border-light); }
.cron-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cron-name { font-size: 14px; font-weight: 700; }
.cron-schedule { font-size: 12px; color: var(--text-secondary); font-family: var(--mono); }
.cron-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.cron-message { font-size: 12px; color: var(--text-muted); margin-top: 8px; padding: 8px 12px; background: var(--bg); border-radius: var(--radius-xs); font-family: var(--mono); line-height: 1.5; }

/* ===== TODO ===== */
.todo-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.todo-check { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.todo-text { font-size: 14px; line-height: 1.5; }
.todo-text.done { color: var(--text-muted); text-decoration: line-through; }

/* ===== MEMORY ===== */
.memory-file {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background var(--transition);
}
.memory-file:hover { background: var(--bg-card-hover); }
.memory-name { font-size: 13px; font-weight: 600; font-family: var(--mono); }
.memory-size { font-size: 11px; color: var(--text-muted); }
.memory-content { padding: 20px; font-family: var(--mono); font-size: 12px; line-height: 1.7; white-space: pre-wrap; color: var(--text-secondary); max-height: 500px; overflow-y: auto; }

/* ===== SKILL GRID ===== */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.skill-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; transition: all var(--transition);
}
.skill-card:hover { border-color: var(--border-light); }
.skill-name { font-size: 14px; font-weight: 700; font-family: var(--mono); margin-bottom: 6px; }
.skill-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* ===== PROCESS TABLE ===== */
.process-row { display: flex; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 12px; }
.process-row:hover { background: var(--bg-card-hover); }
.process-pid { width: 60px; color: var(--accent); font-weight: 600; }
.process-cpu { width: 50px; text-align: right; }
.process-mem { width: 50px; text-align: right; }
.process-cmd { flex: 1; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== MOBILE ===== */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--bg-surface); border-top: 1px solid var(--border);
  padding: 8px 12px 20px; justify-content: space-around;
}
.mob-nav {
  width: 44px; height: 44px; border: none; background: transparent; font-size: 20px;
  border-radius: var(--radius-xs); cursor: pointer; transition: all var(--transition);
}
.mob-nav.active { background: var(--accent-glow); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .main { margin-left: 0; padding: 20px 16px 100px; }
  .metrics-row { grid-template-columns: 1fr 1fr; }
}

/* ===== WATCHLIST ===== */

.wl-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.wl-sort-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wl-sort-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.wl-chip {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
}
.wl-chip:hover { border-color: var(--accent); color: var(--accent); }
.wl-chip.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.wl-add-btn {
  padding: 8px 18px; border-radius: var(--radius-xs); background: var(--accent);
  color: white; border: none; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.wl-add-btn:hover { filter: brightness(1.1); box-shadow: 0 4px 16px rgba(99,102,241,0.35); }

.wl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}

.wl-card {
  background: #161b2e;
  border: 1px solid #1e2640;
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  transition: all var(--transition);
  overflow: hidden;
}
.wl-card:hover { border-color: #2d3660; box-shadow: 0 4px 24px rgba(0,0,0,0.3); }

.wl-alert-badge {
  position: absolute; top: 12px; right: 12px;
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
  z-index: 2;
}
.wl-in-zone { background: rgba(16,185,129,0.15); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.wl-earnings-soon { background: rgba(245,158,11,0.15); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }

.wl-card-header {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px;
  padding-right: 80px; /* space for alert badge */
}
.wl-ticker-box {
  width: 52px; height: 52px; border-radius: 12px; border: 1px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; letter-spacing: 0; flex-shrink: 0;
  font-family: var(--mono); text-align: center; line-height: 1.2;
}
.wl-company-info { flex: 1; min-width: 0; }
.wl-company-name { font-size: 14px; font-weight: 700; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-company-meta { font-size: 11px; color: var(--text-muted); }
.wl-price-block { text-align: right; flex-shrink: 0; }
.wl-current-price { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; font-family: var(--mono); }
.wl-change-badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 20px; margin-top: 4px; display: inline-block; }
.wl-change-pos { background: rgba(16,185,129,0.12); color: var(--green); }
.wl-change-neg { background: rgba(239,68,68,0.12); color: var(--red); }

/* Chart */
.wl-chart-box {
  background: #0f1320; border: 1px solid #1a2035; border-radius: var(--radius-sm);
  padding: 10px 12px 6px; margin-bottom: 12px;
}
.wl-chart-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.wl-chart-tag {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 1px; text-transform: uppercase;
}
.wl-chart-vs { font-size: 11px; font-weight: 700; }
.wl-chart-vs.pos { color: var(--green); }
.wl-chart-vs.neg { color: var(--red); }
.wl-chart-svg { width: 100%; height: 72px; display: block; }
.wl-chart-xlabels {
  position: relative; height: 16px; margin-top: 4px;
  font-size: 10px; color: var(--text-muted);
}
.wl-chart-loading { min-height: 80px; display: flex; align-items: center; justify-content: center; }
.wl-chart-placeholder { color: var(--text-muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.wl-error-text { color: var(--red); }

/* 52W range */
.wl-52w-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 24px;
}
.wl-52w-label { font-size: 11px; color: var(--text-muted); font-family: var(--mono); white-space: nowrap; flex-shrink: 0; }
.wl-52w-label.right { text-align: right; }
.wl-52w-bar-wrap { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.wl-52w-track {
  height: 6px; background: #1a2035; border-radius: 3px; position: relative; overflow: visible;
}
.wl-52w-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #6366f1, #06b6d4);
  max-width: 100%;
}
.wl-52w-dot {
  width: 10px; height: 10px; background: white; border-radius: 50%;
  position: absolute; top: 50%; transform: translate(-50%,-50%);
  box-shadow: 0 0 4px rgba(255,255,255,0.5);
}
.wl-52w-pct { font-size: 10px; color: var(--text-muted); text-align: center; }

/* Stats row */
.wl-stats-row {
  display: flex; gap: 0; background: #1a2035; border-radius: var(--radius-sm);
  margin-bottom: 10px; overflow: hidden; border: 1px solid #1e2640;
}
.wl-stat { flex: 1; padding: 8px 10px; border-right: 1px solid #1e2640; text-align: center; }
.wl-stat:last-child { border-right: none; }
.wl-stat-label { font-size: 9px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.wl-stat-val { font-size: 13px; font-weight: 700; font-family: var(--mono); }
.wl-stat-pos { color: var(--green); }
.wl-stat-neg { color: var(--red); }

/* Earnings row */
.wl-earnings-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: #1a2035; border: 1px solid #1e2640; border-radius: var(--radius-sm);
  margin-bottom: 10px; flex-wrap: wrap;
}
.wl-earnings-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
.wl-earnings-info { flex: 1; font-size: 12px; display: flex; align-items: center; min-width: 0; }
.wl-earnings-eps { font-size: 12px; flex-shrink: 0; }
.wl-eps-beat { color: var(--green); font-weight: 700; }
.wl-eps-miss { color: var(--red); font-weight: 700; }

/* Targets row */
.wl-targets-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px;
}
.wl-targets-col {
  background: #1a2035; border: 1px solid #1e2640; border-radius: var(--radius-sm); padding: 10px 12px;
}
.wl-targets-head { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.wl-targets-val { font-size: 13px; }
.wl-zone-label { font-weight: 700; font-family: var(--mono); display: block; margin-bottom: 3px; }
.wl-target-status { font-size: 12px; font-weight: 600; }
.wl-target-status.ok { color: var(--green); }
.wl-target-status.miss { color: var(--red); }

/* Card footer */
.wl-card-footer {
  display: flex; gap: 8px; align-items: center; padding-top: 10px;
  border-top: 1px solid #1e2640;
}
.wl-btn {
  padding: 6px 14px; border-radius: var(--radius-xs); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--transition); border: 1px solid var(--border);
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.wl-btn-secondary { background: var(--bg); color: var(--text-secondary); }
.wl-btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.wl-btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.wl-btn-ghost:hover { color: var(--red); border-color: rgba(239,68,68,0.3); }

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

.wl-error {
  background: var(--red-glow); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius);
  padding: 20px; color: var(--red); font-size: 13px;
}

@media (max-width: 900px) {
  .wl-grid { grid-template-columns: 1fr; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== REFRESH INDICATOR ===== */
.refresh-btn {
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--bg); color: var(--text-muted); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }
.refresh-btn.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
