/* ============================================================
   Afro Nation Surveys — "Golden Hour Ops" design system
   Warm charcoal, gold gradient sunburst, sand type.
   ============================================================ */

:root {
  --bg: #12100d;
  --surface: #1a1713;
  --surface-2: #221e18;
  --surface-3: #2a251d;
  --line: #2e2921;
  --line-strong: #3d362b;
  --gold: #f2c230;
  --gold-deep: #d9a31b;
  --gold-soft: #ffd966;
  --text: #f2ebdd;
  --muted: #9c9484;
  --faint: #6d665a;
  --coral: #ff6b4a;
  --teal: #2ec4b6;
  --violet: #a78bfa;
  --danger: #e5484d;
  --success: #58b368;
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: 'Unbounded', sans-serif;
  --font-body: 'Instrument Sans', system-ui, sans-serif;
  --font-mono: 'Space Mono', monospace;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-body);
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ---- sunburst mask: paint the logo with any background ---- */
.sunmark {
  display: inline-block;
  background: linear-gradient(140deg, var(--gold-soft), var(--gold-deep));
  -webkit-mask: url('../img/logo.png') center / contain no-repeat;
  mask: url('../img/logo.png') center / contain no-repeat;
}
.sunmark--ambient {
  position: fixed;
  width: 720px; height: 720px;
  right: -220px; bottom: -220px;
  opacity: .05;
  pointer-events: none;
  animation: sunspin 240s linear infinite;
  z-index: 0;
}
@keyframes sunspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .sunmark--ambient { animation: none; }
  * { transition: none !important; }
}

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #0d0b09;
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand .sunmark { width: 40px; height: 40px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.3;
  text-transform: uppercase;
}
.brand-name small { display: block; color: var(--muted); font-family: var(--font-mono); font-size: 9.5px; font-weight: 400; text-transform: none; letter-spacing: .12em; }

.nav-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: linear-gradient(120deg, rgba(242,194,48,.14), rgba(242,194,48,.05)); color: var(--gold); }
.sidebar .spacer { flex: 1; }
.userchip { border-top: 1px solid var(--line); padding: 14px 10px 2px; font-size: 13px; }
.userchip b { display: block; }
.userchip span { color: var(--muted); font-size: 12px; }
.userchip a { font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 30px 36px 60px; position: relative; z-index: 1; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; flex-wrap: wrap; }
.pagehead h1 { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: .01em; margin: 0; }
.pagehead .eyebrow { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-deep); display: block; margin-bottom: 7px; }
.pagehead .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font: 600 13.5px var(--font-body);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.btn:hover { border-color: var(--gold-deep); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-gold {
  background: linear-gradient(140deg, var(--gold-soft), var(--gold) 55%, var(--gold-deep));
  border-color: transparent;
  color: #17130b;
}
.btn-gold:hover { filter: brightness(1.06); color: #17130b; }
.btn-danger { border-color: rgba(229,72,77,.4); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---- cards / KPI ---- */
.card {
  background: linear-gradient(170deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi .label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-family: var(--font-display); font-size: 30px; font-weight: 600; margin: 10px 0 2px; color: var(--text); }
.kpi .value em { font-style: normal; color: var(--gold); }
.kpi .sub { font-size: 12.5px; color: var(--muted); }

/* ---- tables ---- */
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  padding: 10px 14px; border-bottom: 1px solid var(--line-strong);
  font-weight: 400;
}
table.list td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: rgba(242,194,48,.025); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
}
.badge-live { background: rgba(88,179,104,.14); color: var(--success); }
.badge-draft { background: rgba(156,148,132,.14); color: var(--muted); }
.badge-closed { background: rgba(229,72,77,.13); color: var(--danger); }
.badge-admin { background: rgba(242,194,48,.13); color: var(--gold); }
.badge-member { background: rgba(167,139,250,.13); color: var(--violet); }

.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---- forms ---- */
label.field { display: block; margin-bottom: 16px; }
label.field > span, .fieldlabel {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 13px;
  font: 14.5px var(--font-body);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-deep); outline: none; }
textarea { min-height: 90px; resize: vertical; }
.checkline { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); margin-bottom: 14px; cursor: pointer; }
.checkline input { accent-color: var(--gold); width: 16px; height: 16px; }
.formrow { display: flex; gap: 14px; }
.formrow > * { flex: 1; }

