/* KIRA 2.0 – GPI look & feel. Colours taken from the GPI logo. No external fonts (privacy). */

:root {
  --gpi-blue: #0088ab;
  --gpi-blue-dark: #006c88;
  --gpi-cyan: #00a8c0;
  --gpi-cyan-light: #93d5dd;
  --gpi-yellow: #efd746;
  --gpi-green: #cdde99;

  --bg: #f3f7f9;
  --surface: #ffffff;
  --text: #1c2b33;
  --muted: #5b6b74;
  --border: #dde6eb;
  --danger: #b42318;
  --success: #1f7a4d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 56, .06), 0 8px 24px rgba(16, 40, 56, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* SurveyJS theme tokens */
  --sjs2-color-project-brand-600: var(--gpi-blue);
  --sjs2-color-project-brand-700: var(--gpi-blue-dark);
  --sjs2-typography-font-family-text: var(--font);
  --sjs2-base-unit-radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}
h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.2rem); line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
a { color: var(--gpi-blue); }

/* ---------- Layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--text); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.15rem; letter-spacing: .08em; color: var(--gpi-blue); }
.brand-text span { font-size: .8rem; color: var(--muted); }
.usernav { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.user-email { color: var(--muted); }
.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2rem) 3rem; flex: 1; }
.container-wide { max-width: 1280px; }
.footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 1.5rem 1rem; }

@media (max-width: 640px) {
  .user-email, .usernav .link { display: none; }
}

/* ---------- Components ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: 1.5rem;
}
.muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 46rem; }
.hint { font-size: .85rem; color: var(--muted); margin: .5rem 0 0; }
.link { color: var(--gpi-blue); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .7rem 1.3rem;
  border-radius: 999px; border: 1px solid transparent;
  font: 600 .95rem var(--font);
  text-decoration: none; cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--gpi-cyan-light); outline-offset: 2px; }
.btn-primary { background: var(--gpi-blue); color: #fff; }
.btn-primary:hover { background: var(--gpi-blue-dark); box-shadow: 0 4px 14px rgba(0, 136, 171, .3); }
.btn-secondary { background: #fff; color: var(--gpi-blue); border-color: var(--gpi-blue); }
.btn-secondary:hover { background: rgba(0, 136, 171, .06); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); padding: .45rem 1rem; }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-block { width: 100%; }
.btn[disabled] { background: #c9d3d8; color: #fff; cursor: not-allowed; box-shadow: none; }

.notice { padding: .8rem 1rem; border-radius: 10px; background: rgba(0, 168, 192, .08); border-left: 4px solid var(--gpi-cyan); }
.notice-success { background: rgba(205, 222, 153, .35); border-color: #8cab3c; }
.notice-warning { background: rgba(239, 215, 70, .2); border-color: var(--gpi-yellow); }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: rgba(0, 136, 171, .1); color: var(--gpi-blue-dark); font-weight: 600; font-size: .85rem; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1rem; margin-top: 1.25rem; }
.form label { display: grid; gap: .35rem; font-weight: 500; font-size: .92rem; }
.form input {
  font: 1rem var(--font);
  padding: .75rem .9rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fbfdfe;
}
.form input:focus { outline: none; border-color: var(--gpi-blue); box-shadow: 0 0 0 3px rgba(0, 136, 171, .18); background: #fff; }
.form-error { color: var(--danger); margin: 0; font-size: .92rem; }

/* ---------- Login / password ---------- */
.page-auth { background:
  radial-gradient(1200px 500px at 110% -10%, rgba(0, 168, 192, .18), transparent 60%),
  radial-gradient(900px 500px at -10% 110%, rgba(205, 222, 153, .35), transparent 60%),
  var(--bg); }
.auth-card { max-width: 440px; margin: 6vh auto 0; }
.auth-visual { display: flex; justify-content: center; margin-bottom: 1rem; }

/* ---------- Dashboard ---------- */
.hero { margin-bottom: 2rem; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.step { display: flex; gap: 1.25rem; }
.step-number {
  flex: 0 0 auto; width: 2.6rem; height: 2.6rem; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gpi-cyan), var(--gpi-blue));
  color: #fff; font-weight: 700; font-size: 1.1rem;
}
.step-done .step-number { background: linear-gradient(135deg, #a8c25a, #6f9a2e); }
.step-locked .step-number { background: #c9d3d8; }
.step-body { flex: 1; min-width: 0; }
.progress { height: .6rem; border-radius: 999px; background: #e6eef2; overflow: hidden; margin-top: 1rem; }
.progress-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gpi-cyan), var(--gpi-blue)); transition: width .4s; }
.progress-label { font-size: .85rem; color: var(--muted); margin: .4rem 0 1rem; }

.assessment-list { list-style: none; margin: 0; padding: 0; }
.assessment-list li { border-top: 1px solid var(--border); }
.assessment-list li:first-child { border-top: 0; }
.assessment-list li > a, .assessment-list li > span:first-child { display: flex; align-items: center; gap: 1rem; padding: .85rem 0; text-decoration: none; color: var(--text); }
.assessment-list li { display: flex; justify-content: space-between; align-items: center; }
.assessment-list li > a { flex: 1; }
.assessment-list .link { margin-left: auto; }
.assessment-date { font-weight: 500; }

/* ---------- Survey ---------- */
.survey-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; min-height: 1.5rem; }
.save-status { font-size: .85rem; color: var(--muted); }
.save-status.is-error { color: var(--danger); }
.save-status.is-saved::before { content: "✓ "; color: var(--success); }
.survey-host { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface); min-height: 50vh; }
.survey-host .sd-root-modern { background: transparent; }

