* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  line-height: 1.5;
}
.layout { max-width: 1100px; margin: 0 auto; padding: 24px; }

header h1 { font-size: 22px; margin-bottom: 12px; color: #f8fafc; }
.tabs { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid #334155; }
.tab {
  background: none; border: none; color: #94a3b8;
  padding: 10px 16px; cursor: pointer; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: #3b82f6; border-bottom-color: #3b82f6; }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: #1e293b; border: 1px solid #334155; border-radius: 12px;
  padding: 20px; margin-bottom: 16px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: #f8fafc; }
.hint { color: #94a3b8; font-size: 13px; margin-top: 6px; }

input[type=text], input[type=search], input[type=email], input[type=password], select, textarea {
  width: 100%;
  background: #0f172a; color: #e2e8f0;
  border: 1px solid #334155; border-radius: 8px;
  padding: 8px 12px; font-size: 14px; font-family: inherit;
  margin-top: 4px;
  display: block;
  box-sizing: border-box;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #3b82f6; }

.survey-list {
  margin-top: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  max-height: 260px;
  overflow-y: auto;
}
.survey-list .row {
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid #1e293b;
  color: #e2e8f0;
  user-select: none;
}
.survey-list .row:last-child { border-bottom: none; }
.survey-list .row:hover { background: #1e293b; }
.survey-list .row.selected { background: #1e40af; color: #fff; }
.survey-list .row-title { display: flex; align-items: center; gap: 6px; }
.survey-list .row-meta { font-size: 11px; color: #64748b; margin-top: 2px; }
.survey-list .row.selected .row-meta { color: #cbd5e1; }
.survey-list .empty { padding: 16px 12px; color: #64748b; font-style: italic; font-size: 13px; }

.status-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-pill.pill-open { background: #064e3b; color: #6ee7b7; }
.status-pill.pill-closed { background: #4c1d95; color: #c4b5fd; }
.status-pill.pill-other { background: #334155; color: #94a3b8; }

.tier-pill {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
  cursor: help;
}
.tier-pill.tier-a { background: #064e3b; color: #6ee7b7; }
.tier-pill.tier-b { background: #1e3a8a; color: #93c5fd; }
.tier-pill.tier-c { background: #581c87; color: #d8b4fe; }
.tier-pill.tier-unknown { background: #334155; color: #94a3b8; font-weight: 600; }

.survey-list .row.selected .tier-pill { box-shadow: 0 0 0 1px rgba(255,255,255,0.3); }

.tier-legend {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tier-legend .legend-item {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tier-legend .tier-pill { cursor: default; margin-right: 0; }

/* SurveyMonkey draft-app countdown progress bar — clickable, links to dev console */
.token-bar {
  margin: 8px 0 16px;
  padding: 8px 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.token-bar:hover { border-color: #475569; background: #233042; }
.token-bar:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.token-bar[hidden] { display: none; }
.token-bar-label {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
}
.token-bar-track {
  flex: 1;
  height: 8px;
  background: #0f172a;
  border-radius: 4px;
  overflow: hidden;
}
.token-bar-fill {
  height: 100%;
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: 4px;
}
.token-bar.state-ok    .token-bar-fill { background: #22c55e; }
.token-bar.state-warn  .token-bar-fill { background: #eab308; }
.token-bar.state-crit  .token-bar-fill { background: #ef4444; }
.token-bar.state-ok    .token-bar-label { color: #6ee7b7; }
.token-bar.state-warn  .token-bar-label { color: #fde047; }
.token-bar.state-crit  .token-bar-label { color: #fca5a5; }

/* API Key tab */
.apikey-status {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 12px 0 18px;
  font-size: 13px;
}
.apikey-status .meta-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #1e293b;
  color: #cbd5e1;
}
.apikey-status .meta-row:last-child { border-bottom: none; }
.apikey-status .meta-row .label { color: #94a3b8; }
.apikey-status .meta-row .val.ok { color: #6ee7b7; }
.apikey-status .meta-row .val.warn { color: #fde047; }
.apikey-status .meta-row .val.crit { color: #fca5a5; }
.apikey-status .meta-row .val.muted { color: #64748b; }

.apikey-scopes {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
}
.scope-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid #1e293b; }
.scope-row:last-child { border-bottom: none; }
.scope-row .icon { font-size: 14px; line-height: 1.4; }
.scope-row .scope-name { color: #f8fafc; font-weight: 500; }
.scope-row .scope-msg  { color: #94a3b8; font-size: 11px; margin-top: 2px; }
.scope-row.granted     .icon { color: #6ee7b7; }
.scope-row.missing     .icon { color: #fca5a5; }
.scope-row.untested    .icon { color: #94a3b8; }

.renewal-steps {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0 18px;
  font-size: 13px;
  color: #cbd5e1;
}
.renewal-steps summary {
  cursor: pointer;
  font-weight: 600;
  color: #f8fafc;
  user-select: none;
  padding: 2px 0;
}
.renewal-steps summary:hover { color: #93c5fd; }
.renewal-steps ol { margin: 12px 0 0 22px; padding: 0; }
.renewal-steps li { margin-bottom: 6px; line-height: 1.45; }
.renewal-steps li code {
  background: #1e293b; color: #cbd5e1;
  padding: 1px 5px; border-radius: 4px;
  font-size: 12px;
}
.renewal-steps a { color: #93c5fd; text-decoration: underline; }

/* Login overlay */
.login-overlay {
  position: fixed; inset: 0;
  background: #0f172a;
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.login-overlay[hidden] { display: none; }

/* Modal (replaces native prompt/confirm) */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: #1e293b; border: 1px solid #334155; border-radius: 12px;
  padding: 24px; width: 420px; max-width: calc(100vw - 32px);
}
.modal-card h2 { font-size: 17px; color: #f8fafc; margin-bottom: 8px; }
.modal-card .hint { margin-bottom: 14px; }
.modal-card #modal-input { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions button { padding: 8px 16px; font-size: 14px; }
.login-card {
  background: #1e293b; border: 1px solid #334155; border-radius: 12px;
  padding: 32px; width: 380px; max-width: calc(100vw - 32px);
}
.login-card h1 { font-size: 22px; color: #f8fafc; margin-bottom: 4px; }
.login-card .hint { margin-bottom: 16px; }
.login-card label { display: block; margin-top: 12px; }
.login-card button { width: 100%; margin-top: 18px; }
.login-card .hint a {
  color: #93c5fd;
  text-decoration: none;
  border-bottom: 1px dotted #475569;
  padding-bottom: 1px;
}
.login-card .hint a:hover { color: #bfdbfe; border-bottom-color: #93c5fd; }
.login-err { color: #fca5a5; font-size: 13px; margin-top: 12px; min-height: 16px; }

/* Header row */
.header-row { display: flex; align-items: center; justify-content: space-between; }
.header-actions { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #94a3b8; }

/* Published pages list */
#pages-list { margin-top: 12px; }
.page-row {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.page-row .page-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-row .page-title { font-weight: 600; color: #f8fafc; font-size: 15px; flex: 1; }
.page-row .page-meta { font-size: 11px; color: #64748b; margin-top: 4px; }
.page-row .page-url { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #94a3b8; margin-top: 6px; word-break: break-all; }
.page-row .page-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.page-row .page-actions button { font-size: 12px; padding: 4px 10px; }
.page-row.published { border-color: #14532d; }
.page-row.draft { border-color: #334155; }

.lock-pill { font-size: 11px; padding: 1px 7px; border-radius: 8px; }
.lock-pill.locked { background: #4a044e; color: #f0abfc; }
.lock-pill.open { background: #334155; color: #94a3b8; }

code { background: #0f172a; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 8px; }
label.row { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: none; letter-spacing: 0; color: #cbd5e1; }
label.row input { width: auto; margin-top: 0; }

fieldset {
  border: 1px solid #334155; border-radius: 8px;
  padding: 12px; margin-top: 12px;
}
legend { color: #94a3b8; padding: 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

#kn-likert-mappings .lk-row { display: grid; grid-template-columns: 200px 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
#kn-likert-mappings .lk-row span { font-size: 13px; color: #cbd5e1; }

button.primary {
  background: #3b82f6; color: #fff; border: none;
  padding: 10px 18px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 600;
}
button.primary:hover { background: #2563eb; }
button.primary.big { padding: 14px 24px; font-size: 16px; }
button.ghost {
  background: transparent; color: #94a3b8; border: 1px solid #334155;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
button.ghost:hover { color: #f8fafc; border-color: #94a3b8; }

.file-button {
  display: inline-block;
  background: #334155; color: #e2e8f0;
  padding: 10px 16px; border-radius: 8px; cursor: pointer;
  text-transform: none; letter-spacing: 0; font-size: 14px; margin-top: 0;
}
.file-button input { display: none; }
.file-button:hover { background: #475569; }

.row { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }

.theme-row {
  background: #0f172a; border: 1px solid #334155; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.theme-row-header { display: flex; align-items: center; gap: 10px; }
.theme-row-name { flex: 1; background: transparent; border: none; color: #f8fafc; font-weight: 600; padding: 0; margin: 0; }
.theme-row-count { font-size: 12px; color: #94a3b8; }
.theme-row .pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.theme-row .pill.pos { background: #064e3b; color: #6ee7b7; }
.theme-row .pill.neg { background: #7f1d1d; color: #fca5a5; }
.theme-row .pill.neu { background: #334155; color: #cbd5e1; }
.theme-keywords { margin-top: 6px; font-size: 12px; color: #94a3b8; font-family: ui-monospace, Menlo, monospace; }
.theme-examples { margin-top: 6px; font-size: 12px; color: #64748b; font-style: italic; }
.theme-actions { display: flex; gap: 6px; }

#confidence-low { color: #fbbf24; font-size: 11px; margin-left: 6px; }

/* Display tab */
.display-bar {
  display: flex; align-items: center; gap: 12px;
  background: #1e293b; border: 1px solid #334155; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 12px;
}
.display-bar span { flex: 1; font-size: 13px; color: #94a3b8; }
#dash-iframe {
  width: 100%; height: calc(100vh - 200px); min-height: 600px;
  background: #0f172a; border: 1px solid #334155; border-radius: 8px;
}
