/* ═══════════════════════════════════════════════════
   CLIENT RADAR — DESIGN TOKENS
   Change colors and font sizes here only.
   ═══════════════════════════════════════════════════ */
:root {
  /* ── Background layers ── */
  --bg:         #000000;
  --surface:    #0c0c0c;
  --surface-2:  #131313;
  --surface-3:  #1a1a1a;

  /* ── Borders ── */
  --border:       #1c1c1c;
  --border-2:     #252525;
  --border-focus: #4a4a4a;

  /* ── Text ── */
  --text:    #ffffff;
  --text-2:  #999999;
  --text-3:  #555555;
  --text-4:  #2e2e2e;

  /* ── Functional ── */
  --red:    #d93636;
  --amber:  #c98a00;
  --green:  #1f9a5c;

  /* ── Font Sizes ── */
  --fs-xs:   10px;
  --fs-sm:   12px;
  --fs-base: 14px;
  --fs-md:   15px;
  --fs-lg:   17px;
  --fs-xl:   20px;
  --fs-2xl:  26px;
  --fs-3xl:  34px;
  --fs-4xl:  48px;

  /* ── Font Weights ── */
  --fw-light:    300;
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;

  /* ── Geometry ── */
  --radius-sm: 3px;
  --radius:    6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* ── Font ── */
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ─── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
select, input, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ─── Layout ─────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 32px;
  height: 56px;
}
.nav-logo {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
  flex-shrink: 0;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-link {
  font-size: var(--fs-sm);
  color: var(--text-3);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color .15s;
  font-weight: var(--fw-medium);
  letter-spacing: .01em;
}
.nav-link:hover { color: var(--text-2); }
.nav-link.active { color: var(--text); }

.wrap {
  max-width: 1260px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

/* ─── Page Header ────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -.02em;
}
.page-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 4px;
}
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ─── Grid ───────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }

/* ─── Cards ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-sm { padding: 16px; }
.card-lg { padding: 28px; }

/* ─── Stat Cards ─────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.stat-value {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-top: 8px;
}
.stat-sub {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 4px;
}

/* ─── Section ────────────────────────────────────── */
.section { margin-top: 28px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-3);
}
.section-count {
  font-size: var(--fs-xs);
  color: var(--text-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
}

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--radius);
  padding: 7px 16px;
  border: 1px solid transparent;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
  letter-spacing: .01em;
}
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover { opacity: .85; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn-ghost:hover { border-color: var(--border-focus); color: var(--text); }
.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: #2e1010;
}
.btn-danger:hover { background: #1a0a0a; }
.btn-sm { font-size: var(--fs-xs); padding: 4px 10px; }
.btn-icon {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: var(--fs-sm);
  transition: border-color .15s, color .15s;
}
.btn-icon:hover { border-color: var(--border-focus); color: var(--text); }

/* ─── Inputs ─────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--fs-base);
  padding: 9px 13px;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.input:focus { border-color: var(--border-focus); }
.input::placeholder { color: var(--text-4); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.5; }
.input-sm { padding: 6px 10px; font-size: var(--fs-sm); }

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.label {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
  font-weight: var(--fw-medium);
}

/* ─── Table ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
.td-muted { color: var(--text-3); }

/* ─── Badges ─────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  border-radius: 99px;
  padding: 2px 8px;
  border: 1px solid;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-ig  { color: #bbb; border-color: #2a2a2a; background: #0f0f0f; }
.badge-yt  { color: #bbb; border-color: #2a2a2a; background: #0f0f0f; }
.badge-li  { color: #bbb; border-color: #2a2a2a; background: #0f0f0f; }
.status-found          { color: #555; border-color: #222; }
.status-contacted      { color: #888; border-color: #303030; }
.status-replied        { color: #bbb; border-color: #404040; }
.status-on-call        { color: #ddd; border-color: #555; }
.status-converted      { color: #fff; border-color: #fff; }
.status-no-reply       { color: #444; border-color: #1e1e1e; }
.status-not-interested { color: #333; border-color: #1a1a1a; }
.badge-overdue { color: var(--red);   border-color: #2e1010; background: #100808; }
.badge-today   { color: var(--amber); border-color: #2e2000; background: #0f0a00; }
.badge-cold    { color: var(--text-3); border-color: var(--border); font-style: italic; }

/* ─── Stars ──────────────────────────────────────── */
.stars { display: inline-flex; gap: 1px; }
.star { font-size: 12px; color: var(--text-4); }
.star.on { color: var(--text-2); }

.star-rating { display: flex; gap: 4px; flex-direction: row-reverse; justify-content: flex-end; }
.star-rating input[type=radio] { display: none; }
.star-rating label {
  font-size: 20px;
  color: var(--surface-3);
  cursor: pointer;
  transition: color .1s;
}
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label { color: var(--text-2); }

/* ─── Status Inline Select ───────────────────────── */
.status-select {
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
  letter-spacing: .03em;
}
.status-select:focus { border-color: var(--border-focus); }

/* ─── Platform Buttons ───────────────────────────── */
.platform-btns { display: flex; gap: 8px; }
.platform-btn { flex: 1; position: relative; }
.platform-btn input { position: absolute; opacity: 0; width: 0; height: 0; }
.platform-btn span {
  display: block;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--text-3);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.platform-btn input:checked + span {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface-2);
}
.platform-btn span:hover { border-color: var(--border-focus); color: var(--text-2); }

