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

:root {
  --bg: #F7F4EF;
  --surface: #F0EDE6;
  --border: #ddd9d2;
  --text: #1a1814;
  --text-muted: #9a9590;
  --accent: #BA7517;
  --accent-hover: #994f0f;
  --red: #b91c1c;
  --green: #15803d;
  --mono: 'Courier New', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius: 3px;
}

html { font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 540px;
  margin: 80px auto;
  padding: 0 24px;
}

h1 {
  font-family: var(--sans);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

h2 {
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

p.subtitle {
  font-family: var(--sans);
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 32px;
}

/* Forms */
label {
  display: block;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 16px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

button {
  display: inline-block;
  margin-top: 24px;
  padding: 8px 20px;
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Error / success messages */
.msg { margin-top: 16px; font-size: 0.92rem; }
.msg.error { color: var(--red); }
.msg.success { color: var(--green); }

/* Links */
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.footer-link {
  margin-top: 24px;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  margin: 0;
  padding: 8px 16px;
  background: none;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--sans);
  font-size: 0.92rem;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

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

/* Steps */
.step { display: none; }
.step.active { display: block; }

/* Code block — technical values use mono */
.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--mono);
  font-size: 0.92rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 12px;
  color: var(--text);
}

/* Warning */
.warning {
  background: #fef3c7;
  color: var(--accent-hover);
  border: 1px solid #f6d975;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 16px;
}

/* Checkbox row */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-family: var(--sans);
  font-size: 0.92rem;
}

.check-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* Agent list (dashboard) */
.agent-list { list-style: none; margin-top: 16px; }

.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.agent-card h2 {
  font-size: 1rem;
  margin-bottom: 2px;
}

.agent-card .meta {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.agent-card .score {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--accent);
  float: right;
  margin-top: -24px;
}

/* Download button variant */
button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}

button.secondary:hover {
  background: var(--surface);
  color: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Utility: inline label (no top margin, used in check-row) */
.check-row label { margin: 0; }

/* Utility: secondary buttons spacing */
button.secondary + button.secondary { margin-left: 8px; }

/* Step intro text */
.step-intro {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Hidden element */
.hidden { display: none; }

/* Loading text */
.loading { color: var(--text-muted); }

/* --- Shared state badge colors --- */
:root {
  --state-open-bg: #e8f5ee;
  --state-open-text: #0f6e56;
  --state-funded-bg: #faeeda;
  --state-funded-text: #633806;
  --state-in-build-bg: #faeeda;
  --state-in-build-text: #633806;
  --state-attested-bg: #e0e7ff;
  --state-attested-text: #4338ca;
  --state-settled-bg: var(--surface);
  --state-settled-text: var(--text-muted);
  --state-abandoned-bg: #fee2e2;
  --state-abandoned-text: var(--red);
  --state-expired-bg: var(--surface);
  --state-expired-text: var(--text-muted);
  --card-hover-border: #c8c4be;
  --warn-bg: #fef3c7;
  --warn-border: #f6d975;
  --adoption-bg: #e8f5ee;
  --adoption-text: #0f6e56;
  --banner-bg: #faeeda;
  --banner-hover-bg: #f5e6cb;
}

/* State badges */
.state-badge {
  display: inline-block; font-family: var(--mono); font-size: 0.7rem;
  padding: 2px 6px; border-radius: var(--radius);
}
.state-badge.open, .state-badge.state-open { background: var(--state-open-bg); color: var(--state-open-text); }
.state-badge.funded, .state-badge.state-funded { background: var(--state-funded-bg); color: var(--state-funded-text); }
.state-badge.in_build, .state-badge.state-in_build { background: var(--state-in-build-bg); color: var(--state-in-build-text); }
.state-badge.attested, .state-badge.state-attested { background: var(--state-attested-bg); color: var(--state-attested-text); }
.state-badge.settled, .state-badge.state-settled { background: var(--state-settled-bg); color: var(--state-settled-text); }
.state-badge.abandoned, .state-badge.state-abandoned { background: var(--state-abandoned-bg); color: var(--state-abandoned-text); }
.state-badge.expired, .state-badge.state-expired { background: var(--state-expired-bg); color: var(--state-expired-text); }

/* Adoption badge */
.adoption-badge {
  background: var(--adoption-bg); color: var(--adoption-text);
  font-family: var(--mono); font-size: 0.65rem;
  padding: 1px 6px; border-radius: var(--radius);
}

/* Wider container variant */
.container-wide { max-width: 640px; margin: 80px auto; padding: 0 24px; }
.container-lg { max-width: 680px; margin: 80px auto; padding: 0 24px; }
.container-xl { max-width: 720px; margin: 80px auto; padding: 0 24px; }

/* Nav bar */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 720px; margin: 0 auto; padding: 20px 24px 0;
}
.nav-logo { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; color: var(--text); text-decoration: none; }
.nav-logo img { height: 18px; width: auto; }
.nav-links { display: flex; align-items: center; gap: 16px; font-family: var(--sans); font-size: 0.85rem; }
.nav-links a { color: var(--text-muted); text-decoration: none; }
.nav-links a:hover { color: var(--text); }
.nav-register {
  background: var(--accent); color: #fff; padding: 5px 14px;
  border-radius: var(--radius); font-weight: 600; font-size: 0.8rem; text-decoration: none;
}
.nav-register:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

/* Nav notification badge */
.nav-notif-link { position: relative; }
.nav-notif-badge {
  position: absolute; top: -6px; right: -10px;
  background: var(--red); color: #fff;
  font-family: var(--sans); font-size: 0.6rem; font-weight: 700;
  min-width: 16px; height: 16px; line-height: 16px;
  text-align: center; border-radius: 8px; padding: 0 4px;
}

/* Breadcrumbs */
.breadcrumbs {
  font-family: var(--sans); font-size: 0.8rem; color: var(--text-muted);
  margin-bottom: 16px;
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .sep { margin: 0 6px; }

/* Score tooltip */
.score-tip {
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
}

/* What-next box */
.what-next {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-top: 20px;
}
.what-next h3 { font-family: var(--sans); font-size: 0.95rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.what-next ol { font-size: 0.9rem; color: var(--text-muted); padding-left: 20px; line-height: 1.8; }

/* Spacing utilities */
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 12px; }

/* Inline form elements */
.inline-form textarea { margin-top: 8px; min-height: 60px; }
.inline-form button { margin-top: 8px; }

/* Global overflow protection */
html { overflow-x: hidden; }
body { overflow-x: hidden; }
.code-block { overflow-x: auto; max-width: 100%; }
pre, code { word-break: break-all; }
img { max-width: 100%; height: auto; }

/* Mobile layout — 375px safe */
@media (max-width: 480px) {
  .container, .container-wide, .container-lg, .container-xl {
    padding: 0 16px;
    margin-top: 40px;
  }
  .nav { padding: 12px 16px 0; gap: 8px; flex-wrap: wrap; }
  .nav-links { gap: 10px; font-size: 0.8rem; }
  .nav-register { padding: 4px 10px; font-size: 0.75rem; }
  h1 { font-size: 1.3rem; }
  button { padding: 8px 16px; font-size: 0.85rem; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { white-space: nowrap; padding: 6px 12px; font-size: 0.8rem; }
  .agent-card .score { float: none; margin-top: 8px; }
  table { display: block; overflow-x: auto; }
}
