/* ---- tokens: every colour is defined here, light and dark once ---- */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #17221f;
  --muted: #5d6b66;
  --line: #e2ded4;
  --brand: #0e5a4a;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe9;
  --accent: #f4c95d;
  --accent-ink: #1d1a0f;
  --danger: #b4372f; --danger-soft: #fbe9e7; --danger-ink: #7a1f17;
  --warn: #7a5a06; --warn-soft: #fdf3d8;
  --info: #2c4f8a; --info-soft: #e5ecf8; --info-line: #9db8e8;
  --neutral: #6b6a63; --neutral-soft: #ecebe6;
  --violet: #5b3a85; --violet-line: #c9b2e3;
  --hi: #157a4d; --mid: #b07a12; --lo: #8a8f8c;
  /* the hero stays dark green in both themes */
  --hero-from: #0e5a4a; --hero-to: #0a3f34; --hero-ink: #f2f7f5; --hero-muted: #cfe2db; --hero-line: #8fc0b1;
  --display: Unbounded, Inter, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 6px 20px rgba(20, 30, 25, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614; --surface: #18201d; --ink: #e8eeeb; --muted: #9aa8a2; --line: #2a3531;
    --brand: #3fb08f; --brand-ink: #0b1311; --brand-soft: #1d2f29;
    --danger: #ef7d73; --danger-soft: #3a1d1a; --danger-ink: #f3c4bd;
    --warn: var(--accent); --warn-soft: #3a3218;
    --info: #9db8e8; --info-soft: #1f2a3d;
    --neutral: #a8aea9; --neutral-soft: #2a2f2d;
    --violet: #c9b2e3;
    --hi: #4cc78a; --mid: #e0a93a; --lo: #7d8784;
    --shadow: none;
  }
}

/* ---- base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 Inter, system-ui, sans-serif; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font: 700 clamp(1.5rem, 3.2vw, 2.1rem)/1.2 var(--display); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
main { min-height: 70vh; padding-bottom: 48px; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 860px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-line; }
.mt { margin-top: 18px; } .mt-s { margin-top: 8px; }
.inline { display: inline; margin: 0; }
.empty { text-align: center; }
.errorpage { padding: 56px 16px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 600; color: var(--muted); margin: 0 0 .6em; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.linklike:hover { color: var(--danger); }

/* ---- top bar, footer ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 1rem var(--display); color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--accent); }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--brand); }
.footer { border-top: 1px solid var(--line); padding: 22px 0; color: var(--muted); font-size: .85rem; }

/* ---- buttons (allauth's own submit buttons look the same) ---- */
.btn, .auth-card form button[type=submit], .auth-card form button:not(.linklike):not(.btn) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: .7em 1.2em; border-radius: 10px;
  border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink) !important;
  font: 600 .95rem Inter, sans-serif; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--brand) !important; }
