/* Local Eats — leads portal. Brand tokens + portal shell. Styling mirrors
 * terminal.local-eats.co.uk: red #E30613 header, gray-50 body, white
 * rounded cards with gray-200 borders, system font, 700-weight headings. */

:root {
  /* Red ramp from terminal.local-eats.co.uk */
  --brand-50:  #fef2f2;
  --brand-100: #fee2e2;
  --brand-200: #fecaca;
  --brand-300: #fca5a5;
  --brand-400: #f87171;
  --brand-500: #E30613;
  --brand-600: #cc0511;
  --brand-700: #b0040e;
  --brand-800: #8a030b;
  --brand-900: #6b0209;

  --accent: #F39200;
  --accent-600: #C77600;

  /* Neutral gray ramp (Tailwind gray) */
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Semantic */
  --bg: var(--gray-50);
  --card: #ffffff;
  --line: var(--gray-200);
  --line-strong: var(--gray-300);
  --ink: var(--gray-900);
  --muted: var(--gray-500);

  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --info: #1d4ed8;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow: 0 4px 12px rgba(17, 24, 39, 0.06);

  --font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  margin: 0 0 .5em;
  line-height: 1.25;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }

/* ------------------------------- Layout ------------------------------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--brand-500);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.topbar .logo img {
  height: 36px;
  display: block;
  filter: brightness(0) invert(1); /* white logo on red */
}
.topbar-menu {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 20px;
}
.topbar nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  flex-wrap: wrap;
}
/* Burger — hidden on desktop */
.burger { display: none; }
.nav-toggle { position: absolute; left: -9999px; }
.topbar nav a {
  color: rgba(255, 255, 255, 0.86);
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-size: .92rem;
}
.topbar nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; text-decoration: none; }
.topbar nav a.active { background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; color: rgba(255, 255, 255, 0.85); }
.topbar .who strong { color: #fff; font-weight: 600; }
.topbar .who form { display: inline; margin-left: 8px; }
.topbar .who button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 0;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
}
.topbar .who button:hover { background: rgba(255,255,255,0.25); }

