:root {
  --navy: #0a1628;
  --navy-2: #0d1c33;
  --navy-3: #13233d;
  --slate: #4a6078;
  --teal: #00b4b3;
  --teal-2: #33e5e4;
  --orange: #ff6b1a;
  --orange-2: #ff8f4d;
  --cream: #f2f6fb;
  --muted: #8da3b8;

  --bg: var(--navy);
  --panel: var(--navy-2);
  --panel-2: var(--navy-3);
  --line: #1f3552;
  --text: var(--cream);
  --accent: var(--orange);
  --accent-2: var(--orange-2);
  --new: rgba(0, 180, 179, 0.12);
  --ok: #2ecc71;
  --ok-bg: rgba(46, 204, 113, 0.12);
  --warn: #f1c40f;
  --danger: #ff4d4d;
  --danger-bg: rgba(255, 77, 77, 0.12);
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  min-height: 100vh;
}

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

/* --- SVG icon helpers --------------------------------------------------- */
.icon { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }

/* --- Header / Nav ------------------------------------------------------- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 22, 40, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 18px;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--navy);
  box-shadow: 0 0 0 2px rgba(0, 180, 179, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text .sub {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--orange);
}

nav {
  display: flex;
  gap: 4px;
  flex: 1;
  align-items: center;
}

nav a {
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
nav a.active { color: #fff; background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }

header .actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 18px;
}
.menu-toggle:hover, .menu-toggle:focus { border-color: var(--teal); color: var(--teal); outline: none; }

.badge {
  background: var(--orange);
  color: #fff;
  border-radius: 10px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 800;
}

/* --- Layout ------------------------------------------------------------- */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 18px 70px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

h1 { font-size: 26px; margin: 0; }
h2 { font-size: 18px; margin: 28px 0 12px; }

.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 44px 0; text-align: center; }