/* ---- flash toasts ---- */
.flashes { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.flash {
  background: var(--surface-3); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--gold);
  padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-size: 14px;
  animation: flash-in .25s ease;
}
.flash.error { border-left-color: var(--danger); }
.flash.success { border-left-color: var(--success); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---- login screen ---- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.login-sun {
  position: absolute; width: 900px; height: 900px;
  opacity: .07; animation: sunspin 240s linear infinite;
}
.login-card {
  position: relative; width: 400px; max-width: calc(100vw - 40px);
  background: linear-gradient(170deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-strong);
  border-radius: 20px; padding: 42px 38px;
  box-shadow: var(--shadow);
}
.login-card .sunmark { width: 62px; height: 62px; margin-bottom: 18px; }
.login-card h1 { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.login-card .tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 28px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 6px; }
.login-foot { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---- survey cards on dashboard ---- */
.survey-card { display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .15s; }
.survey-card:hover { border-color: var(--gold-deep); transform: translateY(-2px); }
.survey-card h3 { margin: 0; font-size: 16px; font-weight: 650; }
.survey-card h3 a { color: var(--text); }
.survey-card .slugline { font-family: var(--font-mono); font-size: 12px; color: var(--gold-deep); }
.survey-card .statline { display: flex; gap: 18px; color: var(--muted); font-size: 13px; margin-top: auto; padding-top: 8px; }
.survey-card .statline b { color: var(--text); font-family: var(--font-mono); }

/* ---- builder ---- */
.qlist { display: flex; flex-direction: column; gap: 10px; }
.qitem {
  display: flex; gap: 13px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px;
  transition: border-color .15s;
}
.qitem:hover { border-color: var(--line-strong); }
.qitem.dragging { opacity: .4; }
.qitem.is-section { background: transparent; border-style: dashed; }
.qitem .handle { cursor: grab; color: var(--faint); padding-top: 2px; user-select: none; }
.qitem .qbody { flex: 1; min-width: 0; }
.qitem .qlabel { font-weight: 600; }
.qitem .qmeta { font-family: var(--font-mono); font-size: 11px; color: var(--faint); margin-top: 3px; display:flex; gap:12px; flex-wrap:wrap; }
.qitem .qmeta .req { color: var(--coral); }
.qitem .qmeta .cond { color: var(--violet); }
.qitem .qactions { display: flex; gap: 6px; }
.qchoices { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

/* ---- slide-over editor ---- */
.slideover-backdrop {
  position: fixed; inset: 0; background: rgba(6,5,3,.6);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.slideover {
  position: fixed; top: 0; right: -520px; width: 500px; max-width: 100vw; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--line-strong);
  z-index: 100; padding: 28px 28px 40px; overflow-y: auto;
  transition: right .25s ease;
}
body.slideover-open .slideover { right: 0; }
body.slideover-open .slideover-backdrop { opacity: 1; pointer-events: auto; }
.slideover h2 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0 0 22px; }
.slideover .closex { position: absolute; top: 20px; right: 22px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }

/* ---- charts ---- */
.chartbox { position: relative; }
.chartbox h3 { margin: 0 0 4px; font-size: 15px; font-weight: 650; }
.report-section-title { font-size: 16px; }
.chartbox .qtype { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 14px; }
.chartbox canvas { max-height: 300px; }
.grid-charts { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.textanswers { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.textanswers .ta { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13.5px; }
.textanswers .ta time { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); margin-top: 4px; }

/* ---- misc ---- */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty .sunmark { width: 54px; height: 54px; opacity: .5; margin-bottom: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar input[type=text] { width: 260px; }
.pager { display: flex; gap: 8px; margin-top: 18px; align-items: center; color: var(--muted); font-size: 13px; }

.qr-pop { text-align: center; }
.qr-pop #qrbox { background: #fff; padding: 14px; border-radius: var(--radius-sm); display: inline-block; margin: 12px 0; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .spacer, .nav-label { display: none; }
  .main { padding: 20px 16px 40px; }
  .grid-charts { grid-template-columns: 1fr; }
  .formrow { flex-direction: column; gap: 0; }
}