main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; padding: 10px 16px; gap: 12px; }
  .topbar .logo img { height: 30px; }
  .topbar .spacer { display: none; }

  /* Burger button */
  .burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    margin-left: auto;
    cursor: pointer;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, 0.12);
    padding: 0 10px;
    transition: background .12s;
  }
  .burger:hover { background: rgba(255, 255, 255, 0.22); }
  .burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
  }
  #nav-toggle:checked ~ .burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  #nav-toggle:checked ~ .burger span:nth-child(2) { opacity: 0; }
  #nav-toggle:checked ~ .burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* Menu — collapsed by default, expanded when toggle is checked.
     flex-basis: 100% forces it onto its own row below the logo + burger. */
  .topbar-menu {
    display: none;
    order: 3;
    flex: 0 0 100%;
    max-width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    margin-top: 4px;
  }
  #nav-toggle:checked ~ .topbar-menu { display: flex; }

  .topbar nav {
    flex-direction: column;
    width: 100%;
    gap: 2px;
    margin-left: 0;
  }
  .topbar nav a { padding: 10px 12px; font-size: .95rem; border-radius: var(--radius-xs); }

  .topbar .who {
    margin-left: 0;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: .85rem;
  }

  main { padding: 20px 16px 40px; }
  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.1rem; }
}
@media (max-width: 480px) {
  .topbar .logo img { height: 28px; }
  .topbar .who strong { font-size: .8rem; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ------------------------------- Cards -------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.card h2, .card h3 { margin-top: 0; }
.card.table { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid:last-child { margin-bottom: 0; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* ------------------------------- KPI ---------------------------------- */
.kpi {
  background: var(--card);
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.kpi .label {
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.kpi .value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-top: 4px;
  color: var(--gray-900);
}
.kpi .value.brand  { color: var(--brand-600); }
.kpi .value.accent { color: var(--accent); }
@media (max-width: 640px) {
  .kpi { padding: 14px 16px; }
  .kpi .value { font-size: 1.5rem; }
}

/* ------------------------------- Tables ------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  font-size: .72rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  background: var(--gray-50);
  white-space: nowrap;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: 0; }

/* Stacked table view on mobile — each <td data-label="…"> gets its label above
 * the value, so wide tables turn into a list of readable rows. Opt in per
 * table with class="stackable". */
@media (max-width: 640px) {
  table.stackable,
  table.stackable thead,
  table.stackable tbody,
  table.stackable tr,
  table.stackable th,
  table.stackable td { display: block; }
  table.stackable thead { display: none; }
  table.stackable tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }
  table.stackable tr:last-child { border-bottom: 0; }
  table.stackable tr:hover { background: var(--gray-50); }
  table.stackable td {
    padding: 4px 0;
    border: 0;
    font-size: .92rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  table.stackable td::before {
    content: attr(data-label);
    display: block;
    font-size: .68rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 2px;
  }
  table.stackable td[data-label=""]::before,
  table.stackable td:not([data-label])::before { display: none; }
  table.stackable td.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .card.table { overflow-x: visible; }
}

/* ------------------------------- Buttons ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1.1;
  font-family: var(--font-sans);
  white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--brand-500); color: #fff; }
.btn-primary:hover { background: var(--brand-600); color: #fff; text-decoration: none; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-600); color: #fff; text-decoration: none; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-50); color: var(--gray-900); text-decoration: none; }
.btn-danger { background: #fff; border-color: var(--brand-200); color: var(--brand-700); }
.btn-danger:hover { background: var(--brand-50); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ------------------------------- Forms -------------------------------- */
form .field { margin-bottom: 14px; }
label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  font: inherit;
  font-family: var(--font-sans);
  background: #fff;
  color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88rem;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
}
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }

/* ------------------------------- Chips -------------------------------- */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip.new          { background: #FFF7ED; color: #9A3412; border-color: #FED7AA; }
.chip.contacted    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }
.chip.engaged      { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.chip.booked       { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.chip.won          { background: var(--brand-500); color: #fff; }
.chip.lost         { background: var(--gray-100); color: var(--gray-500); border-color: var(--gray-200); }
.chip.unsubscribed { background: #FEE2E2; color: #991B1B; border-color: #FECACA; }

/* ------------------------------- Flashes ------------------------------ */
.flash-stack { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
  border: 1px solid transparent;
  font-weight: 500;
}
.flash.success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.flash.error   { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.flash.info    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }

/* ------------------------------- Pipeline ----------------------------- */
.pipeline { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.pipeline .col {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.pipeline .col:hover { border-color: var(--line-strong); }
.pipeline .col h4 {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 6px;
  font-weight: 600;
}
.pipeline .col .count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}
.pipeline .col.new     .count { color: var(--accent); }
.pipeline .col.booked  .count { color: var(--ok); }
.pipeline .col.won     .count { color: var(--brand-600); }
@media (max-width: 1024px) { .pipeline { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 640px)  { .pipeline { grid-template-columns: repeat(2, 1fr); gap: 8px; } .pipeline .col { padding: 10px; } .pipeline .col .count { font-size: 1.3rem; } }

/* ------------------------------- Auth --------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 500px at 12% -10%, rgba(243, 146, 0, 0.18), transparent),
    radial-gradient(900px 500px at 100% 110%, rgba(227, 6, 19, 0.18), transparent),
    var(--bg);
  padding: 24px;
}
.auth .panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px 34px 32px;
  width: 420px;
  max-width: calc(100vw - 32px);
  border: 1px solid var(--line);
}
.auth .panel .logo { display: flex; justify-content: center; margin-bottom: 20px; }
.auth .panel .logo img { height: 46px; display: block; }
.auth .panel h1 { text-align: center; font-size: 1.4rem; margin-bottom: 4px; }
.auth .panel .sub { text-align: center; color: var(--muted); margin-bottom: 18px; }

/* ------------------------------- Misc --------------------------------- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.row .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.wrap-anywhere { overflow-wrap: anywhere; word-break: break-word; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--gray-100);
  font-size: .7rem;
  color: var(--gray-700);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-red {
  background: var(--brand-500);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

code, pre {
  background: var(--gray-900);
  color: #E6E8EF;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
code { white-space: nowrap; }
pre { padding: 12px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
td code { max-width: 100%; display: inline-block; vertical-align: middle; }

/* ------------------------------- Filters ------------------------------ */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 180px; }
@media (max-width: 480px) {
  .filters { flex-direction: column; align-items: stretch; }
  .filters input, .filters select { width: 100%; min-width: 0; }
  .filters .btn { width: 100%; justify-content: center; }
}

/* ------------------------------- Timeline ----------------------------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: #fff;
}
.timeline li.inbound  { border-left-color: var(--accent); }
.timeline li.outbound { border-left-color: var(--brand-500); }
.timeline li .when { color: var(--muted); font-size: .8rem; }
.timeline li .subject { font-weight: 600; color: var(--gray-900); }
