:root {
  --color-navy: #2d3a7a;
  --color-light-blue: #b8d4e8;
  --color-cream: #f7f9fc;
  --color-white: #ffffff;
  --color-muted: #4a5578;
  --color-border: #c8d8e8;
  --color-success: #2d6a4f;
  --color-success-bg: #e8f5ee;
  --color-error: #9b2335;
  --color-error-bg: #fce8ec;
  --color-running: #2d3a7a;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --max-width: 1100px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-navy);
  background: var(--color-cream);
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--color-navy);
  text-decoration: none;
}

a:hover {
  color: #1e2858;
  text-decoration: underline;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.25;
  margin: 0 0 1rem;
}

h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-light-blue);
}

h3 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 1rem;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-light-blue);
  border-bottom: 1px solid var(--color-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  color: var(--color-navy);
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  color: var(--color-navy);
}

.brand img {
  display: block;
  width: 120px;
  height: auto;
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--color-navy);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.site-nav a:hover {
  color: #1e2858;
  text-decoration: none;
}

/* Sections */

.section {
  padding: 4rem 0;
}

.section:nth-child(even) {
  background: var(--color-white);
}

.section-lead {
  font-size: 1.125rem;
  color: var(--color-muted);
  max-width: 42rem;
}

/* Hero */

.hero {
  padding: 4rem 0 3.5rem;
  background: var(--color-light-blue);
  border-bottom: 1px solid var(--color-border);
}

.hero .container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
}

.hero-tagline {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--color-muted);
  max-width: 36rem;
  margin: 0;
}

/* Coverage grid */

.coverage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 2rem;
}

.coverage-item {
  padding: 0.5rem 0.75rem;
  background: var(--color-cream);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Forms */

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--color-navy);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 2px rgba(45, 58, 122, 0.15);
}

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

.form-error {
  color: var(--color-error);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-navy);
  color: var(--color-white);
}

.btn-primary:hover:not(:disabled) {
  background: #1e2858;
}

.btn-secondary {
  background: transparent;
  color: var(--color-navy);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-navy);
  color: var(--color-navy);
}

/* Alerts */

.alert {
  padding: 0.85rem 1rem;
  border-radius: 4px;
  margin-top: 1rem;
  font-size: 0.95rem;
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid var(--color-error);
}

.alert-info {
  background: #eef4f8;
  color: var(--color-running);
  border: 1px solid var(--color-running);
}

/* Footer */

.site-footer {
  padding: 2.5rem 0;
  background: var(--color-navy);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--color-light-blue);
}

.site-footer a:hover {
  color: var(--color-white);
}

/* Admin */

.admin-page {
  min-height: 100vh;
}

.admin-header {
  padding: 1.5rem 0;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}

.admin-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin: 0;
}

.admin-subtitle {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin: 0.25rem 0 0;
}

.admin-main {
  padding: 2rem 0 4rem;
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.action-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.action-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.action-card h3 {
  margin: 0;
}

.action-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-muted);
  flex: 1;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  white-space: nowrap;
}

.status-idle {
  background: #f0ede8;
  color: var(--color-muted);
}

.status-running {
  background: #e8f0f5;
  color: var(--color-running);
}

.status-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.action-result {
  font-size: 0.9rem;
}

.action-result details {
  margin-top: 0.5rem;
}

.action-result summary {
  cursor: pointer;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.action-result pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--color-cream);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Run log */

.run-log {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.5rem;
}

.run-log h2 {
  margin-bottom: 1rem;
}

.run-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.run-log-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.run-log-item:last-child {
  border-bottom: none;
}

.run-log-item time {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.run-log-empty {
  color: var(--color-muted);
  font-style: italic;
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 58, 122, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--color-white);
  border-radius: 6px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal h2 {
  margin-bottom: 0.5rem;
  border: none;
  padding: 0;
}

.modal p {
  color: var(--color-muted);
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.modal-actions .btn-primary {
  min-width: 100px;
}

.auth-gate .modal {
  max-width: 380px;
}

.hidden {
  display: none !important;
}

/* Responsive */

@media (max-width: 768px) {
  .site-header .container {
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 1rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .hero {
    padding: 3rem 0;
  }

  .hero-tagline {
    font-size: 1.2rem;
  }

  .section {
    padding: 3rem 0;
  }

  .coverage-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .action-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand img {
    width: 96px;
  }

  .coverage-grid {
    grid-template-columns: 1fr;
  }
}
