:root {
  --bg-page: #fafbfc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f3f5;
  --bg-emphasis: #e9ecef;
  --bg-hover: #f6f7f9;
  --border: #e6e8ec;
  --border-strong: #d0d4db;
  --text: #1a1d24;
  --text-muted: #5c6370;
  --text-subtle: #9ca3af;
  --primary: #5e6ad2;
  --primary-hover: #4f5bc4;
  --primary-soft: #ede9fe;
  --primary-text: #4f46e5;
  --accent: #8b5cf6;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --success-text: #15803d;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-text: #b91c1c;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --warning-text: #a16207;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --info-text: #1e40af;
  --orange: #fb923c;
  --pink: #ec4899;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 2px 8px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow-lg: 0 8px 24px rgba(15,23,42,.08);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  margin: 0;
  background: var(--bg-page);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* === HEADER === */
header.nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}
header.nav h1 {
  font-size: 15px;
  margin: 0 24px 0 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
header.nav h1::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 6px;
  margin-right: 4px;
}
header.nav nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
header.nav a:hover { background: var(--bg-subtle); color: var(--text); }
header.nav a.active { background: var(--bg-subtle); color: var(--text); font-weight: 600; }
header.nav .right { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--text-muted); }
header.nav .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
}

/* === LAYOUT === */
main { max-width: 1280px; margin: 28px auto; padding: 0 24px; }

/* === CARDS === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card h3 {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin: 20px 0 10px;
}

/* === FORMS === */
label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
  margin-bottom: 5px;
  font-weight: 500;
}
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94,106,210,.12);
}
textarea {
  font-family: 'JetBrains Mono', 'SF Mono', 'Monaco', monospace;
  font-size: 12px;
  min-height: 200px;
}

/* === BUTTONS === */
button, .btn {
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all .15s;
  letter-spacing: -0.005em;
}
button:hover, .btn:hover { background: var(--primary-hover); }
button:active, .btn:active { transform: scale(.98); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-text); }
.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-text); }
.btn-warn { background: var(--warning); }
.btn-warn:hover { background: var(--warning-text); }
.btn-purple { background: var(--accent); }
.btn-purple:hover { background: #7c3aed; }
.btn-dark { background: #1a1a1a; color: #fff; }
.btn-dark:hover { background: #000; }

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-card);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--bg-hover); }

/* === FLASH === */
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.flash.info { background: var(--info-soft); color: var(--info-text); }
.flash.success { background: var(--success-soft); color: var(--success-text); }
.flash.error { background: var(--danger-soft); color: var(--danger-text); }
.flash.warning { background: var(--warning-soft); color: var(--warning-text); }

/* === GRID === */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.row4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
.row6 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* === METRICS === */
.metric {
  background: var(--bg-card);
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all .15s;
}
.metric:hover { border-color: var(--border-strong); }
.metric .label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.metric .value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}
.metric .value.positive { color: var(--success); }
.metric .value.negative { color: var(--danger); }
.metric .value.accent { color: var(--primary); }
.metric .delta {
  font-size: 11.5px;
  margin-top: 4px;
  font-weight: 500;
}
.metric .delta.positive { color: var(--success); }
.metric .delta.negative { color: var(--danger); }

/* === TAGS === */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  background: var(--bg-emphasis);
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tag.green { background: var(--success-soft); color: var(--success-text); }
.tag.red { background: var(--danger-soft); color: var(--danger-text); }
.tag.blue { background: var(--info-soft); color: var(--info-text); }
.tag.yellow { background: var(--warning-soft); color: var(--warning-text); }
.tag.purple { background: var(--primary-soft); color: var(--primary-text); }

