/* Family Dashboard — shared design system.
   One stylesheet for every page: tokens, app shell, and components.
   Light by default, automatic dark mode, no external fonts. */

:root {
  /* Brand + semantic colors */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --pos: #16a34a; /* calls / gains */
  --neg: #dc2626; /* puts / losses */
  --warn: #b45309; /* pending / dry-run */
  --warn-soft: #fef3c7;
  --neg-soft: #fee2e2;
  --pos-soft: #dcfce7;

  /* Neutrals (slate) */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Shape + depth */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, .25);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --maxw: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-soft: #1e293b;
    --pos: #4ade80;
    --neg: #f87171;
    --warn: #fbbf24;
    --warn-soft: #422006;
    --neg-soft: #450a0a;
    --pos-soft: #052e16;
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f1729;
    --text: #e5e7eb;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --border: #1f2937;
    --border-strong: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text);
  font-size: 1.02em;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: inline-block;
}
.appnav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.appnav a {
  color: var(--text-muted);
  font-size: .9em;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  white-space: nowrap;
}
.appnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.appnav a.active { background: var(--accent-soft); color: var(--accent); }

.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.subnav a {
  color: var(--text-muted);
  font-size: .85em;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  white-space: nowrap;
}
.subnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.subnav a.active { background: var(--accent-soft); color: var(--accent); }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- Persistent side panel shell (StockTwits) ---------- */

.shell {
  max-width: calc(var(--maxw) + 360px);
  margin: 0 auto;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 0 20px;
}
.shell main { flex: 1; min-width: 0; max-width: var(--maxw); margin: 0; padding: 28px 0 60px; }

.st-panel {
  width: 320px;
  flex-shrink: 0;
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  margin-top: 28px;
}
.st-panel-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.st-who { font-weight: 800; font-size: .92em; }
.st-userform { display: flex; gap: 6px; }
.st-userform input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: .78em;
}
.st-userform button {
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: .78em;
  font-weight: 700;
  cursor: pointer;
}
.st-userform button:hover { background: var(--accent-hover); }
.st-myfeed-btn {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .74em;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.st-myfeed-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.st-author { display: block; font-weight: 700; font-size: .85em; color: var(--text); margin-bottom: 2px; }
.st-post { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .86em; line-height: 1.5; }
.st-post:last-child { border-bottom: none; }
.st-post .meta {
  display: flex; gap: 8px; align-items: center; margin-top: 5px;
  font-size: .78em; color: var(--text-faint); flex-wrap: wrap;
}
.st-reply-quote {
  margin: 4px 0 8px; padding: 6px 10px; border-left: 2px solid var(--border);
  background: var(--accent-soft); border-radius: 0 6px 6px 0;
  font-size: .92em; color: var(--text-faint);
}
.st-reply-quote .st-author { display: inline; margin-bottom: 0; }
.st-reply-quote-body { margin-top: 2px; color: var(--text); }
.cashtag { color: var(--accent); font-weight: 700; font-family: var(--mono); }
.sent-bull { color: var(--pos); font-weight: 700; }
.sent-bear { color: var(--neg); font-weight: 700; }
.st-loading, .st-empty { color: var(--text-faint); font-style: italic; font-size: .85em; padding: 8px 0; }

@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .shell main { max-width: none; padding: 28px 0 0; }
  .st-panel { width: 100%; position: static; max-height: none; margin-top: 18px; margin-bottom: 10px; }
}

.page-head { margin: 8px 0 22px; }
.page-head h1 {
  font-size: 1.7em;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 0 4px;
}
.page-head .lede { color: var(--text-muted); margin: 0; font-size: .98em; }

footer.appfoot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 20px 40px;
  color: var(--text-faint);
  font-size: .8em;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

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

.tile {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  text-decoration: none;
}
.tile .ico {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25em; margin-bottom: 12px;
  background: var(--accent-soft);
}
.tile h2 { margin: 0 0 4px; font-size: 1.05em; font-weight: 700; color: var(--text); }
.tile p { margin: 0; color: var(--text-muted); font-size: .9em; flex: 1; }
.tile .go { margin-top: 14px; color: var(--accent); font-weight: 700; font-size: .88em; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-size: .9em;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-neg { background: var(--neg-soft); color: var(--neg); }
.badge-pos { background: var(--pos-soft); color: var(--pos); }

/* ---------- Tables ---------- */

table.data { width: 100%; border-collapse: collapse; font-size: .9em; }
table.data th {
  text-align: left;
  padding: 9px 12px;
  color: var(--text-faint);
  font-size: .72em;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }

.ticker { font-family: var(--mono); font-weight: 800; }
.call, .pos { color: var(--pos); font-weight: 700; }
.put, .neg { color: var(--neg); font-weight: 700; }

/* ---------- Empty / coming-soon states ---------- */

.empty-state {
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-state .ico {
  font-size: 2.4em;
  margin-bottom: 10px;
}
.empty-state h2 { margin: 0 0 6px; font-size: 1.15em; }
.empty-state p { margin: 0 auto; color: var(--text-muted); max-width: 420px; }

/* ---------- Utilities ---------- */

.muted { color: var(--text-muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.mt-0 { margin-top: 0; }

@media (max-width: 560px) {
  .appbar-inner { gap: 12px; }
  main { padding: 20px 14px 50px; }
  .page-head h1 { font-size: 1.4em; }
}
