/* ============================================================
   NE2NE brand layer on top of Pico CSS.
   Palette (Brand Guidelines 2022):
     white      #FFFFFF
     background #EBFEFF
     mint green #53EDC0
     bright blue #408AF4
     blue (navy) #1E2099
     light blue #9CCFE2
   Typeface: DM Sans (vendored, variable weight)
   ============================================================ */

@font-face {
  font-family: "DM Sans";
  src: url("fonts/dmsans.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

:root,
:root:not([data-theme=dark]),
[data-theme=light] {
  --ne-white: #ffffff;
  --ne-bg: #ebfeff;
  --ne-mint: #53edc0;
  --ne-bright: #408af4;
  --ne-navy: #1e2099;
  --ne-light: #9ccfe2;
  --ne-ink: #232557;
  --ne-muted: #6b7a99;
  --ne-border: #dcedf3;
  --ne-shadow: 0 2px 12px rgba(30, 32, 153, 0.07);

  --pico-font-family: "DM Sans", "Helvetica Neue", Arial, sans-serif;
  --pico-border-radius: 0.75rem;

  --pico-background-color: var(--ne-bg);
  --pico-color: var(--ne-ink);
  --pico-h1-color: var(--ne-navy);
  --pico-h2-color: var(--ne-navy);
  --pico-h3-color: var(--ne-navy);
  --pico-muted-color: var(--ne-muted);
  --pico-muted-border-color: var(--ne-border);

  --pico-primary: var(--ne-bright);
  --pico-primary-background: var(--ne-bright);
  --pico-primary-border: var(--ne-bright);
  --pico-primary-inverse: #ffffff;
  --pico-primary-hover: var(--ne-navy);
  --pico-primary-hover-background: var(--ne-navy);
  --pico-primary-hover-border: var(--ne-navy);
  --pico-primary-underline: rgba(64, 138, 244, 0.4);
  --pico-primary-focus: rgba(64, 138, 244, 0.35);

  --pico-secondary: var(--ne-navy);
  --pico-secondary-background: rgba(64, 138, 244, 0.08);
  --pico-secondary-border: var(--ne-light);
  --pico-secondary-inverse: var(--ne-navy);
  --pico-secondary-hover: var(--ne-navy);
  --pico-secondary-hover-background: rgba(64, 138, 244, 0.16);
  --pico-secondary-hover-border: var(--ne-bright);
  --pico-secondary-focus: rgba(64, 138, 244, 0.25);

  --pico-card-background-color: var(--ne-white);
  --pico-card-border-color: transparent;
  --pico-card-box-shadow: var(--ne-shadow);

  --pico-form-element-border-color: var(--ne-border);
  --pico-form-element-focus-color: var(--ne-bright);
  --pico-table-border-color: var(--ne-border);
}

body { min-height: 100vh; }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }

/* --- Top navigation ------------------------------------------------ */
.topnav {
  background: var(--ne-white);
  border-radius: 1rem;
  box-shadow: var(--ne-shadow);
  margin-top: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.25rem 1.25rem;
}
.topnav a { color: var(--ne-navy); font-weight: 500; text-decoration: none; }
.topnav a:hover { color: var(--ne-bright); }
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-logo { height: 2.1rem; display: block; }
.brand-text {
  font-weight: 700;
  color: var(--ne-navy);
  border-left: 2px solid var(--ne-border);
  padding-left: 0.5rem;
  line-height: 1.2;
}
.topnav details.dropdown summary { color: var(--ne-navy); font-weight: 500; }
.topnav details.dropdown ul { border-radius: 0.75rem; box-shadow: var(--ne-shadow); }

/* --- Generic layout ------------------------------------------------ */
.narrow { max-width: 32rem; margin: 2rem auto; }

article {
  border: none;
  border-radius: 1rem;
  box-shadow: var(--ne-shadow);
}
article > header {
  background: transparent;
  border-bottom: 1px solid var(--ne-border);
  color: var(--ne-navy);
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
}

.auth-card { text-align: left; }
.auth-logo { display: block; height: 4.5rem; margin: 0.5rem auto 1.25rem; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.page-head h1 { margin-bottom: 0; }
.actions { display: flex; gap: 0.5rem; align-items: center; }
.actions form { margin: 0; }
.inline-filter select { margin: 0; width: auto; }

.muted { color: var(--ne-muted); }
.small { font-size: 0.8em; }

/* --- Buttons -------------------------------------------------------- */
[role="button"], button { border-radius: 999px; font-weight: 500; }
button.danger {
  background: #d9376e;
  border-color: #d9376e;
  color: #fff;
  width: auto;
  margin-bottom: 0;
}
button.danger:hover { background: #b02456; border-color: #b02456; }
button.linklike {
  background: none;
  border: none;
  color: var(--ne-bright);
  padding: 0;
  margin: 0;
  width: auto;
  font-size: inherit;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
  display: inline;
}
button.linklike:hover { color: var(--ne-navy); }

/* --- Flash messages -------------------------------------------------- */
.flash {
  padding: 0.7rem 1.1rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  font-weight: 500;
}
.flash-success { background: rgba(83, 237, 192, 0.25); color: #0b5c44; border: 1px solid var(--ne-mint); }
.flash-error { background: #fdeaf1; color: #8e1747; border: 1px solid #f2b8cf; }
.flash-message, .flash-info { background: rgba(64, 138, 244, 0.12); color: var(--ne-navy); border: 1px solid var(--ne-light); }

/* --- Filters row ----------------------------------------------------- */
.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--ne-white);
  border-radius: 1rem;
  box-shadow: var(--ne-shadow);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.filters input, .filters select, .filters button { width: auto; margin-bottom: 0; }

/* --- Tables ----------------------------------------------------------- */
table {
  background: var(--ne-white);
  border-radius: 1rem;
  box-shadow: var(--ne-shadow);
  overflow: hidden;
}
thead th {
  color: var(--ne-navy);
  font-weight: 700;
  background: rgba(64, 138, 244, 0.06);
}
tbody tr:hover { background: rgba(235, 254, 255, 0.6); }

/* --- Badges ------------------------------------------------------------ */
.badge {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
  background: var(--ne-border);
  color: var(--ne-ink);
}
.stage-new        { background: rgba(64, 138, 244, 0.14); color: #1d4fa8; }
.stage-contacted  { background: rgba(156, 207, 226, 0.45); color: #1a5c78; }
.stage-qualified  { background: rgba(30, 32, 153, 0.12); color: var(--ne-navy); }
.stage-proposal   { background: #fff1d6; color: #8a5a00; }
.stage-won        { background: rgba(83, 237, 192, 0.35); color: #0b5c44; }
.stage-lost       { background: #fdeaf1; color: #8e1747; }
.type-call    { background: rgba(64, 138, 244, 0.14); color: #1d4fa8; }
.type-email   { background: rgba(30, 32, 153, 0.12); color: var(--ne-navy); }
.type-meeting { background: rgba(83, 237, 192, 0.35); color: #0b5c44; }
.type-other   { background: var(--ne-border); color: var(--ne-ink); }
.type-note    { background: #fff1d6; color: #8a5a00; }
.type-stage   { background: rgba(156, 207, 226, 0.45); color: #1a5c78; }

/* --- Pipeline board ------------------------------------------------------ */
.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
  margin-bottom: 1rem;
}
.board-col {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--ne-border);
  border-radius: 1rem;
  padding: 0.7rem;
  min-height: 9rem;
}
.board-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
  padding: 0 0.15rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--ne-white);
  border: 1px solid var(--ne-border);
  border-left: 4px solid var(--ne-bright);
  border-radius: 0.75rem;
  box-shadow: var(--ne-shadow);
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.6rem;
  text-decoration: none;
  color: var(--ne-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(30, 32, 153, 0.14);
  border-left-color: var(--ne-mint);
}
.card strong { color: var(--ne-navy); }

/* --- Lead detail ----------------------------------------------------------- */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; margin: 0; }
.facts dt { color: var(--ne-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.outcome-box { margin-top: 0.75rem; padding: 0.7rem 0.9rem; border-radius: 0.75rem; }
.outcome-box p { margin: 0.3rem 0 0; }
.outcome-won { background: rgba(83, 237, 192, 0.3); color: #0b5c44; border: 1px solid var(--ne-mint); }
.outcome-lost { background: #fdeaf1; color: #8e1747; border: 1px solid #f2b8cf; }

/* --- Timeline ----------------------------------------------------------------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item {
  background: var(--ne-white);
  border-radius: 0.9rem;
  box-shadow: var(--ne-shadow);
  border-left: 4px solid var(--ne-light);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.7rem;
}
.timeline-item.kind-interaction { border-left-color: var(--ne-bright); }
.timeline-item.kind-note { border-left-color: #f0c866; }
.timeline-item.kind-outcome { border-left-color: var(--ne-mint); }
.timeline-item p { margin: 0.35rem 0 0; white-space: pre-wrap; }
.timeline-head { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.timeline-head form { margin: 0; margin-left: auto; }

.row-actions { display: flex; gap: 0.75rem; }
.row-actions form { margin: 0; }

.table-scroll { overflow-x: auto; margin-bottom: 1rem; }
.context-cell { max-width: 24rem; }

article form select { margin-bottom: 0.5rem; }