/* ─── Keyword Chips ──────────────────────────────── */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; }
.chip {
  font-size: var(--fs-xs);
  padding: 4px 10px;
  border: 1px solid var(--border-2);
  border-radius: 99px;
  color: var(--text-3);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--border-focus); color: var(--text); }

/* ─── Quick Dates ────────────────────────────────── */
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; }
.qdate-btn {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  padding: 5px 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  transition: border-color .15s, color .15s;
}
.qdate-btn:hover { border-color: var(--border-focus); color: var(--text); }

/* ─── Modal ──────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: var(--fs-md);
  transition: color .15s, border-color .15s;
}
.modal-close:hover { color: var(--text); border-color: var(--border-focus); }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─── Flash ──────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  margin-bottom: 20px;
  border: 1px solid;
}
.flash-success { background: #091a10; border-color: #1a3a22; color: #6dcc96; }
.flash-error   { background: #1a0808; border-color: #3a1818; color: #e06060; }
.flash-close { cursor: pointer; opacity: .6; font-size: var(--fs-lg); }
.flash-close:hover { opacity: 1; }

/* ─── Toast ──────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: var(--fs-sm);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  z-index: 300;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ─── Filters ────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar .input { max-width: 200px; }
.filter-bar .input-search { max-width: 260px; }

/* ─── Bar Chart (Insights) ───────────────────────── */
.chart { display: flex; flex-direction: column; gap: 10px; }
.chart-row { display: grid; grid-template-columns: 120px 1fr 60px; align-items: center; gap: 10px; }
.chart-label { font-size: var(--fs-sm); color: var(--text-2); text-align: right; }
.chart-track {
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.chart-fill {
  height: 100%;
  background: var(--text);
  border-radius: 99px;
  transition: width .4s ease;
}
.chart-val {
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ─── Insight Cards ──────────────────────────────── */
.insight-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Pagination ─────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: var(--fs-sm);
  padding: 0 8px;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--border-focus); color: var(--text); }
.page-btn.active { border-color: var(--text); color: var(--text); }
.page-btn.disabled { opacity: .3; pointer-events: none; }

/* ─── Misc ───────────────────────────────────────── */
.mt-6  { margin-top: 6px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }
.empty-state {
  padding: 48px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-bottom: 20px;
  transition: color .15s;
}
.back-link:hover { color: var(--text); }

/* ─── Template Card ──────────────────────────────── */
.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tpl-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tpl-body {
  font-size: var(--fs-sm);
  color: var(--text-2);
  white-space: pre-wrap;
  line-height: 1.6;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-height: 140px;
  overflow-y: auto;
}
.tpl-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ─── Dashboard Leads List ───────────────────────── */
.dash-lead-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.dash-lead-row:last-child { border-bottom: none; }
.dash-lead-name { flex: 1; font-weight: var(--fw-medium); }
.dash-lead-handle { color: var(--text-3); font-size: var(--fs-xs); }
.dash-lead-meta { display: flex; gap: 8px; align-items: center; }


/* ═══════════════════════════════════════════════════
   RESPONSIVE — ALL BREAKPOINTS
   ═══════════════════════════════════════════════════ */

/* ─── Tablet — 900px ─────────────────────────────── */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .insight-row { grid-template-columns: 1fr; }
  .wrap { padding: 28px 24px 56px; }
}

