:root {
  --accent: #cf6a1a;
  --accent-dark: #a8550f;
  --ink: #17181a;
  --border: #e3e0d9;
  --bg: #f0eeea;
  --card: #ffffff;
  --danger: #c0392b;
  --ok: #1f8a4d;
  --muted: #5c5952;
  --faint: #8a867e;
  --faint-2: #9a968e;
  font-family: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
}

.mono {
  font-family: 'IBM Plex Mono', monospace;
}

.label-mono {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  font-weight: 500;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
}

.logo-chip {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.wordmark-title { font-weight: 800; font-size: 15px; line-height: 1.2; }
.wordmark-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

header nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
header nav::-webkit-scrollbar { display: none; }

nav button {
  position: relative;
  border: none;
  background: none;
  padding: 9px 15px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  white-space: nowrap;
}

nav button.active {
  background: var(--ink);
  color: #fff;
}

.nav-badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

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

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--border);
}
.btn.secondary:hover { border-color: var(--ink); }

.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: top;
}

th {
  background: #f7f5f1;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

tr { cursor: default; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #faf9f6; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.new { background: #e4eefb; color: #2b6cb0; }
.badge.contacted { background: #ede4fb; color: #6b3fc7; }
.badge.quoted { background: #fde7d3; color: var(--accent); }
.badge.negotiating { background: #f7ecd2; color: #93650f; }
.badge.won { background: #e0f3e6; color: var(--ok); }
.badge.lost { background: #f8dfdc; color: var(--danger); }
.badge.published { background: #e0f3e6; color: var(--ok); }
.badge.draft { background: #eee; color: #666; }

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot.new { background: #2b6cb0; }
.dot.contacted { background: #6b3fc7; }
.dot.quoted { background: var(--accent); }
.dot.negotiating { background: #93650f; }
.dot.won { background: var(--ok); }
.dot.lost { background: var(--danger); }

select, input[type="text"], input[type="url"], input[type="number"], input[type="search"], input[type="file"], textarea {
  width: 100%;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 100px; resize: vertical; }

label {
  display: block;
  font-weight: 700;
  font-size: 12.5px;
  margin-bottom: 5px;
  margin-top: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.error {
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 600;
  margin: 8px 0;
}

.success { color: var(--ok); font-size: 13.5px; font-weight: 600; margin: 8px 0; }

.muted { color: var(--muted); font-size: 13px; }
.faint { color: var(--faint); font-size: 13px; }

.row-actions { display: flex; gap: 8px; }
.row-actions button { padding: 6px 10px; font-size: 12.5px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--faint);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

/* ---------- Dashboard summary ---------- */

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.dash-greeting { font-size: 24px; font-weight: 800; margin: 4px 0 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.stat-tile:hover { border-color: var(--ink); }
.stat-tile.alert { background: #fdf1ef; border-color: #f0c3ba; }
.stat-tile .big { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; }
.stat-tile.alert .big { color: var(--danger); }

.pipeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.pipeline-stage {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.pipeline-stage:hover { border-color: var(--ink); }
.pipeline-stage .stage-name { font-weight: 700; font-size: 13.5px; }
.pipeline-stage .stage-count { font-size: 26px; font-weight: 800; margin-top: 6px; }
.pipeline-stage .stage-value { font-size: 12px; color: var(--faint); margin-top: 2px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.activity-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.activity-row:last-child { border-bottom: none; }
.activity-row .who { font-weight: 700; }

.followup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.followup-row:last-child { border-bottom: none; }
.followup-row:hover { color: var(--accent); }

/* ---------- Lead detail ---------- */

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.copy-field {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.copy-field .copied-flash {
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
}
.copy-field .copied-flash.show { opacity: 1; }

.timeline-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-entry:last-child { border-bottom: none; }
.timeline-entry .entry-meta { font-size: 12px; color: var(--faint); margin-bottom: 3px; }
.timeline-entry .entry-type {
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 600;
}

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input[type="search"] { flex: 1; min-width: 200px; }
.filter-bar select { width: auto; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Mobile ---------- */

.menu-toggle { display: none; }
.mobile-menu-overlay { display: none; }
.mobile-menu { display: none; }

@media (max-width: 900px) {
  header { padding: 10px 16px; gap: 12px; }
  /* The pill-strip nav that lives in the header only works with room to
     breathe (it's a horizontal scroller) — on a phone-width header it was
     squeezed into a tiny scrolling box. Below, a slide-out side menu
     (opened via the hamburger button) takes over as the real navigation. */
  header nav { display: none; }
  main { padding: 16px 16px 48px; }
  .stat-grid { grid-template-columns: 1fr; }
  .pipeline-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }

  .menu-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    border: none;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    padding: 9px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
  }
  .menu-toggle svg { flex-shrink: 0; transition: transform 0.15s; }
  .menu-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

  .mobile-menu-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: transparent;
    pointer-events: none;
  }
  .mobile-menu-overlay.open { pointer-events: auto; }

  .mobile-menu {
    display: block;
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 201;
    width: min(220px, 68vw);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.3);
    padding: 8px;
    transform-origin: top right;
    transform: scale(0.95) translateY(-6px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
  }
  .mobile-menu.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }

  .mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .mobile-menu-nav button {
    position: relative;
    text-align: left;
    border: none;
    background: none;
    padding: 11px 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    border-radius: 9px;
  }
  .mobile-menu-nav button.active { background: var(--ink); color: #fff; }
  .mobile-menu-nav .nav-badge { position: static; margin-left: 8px; }
}

@media (max-width: 600px) {
  .pipeline-grid { grid-template-columns: repeat(2, 1fr); }
}
