:root {
  --bg: #0b1020;
  --bg-card: #131a2e;
  --bg-elev: #1a2340;
  --border: #263153;
  --text: #e8ecf6;
  --text-dim: #9aa7c7;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --good: #2ecc8f;
  --warn: #f5b942;
  --radius: 14px;
  font-size: 16px;
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* Header */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11,16,32,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.logo span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-right { display: flex; gap: 10px; align-items: center; }

.lang-toggle {
  display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
}
.lang-toggle button {
  background: none; border: none; color: var(--text-dim); padding: 6px 14px; cursor: pointer; font-size: .85rem;
}
.lang-toggle button.active { background: var(--accent); color: #fff; }

/* Hero */
.hero { padding: 72px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3.1rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { max-width: 640px; margin: 18px auto 0; color: var(--text-dim); font-size: 1.1rem; }
.hero .stats { display: flex; gap: 32px; justify-content: center; margin-top: 34px; flex-wrap: wrap; }
.hero .stat { text-align: center; }
.hero .stat b { display: block; font-size: 1.6rem; color: var(--accent); }
.hero .stat span { color: var(--text-dim); font-size: .9rem; }

/* Wizard */
.wizard {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; margin: 36px auto; max-width: 860px;
}
.wizard h2 { font-size: 1.25rem; margin-bottom: 4px; }
.wizard .sub { color: var(--text-dim); font-size: .92rem; margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }

label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
select, input[type=text], input[type=number], input[type=date], textarea {
  width: 100%; background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font-size: .95rem;
  font-family: inherit;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; min-height: 74px; }

.orgnr-row { display: flex; gap: 10px; }
.orgnr-row input { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: 10px; padding: 12px 26px;
  font-size: 1rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.btn.small { padding: 8px 16px; font-size: .85rem; }
.wizard .actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 10px; }

.brreg-status { font-size: .85rem; margin-top: 6px; min-height: 1.2em; }
.brreg-status.ok { color: var(--good); }
.brreg-status.err { color: var(--warn); }

/* Results */
.results-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 30px 0 14px; }
.results-head h2 { font-size: 1.3rem; }
.results-head .count { color: var(--text-dim); font-size: .9rem; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters select { width: auto; padding: 8px 12px; font-size: .85rem; }

.grant-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 14px; display: grid; grid-template-columns: 64px 1fr auto; gap: 18px;
  align-items: start; cursor: pointer; transition: border-color .15s;
}
.grant-card:hover { border-color: var(--accent); }
.score-ring {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; color: #fff;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--score) * 1%), var(--bg-elev) 0);
  position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 6px; background: var(--bg-card); border-radius: 50%; }
.score-ring span { position: relative; }
.grant-main h3 { font-size: 1.05rem; margin-bottom: 2px; }
.grant-main .provider { color: var(--text-dim); font-size: .85rem; margin-bottom: 8px; }
.grant-main .summary { font-size: .92rem; color: var(--text); opacity: .9; }
.grant-main .why { font-size: .84rem; color: var(--good); margin-top: 8px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pill {
  font-size: .74rem; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
}
.pill.eu { background: rgba(79,140,255,.15); border-color: rgba(79,140,255,.4); color: #8ab4ff; }
.pill.deadline { background: rgba(245,185,66,.12); border-color: rgba(245,185,66,.35); color: var(--warn); }
.grant-side { text-align: right; min-width: 130px; }
.grant-side .amount { font-weight: 700; font-size: .95rem; }
.grant-side .type { color: var(--text-dim); font-size: .8rem; margin-top: 2px; }
@media (max-width: 720px) {
  .grant-card { grid-template-columns: 48px 1fr; }
  .grant-side { grid-column: 1 / -1; text-align: left; }
  .score-ring { width: 48px; height: 48px; font-size: .85rem; }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 760px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 30px;
}
.modal h3 { font-size: 1.3rem; margin-bottom: 4px; }
.modal .provider { color: var(--text-dim); margin-bottom: 16px; }
.modal .meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 18px 0; }
.modal .meta div { background: var(--bg-elev); border-radius: 10px; padding: 10px 14px; }
.modal .meta b { display: block; font-size: .78rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.modal .meta span { font-size: .92rem; }
.modal .actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.draft-output {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; margin-top: 18px; white-space: pre-wrap; font-size: .9rem; line-height: 1.6;
  display: none;
}
.draft-output.visible { display: block; }

/* Draft wizard */
.dw-dots { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.dw-dots i { flex: 0 0 12px; height: 1px; background: var(--border); }
.dw-dot {
  width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
  flex-shrink: 0;
}
.dw-dot.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.dw-dot.done { background: rgba(46,204,143,.18); color: var(--good); border-color: var(--good); }
.dw-dots em { font-style: normal; font-size: .74rem; color: var(--text-dim); margin-right: 2px; }
.dw-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.dw-result { white-space: pre-wrap; font-family: inherit; font-size: .88rem; line-height: 1.6; margin: 0; }

/* Selectable chips & idea cards */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .chip {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 999px; padding: 7px 14px; font-size: .85rem; cursor: pointer; font-family: inherit;
}
.chips .chip:hover { border-color: var(--accent); }
.chips .chip.sel { background: rgba(79,140,255,.18); border-color: var(--accent); color: #8ab4ff; font-weight: 600; }
.idea-cards { display: grid; gap: 10px; margin-top: 10px; }
.idea-card {
  text-align: left; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; font-family: inherit; color: var(--text);
}
.idea-card:hover { border-color: var(--accent); }
.idea-card.sel { border-color: var(--good); background: rgba(46,204,143,.08); }
.idea-card b { display: block; margin-bottom: 4px; }
.idea-card span { font-size: .85rem; color: var(--text-dim); }

/* Score card */
.score-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.score-num { font-size: 2rem; font-weight: 800; }
.score-bar { height: 10px; border-radius: 999px; background: var(--bg); margin: 8px 0 14px; overflow: hidden; }
.score-bar div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--warn), var(--good)); }
.score-item { font-size: .88rem; padding: 3px 0; }
.score-item .tip { color: var(--warn); font-size: .82rem; margin-left: 22px; }

/* Deadlines */
.pill.dl-soon { background: rgba(245,110,110,.15); border-color: rgba(245,110,110,.5); color: #f57070; font-weight: 700; }
.pill.dl-later { background: rgba(245,185,66,.12); border-color: rgba(245,185,66,.35); color: var(--warn); }
.pill.dl-rolling { background: rgba(46,204,143,.12); border-color: rgba(46,204,143,.35); color: var(--good); }
.pill.dl-check { background: rgba(154,167,199,.12); border-color: var(--border); color: var(--text-dim); }
span.dl-soon { color: #f57070; }
span.dl-later { color: var(--warn); }
span.dl-rolling { color: var(--good); }
span.dl-check { color: var(--text-dim); }
.dl-row {
  display: flex; align-items: center; gap: 12px; padding: 7px 0; cursor: pointer;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.dl-row:hover b { color: var(--accent); }
.dl-row .pill { flex-shrink: 0; min-width: 210px; text-align: center; }

.hidden { display: none !important; }

/* Tabs */
.tabs { display: flex; gap: 4px; }
.tabs button {
  background: none; border: none; color: var(--text-dim); padding: 8px 16px; cursor: pointer;
  font-size: .92rem; font-family: inherit; border-radius: 8px; font-weight: 600;
}
.tabs button.active { background: var(--bg-elev); color: var(--text); }
@media (max-width: 720px) { .tabs button { padding: 8px 10px; font-size: .82rem; } }

/* Portal / applications */
.section-title { font-size: 1.3rem; margin: 34px 0 6px; }
.section-sub { color: var(--text-dim); font-size: .92rem; margin-bottom: 18px; }
.app-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 14px;
}
.app-card .top { display: flex; justify-content: space-between; align-items: start; gap: 14px; flex-wrap: wrap; }
.app-card h3 { font-size: 1.02rem; }
.app-card .provider { color: var(--text-dim); font-size: .84rem; }
.status-select { width: auto !important; padding: 7px 10px !important; font-size: .84rem !important; }
.status-badge { font-size: .76rem; padding: 3px 12px; border-radius: 999px; font-weight: 700; }
.status-draft { background: rgba(154,167,199,.15); color: var(--text-dim); }
.status-submitted { background: rgba(79,140,255,.15); color: #8ab4ff; }
.status-granted { background: rgba(46,204,143,.15); color: var(--good); }
.status-rejected { background: rgba(245,110,110,.15); color: #f57070; }

.report-list { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.report-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: .9rem;
}
.report-item input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--good); }
.report-item.done span.title { text-decoration: line-through; opacity: .55; }
.report-item .due { margin-left: auto; color: var(--warn); font-size: .8rem; white-space: nowrap; }
.report-item .due.overdue { color: #f57070; font-weight: 700; }
.inline-fields { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-top: 12px; }
.inline-fields > div { min-width: 150px; }
.inline-fields input { padding: 8px 10px; font-size: .85rem; }

/* Requirements & ideas in modal */
.req-block { margin-top: 16px; }
.req-block h4 { font-size: .92rem; margin-bottom: 8px; color: var(--accent); }
.req-block ul { padding-left: 20px; }
.req-block li { font-size: .9rem; margin-bottom: 5px; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th, .admin-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--text-dim); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.admin-table tr:hover td { background: var(--bg-elev); }
.admin-table .actions-cell { white-space: nowrap; }
.admin-table button { margin-right: 6px; }
.admin-form {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin: 18px 0;
}
.table-wrap { overflow-x: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 14px 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 14px; margin: 18px 0 26px; }
.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi b { display: block; font-size: 1.55rem; color: var(--accent); }
.kpi span { color: var(--text-dim); font-size: .84rem; }

footer { border-top: 1px solid var(--border); margin-top: 60px; padding: 28px 0 40px; color: var(--text-dim); font-size: .85rem; text-align: center; }
footer a { color: var(--accent); }