/* --- Hero banner -------------------------------------------------------- */
.hero-banner {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 26px;
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  padding: 22px 24px;
  background: linear-gradient(100deg, rgba(10,22,40,0.92) 0%, rgba(10,22,40,0.65) 60%, rgba(10,22,40,0.35) 100%),
              url('/static/images/hero.jpg') center/cover no-repeat;
  border: 1px solid var(--line);
}
.hero-content { position: relative; z-index: 1; max-width: 640px; }
.hero-content h2 { margin: 0 0 6px; font-size: 28px; color: #fff; }
.hero-content p { margin: 0; color: var(--muted); font-size: 15px; }
.hero-cta { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

.wave-divider {
  height: 6px;
  background: repeating-linear-gradient(
    110deg,
    var(--teal) 0px,
    var(--teal) 12px,
    var(--orange) 12px,
    var(--orange) 24px,
    transparent 24px,
    transparent 36px
  );
  border-radius: 3px;
  margin: 0 0 22px;
  opacity: 0.85;
}

/* --- Hero deal cards (top 3) -------------------------------------------- */
.hero-deals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.hero-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .15s ease;
}
.hero-card:hover { transform: translateY(-3px); border-color: var(--orange); }
.hero-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  background: #070e18;
  position: relative;
  overflow: hidden;
}
.hero-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hero-thumb .noimg {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.hero-profit {
  position: absolute;
  bottom: 10px; left: 10px;
  background: var(--orange);
  color: #fff;
  font-weight: 900;
  font-size: 22px;
  padding: 5px 13px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.hero-body { padding: 14px; }
.hero-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
}
.hero-meta .price { font-weight: 800; color: var(--ok); }
.hero-title { color: #fff; font-weight: 700; font-size: 16px; text-decoration: none; }
.hero-title:hover { color: var(--teal); text-decoration: none; }

/* --- Score badge -------------------------------------------------------- */
.score-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  background: var(--teal);
  color: var(--navy);
  font-weight: 900;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 7px;
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: transform .06s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--teal); color: var(--text); text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: var(--orange-2); border-color: var(--orange-2); }
.btn.secondary { background: var(--teal); border-color: var(--teal); color: var(--navy); }
.btn.secondary:hover { background: var(--teal-2); border-color: var(--teal-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { background: transparent; }
.btn.active { border-color: var(--teal); color: var(--teal); background: rgba(0,180,179,0.12); }

/* --- Stats dashboard ---------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: transform .1s ease, border-color .15s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--slate); }
.stat-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; font-weight: 700; }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 6px; color: #fff; }
.stat-card .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.stat-card.good { border-top-color: var(--ok); }
.stat-card.good .value { color: var(--ok); }
.stat-card.warn { border-top-color: var(--warn); }
.stat-card.warn .value { color: var(--warn); }

.stat-pill {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px; font-weight: 700;
}
.stat-pill .label { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.stat-pill .value { color: var(--ok); font-size: 20px; }

/* --- Tables ------------------------------------------------------------- */
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.grid th {
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.grid td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:last-child td { border-bottom: none; }
.grid tr.is-new { background: var(--new); }
.grid a { color: var(--teal); }
.grid a:hover { text-decoration: underline; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }

/* --- Cards (listings / matches / deals) --------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
}
.card-item:hover { border-color: var(--teal); transform: translateY(-3px); box-shadow: 0 16px 40px rgba(0,0,0,0.4); }
.card-item.favorite { border-color: var(--warn); }
.card-item.ignored { opacity: .55; }
.card-item.is-new { background: var(--new); border-left: 3px solid var(--teal); }

.card-item .thumb {
  display: block;
  aspect-ratio: 16 / 10;
  background: #070e18;
  position: relative;
  overflow: hidden;
}
.deal-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 7px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.fav-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--warn);
  color: #000;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 7px;
}
.source-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(10, 22, 40, 0.85);
  color: var(--cream);
  font-weight: 700;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  backdrop-filter: blur(4px);
}
.card-item .score-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}
.card-item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.card-item:hover .thumb img { transform: scale(1.04); }
.card-item .noimg {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; gap: 6px;
}
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.card-title { color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; line-height: 1.35; }
.card-title:hover { color: var(--teal); text-decoration: none; }
.card-meta { display: flex; gap: 14px; font-size: 14px; flex-wrap: wrap; align-items: center; }
.card-meta .price { font-weight: 800; color: var(--ok); font-size: 16px; }
.card-sub { font-size: 13px; }
.card-sub.est .good { color: var(--ok); font-weight: 700; }
.card-sub.ai { color: var(--teal); }
.card-sub.ai .ai-notes { color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.4; }
.card-sub.removed { color: var(--danger); font-weight: 700; }
.card-actions { margin-top: auto; padding-top: 12px; display: flex; gap: 7px; flex-wrap: wrap; }

.deal-card .deal-profit {
  font-size: 28px;
  font-weight: 900;
  color: var(--orange);
  line-height: 1.1;
}

.market-bar { margin: 6px 0; }
.market-track {
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.market-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--teal));
  border-radius: 4px;
}
.market-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted); margin-top: 4px;
}

.stage-form, .stage-select {
  display: inline-flex; align-items: center;
}
.stage-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.stage-select:focus { outline: none; border-color: var(--teal); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 9px;
  margin: 2px 4px 2px 0;
  font-size: 12px;
  font-weight: 600;
}
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger-text { color: var(--danger); }

/* --- Detail page -------------------------------------------------------- */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}
.detail-main { min-width: 0; }
.detail-side { display: flex; flex-direction: column; gap: 16px; }

.detail-image {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: #070e18;
}
.detail-image img { width: 100%; display: block; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.info-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--teal);
  border-radius: var(--radius);
  padding: 13px;
}
.info-box.good { border-top-color: var(--orange); }
.info-box .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.info-box .value { font-size: 19px; font-weight: 800; margin-top: 4px; color: #fff; }

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 18px;
}
.section h2 { margin: 0 0 12px; }

pre.raw {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  overflow-x: auto;
  font-size: 12px;
  color: var(--muted);
  max-height: 420px;
}

textarea.notes {
  width: 100%;
  min-height: 130px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  padding: 12px;
  font: inherit;
  resize: vertical;
}
textarea.notes:focus { outline: none; border-color: var(--teal); }

.form-select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 14px;
}
.form-select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,180,179,0.15); }

/* --- Pipeline ----------------------------------------------------------- */
.pipeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  align-items: start;
}
.pipeline-column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.pipeline-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px;
}
.pipeline-header h3 { margin: 0; font-size: 15px; text-transform: capitalize; }
.pipeline-header .count {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 8px; font-size: 12px; font-weight: 800;
}
.pipeline-header .stage-profit { margin-left: auto; color: var(--ok); font-weight: 800; font-size: 14px; }