/* ─── Large Mobile — 768px ───────────────────────── */
@media (max-width: 768px) {

  /* ── Wrap ── */
  .wrap { padding: 20px 16px 52px; }

  /* ── Nav: 2-row layout ── */
  .nav {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px 0;
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .nav-logo {
    order: 1;
    height: 40px;
    line-height: 40px;
    flex-shrink: 0;
  }
  /* user actions (+ Add Lead, Sign out) */
  .nav > div:last-child {
    order: 2;
    margin-left: auto;
    height: 40px;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  /* hide username label on small nav */
  .nav > div:last-child > span {
    display: none;
  }
  /* nav links: full-width scrollable row 2 */
  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    white-space: nowrap;
    padding: 6px 0 8px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    gap: 2px;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-link {
    padding: 5px 10px;
    flex-shrink: 0;
    display: inline-flex;
  }

  /* ── Page Header ── */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
  }
  .page-actions {
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .page-title { font-size: var(--fs-xl); letter-spacing: -.015em; }

  /* ── Grids ── */
  .grid-2 { grid-template-columns: 1fr; }

  /* ── Section ── */
  .section { margin-top: 22px; }
  .section-header { flex-wrap: wrap; gap: 6px; }

  /* ── Filter Bar ── */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-bar .input,
  .filter-bar .input-search { max-width: 100%; width: 100%; }
  .filter-bar > button,
  .filter-bar > a { align-self: flex-start; }

  /* ── Form Rows → 1 col ── */
  .form-row,
  .form-row-3 { grid-template-columns: 1fr; gap: 0; }

  /* ── Cards ── */
  .card { padding: 16px; }
  .card-lg { padding: 20px; }
  .stat-card { padding: 16px 18px; }
  .stat-value { font-size: var(--fs-2xl); }

  /* ── Table: horizontal scroll ── */
  .table-wrap { border-radius: var(--radius); }
  .table-wrap table { min-width: 680px; }

  /* ── Modal: slides up from bottom ── */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
    overflow-y: auto;
    padding: 22px 18px 28px;
  }
  /* drag handle visual cue */
  .modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 3px;
    background: var(--border-2);
    border-radius: 99px;
    margin: 0 auto 16px;
  }
  .modal-header { margin-top: 0; }

  /* ── Platform Buttons ── */
  .platform-btn span { padding: 9px 6px; font-size: var(--fs-xs); }

  /* ── Quick Dates ── */
  .qdate-btn { font-size: 11px; padding: 5px 9px; }

  /* ── Chart ── */
  .chart-row { grid-template-columns: 88px 1fr 44px; gap: 8px; }
  .chart-label { font-size: 11px; }

  /* ── Dashboard lead rows ── */
  .dash-lead-row { flex-wrap: wrap; row-gap: 6px; padding: 11px 14px; }
  .dash-lead-meta { flex-wrap: wrap; flex: 1 1 100%; }
  .dash-lead-row > div:last-child { margin-left: auto; }

  /* ── Toast ── */
  .toast { bottom: 16px; right: 16px; left: 16px; text-align: center; }

  /* ── Back link ── */
  .back-link { margin-bottom: 14px; }

  /* ── Pagination ── */
  .pagination { gap: 3px; }
  .page-btn { min-width: 30px; height: 30px; }

  /* ── Templates grid ── */
  .tpl-card { padding: 14px 16px; }

  /* ════════════════════════════════════════════════
     INLINE-STYLE OVERRIDES (edit.php + niches.php)
     Uses attribute substring selectors to override
     inline grid styles set inside PHP templates.
     ════════════════════════════════════════════════ */

  /* edit.php: 2-col "form | sidebar" → stack */
  div[style*="1fr 340px"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }

  /* niches.php: "280px sidebar | content" → stack */
  div[style*="280px 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  /* niches.php: un-stick the sidebar on mobile */
  .card[style*="position:sticky"] {
    position: static !important;
    top: auto !important;
  }
  /* niches.php: niche list max-height removed on mobile */
  #nicheListNav {
    max-height: 260px !important;
  }

  /* edit.php: proof item thumbnails */
  .proof-item { padding: 10px 12px !important; }

  /* insights.php: key findings flex wrap */
  .card > div[style*="display:flex;flex-wrap:wrap;gap:24px"] {
    flex-direction: column !important;
    gap: 16px !important;
  }

  /* Weekly stats small cards */
  .grid-4 .card-sm { padding: 12px 14px; }
}