.muted { color: var(--text-muted); font-size: 13px; }
.right { text-align: right; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.positive { color: var(--success); }
.negative { color: var(--danger); }

/* === LOGIN === */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #fafbfc 0%, #ede9fe 100%);
}
.login-card {
  background: var(--bg-card);
  padding: 36px;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.login-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
  text-align: center;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.login-card .sub {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 13px;
}
.login-card button { width: 100%; padding: 10px; font-size: 14px; }

/* === PROGRESS === */
.progress-bar {
  background: var(--bg-emphasis);
  border-radius: 999px;
  overflow: hidden;
  height: 6px;
  margin: 6px 0;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .3s ease;
}

/* === STATUS GRID === */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.status-cell {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 12px;
  border: 1px solid var(--border);
}
.status-cell.fresh { background: var(--success-soft); border-color: rgba(22,163,74,.2); }
.status-cell.stale { background: var(--warning-soft); border-color: rgba(217,119,6,.2); }
.status-cell.empty { background: var(--danger-soft); border-color: rgba(220,38,38,.2); }
.status-cell strong { display: block; font-size: 13px; font-weight: 600; }

/* === DASHBOARD CARDS === */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  display: flex;
  gap: 14px;
  align-items: center;
  transition: all .15s;
  position: relative;
}
.dash-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.dash-card .icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.dash-card .icon-wrap.purple { background: var(--primary-soft); }
.dash-card .icon-wrap.green { background: var(--success-soft); }
.dash-card .icon-wrap.yellow { background: var(--warning-soft); }
.dash-card .icon-wrap.blue { background: var(--info-soft); }
.dash-card .body { flex: 1; min-width: 0; }
.dash-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 2px;
  color: var(--text);
  text-transform: none;
  letter-spacing: -0.005em;
}
.dash-card p { color: var(--text-muted); margin: 0; font-size: 12px; line-height: 1.4; }
.dash-card .badge {
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

/* === SAVED ITEM CARDS === */
.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.saved-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  transition: all .15s;
}
.saved-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.saved-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.saved-card .top .title { font-weight: 600; font-size: 14px; line-height: 1.3; flex: 1; color: var(--text); }
.saved-card .meta { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5; }
.saved-card .actions { display: flex; gap: 6px; }
.saved-card .actions a, .saved-card .actions button {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
.fav-star {
  background: transparent;
  border: 0;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
}
.fav-star.active { color: var(--warning); }
.fav-star:hover { background: transparent; transform: scale(1.15); }

/* === LIST ROW === */
.list-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.list-row .row-item {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.list-row .row-item:last-child { border-bottom: none; }
.list-row .row-item:hover { background: var(--bg-hover); }
.list-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.list-row .dot.purple { background: var(--accent); }
.list-row .dot.green { background: var(--success); }
.list-row .dot.blue { background: var(--info); }
.list-row .dot.yellow { background: var(--warning); }
.list-row .row-title { flex: 1; font-size: 13.5px; color: var(--text); font-weight: 500; }
.list-row .row-detail { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.list-row .row-time { font-size: 12px; color: var(--text-subtle); width: 90px; text-align: right; }

/* === BANNER === */
.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid transparent;
}
.banner.info { background: var(--info-soft); border-color: rgba(37,99,235,.15); color: var(--info-text); }
.banner.success { background: var(--success-soft); border-color: rgba(22,163,74,.15); color: var(--success-text); }
.banner.warning { background: var(--warning-soft); border-color: rgba(217,119,6,.15); color: var(--warning-text); }
.banner.danger { background: var(--danger-soft); border-color: rgba(220,38,38,.15); color: var(--danger-text); }

/* === PAGE HEADER === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.025em;
}
.page-header .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.page-header h1 + .subtitle { margin-top: 4px; }

/* === SECTION TITLE === */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 10px;
  letter-spacing: -0.005em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-title a {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
}
.section-title a:hover { color: var(--text); }

/* === ACTIVITY CHART (mini bar chart) === */
.activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 50px;
  padding: 8px 0;
}
.activity-chart .bar {
  flex: 1;
  background: var(--primary-soft);
  border-radius: 3px;
  min-height: 4px;
  transition: background .15s;
  position: relative;
}
.activity-chart .bar:hover { background: var(--primary); }
.activity-chart .bar.active { background: var(--primary); }

/* === STOCK PRICE TICKER === */
.ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: all .15s;
}
.ticker:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.ticker .symbol { font-weight: 600; color: var(--text); flex: 1; }
.ticker .price { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--text); }
.ticker .change { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; }
.ticker .change.positive { color: var(--success); }
.ticker .change.negative { color: var(--danger); }