.pipeline-cards { display: flex; flex-direction: column; gap: 12px; }
.pipeline-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: transform .1s ease, border-color .15s ease;
}
.pipeline-card:hover { transform: translateY(-2px); border-color: var(--teal); }
.pipeline-card.favorite { border-color: var(--warn); }
.pipeline-card.ignored { opacity: .55; }
.pipeline-thumb {
  display: block; aspect-ratio: 16 / 9; background: #070e18; position: relative; overflow: hidden;
}
.pipeline-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pipeline-thumb .noimg {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px;
}
.pipeline-thumb .score-badge { position: absolute; top: 8px; right: 8px; }
.pipeline-body { padding: 12px; }
.pipeline-profit { font-size: 20px; font-weight: 900; color: var(--orange); }
.pipeline-title { color: #fff; font-weight: 700; font-size: 14px; text-decoration: none; }
.pipeline-title:hover { color: var(--teal); text-decoration: none; }
.pipeline-card .stage-form { margin-top: 10px; }
.pipeline-card .stage-select { width: 100%; }

/* --- Filter bar --------------------------------------------------------- */
.filterbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.filterbar > details > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.filterbar > details > summary::-webkit-details-marker { display: none; }
.filterbar > details > summary::before {
  content: '▸';
  color: var(--teal);
  font-size: 14px;
  transition: transform .15s ease;
}
.filterbar > details[open] > summary::before { content: '▾'; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.filterbar input, .filterbar select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
}
.filterbar input:focus, .filterbar select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,180,179,0.15); }
.filterbar input[type="checkbox"] { width: auto; }
.filterbar label.chk { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 13px; cursor: pointer; }
.filter-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 14px; align-items: center; }

/* --- Presets ------------------------------------------------------------- */
.presets { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.preset-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.preset-btn:hover { border-color: var(--teal); color: var(--text); text-decoration: none; }
.preset-btn.active { border-color: var(--orange); color: var(--orange); background: rgba(255,107,26,0.12); }

/* --- Forms -------------------------------------------------------------- */
.card.form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 820px;
  box-shadow: var(--shadow);
}
.form .row { margin-bottom: 16px; }
.form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.form input, .form select, .form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,180,179,0.15); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 9px; margin: 14px 0; padding: 14px; }
legend { color: var(--muted); font-size: 13px; padding: 0 7px; font-weight: 700; }
label.inline { display: inline-flex; align-items: center; gap: 7px; margin-right: 16px; margin-bottom: 6px; color: var(--text); font-size: 14px; cursor: pointer; }
label.inline input { width: auto; margin: 0; }

/* --- Source status cards ------------------------------------------------ */
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.source-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .1s ease, border-color .15s ease;
}
.source-card:hover { border-color: var(--teal); transform: translateY(-2px); }
.source-card .head { display: flex; align-items: center; gap: 10px; }
.source-card .icon-wrap {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--panel-2); display: grid; place-items: center; color: var(--teal);
}
.source-card .name { font-weight: 800; font-size: 15px; color: #fff; }
.source-card .key { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.source-card .status { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.source-card .meta { font-size: 12px; color: var(--muted); }

/* --- Dashboard ---------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}
.dashboard-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.dashboard-card h2 { margin: 0 0 14px; font-size: 16px; }

/* --- Login -------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 30% 20%, rgba(0,180,179,0.12) 0%, transparent 40%),
              radial-gradient(circle at 80% 80%, rgba(255,107,26,0.10) 0%, transparent 40%),
              var(--bg);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.login-card .brand { margin-bottom: 18px; }
.login-card h1 { margin-bottom: 20px; font-size: 22px; }
.login-card .error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 11px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}

/* --- Toasts ------------------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 9px;
  padding: 13px 17px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  max-width: 320px;
  font-weight: 500;
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Loading state ------------------------------------------------------ */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- View toggle -------------------------------------------------------- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.view-toggle button {
  background: var(--panel-2);
  border: none;
  color: var(--muted);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.view-toggle button.active { background: var(--teal); color: var(--navy); }
.view-toggle button:hover { color: var(--text); }

/* --- Mobile ------------------------------------------------------------- */
@media (max-width: 860px) {
  .menu-toggle { display: block; }
  nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 12px 18px;
    gap: 3px;
  }
  nav.open { display: flex; }
  nav a { padding: 11px 13px; width: 100%; }
  header .actions { display: none; }
  .detail-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .hero-content h2 { font-size: 22px; }
  .pipeline { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  main { padding: 16px 12px 50px; }
  h1 { font-size: 22px; }
  .stats-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .grid th, .grid td { padding: 10px; font-size: 13px; }
  .filter-grid { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .hero-deals { grid-template-columns: 1fr; }
}

/* --- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