/* ---------- Result ---------- */
.result-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.5rem; }
@media (max-width: 860px) { .result-grid { grid-template-columns: 1fr; } }
.chart-card svg { width: 100%; height: auto; display: block; }
.total { display: grid; justify-items: start; margin-bottom: 1.5rem; }
.total-label { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.total-value { font-size: 3.5rem; font-weight: 700; line-height: 1; color: var(--gpi-blue); }
.total-level { font-weight: 600; color: var(--gpi-blue-dark); }
.scores { width: 100%; border-collapse: collapse; }
.scores th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding-bottom: .5rem; }
.scores td { padding: .55rem 0; border-top: 1px solid var(--border); }
.scores td:last-child { display: flex; align-items: center; gap: .6rem; justify-content: flex-end; }
.meter { display: inline-block; width: 90px; height: .45rem; border-radius: 999px; background: #e6eef2; overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--gpi-cyan), var(--gpi-blue)); }

/* ---------- Recommendations ---------- */
.llm-pending { display: flex; align-items: center; gap: 1.25rem; }
.llm-pending h2 { margin-bottom: .25rem; }
.spinner {
  flex: 0 0 auto; width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 4px solid rgba(0, 136, 171, .15); border-top-color: var(--gpi-blue);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.lead-text { font-size: 1.05rem; margin: 0; white-space: pre-line; }
.plan-chart { overflow-x: auto; margin-bottom: .75rem; }
.plan-chart svg { display: block; min-width: 720px; width: 100%; height: auto; }
.section-title { margin: 2rem 0 1rem; }
.dimension { padding: 0; }
.dimension summary {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem clamp(1.25rem, 3vw, 2rem); cursor: pointer; list-style: none;
  font-weight: 600; font-size: 1.05rem;
}
.dimension summary::-webkit-details-marker { display: none; }
.dimension summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
.dimension[open] summary::after { transform: rotate(180deg); }
.dimension-title { flex: 1; }
.dimension > :not(summary) { margin-left: clamp(1.25rem, 3vw, 2rem); margin-right: clamp(1.25rem, 3vw, 2rem); }
.development { color: var(--muted); margin-top: 0; }
.measures { padding-left: 1.2rem; margin-bottom: 1.5rem; }
.measures li { margin-bottom: 1rem; }
.measures li::marker { color: var(--gpi-blue); font-weight: 700; }
.measures p { margin: .25rem 0; }
.benefit span { font-weight: 600; color: var(--gpi-blue-dark); }

/* ---------- Admin ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: 0; }
.nav-admin { font-weight: 600; }
.form-inline { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) auto; align-items: end; }
.form-inline .form-error { grid-column: 1 / -1; }
.table-card { padding: 0; overflow: hidden; }
.table-filter { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.table-filter input { width: 100%; max-width: 360px; font: 1rem var(--font); padding: .6rem .9rem; border: 1px solid var(--border); border-radius: 10px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.data-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .8rem 1.25rem; background: #f8fbfc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tbody tr[data-href] { cursor: pointer; }
.data-table tbody tr[data-href]:hover { background: rgba(0, 136, 171, .04); }
.data-table tr.is-inactive td { opacity: .6; }
.data-table.compact td { padding: .5rem .25rem; }
.data-table .value { text-align: right; font-weight: 700; color: var(--gpi-blue-dark); width: 3rem; }
.row-link { font-weight: 600; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--gpi-blue); }
.sub { display: block; font-size: .82rem; color: var(--muted); }
.tag { display: inline-block; margin: .25rem .25rem 0 0; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: rgba(239, 215, 70, .3); color: #6b5a00; }
.tag-muted { background: #e6eef2; color: var(--muted); }
.tag-success { background: rgba(140, 171, 60, .2); color: #4c6417; }
.tag-info { background: rgba(0, 168, 192, .15); color: var(--gpi-blue-dark); }
.tag-danger { background: rgba(180, 35, 24, .12); color: var(--danger); }
.mini-progress { display: block; width: 110px; height: .4rem; border-radius: 999px; background: #e6eef2; overflow: hidden; margin: .4rem 0 .2rem; }
.mini-progress span { display: block; height: 100%; background: var(--gpi-cyan); }
.mini-progress.is-complete span { background: #8cab3c; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.facts { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: .5rem 1.25rem; margin: 0 0 1.25rem; }
.answers { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem 1.25rem; margin: 0 0 1.25rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.facts dt, .answers dt { color: var(--muted); font-size: .9rem; }
.facts dd, .answers dd { margin: 0; }
@media (max-width: 640px) { .answers { grid-template-columns: 1fr; } .answers dd { margin-bottom: .5rem; } }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; color: var(--gpi-blue-dark); }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.btn-danger { color: var(--danger); border-color: rgba(180, 35, 24, .35); }
.btn-danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.credentials { border: 2px solid var(--gpi-cyan); }
.credentials-list { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; margin: 1rem 0; }
.credentials-list dt { color: var(--muted); }
.credentials-list dd { margin: 0; }
.credentials code, .admin-note code { font-size: 1rem; background: #f3f7f9; padding: .15rem .45rem; border-radius: 6px; user-select: all; }
.admin-note code { font-size: .85rem; }
.answer-group { border-top: 1px solid var(--border); padding: .6rem 0; }
.answer-group summary { cursor: pointer; font-weight: 600; color: var(--gpi-blue-dark); }
