/*
  Vodafone IoT — Intelligence Hub
  Palette per Atlas binding spec §9.2: white default background, near-black text,
  Vodafone Red used sparingly (CTAs / accents, never a full background),
  Aqua and Aubergine reserved for data-viz chips and category badges.
*/
:root {
  --vf-red: #e60000;
  --vf-red-dark: #bd0000;
  --vf-aqua: #00b0ca;
  --vf-aubergine: #5e2750;
  --vf-ink: #0d0d0d;

  --surface: #ffffff;     /* default page background */
  --surface-1: #f4f4f4;   /* section bands, cards-behind-body */
  --surface-2: #ffffff;   /* raised cards / inputs */
  --line: #e0e0e0;        /* borders, rules, dividers */
  --muted: #666666;       /* secondary text, captions */
  --muted-2: #8a8a8a;     /* tertiary text */

  /* Category accents (data-viz only) */
  --iot: #00b0ca;
  --telecom: #5e2750;
  --g5: #e60000;
  --networking: #008a99;
  --hardware: #99286f;
  --security: #bd0000;

  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', "IBM Plex Sans", system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface-1);
  color: var(--vf-ink);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(230, 0, 0, 0.18); }

/* ---- Header ---- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 1.75rem 1.5rem 1.5rem;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.rep-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.rep-name { font-weight: 700; color: var(--vf-ink); }
.my-opps-btn { border-color: var(--vf-red) !important; color: var(--vf-red) !important; font-weight: 700; }
.my-opps-btn.active { background: var(--vf-red) !important; color: #fff !important; }
.all-opps-btn { border-color: var(--vf-aubergine) !important; color: var(--vf-aubergine) !important; font-weight: 700; }
.all-opps-btn.active { background: var(--vf-aubergine) !important; color: #fff !important; border-color: var(--vf-aubergine) !important; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark { display: block; flex-shrink: 0; }

.brand-lockup { line-height: 1.15; }

.brand-name {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--vf-ink);
}

.brand-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--vf-red);
}

.subtitle {
  color: var(--muted);
  margin-top: 0.8rem;
  font-size: 0.95rem;
  max-width: 60ch;
}

/* ---- Layout ---- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.filter-btn:hover { border-color: var(--vf-red); color: var(--vf-ink); }
.filter-btn.active {
  background: var(--vf-red);
  color: #fff;
  border-color: var(--vf-red);
}

.meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--vf-red); cursor: pointer; }

.sector-select {
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--vf-ink);
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.sector-select:focus { outline: none; border-color: var(--vf-red); }

#refresh-btn {
  background: var(--surface-2);
  color: var(--vf-red);
  border: 1px solid var(--line);
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

#refresh-btn:hover { background: var(--vf-red); color: #fff; border-color: var(--vf-red); }
#refresh-btn.spinning { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ---- Article grid ---- */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.2rem;
}

.article-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.article-card:hover {
  border-color: var(--line);
  box-shadow: 0 6px 22px rgba(13, 13, 13, 0.08);
  transform: translateY(-2px);
}

.article-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.article-card .category-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-iot { background: rgba(0,176,202,0.12); color: var(--iot); }
.badge-telecom { background: rgba(94,39,80,0.12); color: var(--telecom); }
.badge-5g { background: rgba(230,0,0,0.10); color: var(--vf-red); }
.badge-networking { background: rgba(0,138,153,0.12); color: var(--networking); }
.badge-hardware { background: rgba(153,40,111,0.12); color: var(--hardware); }
.badge-security { background: rgba(189,0,0,0.10); color: var(--security); }
.badge-general { background: rgba(102,102,102,0.10); color: var(--muted); }
.badge-competitor { background: rgba(230,0,0,0.10); color: var(--vf-red); }
.badge-supplier { background: rgba(94,39,80,0.12); color: var(--vf-aubergine); }
.badge-customer { background: rgba(0,176,202,0.14); color: var(--networking); }

