:root {
  /* Pastel theme + compact spacing */
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #e6eaf2;
  --line-strong: #cdd6e3;
  --blue: #7aa7ff;
  --green: #7fd6a6;
  --purple: #c9a6ff;
  --grey: #a8b0be;
  --orange: #ffbf8a;
  --teal: #7fd7d1;
  --red: #ff9aa2;
  --yellow: #ffe08a;
  --radius: 12px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
a { color: inherit; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(6px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.app-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: block;
}
.brand .brand-text { min-width: 0; }
.topbar h1, .board-header h2, .form-card h2, .table-card h2 { margin: 0 0 4px; }
.topbar p, .board-header p { margin: 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.button, .mini-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 7px 10px;
  border-radius: 9px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
}
.button.primary { background: #2f3b52; color: #fff; border-color: #2f3b52; }
.mini-button.primary { background: #2f3b52; color: #fff; border-color: #2f3b52; }
.mini-button { padding: 5px 8px; font-size: 12px; }
.mini-button.danger { color: var(--red); border-color: #e8a8a8; }
.alert {
  margin: var(--space-2) auto;
  max-width: 1240px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.alert.success { border-color: #a4dbad; background: #edfbed; }
.alert.error { border-color: #efb3b3; background: #fff0f0; }
.controls { padding: var(--space-2) var(--space-3); background: #f8fafc; border-bottom: 1px solid var(--line); }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 8px;
  align-items: end;
}
label { display: grid; gap: 5px; font-weight: 700; color: #263645; }
input, select, textarea {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
textarea { resize: vertical; }
div.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}
.link-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  position: relative;
}
.link-editor:focus-within { outline: 2px solid rgba(11, 115, 183, 0.2); border-color: rgba(11, 115, 183, 0.55); }
.link-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  padding: 6px;
  max-height: 240px;
  overflow: auto;
}
.link-suggest[hidden] { display: none; }
.link-suggest-item {
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}
.link-suggest-item:hover { background: #f1f5f9; }
.link-layer .link-path { pointer-events: stroke; }
.tag-editor:focus-within { outline: 2px solid rgba(11, 115, 183, 0.2); border-color: rgba(11, 115, 183, 0.55); }
.tag-chips { display: contents; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #1e293b;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  max-width: 100%;
}
.tag-chip-label {
  flex: 1 1 auto;
}
.tag-chip { word-break: break-word; }
.tag-chip button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
  padding: 2px 6px;
  margin-left: 2px;
  border-radius: 999px;
}
.tag-chip button:hover { background: rgba(15, 23, 42, 0.08); }
input.tag-editor-input {
  border: 0;
  padding: 6px 2px;
  min-width: 140px;
  flex: 1 1 140px;
}
input.tag-editor-input:focus { outline: none; }
div.tag-editor { position: relative; }
.tag-error {
  width: 100%;
  color: #b91c1c;
  font-weight: 700;
  font-size: 12px;
  padding: 2px 2px 0;
}
.tag-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  padding: 6px;
  max-height: 240px;
  overflow: auto;
}
.tag-suggest[hidden] { display: none; }
.tag-suggest-item {
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}
.tag-suggest-item:hover { background: #f1f5f9; }
fieldset.tag-options {
  grid-column: span 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 0;
}

/* Notice (acceptable-use) page */
.notice-page { background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 40%, #f8fafc 100%); }
.notice-layout {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: stretch;
}
.notice-side {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(6px);
}
.notice-brand { display: flex; gap: 12px; align-items: flex-start; }
.notice-logo { width: 72px; height: 72px; border-radius: 14px; background: #fff; border: 1px solid var(--line); padding: 10px; }
.notice-title { font-size: 34px; font-weight: 1000; line-height: 1.05; color: #0f172a; }
.notice-title span { color: #0b73b7; }
.notice-side-card { margin-top: 14px; }
.notice-side-line { height: 3px; width: 90px; background: #0b73b7; border-radius: 999px; margin: 12px 0 14px; }
.notice-side-lead { margin: 0 0 14px; color: var(--muted); font-weight: 800; }
.notice-side-body { margin: 0; color: #0f172a; font-weight: 600; }

.notice-main { display: flex; }
.notice-card {
  flex: 1 1 auto;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.notice-card-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.notice-card-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: #eef2ff; border: 1px solid #c7d2fe; font-size: 18px; }
.notice-card h1 { margin: 0; font-size: 20px; }
.notice-card p { margin: 4px 0 0; color: var(--muted); font-weight: 500; }

.notice-sections { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 10px 0; }
.notice-section { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: #fff; }
.notice-section-head { font-weight: 800; display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.notice-section ul { margin: 0; padding-left: 18px; color: #0f172a; font-weight: 500; }
.notice-section p { margin: 0; color: #0f172a; font-weight: 500; }
.badge { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 999px; font-weight: 1000; font-size: 12px; }
.badge.ok { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.badge.no { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }
.badge.warn { background: #ffedd5; border: 1px solid #fdba74; color: #9a3412; }

.notice-details { margin-top: 10px; }
.notice-details summary { cursor: pointer; font-weight: 900; color: #0f172a; }
.notice-full-text {
  margin-top: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px;
  max-height: 320px;
  overflow: auto;
  background: #fff;
  line-height: 1.4;
  font-size: 13px;
  color: #0f172a;
}
.notice-ack { display:flex; gap:14px; align-items:flex-start; margin-top:14px; font-weight: 600; color: #0f172a; }
.notice-ack input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: #16a34a;
}
.notice-ack span { font-size: 14px; line-height: 1.25; }
.notice-actions { margin-top: 12px; }
.notice-actions .form-actions { gap: 12px; }
.notice-actions .button { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
.notice-actions .button.notice-accept { background: #16a34a; border-color: #16a34a; }
.notice-actions .button.notice-accept:hover { background: #15803d; border-color: #15803d; }
.notice-actions .button.notice-quit { background: #ef4444; border-color: #ef4444; color: #fff; }
.notice-actions .button.notice-quit:hover { background: #dc2626; border-color: #dc2626; }

@media (max-width: 980px) {
  .notice-layout { grid-template-columns: 1fr; }
  .notice-side { display: none; }
}
fieldset.tag-options label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
fieldset.tag-options input { width: auto; }
.filter-actions { display: flex; gap: 8px; }
.page-wrap {
  padding: var(--space-2) var(--space-3) var(--space-3);
  max-width: none;
  width: 100%;
  margin: 0;
}
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-2);
  align-items: start;
}
.sidebar { position: sticky; top: 12px; }
.sidebar-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  padding: var(--space-2);
}
.sidebar-card h2 { margin: 0 0 10px; }
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}
.sidebar-head h2 { margin: 0; }
.sidebar-head-actions { display: inline-flex; gap: 6px; align-items: center; }
.sidebar-toggle-fab {
  position: fixed;
  top: 70px;
  left: 10px;
  z-index: 70;
  display: none;
}
body.sidebar-collapsed .sidebar { display: none; }
body.sidebar-collapsed .layout { grid-template-columns: 1fr; }
body.sidebar-collapsed .sidebar-toggle-fab { display: inline-flex; }
.sidebar-filter { grid-template-columns: 1fr; }
.sidebar-filter fieldset.tag-options { grid-column: auto; }
.content { min-width: 0; }
.board-card, .form-card, .table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.board-card { padding: var(--space-2); overflow-x: auto; }
.roadmap-wrap { position: relative; }
.link-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}
.board-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  align-items: flex-start;
}
.board-header-tags { display: flex; align-items: flex-start; }
.board-header-tags fieldset.tag-options {
  max-width: 520px;
  background: #f8fafc;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 520px; }
.legend-item {
  color: #fff;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.roadmap {
  display: grid;
  grid-template-columns: 160px repeat(var(--col-count), minmax(210px, 1fr));
  min-width: calc(160px + var(--col-count) * 210px);
  border: 1px dashed #1aa7e1;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.corner-label, .axis-head, .pillar-label, .cell {
  border-right: 1px dashed #1aa7e1;
  border-bottom: 1px dashed #1aa7e1;
}
.corner-label, .axis-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 800;
  background: #fbfdff;
  font-size: 16px;
}
.pillar-label {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 800;
  font-size: 16px;
  background: #fbfdff;
}
.cell {
  min-height: 140px;
  padding: 6px;
  background: #fff;
}
.project-card {
  position: relative;
  border-radius: 8px;
  margin: 4px 0;
  padding: 7px 7px 6px;
  color: #fff;
  background: var(--grey);
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.14);
  border: 2px solid rgba(255,255,255,0.1);
  page-break-inside: avoid;
}
.project-card[draggable="true"] { cursor: grab; }
.project-card.is-dragging { opacity: 0.55; cursor: grabbing; }
.cell.is-drop { outline: 2px solid rgba(122, 167, 255, 0.6); outline-offset: -2px; }
.project-card.status-planned,
.project-card.status-discovery,
.project-card.status-idea,
.project-card.status-in-preparation { border-style: dashed; }
.project-card.status-submitted { border-width: 3px; }
.project-card.status-rejected,
.project-card.status-withdrawn,
.project-card.status-on-hold { opacity: 0.72; }
.project-card.priority-high { outline: 2px solid rgba(0,0,0,0.25); }
.card-edit {
  position: absolute;
  top: 3px;
  right: 6px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 12px;
  background: transparent;
  border: 0;
  padding: 2px 4px;
  line-height: 1;
}
.card-edit:hover { color: #fff; }
.card-title {
  font-size: 17px;
  font-weight: 900;
  line-height: 1.05;
  margin-right: 18px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; min-width: 0; }
.tag {
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-card .tag {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}
.card-note {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.25;
  opacity: 0.93;
}
.color-business-finland, .color-bf-r2b, .color-bf-co-innovation, .color-bf-co-research, .color-funded, .color-high { background: var(--green); }
.color-pipeline { background: #ffb0b7; }
.color-active { background: #90b7ff; }
.color-01-ideavaihe,
.color-02-valmis-tki-ryhm-n-k-sittelyyn,
.color-03-valmisteilla { background: #b9c2d3; }
.color-04-arviointi,
.color-05-hyv-ksytty-j-tett-v-ksi-rahoittajalle,
.color-07-rahoittajan-k-sittelyss { background: var(--orange); }
.color-06-valmistelu-keskeytetty,
.color-09-kielteinen-p-t-s,
.color-12-peruttu { background: #ffb0b7; }
.color-08-hyv-ksytty-p-t-s-resurssienhallinnan-aloitus { background: #9bbcff; }
.color-10-k-ynniss { background: #90b7ff; }
.color-11-p-ttynyt { background: #a6e6b9; }
.color-horizon-europe { background: var(--blue); }
.color-eakr-regional { background: var(--purple); }
.color-erasmus { background: #a6e6b9; }
.color-academy-of-finland { background: #83d8cf; }
.color-creative-europe { background: #d7b5ff; }
.color-sitra, .color-100-500k, .color-medium { background: var(--orange); }
.color-daad { background: #f2c6a0; }
.color-internal-tbd, .color-other, .color-no-estimate, .color-watch { background: var(--grey); }
.color-submitted { background: var(--orange); }
.color-planned, .color-in-preparation, .color-discovery, .color-idea { background: #b9c2d3; }
.color-rejected, .color-withdrawn { background: #ffb0b7; }
.color-completed { background: #a6e6b9; }
.color-on-hold { background: #ffe6a8; }
.color-500k-1m, .color-1-3m, .color-3m { background: #90b7ff; }
.color-1-2-years, .color-2-3-years, .color-3-years { background: var(--teal); }
.admin-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.75fr) minmax(560px, 1.25fr);
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.form-card, .table-card { padding: var(--space-2); }
.project-form { display: grid; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
#project-modal-confirm { align-items: center; }
.button.danger {
  background: #ffe5e5;
  border-color: #f1b1b1;
  color: #7a1f2b;
}
.button.danger:hover { background: #ffd7d7; }
.button.logout {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.button.logout:hover { background: #dc2626; border-color: #dc2626; }

.add-project-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
}
.add-project-fab:hover { filter: brightness(0.98); }
.add-project-fab:active { transform: translateY(1px); }
.settings-intro { margin-bottom: var(--space-2); }
.settings-list {
  margin: 8px 0 0 18px;
  padding: 0;
  color: var(--muted);
}
.settings-list li + li { margin-top: 4px; }
.settings-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.settings-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef5ff;
  border: 1px solid #d6e1f3;
  font-weight: 700;
}
.settings-grid {
  grid-template-columns: minmax(280px, 0.8fr) minmax(540px, 1.2fr);
}
.settings-table input[type="text"],
.settings-table input[type="number"] { min-width: 110px; }
.settings-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.settings-check input { width: auto; }
.settings-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
}
.settings-badge.is-active {
  background: #edfbed;
  border-color: #b7dfbe;
  color: #29593b;
}
.settings-badge.is-inactive {
  background: #f5f7fb;
  border-color: #d9e0eb;
  color: #64748b;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #475569; }
td small { color: var(--muted); }
.row-actions { display: flex; gap: 6px; align-items: flex-start; }
.row-actions form { margin: 0; }
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
}
.modal {
  width: min(960px, 100%);
  max-height: min(92vh, 980px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: var(--space-2);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.modal-head h2 { margin: 0; }
.modal-save-status {
  margin-left: auto;
  font-weight: 800;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid var(--line);
}
.install-page { min-height: 100vh; display: grid; place-items: center; }
.install-card { max-width: 760px; margin: 40px auto; padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08); }
.presentation-mode .controls,
.presentation-mode .admin-grid,
.presentation-mode .card-edit,
.presentation-mode .no-print { display: none !important; }
.presentation-mode .layout { grid-template-columns: 1fr !important; }
.presentation-mode .sidebar { display: none !important; }
.presentation-mode .content { grid-column: 1 / -1; min-width: 0; }
.presentation-mode .page-wrap { padding: 18px; }
.presentation-mode .board-card { box-shadow: none; border-radius: 4px; }
.presentation-mode .roadmap { min-width: 0; width: 100%; }
.presentation-mode body, body.presentation-mode { background: #fff; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .filter-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  fieldset.tag-options { grid-column: span 2; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media print {
  body { background: #fff; }
  .no-print, .controls, .topbar, .admin-grid, .card-edit { display: none !important; }
  .page-wrap { padding: 0; }
  .board-card { box-shadow: none; border: none; padding: 0; }
  .roadmap { min-width: 0; width: 100%; }
  .project-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A3 landscape; margin: 10mm; }
}