.btn-sm { padding: .4em .8em; font-size: .85rem; }
.btn-lg { padding: .9em 1.6em; font-size: 1.05rem; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-google { width: 100%; background: var(--surface); color: var(--ink) !important; border-color: var(--line); }

/* ---- flashes ---- */
.flash { margin: 16px 0 0; padding: 12px 16px; border-radius: 10px; background: var(--brand-soft); border: 1px solid var(--line); }
.flash-error { background: var(--danger-soft); color: var(--danger-ink); }
.flash + .plans, .flash + .grid { margin-top: 14px; }
.ai-pending { display: flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---- surfaces ---- */
.card, .tcard, .step, .match { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.comment, .mini-stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.cta-box, .ai-panel { background: var(--brand-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.grid > p.muted, .grid > .empty { grid-column: 1 / -1; }      /* empty states take the whole row */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 14px; flex-wrap: wrap; }
.section-head h1, .section-head h2 { margin: 0; }
.section-head.tight { margin: 0 0 8px; }

/* ---- home ---- */
.hero { background: linear-gradient(160deg, var(--hero-from) 0%, var(--hero-to) 100%); color: var(--hero-ink); padding: 56px 0 48px; margin-bottom: 32px; }
.hero-in { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(1.6rem, 3.6vw, 2.5rem); }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { font-size: 1.08rem; color: var(--hero-muted); max-width: 620px; }
.hero .eyebrow { color: var(--accent); }
.hero .btn { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) !important; }
.hero .btn-ghost { background: transparent; border-color: var(--hero-line); color: var(--hero-ink) !important; }
.hero .ai-tag { background: var(--accent); color: var(--accent-ink); }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font: 700 1.5rem var(--display); color: var(--hero-ink); }
.stat span { font-size: .85rem; color: var(--hero-muted); }
.steps, .features, .ai-how { margin-bottom: 36px; }
.step span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; margin-bottom: 8px; }
.step p, .ai-how .grid-4 p, .feature p { margin: 0; color: var(--muted); }
.feature { text-decoration: none; color: var(--ink); }
.feature:hover { border-color: var(--brand); }
.feature b { font: 700 1.4rem var(--display); color: var(--brand); }
.feature h3 { margin: 6px 0 4px; }
.feature p, .ai-how .grid-4 p { font-size: .9rem; }

/* ---- tender and funding-call cards ---- */
.tcard { display: flex; flex-direction: column; }
.tcard h2, .match h2 { font-size: 1.02rem; }      /* card titles: h2 under the page h1, sized as h3 */
.tcard h2 a, .match h2 a { color: var(--ink); text-decoration: none; }
.tcard h2 a:hover { color: var(--brand); }
.tcard-top { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; font-size: .78rem; }
.badge, .tag { padding: 2px 9px; border-radius: 99px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.tag { display: inline-block; font-size: .72rem; padding: 1px 7px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
/* status colours — tenders, funding calls (Grant.badge) and applications share them */
.badge-planned, .badge-app-preparing { background: var(--warn-soft); color: var(--warn); }
.badge-awarded, .badge-app-submitted { background: var(--info-soft); color: var(--info); }
.badge-closed, .badge-app-lost, .badge-app-dropped { background: var(--neutral-soft); color: var(--neutral); }
.badge-cancelled { background: var(--danger-soft); color: var(--danger); }
.badge-app-won { color: var(--hi); }
.scope { padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.scope-eu { border-color: var(--info-line); color: var(--info); }
.scope-small { border-color: var(--accent); color: var(--warn); }
.scope-private { border-color: var(--violet-line); color: var(--violet); }
.scope-abroad { border-color: var(--brand); color: var(--brand); }
.deadline { color: var(--muted); }
.deadline.soon { color: var(--danger); font-weight: 600; }
.cpv { font-family: ui-monospace, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.buyer { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }
.facts { display: flex; gap: 18px; flex-wrap: wrap; margin: auto 0 0; font-size: .85rem; }
.facts dt { color: var(--muted); font-size: .75rem; }
.facts dd { margin: 0; font-weight: 600; }
.pager { display: flex; gap: 18px; justify-content: center; align-items: center; margin: 24px 0; }

/* filters: search on its own line, the selects share the next one — labels are never cut */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filters > input[type=search] { flex: 1 1 100%; }
.filters > select { flex: 1 1 180px; width: auto; min-width: 0; }
.filters > .btn { flex: 0 0 auto; min-width: 130px; }

/* ---- detail pages ---- */
.detail .dtitle { font-size: clamp(1.25rem, 2.6vw, 1.7rem); }
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin: 18px 0; align-items: start; }
.facts-v dt { color: var(--muted); font-size: .8rem; margin-top: 10px; }
.facts-v dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.match-note { border-left: 4px solid var(--hi); background: var(--surface); padding: 12px 16px; border-radius: 8px; margin: 10px 0; }
.match-note.score-mid { border-color: var(--mid); } .match-note.score-lo { border-color: var(--lo); }
.cta-box { padding: 16px; margin-top: 14px; }
.cta-box p { margin: 0 0 10px; }
.source-note { font-size: .85rem; color: var(--muted); margin-top: 10px; }

/* ---- forms ---- */
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input[type=url], input[type=tel], select, textarea {
  width: 100%; padding: .65em .8em; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.auth { display: grid; place-items: center; padding-top: 40px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card form p { margin: 0 0 14px; }
.auth-card form button[type=submit], .auth-card form button:not(.linklike):not(.btn) { width: 100%; }
.form .field { margin-bottom: 14px; }
.form label, .form .label, .auth-card form label { display: block; font-weight: 600; margin-bottom: 6px; }
.field-check label { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.err, .auth-card .errorlist { color: var(--danger); font-size: .85rem; margin-top: 4px; }
.auth-card .errorlist { padding-left: 18px; }
.has-error input { border-color: var(--danger); }
.form ul, .auth-card .helptext, .auth-card form ul { color: var(--muted); font-size: .85rem; }
.form ul { padding-left: 18px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.inline-form input[type=text] { flex: 1 1 220px; width: auto; }
.inline-form input[type=date] { width: auto; padding: .55em .6em; }
.tight-form { margin: 0; flex-wrap: nowrap; }
.tight-form input { flex: 1; min-width: 0; }
.tight-form .btn { white-space: nowrap; }
.add-form { margin-top: 12px; }
.add-form > summary { list-style: none; display: inline-flex; }
.add-form > summary::-webkit-details-marker { display: none; }
.add-form[open] > summary { display: none; }
.danger { margin-top: 24px; text-align: right; }

/* company profile form */
.company-form fieldset { border: 1px solid var(--line); margin: 0 0 16px; }
.company-form legend { font-weight: 700; font-size: 1.05rem; padding: 0 6px; display: flex; align-items: center; gap: 8px; }
.company-form legend span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: .85rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-2 { display: grid; grid-template-columns: repeat(2, 1fr); }
.chips-4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.chips > div { display: contents; }
.chip { position: relative; display: flex !important; align-items: center; gap: 8px; margin: 0 !important; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); cursor: pointer; font-weight: 500 !important; font-size: .92rem; }
.chip:hover { border-color: var(--brand); }
.chip input { accent-color: var(--brand); width: 17px; height: 17px; margin: 0; flex: none; }
.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.chip-wide { margin-bottom: 12px !important; }
.sector-group { border-top: 1px solid var(--line); padding: 10px 0; }
.sector-group summary { cursor: pointer; font-weight: 600; padding: 4px 0 10px; }
.sector-group .count { font-size: .78rem; font-weight: 600; color: var(--brand); background: var(--brand-soft); border-radius: 99px; padding: 1px 8px; margin-left: 6px; }

/* ---- company pages ---- */
.company-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin: 28px 0 10px; }
.company-head h1 { margin: 0 0 4px; }
.company-head .actions { margin-left: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
.company-link { display: flex; justify-content: space-between; text-decoration: none; color: var(--ink); margin-bottom: 10px; }
.subnav { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; margin: 8px 0 4px; padding-bottom: 2px; }
.subnav a { white-space: nowrap; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 500; font-size: .92rem; background: var(--surface); }
.subnav a.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.subnav a:not(.on):hover { border-color: var(--brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 10px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--brand); font-weight: 600; }
.matches { display: grid; gap: 12px; }
.match { display: grid; grid-template-columns: 76px 1fr auto; gap: 16px; padding: 16px; }
.match p { margin: 0 0 8px; }
.match-actions { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
.risk { color: var(--mid); font-size: .9rem; }
.score { display: grid; place-items: center; align-content: center; height: 76px; border-radius: 12px; background: var(--brand-soft); text-align: center; }
.score b { font: 700 1.6rem var(--display); }
.score span { font-size: .68rem; color: var(--muted); }
.score-hi b { color: var(--hi); } .score-mid b { color: var(--mid); } .score-lo b { color: var(--lo); }
.profile-card .facts-v dd { font-weight: 500; }
.card .profile-card { box-shadow: none; background: var(--bg); margin: 10px 0; }

/* ---- AI: one visual language wherever the AI did the work ---- */
.ai-panel { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; margin: 14px 0; }
.ai-panel p { margin: 0 0 6px; }
.ai-panel p:last-child { margin-bottom: 0; }
.ai-panel-body { flex: 1; min-width: 0; }
.ai-panel form { margin: 0; flex: none; }
.ai-mark { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--accent); font: 700 .8rem var(--display); }
.ai-tag { display: inline-block; font: 700 .64rem var(--display); letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; background: var(--brand); color: var(--accent); vertical-align: 2px; }

/* ---- application workspace ---- */
.progress { width: 100%; height: 8px; margin: 4px 0 12px; accent-color: var(--brand); }
.checklist, .doclist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.checklist li form { margin: 0; }
.checklist li.done > div > span { color: var(--muted); text-decoration: line-through; }
.check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); background: var(--surface); color: var(--brand-ink); font-weight: 700; cursor: pointer; padding: 0; line-height: 1; }
.checklist li.done .check { background: var(--brand); border-color: var(--brand); }
.check:hover { border-color: var(--brand); }
.doclist { margin-top: 10px; }
.doclist li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.comment { padding: 8px 12px; margin-bottom: 8px; }
.comment.mine { background: var(--brand-soft); }
.comment p { margin: 4px 0 0; }
.engagement { border-top: 1px solid var(--line); padding-top: 6px; }
.engagement p { margin: 0 0 4px; }
.app-row { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; text-decoration: none; color: var(--ink); }
.app-row-main { display: flex; flex-direction: column; min-width: 0; }
.app-row-flex { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.app-row-flex form { margin: 0; }
.consultant-pick { display: grid; gap: 8px; }
.consultant-pick .chip { align-items: flex-start; }
.consultant-pick .pick { display: grid; gap: 2px; }

/* ---- benchmarks ---- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 14px; }
.mini-stat { padding: 12px; }
.mini-stat b { display: block; font: 700 1.25rem var(--display); }
.mini-stat span { font-size: .8rem; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .78rem; color: var(--muted); font-weight: 600; border-top: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- plans ---- */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.plan { display: flex; flex-direction: column; }
.plan-current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.price { font: 700 1.5rem var(--display); margin: 8px 0 12px; }
.bullets { padding-left: 18px; margin: 0 0 16px; flex: 1; }
.bullets li { margin-bottom: 4px; }

/* ---- narrow screens ---- */
@media (max-width: 860px) {
  .hero-in, .detail-grid { grid-template-columns: 1fr; }
  .grid-4, .chips-4 { grid-template-columns: 1fr 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  /* one scrollable row of links instead of a stack of wrapped lines */
  .topbar-in { flex-wrap: nowrap; }
  .nav { flex-wrap: nowrap; overflow-x: auto; gap: 14px; padding: 4px 0; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav .linklike { white-space: nowrap; }
  .ai-panel { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .grid, .grid-4, .row2, .chips-2, .app-row { grid-template-columns: 1fr; }
  .brand { font-size: 0; gap: 0; }
  .brand-mark { font-size: 1rem; }
  .match { grid-template-columns: 60px 1fr; }
  .match-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .score { height: 60px; }
  .score b { font-size: 1.25rem; }
  .steps .step { display: grid; grid-template-columns: 28px 1fr; column-gap: 10px; padding: 14px; }
  .steps .step span { grid-row: span 2; margin: 0; }
  .steps .step h3 { margin: 2px 0; }
  .filters > select, .filters > .btn { flex: 1 1 100%; }
  .checklist li { grid-template-columns: 30px 1fr 20px; }
  .tight-form { flex-wrap: wrap; }
  .ai-panel-body { flex-basis: calc(100% - 48px); }       /* the panel's button goes under the text */
}
