/* Survey platform — admin portal.
   The palette is derived from what the product measures: the promoter /
   passive / detractor trio is the same everywhere a score appears, so a colour
   always means the same thing whether it's on a chart, a table cell or a badge. */

:root {
  --ink:        #16202A;
  --ink-soft:   #52636F;
  --ink-faint:  #8695A0;
  --petrol:     #12414F;
  --petrol-dim: #0D3340;
  --petrol-lit: #1C5C6E;
  --paper:      #FBFCFD;
  --surface:    #FFFFFF;
  --rule:       #DDE3E7;
  --rule-soft:  #EDF1F3;

  --promoter:   #2E7D5B;
  --passive:    #E8A33D;
  --detractor:  #C2453D;
  --promoter-wash:  #E8F2EC;
  --passive-wash:   #FBF1DF;
  --detractor-wash: #F7E7E5;

  --radius: 5px;
  --rail: 232px;
  --shadow-lift: 0 1px 2px rgba(22, 32, 42, .06), 0 8px 24px rgba(22, 32, 42, .08);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

a { color: var(--petrol-lit); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--petrol-lit); outline-offset: 2px; }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: linear-gradient(180deg, var(--petrol) 0%, var(--petrol-dim) 100%);
  color: #CFDDE2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.rail__brand {
  padding: 22px 20px 18px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  flex-shrink: 0;
}
.rail__brand-link { display: block; text-decoration: none; }
.rail__logo { max-height: 30px; display: block; }
.rail__logo-fallback { font-weight: 650; font-size: 1.05rem; color: #fff; letter-spacing: -.01em; }
.rail__brand small { display: block; font-weight: 400; font-size: .74rem; color: #9FBAC3; margin-top: 6px; }

.rail__scroll { flex: 1; overflow-y: auto; padding: 10px 12px; }
.rail__scroll::-webkit-scrollbar { width: 6px; }
.rail__scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

@media (max-width: 860px) {
  .rail__group, .rail__foot, .rail__label, .rail__scroll { display: none; }
  .rail__brand { border: 0; white-space: nowrap; }
  .shell { flex-direction: column; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

.rail__group { padding: 10px 0; }
.rail__group + .rail__group { border-top: 1px solid rgba(255, 255, 255, .07); }
.rail__label {
  padding: 0 8px 6px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6F97A3;
}
.rail a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  margin: 1px 0;
  border-radius: 7px;
  color: #CFDDE2;
  font-size: .89rem;
  transition: background .12s ease, color .12s ease;
}
.rail__icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.rail a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.rail a:hover .rail__icon { opacity: 1; }
.rail a.is-active {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-weight: 500;
}
.rail a.is-active .rail__icon { opacity: 1; color: var(--passive); }

.rail__foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  background: rgba(0, 0, 0, .1);
}
.rail__avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--petrol-lit);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem;
  flex-shrink: 0;
}
.rail__foot-text { flex: 1; min-width: 0; font-size: .8rem; line-height: 1.3; }
.rail__foot-text strong { display: block; color: #fff; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail__foot-text span { color: #9FBAC3; }
.rail__signout-form { margin: 0; }
.rail__signout {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  padding: 0; border: 0; background: transparent; color: #9FBAC3; cursor: pointer;
}
.rail__signout:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.topbar__title h1 { margin: 0; }
.topbar__actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.content { padding: 24px 28px 64px; max-width: 1280px; }

/* ---------- Instrument strip: the headline metrics ---------- */
.strip {
  display: flex;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 24px;
}
.strip__cell {
  flex: 1 1 150px;
  padding: 16px 20px;
  border-right: 1px solid var(--rule-soft);
}
.strip__cell:last-child { border-right: 0; }
.strip__value {
  font-size: 1.85rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.strip__label { font-size: .82rem; color: var(--ink-soft); margin-top: 2px; }
.strip__note { font-size: .76rem; color: var(--ink-faint); }
.value--promoter { color: var(--promoter); }
.value--passive { color: var(--passive); }
.value--detractor { color: var(--detractor); }
.value--muted { color: var(--ink-faint); }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--rule);
}
.panel__head h2, .panel__head h3 { margin: 0; font-size: .98rem; }
.panel__body { padding: 18px; }
.panel__body--flush { padding: 0; }
.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: .8rem;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--rule-soft);
  white-space: nowrap;
}
.table td { padding: 11px 18px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #F7FAFB; }
.table .num { text-align: right; }
.table__empty { padding: 40px 18px; text-align: center; color: var(--ink-soft); }
.table-scroll { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: .76rem;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge--draft      { background: var(--rule-soft); color: var(--ink-soft); border-color: var(--rule); }
.badge--published  { background: var(--promoter-wash); color: var(--promoter); }
.badge--paused     { background: var(--passive-wash); color: #96631A; }
.badge--closed,
.badge--archived   { background: #EFF2F4; color: var(--ink-faint); }
.badge--completed  { background: var(--promoter-wash); color: var(--promoter); }
.badge--in_progress { background: #E6F0F3; color: var(--petrol-lit); }
.badge--screened_out,
.badge--quota_full { background: var(--passive-wash); color: #96631A; }
.badge--abandoned,
.badge--failed,
.badge--bounced    { background: var(--detractor-wash); color: var(--detractor); }
.badge--type       { background: #E6F0F3; color: var(--petrol); font-family: ui-monospace, monospace; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #F2F6F7; text-decoration: none; }
.btn--primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn--primary:hover { background: var(--petrol-dim); }
.btn--danger { color: var(--detractor); border-color: #E9C9C6; }
.btn--danger:hover { background: var(--detractor-wash); }
.btn--small { padding: 5px 11px; font-size: .82rem; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 5px; }
.field .hint { font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=date], input[type=datetime-local], input[type=search],
select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-size: .9rem;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--petrol-lit);
  outline: 2px solid rgba(28, 92, 110, .16);
  outline-offset: 0;
}
textarea { resize: vertical; min-height: 78px; }
input[type=color] { width: 46px; height: 34px; padding: 2px; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--surface); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 180px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: .88rem; }
.checkline input { width: auto; }

/* ---------- Toolbar / filters ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 190px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 11px;
  border: 1px solid var(--rule);
  border-radius: 100px;
  font-size: .82rem;
  color: var(--ink-soft);
  background: var(--surface);
}
.chip.is-active { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.chip:hover { text-decoration: none; }

/* ---------- Flash ---------- */
.flashes { padding: 12px 28px 0; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  border-left: 3px solid;
  margin-bottom: 8px;
  font-size: .9rem;
}
.flash--success { background: var(--promoter-wash); border-color: var(--promoter); }
.flash--error   { background: var(--detractor-wash); border-color: var(--detractor); }
.flash--info    { background: #E6F0F3; border-color: var(--petrol-lit); }
.flash--warning { background: var(--passive-wash); border-color: var(--passive); }

/* ---------- Builder ---------- */
.builder { display: grid; grid-template-columns: 1fr 268px; gap: 20px; align-items: start; }
.page-block { margin-bottom: 18px; }
.page-block__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: #EFF4F5;
  border: 1px solid var(--rule);
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
  font-size: .92rem;
}
.q-list { border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface); min-height: 54px; }
.q-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--surface);
}
.q-item:last-child { border-bottom: 0; }
.q-item.dragging { opacity: .4; }
.q-item.drag-over { border-top: 2px solid var(--petrol-lit); }
.q-handle {
  cursor: grab;
  color: var(--ink-faint);
  font-size: 1.05rem;
  line-height: 1.3;
  user-select: none;
  padding-top: 1px;
}
.q-body { flex: 1; min-width: 0; }
.q-title { font-weight: 500; }
.q-meta { font-size: .8rem; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center; margin-top: 3px; }
.q-code { font-family: ui-monospace, monospace; font-size: .78rem; color: var(--petrol-lit); }
.q-actions { display: flex; gap: 6px; flex-shrink: 0; }
.type-list { display: flex; flex-direction: column; gap: 3px; }
.type-btn {
  text-align: left;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-size: .86rem;
  cursor: pointer;
  color: var(--ink);
}
.type-btn:hover { background: #EFF4F5; border-color: var(--rule); }
.type-group { font-size: .74rem; color: var(--ink-faint); padding: 9px 11px 3px; }

/* ---------- Charts (CSS-only, no JS dependency) ---------- */
.bar-row { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 62px; gap: 12px;
  align-items: center; margin-bottom: 9px; font-size: .88rem; }
.bar-track { background: var(--rule-soft); border-radius: 3px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--petrol-lit); border-radius: 3px; }
.bar-fill--promoter { background: var(--promoter); }
.bar-fill--passive { background: var(--passive); }
.bar-fill--detractor { background: var(--detractor); }
.bar-value { text-align: right; color: var(--ink-soft); font-size: .84rem; }

.nps-band { display: flex; height: 26px; border-radius: 3px; overflow: hidden;
  border: 1px solid var(--rule); }
.nps-band span { display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: .76rem; font-weight: 500; }
.nps-band .seg--detractor { background: var(--detractor); }
.nps-band .seg--passive { background: var(--passive); }
.nps-band .seg--promoter { background: var(--promoter); }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 64px; }
.spark__bar { flex: 1; background: var(--petrol-lit); border-radius: 2px 2px 0 0; min-height: 2px; }
.spark__bar--muted { background: #BBCCD3; }

.matrix-cell { text-align: center; font-variant-numeric: tabular-nums; }
.heat-1 { background: #F4F8F6; } .heat-2 { background: #E4F0E9; }
.heat-3 { background: #CFE5D8; } .heat-4 { background: #B4D7C3; }
.heat-5 { background: #93C7AB; }

/* ---------- Misc ---------- */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; font-size: .88rem; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--surface); }
.pagination .is-current { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-soft); }
.empty h3 { color: var(--ink); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .84rem; }
.stack > * + * { margin-top: 14px; }
.inline-form { display: inline; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-family: ui-monospace, monospace; font-size: .82rem; }
details.disclosure summary { cursor: pointer; font-weight: 500; padding: 6px 0; }

/* ---------- Auth screens ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth__aside {
  background: var(--petrol);
  color: #DCE7EA;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth__aside h1 { color: #fff; font-size: 2rem; max-width: 15ch; }
.auth__aside p { max-width: 42ch; }
.auth__scale { display: flex; gap: 3px; margin-top: 28px; }
.auth__scale i {
  height: 7px;
  flex: 1;
  border-radius: 2px;
  display: block;
}
.auth__form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth__form form { width: 100%; max-width: 350px; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .builder { grid-template-columns: 1fr; }
  .rail {
    position: static;
    width: 100%;
    flex: none;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    align-items: center;
  }
  .rail__group, .rail__foot, .rail__label { display: none; }
  .rail__brand { border: 0; white-space: nowrap; }
  .shell { flex-direction: column; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  padding: 32px 20px;
  border: 2px dashed var(--rule);
  border-radius: 12px;
  background: var(--surface-2, #F7F9FA);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--petrol);
  background: rgba(18, 65, 79, .04);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone__icon {
  width: 40px; height: 40px;
  color: var(--petrol);
  opacity: .7;
}
.dropzone__title { font-weight: 600; font-size: .95rem; color: var(--ink, #1A2B30); }
.dropzone__hint { font-size: .8rem; color: var(--muted, #6B838A); }
.dropzone__filename {
  margin-top: 4px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--petrol);
  display: none;
}
.dropzone.has-file .dropzone__filename { display: block; }
.dropzone.has-file .dropzone__title { display: none; }