:root {
  color-scheme: light;
  --ink: #102033;
  --muted: #64748b;
  --paper: #eef7f4;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #fffdf7;
  --line: rgba(16, 32, 51, 0.14);
  --brand: #0f766e;
  --brand-2: #1d4ed8;
  --amber: #ffb545;
  --rose: #ef6461;
  --shadow: 0 24px 80px rgba(15, 35, 60, 0.14);
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Instrument Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 10%, rgba(15, 118, 110, 0.25), transparent 28rem),
    radial-gradient(circle at 86% 8%, rgba(255, 181, 69, 0.3), transparent 24rem),
    linear-gradient(135deg, #f9efe1 0%, #e9f8f5 50%, #edf4ff 100%);
}

button, input, select { font: inherit; }

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.72);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 22px;
  color: #fff;
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), #5eead4);
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.22);
}

.brand h1, .hero h2, .module-header h3, .panel-head h3 { margin: 0; }
.brand h1 { font-size: 1.05rem; line-height: 1.12; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.status-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin-bottom: 24px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.56);
}

.status-card small { display: block; color: var(--muted); margin-top: 3px; }
.pulse {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 8px rgba(255, 181, 69, 0.14);
}
.status-card.is-ok .pulse { background: var(--brand); box-shadow: 0 0 0 8px rgba(15, 118, 110, 0.14); }
.status-card.is-error .pulse { background: var(--rose); box-shadow: 0 0 0 8px rgba(239, 100, 97, 0.14); }

.module-nav { display: grid; gap: 10px; }
.module-nav button, .module-skeleton {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 18px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.44);
  cursor: pointer;
}
.module-nav button:hover, .module-nav button.is-active {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(255, 255, 255, 0.86);
  transform: translateX(4px);
}
.module-nav strong { display: block; margin-bottom: 4px; }
.module-nav small { color: var(--muted); }

.content, .admin-shell { padding: 32px; }
.admin-shell { max-width: 1120px; margin: 0 auto; }

.hero, .module-header, .metric-card, .legacy-panel, .admin-card {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  min-height: 230px;
  padding: 34px;
  border-radius: 36px;
  color: #f8fffd;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 181, 69, 0.55), transparent 14rem),
    linear-gradient(135deg, #103c3b 0%, #1f6f6a 52%, #16354b 100%);
}
.hero .eyebrow { color: #ffdc9d; }
.hero h2 {
  max-width: 880px;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.96;
  letter-spacing: -0.07em;
}
.hero-copy {
  max-width: 740px;
  color: rgba(248, 255, 253, 0.78);
  font-size: 1.05rem;
  line-height: 1.7;
}
.hero-actions, .module-actions, .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.primary-button, .ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.primary-button { color: #102033; background: #ffcc70; }
.ghost-button { color: #f8fffd; border: 1px solid rgba(255, 255, 255, 0.32); background: rgba(255, 255, 255, 0.1); }
.local-button { color: var(--ink); border-color: var(--line); background: rgba(255, 255, 255, 0.7); }

.module-header, .admin-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
  padding: 26px;
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}
.module-header h3 { font-size: 2rem; letter-spacing: -0.04em; }
.module-header p:last-child { color: var(--muted); margin-bottom: 0; }
.source-chip {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--brand);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(15, 118, 110, 0.1);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.metric-card {
  padding: 22px;
  border-radius: 26px;
  background: var(--panel-solid);
}
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong {
  display: block;
  margin: 8px 0;
  font-size: 2.5rem;
  line-height: 1;
}

.legacy-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 30px;
  background: var(--panel-solid);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.panel-head small { color: var(--muted); }
.legacy-panel iframe {
  display: block;
  width: 100%;
  height: min(82vh, 980px);
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
}

.admin-card {
  display: block;
  background: var(--panel-solid);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-weight: 800; }
.field input, .field select {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
}
.progress-box { display: grid; gap: 10px; margin-top: 24px; }
.progress-track { height: 12px; overflow: hidden; border-radius: 999px; background: rgba(16, 32, 51, 0.1); }
.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--amber));
  transition: width 180ms ease;
}
.log-box {
  min-height: 160px;
  max-height: 360px;
  overflow: auto;
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  color: #d9fff5;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  background: #0f2928;
  white-space: pre-wrap;
}
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  padding: 12px 16px;
  border-radius: 999px;
  color: #f8fffd;
  background: #102033;
  opacity: 0;
  transform: translateY(10px);
  transition: 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .hero, .module-header { display: grid; }
  .metrics-grid, .form-grid { grid-template-columns: 1fr; }
  .content, .admin-shell { padding: 18px; }
}