/* ---- Search bar (prominent) ---- */
.search-wrap {
  margin-bottom: 1.5rem;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 0 1.1rem;
  box-shadow: 0 2px 10px rgba(13,13,13,0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-box:focus-within {
  border-color: var(--vf-red);
  box-shadow: 0 0 0 4px rgba(230,0,0,0.10);
}
.search-icon { color: var(--muted); flex-shrink: 0; }
.search-box:focus-within .search-icon { color: var(--vf-red); }
#search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 1rem 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--vf-ink);
  outline: none;
}
#search-input::placeholder { color: var(--muted-2); font-weight: 400; }
#search-input::-webkit-search-cancel-button { display: none; }
#search-clear {
  border: none;
  background: var(--surface-1);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
#search-clear:hover { background: var(--vf-red); color: #fff; }

/* ---- Card footer + New Opp button ---- */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: auto;
  flex-wrap: wrap;
}
.new-opp-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.new-opp-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.new-opp-btn .opp-score {
  background: rgba(255,255,255,0.28);
  border-radius: 999px;
  padding: 0.02rem 0.4rem;
  font-size: 0.72rem;
}
.opp-spark { font-size: 0.85rem; }
.opp-hot { background: var(--vf-red); }
.opp-warm { background: #e07c1a; }
.opp-cool { background: var(--vf-aubergine); }

/* ---- New Opp modal ---- */
.opp-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,13,13,0.55);
  z-index: 1000;
  padding: 1.5rem;
  overflow-y: auto;
}
.opp-modal.open { display: flex; align-items: flex-start; justify-content: center; }
.opp-modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 600px;
  width: 100%;
  margin: 4vh auto;
  padding: 1.8rem 1.9rem 1.6rem;
  position: relative;
  box-shadow: 0 18px 60px rgba(13,13,13,0.30);
}
.opp-modal-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  border: none;
  background: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.opp-modal-close:hover { color: var(--vf-red); }
.opp-modal-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.opp-heat {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}
.opp-modal-card h2 { font-size: 1.25rem; font-weight: 700; line-height: 1.35; margin-bottom: 0.5rem; }
.opp-section { margin-top: 1.1rem; }
.opp-section h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.opp-section p { font-size: 0.95rem; line-height: 1.55; }
.opp-angle {
  background: rgba(230,0,0,0.05);
  border-left: 3px solid var(--vf-red);
  padding: 0.7rem 0.9rem;
  border-radius: 0 8px 8px 0;
}
.opp-angle h4 { color: var(--vf-red); }
.opp-modal-actions { margin-top: 1.4rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.opp-modal-actions .btn-primary { display: inline-block; text-decoration: none; border: none; cursor: pointer; font-family: inherit; }
.login-modal-card { max-width: 460px; }
.login-modal-card form { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 1rem; }
.login-modal-card h2 { font-size: 1.35rem; }
.login-modal-card .btn-primary, .login-card .btn-primary { width: 100%; padding: 0.9rem; font-size: 1.05rem; }

/* AI outreach output */
.outreach-out { margin-top: 1.2rem; }
.outreach-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  position: relative;
}
.outreach-card h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--vf-red); margin: 0.9rem 0 0.3rem; }
.outreach-card h4:first-child { margin-top: 0; }
.outreach-card p { font-size: 0.9rem; line-height: 1.5; margin: 0.3rem 0; }
.outreach-card ul { margin: 0.3rem 0 0.3rem 1.1rem; }
.outreach-card li { font-size: 0.9rem; line-height: 1.45; }
.copy-outreach { margin-top: 0.7rem; }

/* ---- Leadership dashboard ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.kpi-val { font-size: 2rem; font-weight: 800; color: var(--vf-red); line-height: 1; }
.kpi-label { font-size: 0.82rem; font-weight: 600; margin-top: 0.35rem; }
.kpi-sub { font-size: 0.72rem; color: var(--muted); }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .dash-cols { grid-template-columns: 1fr; } }

.dash-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0; font-size: 0.88rem; }
.dash-row-label { flex: 0 0 38%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-row-label a { color: var(--vf-ink); text-decoration: none; }
.dash-row-label a:hover { color: var(--vf-red); }
.dash-bar-track { flex: 1; height: 8px; background: var(--surface-1); border-radius: 999px; overflow: hidden; }
.dash-bar-fill { height: 100%; background: linear-gradient(90deg, var(--vf-aubergine), var(--vf-red)); border-radius: 999px; }
.dash-row-val { flex: 0 0 auto; font-weight: 600; min-width: 54px; text-align: right; }
.hot-pip { background: var(--vf-red); color: #fff; font-size: 0.66rem; font-weight: 700; padding: 0.05rem 0.4rem; border-radius: 999px; }

.top-opp-list { display: flex; flex-direction: column; gap: 0.8rem; }
.top-opp { display: flex; gap: 0.8rem; align-items: flex-start; }
.top-opp .opp-heat { flex: 0 0 auto; min-width: 36px; text-align: center; }
.top-opp a { color: var(--vf-ink); text-decoration: none; }
.top-opp a:hover { color: var(--vf-red); }

/* AI account brief (admin) */
.brief-body h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--vf-red); margin: 1rem 0 0.3rem; }
.brief-body h4:first-child { margin-top: 0; }
.brief-body p { font-size: 0.92rem; line-height: 1.55; margin: 0.3rem 0; }
.brief-body ul { margin: 0.3rem 0 0.3rem 1.1rem; }
.brief-body li { font-size: 0.92rem; line-height: 1.5; }

