:root {
  --navy: #1F2A44;
  --navy-2: #2c3a5c;
  --olive: #73864F;
  --olive-dark: #5d6d3f;
  --beige: #E8E3D9;
  --beige-soft: #F4F1EB;
  --paper: #FBFAF7;
  --white: #ffffff;
  --ink: #1F2A44;
  --muted: #5b6478;
  --line: #DDD7CB;
  --danger: #A23B3B;
  --danger-bg: #F6E7E5;
  --ok-bg: #EBEFE2;
  --warn-bg: #F5EEDB;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(31, 42, 68, .06), 0 4px 16px rgba(31, 42, 68, .06);
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: 'Outfit', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 350;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; letter-spacing: .2px; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
a { color: var(--navy); }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.eyebrow { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--olive); font-weight: 500; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--navy);
  color: var(--beige);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar img { height: 34px; display: block; }
.topbar .brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.topbar .brand span { font-family: var(--serif); font-size: 19px; letter-spacing: 1px; }
.topbar .spacer { flex: 1; }
.topbar button.link { color: var(--beige); }
.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.narrow { max-width: 720px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 16px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ---------- Forms ---------- */
label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31, 42, 68, .12); }
.field + .field { margin-top: 16px; }

.btn {
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: .3px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--navy-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--white); color: var(--navy); }
.btn.secondary:hover { background: var(--beige-soft); }
.btn.olive { background: var(--olive); border-color: var(--olive); }
.btn.olive:hover { background: var(--olive-dark); }
.btn.danger { background: var(--white); color: var(--danger); border-color: #dcbcbc; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 13px; }
button.link { background: none; border: none; padding: 0; font: inherit; color: var(--navy); cursor: pointer; text-decoration: underline; }

.alert { padding: 12px 16px; border-radius: 4px; font-size: 14px; }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--ok-bg); color: var(--olive-dark); }
.alert.warn { background: var(--warn-bg); color: #7a5c1e; }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 99px; font-weight: 500; background: var(--beige); color: var(--navy); white-space: nowrap; }
.badge.activa, .badge.enviado, .badge.respondida { background: var(--ok-bg); color: var(--olive-dark); }
.badge.cerrada { background: #E4E6EC; color: var(--muted); }
.badge.error { background: var(--danger-bg); color: var(--danger); }
.badge.en-cola { background: var(--warn-bg); color: #7a5c1e; }

/* ---------- Auth screens ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth .side {
  background: var(--navy);
  color: var(--beige);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  text-align: center;
}
.auth .side img { width: min(300px, 70%); }
.auth .side p { margin-top: 32px; max-width: 340px; font-family: var(--serif); font-size: 22px; line-height: 1.35; }
.auth .main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth form { width: 100%; max-width: 380px; }
.auth .mobile-logo { display: none; }
#brand-side { display: flex; flex-direction: column; align-items: center; width: 100%; }
.auth .side .mp-logo { width: min(300px, 70%); }
.auth .side .mp-logo.sm { width: min(190px, 50%); }
.client-box { display: inline-flex; align-items: center; justify-content: center; background: var(--white); border-radius: var(--radius); padding: 18px 26px; }
.client-box img { display: block; max-width: 220px; max-height: 90px; width: auto; height: auto; }
.client-box.client-name { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--navy); }
.collab { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; opacity: .7; margin: 28px 0 22px; }
.cobrand { display: inline-flex; align-items: center; justify-content: center; gap: 22px; margin-bottom: 24px; }
.cobrand .sep { width: 1px; align-self: stretch; background: currentColor; opacity: .35; }
.cobrand .mp-mono { height: 56px; display: block; }
.cobrand .client-box { padding: 10px 16px; }
.cobrand .client-box img { max-width: 160px; max-height: 52px; }
.cobrand .client-box.client-name { font-size: 20px; }
.cobrand.light { color: var(--navy); margin-bottom: 0; }
.cobrand.light .client-box { padding: 0; background: none; }
.survey-head .mp-mono { height: 64px; }
.client-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.client-chip img { height: 24px; max-width: 90px; object-fit: contain; }
.logo-field { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { width: 180px; height: 80px; border: 1px dashed var(--line); border-radius: 4px; display: flex; align-items: center; justify-content: center; background: var(--white); padding: 8px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth .side { display: none; }
  .auth .mobile-logo { display: flex; justify-content: center; margin: 0 auto 32px; }
  .auth .mobile-logo > img { width: 180px; }
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; background: var(--beige-soft); }
tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: Consolas, Menlo, monospace; font-size: 13px; }

/* ---------- Survey list ---------- */
.survey-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.survey-card { display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, transform .15s; text-decoration: none; color: inherit; }
.survey-card:hover { border-color: var(--navy); transform: translateY(-1px); }
.survey-card h3 { margin: 0; }
.stats { display: flex; gap: 20px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.stats div { font-size: 12px; color: var(--muted); }
.stats strong { display: block; font-size: 20px; color: var(--navy); font-family: var(--serif); font-weight: 600; }
.empty { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty img { width: 64px; opacity: .35; margin-bottom: 16px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 24px 0; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  background: none; border: none; font: inherit; font-weight: 500; color: var(--muted);
  padding: 12px 16px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.active { color: var(--navy); border-bottom-color: var(--olive); }

/* ---------- Question builder ---------- */
.q-item { position: relative; border-left: 3px solid var(--olive); }
.q-item .q-head { display: flex; gap: 12px; align-items: flex-start; }
.q-item .q-num { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--olive); min-width: 28px; line-height: 40px; }
.q-item .q-body { flex: 1; min-width: 0; }
.q-item .q-tools { display: flex; gap: 4px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 4px; width: 32px; height: 32px; cursor: pointer; color: var(--muted); font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--beige-soft); border-color: var(--line); color: var(--navy); }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; border-color: transparent; }
.q-grid { display: grid; grid-template-columns: 1fr 200px; gap: 12px; }
.option-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.option-row .dot { width: 14px; height: 14px; border: 1.5px solid var(--muted); border-radius: 50%; flex: none; }
.option-row .dot.square { border-radius: 3px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; margin: 0; }
.check input { width: 16px; height: 16px; accent-color: var(--navy); }
.add-q { border: 1.5px dashed var(--line); background: transparent; border-radius: var(--radius); padding: 18px; width: 100%; font: inherit; color: var(--muted); cursor: pointer; }
.add-q:hover { border-color: var(--olive); color: var(--olive-dark); background: var(--white); }
@media (max-width: 640px) { .q-grid { grid-template-columns: 1fr; } }

/* ---------- Upload ---------- */
.dropzone { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center; background: var(--beige-soft); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.drag, .dropzone:hover { border-color: var(--olive); background: #EEF0E6; }
.dropzone strong { color: var(--navy); }

/* ---------- Results ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.kpi .value { font-family: var(--serif); font-size: 36px; font-weight: 600; line-height: 1; }
.kpi .label { color: var(--muted); font-size: 13px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 220px) 1fr 70px; gap: 12px; align-items: center; margin-top: 10px; font-size: 14px; }
.bar { height: 12px; background: var(--beige-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--olive); border-radius: 99px; min-width: 2px; }
.bar-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.text-answers { max-height: 320px; overflow-y: auto; margin-top: 12px; }
.text-answers blockquote { margin: 0; padding: 10px 14px; border-left: 2px solid var(--beige); background: var(--beige-soft); border-radius: 0 4px 4px 0; }
.text-answers blockquote + blockquote { margin-top: 8px; }
.text-answers cite { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 4px; }
.progress { height: 6px; background: var(--beige); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--olive); }

/* ---------- Respondent survey ---------- */
.survey-head { background: var(--navy); color: var(--beige); padding: 48px 24px 72px; text-align: center; }
.survey-head h1 { font-size: 2.4rem; color: var(--white); max-width: 720px; margin: 0 auto .3em; }
.survey-head p { max-width: 620px; margin: 0 auto; opacity: .85; white-space: pre-line; }
.survey-body { max-width: 720px; margin: -40px auto 0; padding: 0 16px 64px; }
.question { margin-bottom: 16px; }
.question .q-title { font-weight: 500; font-size: 16px; margin-bottom: 4px; }
.question .q-title .req { color: var(--olive); margin-left: 2px; }
.question .q-help { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.question.invalid { border-color: var(--danger); }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font-weight: 400; margin: 0; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--navy); }
.choice input { width: 18px; height: 18px; accent-color: var(--navy); margin: 0; flex: none; }
.choice:has(input:checked) { border-color: var(--navy); background: var(--beige-soft); }
.scale { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.scale label { flex: 1 1 0; min-width: 40px; margin: 0; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale span { display: flex; align-items: center; justify-content: center; height: 46px; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font-weight: 500; transition: all .15s; }
.scale span:hover { border-color: var(--navy); }
.scale input:checked + span { background: var(--navy); border-color: var(--navy); color: var(--white); }
.scale input:focus-visible + span { box-shadow: 0 0 0 3px rgba(31, 42, 68, .2); }
.scale-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; gap: 12px; }
.done { text-align: center; padding: 48px 32px; }
.done .check-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--olive); display: inline-flex; align-items: center; justify-content: center; font-size: 30px; margin-bottom: 16px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; letter-spacing: .5px; }
.footer a { color: var(--muted); }

/* ---------- Toast & modal ---------- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--navy); color: var(--white); padding: 12px 20px; border-radius: 4px; opacity: 0; transition: all .2s; pointer-events: none; z-index: 100; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }
dialog { border: none; border-radius: var(--radius); padding: 0; max-width: min(760px, calc(100% - 32px)); width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); }
dialog::backdrop { background: rgba(31, 42, 68, .5); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
dialog .dlg-body { padding: 20px; }
dialog iframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 4px; }

@media (max-width: 640px) {
  .container { padding: 24px 16px 48px; }
  .topbar { padding: 0 16px; }
  .topbar .brand span { display: none; }
  h1 { font-size: 1.8rem; }
  .survey-head h1 { font-size: 1.9rem; }
  .card { padding: 18px; }
  .bar-row { grid-template-columns: 1fr 60px; }
  .bar-row .bar { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Main nav ---------- */
.mainnav { display: flex; gap: 4px; margin-left: 8px; }
.mainnav a { color: var(--beige); text-decoration: none; padding: 8px 12px; border-radius: 4px; font-size: 14px; opacity: .75; }
.mainnav a:hover { opacity: 1; background: rgba(255, 255, 255, .06); }
.mainnav a.active { opacity: 1; background: rgba(255, 255, 255, .1); }

/* ---------- Survey strip ---------- */
.survey-strip { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-top: 20px; }
.participation .big { font-family: var(--serif); font-size: 34px; font-weight: 600; line-height: 1; }
.participation .progress { height: 8px; }
.share input { font-family: Consolas, Menlo, monospace; font-size: 13px; padding: 7px 10px; background: var(--beige-soft); }
@media (max-width: 820px) { .survey-strip { grid-template-columns: 1fr; } }

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--white); color: var(--navy); border-radius: 99px; padding: 6px 14px; cursor: pointer; }
.chip span { color: var(--muted); margin-left: 4px; }
.chip.active { background: var(--navy); border-color: var(--navy); color: var(--white); }
.chip.active span { color: var(--beige); }
input[type=search] { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; background: var(--white); color: var(--ink); }

/* ---------- Analytics ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }
.cols { margin: 0; display: grid; grid-template-columns: 28px 1fr; grid-template-rows: 150px auto; column-gap: 8px; }
.cols-grid { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: right; margin: -6px 0; }
.cols-plot { display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--line); background: linear-gradient(var(--line), var(--line)) 0 0 / 100% 1px no-repeat, linear-gradient(var(--line), var(--line)) 0 50% / 100% 1px no-repeat; }
.col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.col span { display: block; width: 100%; max-width: 24px; background: var(--olive); border-radius: 4px 4px 0 0; }
.col:hover span { background: var(--olive-dark); }
.col:hover { background: rgba(115, 134, 79, .06); }
.cols-x { grid-column: 2; display: flex; gap: 2px; margin-top: 6px; }
.cols-x span { flex: 1; width: 0; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; }
.chart-tip { position: fixed; left: 0; top: 0; pointer-events: none; opacity: 0; background: var(--navy); color: var(--white); font-size: 12px; padding: 6px 10px; border-radius: 4px; z-index: 200; transition: opacity .1s; white-space: nowrap; }
.bar-row[data-tip]:hover .bar > span { background: var(--olive-dark); }
.link-row { cursor: pointer; }
.link-row:hover td { background: var(--beige-soft); }
details summary { cursor: pointer; margin-top: 8px; }

.upload-card summary { cursor: pointer; list-style: none; }
.upload-card summary::-webkit-details-marker { display: none; }
.upload-card summary::before { content: '+'; display: inline-block; width: 20px; color: var(--olive); font-weight: 500; }
.upload-card[open] summary::before { content: '–'; }
@media (max-width: 640px) {
  #me { display: none; }
  .mainnav { margin-left: 0; }
  .mainnav a { padding: 8px; }
  .topbar { gap: 10px; }
}
.bar > span[style="width:0%"] { display: none; }

/* ---------- Client co-branding: the client's logo leads, MP's logo supports ---------- */
#brand-side .client-box { width: min(380px, 86%); min-height: 150px; padding: 28px 36px; }
#brand-side .client-box img { max-width: 100%; max-height: 140px; }
#brand-side .client-box.client-name { font-size: 30px; text-align: center; }
#brand-side .collab { margin: 36px 0 22px; }
.auth .side .mp-logo.sm { width: min(150px, 38%); }
#brand-side ~ p { margin-top: 40px; font-size: 20px; }
.cobrand .client-box { padding: 12px 20px; }
.cobrand .client-box img { max-width: 240px; max-height: 76px; }
.cobrand.light .client-box img { max-width: 190px; max-height: 64px; }
@media (max-width: 640px) {
  .cobrand { gap: 14px; }
  .cobrand .client-box img { max-width: 170px; max-height: 56px; }
  .cobrand .mp-mono { height: 44px; }
}