/* ─── Mobile — 480px ─────────────────────────────── */
@media (max-width: 480px) {

  /* ── Token overrides ── */
  :root {
    --fs-base: 13px;
    --fs-md:   14px;
    --fs-lg:   16px;
    --fs-xl:   18px;
    --fs-2xl:  22px;
    --fs-3xl:  28px;
    --fs-4xl:  38px;
  }

  /* ── Wrap ── */
  .wrap { padding: 14px 12px 44px; }

  /* ── Nav ── */
  .nav { padding: 8px 12px 0; }
  .nav-logo { font-size: 10px; letter-spacing: .15em; }
  .nav-links { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }

  /* ── Grids ── */
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .grid-3,
  .grid-2 { grid-template-columns: 1fr; }

  /* ── Stat cards ── */
  .stat-card { padding: 13px 15px; }
  .stat-value { font-size: 26px; }
  .stat-label { font-size: 9px; margin-top: 6px; }
  .stat-sub { font-size: 11px; }

  /* ── Page title ── */
  .page-title { font-size: 20px; }
  .page-subtitle { font-size: 11px; }

  /* ── Buttons ── */
  .btn { font-size: 11px; padding: 6px 11px; }
  .btn-sm { font-size: 10px; padding: 4px 9px; }
  .btn-icon { width: 28px; height: 28px; font-size: 12px; }

  /* ── Card ── */
  .card { padding: 14px 12px; border-radius: var(--radius); }
  .card-lg { padding: 16px 14px; }

  /* ── Modal ── */
  .modal { padding: 16px 14px 24px; }
  .modal-footer { gap: 6px; }
  .modal-footer .btn { flex: 1; justify-content: center; }
  .modal-title { font-size: var(--fs-base); }

  /* ── Input ── */
  .input { padding: 8px 10px; font-size: 13px; border-radius: var(--radius-sm); }
  .input-sm { padding: 5px 8px; font-size: 11px; }
  .label { font-size: 9px; letter-spacing: .06em; margin-bottom: 5px; }
  .form-group { margin-bottom: 14px; }

  /* ── Platform buttons ── */
  .platform-btn span { padding: 8px 4px; font-size: 10px; border-radius: var(--radius-sm); }

  /* ── Quick dates ── */
  .qdate-btn { font-size: 10px; padding: 4px 7px; }

  /* ── Star rating ── */
  .star-rating label { font-size: 18px; }
  .star { font-size: 11px; }

  /* ── Table ── */
  .table-wrap table { min-width: 580px; font-size: 11px; }
  thead th { padding: 8px 10px; font-size: 9px; }
  tbody td { padding: 8px 10px; }

  /* ── Chart ── */
  .chart { gap: 8px; }
  .chart-row { grid-template-columns: 72px 1fr 34px; gap: 6px; }
  .chart-label { font-size: 10px; }
  .chart-val { font-size: 10px; }
  .chart-track { height: 5px; }

  /* ── Flash ── */
  .flash { font-size: 12px; padding: 10px 13px; }

  /* ── Section ── */
  .section { margin-top: 18px; }
  .section-title { font-size: 9px; }

  /* ── Badges ── */
  .badge { font-size: 9px; padding: 2px 7px; }

  /* ── Dashboard lead rows ── */
  .dash-lead-row { padding: 9px 12px; gap: 8px; }
  .dash-lead-name { font-size: 13px; }
  .dash-lead-handle { font-size: 10px; }

  /* ── Keyword chips ── */
  .chip { font-size: 10px; padding: 3px 9px; }
  .chip-group { gap: 5px; }

  /* ── Template cards ── */
  .tpl-card { padding: 12px; gap: 8px; }
  .tpl-body { font-size: 11px; padding: 9px 11px; max-height: 110px; }
  .tpl-actions { gap: 5px; }
  .tpl-actions .btn { font-size: 10px; padding: 4px 9px; }

  /* ── Pagination ── */
  .page-btn { min-width: 28px; height: 28px; font-size: 11px; }

  /* ── Insight: keyword cloud items ── */
  div[style*="border-radius: 99px"][style*="padding: 5px 12px"] {
    font-size: 10px !important;
    padding: 4px 10px !important;
  }

  /* ── Toast ── */
  .toast { font-size: 12px; padding: 9px 14px; bottom: 14px; }

  /* ── Users table: hide Last Login + Created cols ── */
  .table-wrap table thead th:nth-child(5),
  .table-wrap table thead th:nth-child(6),
  .table-wrap table tbody td:nth-child(5),
  .table-wrap table tbody td:nth-child(6) { display: none; }

  /* ── Back link ── */
  .back-link { font-size: 11px; margin-bottom: 12px; }

  /* ── Weekly activity grid numbers ── */
  .grid-4 .card-sm div:first-child { font-size: 22px !important; }
}

/* ─── Very Small — 360px ─────────────────────────── */
@media (max-width: 360px) {
  :root {
    --fs-base: 12px;
    --fs-xl:   16px;
    --fs-2xl:  20px;
  }

  .wrap { padding: 12px 10px 40px; }
  .nav { padding: 7px 10px 0; }
  .nav-links { padding-left: 10px; padding-right: 10px; margin: 0 -10px; }

  /* 1-col all grids */
  .grid-4,
  .grid-3,
  .grid-2 { grid-template-columns: 1fr; }

  .page-title { font-size: 18px; }
  .stat-value { font-size: 22px; }
  .stat-card { padding: 12px 14px; }

  .btn { font-size: 10px; padding: 5px 10px; }
  .btn-sm { font-size: 9px; padding: 4px 8px; }

  .card { padding: 12px 10px; }
  .modal { padding: 14px 12px 20px; }

  .table-wrap table { min-width: 520px; font-size: 10px; }
  thead th { padding: 7px 8px; }
  tbody td { padding: 7px 8px; }

  /* nav: show only icon-size Add button */
  .nav > div:last-child .btn-primary { padding: 4px 8px; font-size: 10px; }
  .nav > div:last-child .btn-ghost   { padding: 4px 8px; font-size: 10px; }
}