/* ---- Admin section ---- */
.admin-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.25rem;
}
.admin-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; }
.muted-text { color: var(--muted); font-size: 0.85rem; }
.login-card { max-width: 420px; margin: 2rem auto 1rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.back-link, .card-head-row { text-align: center; }
.back-link a, .ghost-link, .view-link { color: var(--vf-red); text-decoration: none; font-size: 0.85rem; }

.btn-primary {
  background: var(--vf-red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--vf-red-dark); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.form-error { color: var(--vf-red); font-size: 0.85rem; margin-top: 0.5rem; min-height: 1rem; }

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.ghost-link {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
.ghost-link:hover { border-color: var(--vf-red); }
.ghost-link.danger { color: var(--vf-red); }

.add-row { display: flex; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }
/* Form inputs (login boxes, admin forms) — comfortably sized, brand-styled */
.input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--vf-ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus { border-color: var(--vf-red); box-shadow: 0 0 0 3px rgba(230,0,0,0.10); }
.input::placeholder { color: var(--muted-2); }

.add-row .input { flex: 1; min-width: 220px; }

.card-head-row { display: flex; justify-content: space-between; align-items: baseline; }

table.customers { width: 100%; border-collapse: collapse; margin-top: 0.8rem; font-size: 0.88rem; }
table.customers th, table.customers td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
table.customers th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
table.customers td.num, table.customers th.num { text-align: right; }
table.customers .cust-name { font-weight: 600; }
table.customers .actions { text-align: right; white-space: nowrap; display: flex; gap: 0.4rem; justify-content: flex-end; }

/* Vodafone IoT relevance pill */
.relevance-pill {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.rel-high { background: var(--vf-red); color: #fff; }
.rel-medium { background: rgba(94,39,80,0.12); color: var(--vf-aubergine); border-color: rgba(94,39,80,0.25); }
.rel-low { background: var(--surface-1); color: var(--muted); border-color: var(--line); }
.rel-none { background: var(--surface-1); color: var(--muted-2); border-color: var(--line); }

/* "AI" marker on Claude-assessed relevance pills */
.ai-mark {
  margin-left: 0.4rem;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.04rem 0.28rem;
  border-radius: 3px;
  background: rgba(255,255,255,0.25);
  vertical-align: middle;
}
.rel-medium .ai-mark, .rel-low .ai-mark, .rel-none .ai-mark {
  background: rgba(13,13,13,0.08);
  color: var(--vf-ink);
}

/* Claude's one-line "why it matters" rationale */
.rationale {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--vf-ink);
  background: var(--surface-1);
  border-left: 3px solid var(--vf-aqua);
  padding: 0.45rem 0.6rem;
  border-radius: 0 6px 6px 0;
}
.rationale-label {
  font-weight: 700;
  color: var(--vf-aubergine);
}

/* Vodafone IoT focus-area tags (how the story maps to the business) */
.focus-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.focus-tag {
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(0,176,202,0.12);
  color: var(--networking);
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.2px;
}

.article-card .source {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.article-card h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.article-card h3 a {
  color: var(--vf-ink);
  text-decoration: none;
}

.article-card h3 a:hover { color: var(--vf-red); }

.article-card .summary {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card .topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.topic-tag {
  font-size: 0.65rem;
  font-weight: 500;
  background: rgba(0,176,202,0.10);
  color: var(--networking);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  letter-spacing: 0.3px;
}

.article-card .date {
  font-size: 0.75rem;
  color: var(--muted-2);
  margin-top: auto;
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}

#load-more-wrap {
  text-align: center;
  padding: 2rem;
}

#load-more-btn {
  background: var(--surface-2);
  color: var(--vf-red);
  border: 1px solid var(--line);
  padding: 0.6rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

#load-more-btn:hover { background: var(--vf-red); color: #fff; border-color: var(--vf-red); }

/* ---- Footer ---- */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  background: var(--surface);
}

.footer-brand {
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--vf-ink);
  letter-spacing: 0.02em;
}

footer a { color: var(--vf-red); text-decoration: none; }

@media (max-width: 600px) {
  header { padding: 1.25rem 1rem; }
  .brand-name { font-size: 1.3rem; }
  .controls { flex-direction: column; align-items: stretch; }
  .meta { justify-content: center; }
  .articles-grid { grid-template-columns: 1fr; }
}
