:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --blue: #2563eb;
  --yellow: #eab308;
  --red: #dc2626;
  --green: #16a34a;
  --navy: #3730a3;
  --flash-bg: #ecfeff;
  --flash-border: #a5f3fc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 90px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 16px;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
}

.topbar-link {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.topbar-link.active {
  color: var(--navy);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  margin-bottom: 16px;
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

h1, h2, h3 {
  margin: 0 0 8px;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  background: #eef2ff;
  color: var(--navy);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.loop-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 14px;
}

.loop-button {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.loop-button.prepare {
  background: var(--blue);
  color: white;
}

.loop-button.notice {
  background: var(--yellow);
  color: #111827;
}

.loop-button.act {
  background: var(--red);
  color: white;
}

.secondary-button {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  text-align: center;
}

.action-button {
  display: inline-block;
  text-decoration: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
}

.action-button.green {
  background: var(--green);
  color: white;
}

.action-button.act {
  background: var(--red);
  color: white;
}

.action-button.blue {
  background: var(--blue);
  color: white;
}

.danger-button {
  display: inline-block;
  text-decoration: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  background: var(--red);
  color: white;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 4px;
}

.filter-chip {
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}

.filter-chip.active {
  background: #eef2ff;
  color: var(--navy);
}

.filter-form {
  display: grid;
  gap: 10px 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  margin: 14px 0 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafbff;
}

.filter-field {
  display: grid;
  gap: 6px;
  align-content: end;
}

.tag-link {
  text-decoration: none;
  font-weight: 700;
}

.tag-link:hover,
.tag-link:focus {
  background: #e5e7eb;
}

.stats-grid,
.two-column-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stat-list {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.form-stack {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

label {
  font-weight: 700;
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: white;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.form-actions,
.card-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 8px;
}

.inline-form {
  display: contents;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash-message {
  background: var(--flash-bg);
  border: 1px solid var(--flash-border);
  border-radius: 14px;
  padding: 12px 14px;
}

.item-list {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.item-list.compact {
  gap: 10px;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.item-card.compact {
  padding: 12px 14px;
}

.item-card-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.status-pill,
.meta-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.status-pill {
  font-weight: 700;
}

.status-pill.not_acted {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.acted {
  background: #dcfce7;
  color: #166534;
}

.status-pill.scheduled {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-pill.dismissed {
  background: #f3f4f6;
  color: #4b5563;
}

.status-pill.strong {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-pill.active {
  background: #dcfce7;
  color: #166534;
}

.status-pill.dormant {
  background: #fef3c7;
  color: #92400e;
}

.meta-row,
.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.meta-pill {
  background: #f3f4f6;
  color: #374151;
}

.network-section {
  margin-top: 18px;
}

.progress-block {
  margin-top: 14px;
}

.progress-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
}

.progress-bar.blue {
  background: var(--blue);
}

.progress-bar.yellow {
  background: var(--yellow);
}

.progress-bar.red {
  background: var(--red);
}

.progress-bar.green {
  background: var(--green);
}

.profile-stat-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.profile-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.badge-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: 12px;
}

.badge-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
  background: #fff;
}

.badge-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.badge-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.stats-tiles {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: 12px;
}

.stat-tile {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  text-align: center;
}

.stat-tile-number {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
}

/* The nav spreads evenly when the destinations fit and scrolls sideways when
   they do not, so adding a section never squeezes the labels into columns. */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 4px;
  padding: 10px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.bottom-nav::-webkit-scrollbar {
  display: none;
}

.bottom-nav a {
  flex: 1 0 auto;
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 10px;
}

.bottom-nav a.active {
  background: #eef2ff;
  color: var(--navy);
  font-weight: 700;
}

.secondary-button {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  text-align: center;
}

.status-pill.open {
  background: #fef3c7;
  color: #92400e;
}

.status-pill.completed {
  background: #dcfce7;
  color: #166534;
}

.status-pill.new {
  background: #dcfce7;
  color: #166534;
}

.status-pill.duplicate {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-pill.skipped {
  background: #f3f4f6;
  color: #4b5563;
}

.import-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.import-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: white;
}

.import-table th,
.import-table td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.import-table th {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
}

.import-table tr:last-child td {
  border-bottom: 0;
}

.checklist-stack {
  display: grid;
  gap: 10px;
}

.checklist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-weight: 700;
}

.checklist-row input {
  width: auto;
}

/* ---------------------------------------------------------------- admin --
   The console reuses the app's tokens but reads as a denser, more
   instrument-like surface: a slate rail, tabular data, and monospace for
   anything an administrator might need to copy exactly. */

:root {
  --slate: #1e293b;
  --slate-soft: #334155;
  --admin-tint: #f1f5f9;
}

.topbar-link.admin-link {
  color: var(--slate);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  background: white;
}

.topbar-link.admin-link.active {
  background: var(--slate);
  color: white;
  border-color: var(--slate);
}

.announcement-banner {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-left: 4px solid var(--yellow);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.admin-rail {
  background: var(--slate);
  color: #e2e8f0;
  border-radius: 18px;
  padding: 20px 20px 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.admin-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
}

.admin-title {
  margin: 6px 0 0;
  color: white;
  font-size: 1.6rem;
  line-height: 1.2;
}

.admin-lede {
  margin: 6px 0 0;
  color: #94a3b8;
  font-size: 0.95rem;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.admin-tab {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: 12px 12px 0 0;
  border-bottom: 3px solid transparent;
}

.admin-tab:hover {
  background: var(--slate-soft);
  color: white;
}

.admin-tab.active {
  background: var(--bg);
  color: var(--slate);
  border-bottom-color: var(--blue);
}

.admin-metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 16px;
}

.admin-metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--slate);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  gap: 2px;
  align-content: start;
}

.admin-metric.flagged {
  border-left-color: var(--red);
}

.admin-metric-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.admin-metric-label {
  font-weight: 700;
  font-size: 0.9rem;
}

.admin-metric-note {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-table-scroll {
  overflow-x: auto;
  margin-top: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th {
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 0 12px 8px 0;
  white-space: nowrap;
}

.admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px 10px 0;
  vertical-align: top;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table a {
  color: var(--blue);
  text-decoration: none;
}

.admin-number {
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding-right: 18px !important;
}

.admin-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  word-break: break-word;
}

.admin-kind {
  display: inline-block;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
}

.admin-row-actions {
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.admin-row-actions .link-button.danger {
  color: var(--red);
}

.admin-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.admin-field-pair {
  display: grid;
  gap: 10px;
  grid-template-columns: 2fr 1fr;
}

.admin-legend {
  font-weight: 700;
  font-size: 0.95rem;
}

.admin-check-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  background: var(--admin-tint);
  border-radius: 14px;
  padding: 12px 14px;
}

.admin-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  font-weight: 400;
}

.admin-check input {
  width: auto;
  margin-top: 3px;
}

.admin-check span span {
  display: block;
}

.admin-inline-test {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 14px;
}

.admin-subhead {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.admin-empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 22px 18px;
  text-align: center;
  margin-top: 12px;
}

.admin-empty p {
  margin: 0 0 4px;
}

.admin-highlight {
  border-left: 4px solid var(--blue);
}

.admin-secret {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  background: var(--slate);
  color: #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  word-break: break-all;
  user-select: all;
  margin: 12px 0 0;
}

.admin-danger {
  border-left: 4px solid var(--red);
}

.admin-notice {
  background: var(--admin-tint);
  border: 1px solid var(--border);
  border-left: 3px solid var(--slate);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
}

.admin-maintenance {
  text-align: center;
  padding: 40px 24px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .admin-field-pair,
  .admin-search-row {
    grid-template-columns: 1fr;
  }

  .admin-rail {
    padding: 16px 16px 0;
  }
}

.connect-form {
  margin-top: 12px;
}

.goal-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.goal-summary-row + .progress-track {
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------------------
   Gamification: quests, badge progress, and the API key reveal.
   --------------------------------------------------------------------------- */

.loop-button small {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.85;
}

.progress-track.slim {
  height: 7px;
}

.quest-step-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.quest-step {
  display: grid;
  gap: 4px;
}

.quest-step .progress-label-row {
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.badge-card.locked {
  background: #f9fafb;
  border-style: dashed;
  opacity: 0.72;
}

.profile-stat-row.mine {
  font-weight: 700;
}

.callout {
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 12px;
  background: #f0fdf4;
}

.callout p {
  margin: 0 0 8px;
}

.callout p:last-child {
  margin-bottom: 0;
}

.token-reveal {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: #111827;
  color: #f9fafb;
  font-size: 0.85rem;
  word-break: break-all;
}
