:root {
  --bg: #f5efe4;
  --bg-accent: #e7dcc8;
  --panel: rgba(255, 252, 247, 0.9);
  --text: #201a14;
  --muted: #6f6256;
  --line: rgba(32, 26, 20, 0.1);
  --accent: #c96f2d;
  --accent-strong: #8c3d12;
  --shadow: 0 24px 60px rgba(76, 47, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(201, 111, 45, 0.2), transparent 30%),
    radial-gradient(circle at bottom right, rgba(140, 61, 18, 0.18), transparent 25%),
    linear-gradient(135deg, var(--bg), var(--bg-accent));
}

body.theme-emgea {
  --bg: #eef5ff;
  --bg-accent: #dcecff;
  --panel: rgba(255, 255, 255, 0.92);
  --text: #0d1424;
  --muted: #5c6778;
  --line: rgba(18, 93, 193, 0.12);
  --accent: #22a2ec;
  --accent-strong: #0a7ed0;
  --shadow: 0 24px 60px rgba(18, 93, 193, 0.12);
  background:
    radial-gradient(circle at top left, rgba(34, 162, 236, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(42, 64, 240, 0.14), transparent 24%),
    linear-gradient(135deg, var(--bg), var(--bg-accent));
}

.splash,
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.layout {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.hero {
  margin-bottom: 24px;
}

.hero-actions {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.brand-top {
  margin-bottom: 20px;
}

.brand-logo {
  width: 200px;
  height: auto;
}

.emgea-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.emgea-brand-hero {
  gap: 22px;
}

.emgea-mark {
  width: 74px;
  height: auto;
  flex: 0 0 auto;
}

.emgea-brand-hero .emgea-mark {
  width: 92px;
}

.emgea-wordmark {
  color: #111111;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--accent-strong);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 10ch;
  margin-bottom: 12px;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.95;
}

.lead {
  max-width: 640px;
  color: var(--muted);
  font-size: 1.05rem;
}

.panel {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.grid,
.formula-grid,
.result-list {
  display: grid;
  gap: 16px;
}

.grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.actions {
  margin-top: 20px;
}

.calc-error {
  margin: 12px 0 0;
}

.calculate-button {
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #123a2a, #1f6a46);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(18, 58, 42, 0.18);
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

body.theme-emgea .calculate-button {
  background: linear-gradient(135deg, #1564c0, #2a40f0);
  box-shadow: 0 14px 28px rgba(21, 100, 192, 0.18);
}

.calculate-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(18, 58, 42, 0.22);
  filter: brightness(1.02);
}

.calculate-button:focus {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(31, 106, 70, 0.18),
    0 18px 32px rgba(18, 58, 42, 0.22);
}

.calculate-button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.ghost-button {
  align-self: flex-start;
  padding: 12px 18px;
  border: 1px solid rgba(18, 58, 42, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

body.theme-emgea .ghost-button {
  border-color: rgba(21, 100, 192, 0.16);
}

.formula-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.formula-panel .formula-grid .field {
  align-self: start;
}

.formula-panel .formula-grid .field span {
  display: block;
  min-height: 3.6em;
  line-height: 1.2;
}

.hidden {
  display: none;
}

.field span,
.result-label,
.formula-header p,
.result-card small {
  color: var(--muted);
}

.form-error {
  margin: 0;
  color: #9b2c2c;
}

.field input,
.field select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font: inherit;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(201, 111, 45, 0.7);
  box-shadow: 0 0 0 4px rgba(201, 111, 45, 0.14);
  transform: translateY(-1px);
}

.field-highlight input,
.field-highlight select {
  border-color: rgba(201, 111, 45, 0.45);
  background: linear-gradient(180deg, rgba(255, 245, 235, 0.95), rgba(255, 255, 255, 0.95));
}

.formula-header {
  margin-bottom: 16px;
}

.formula-subheader {
  margin-top: 28px;
}

.formula-header h2 {
  margin-bottom: 6px;
}

.formula-notes {
  padding: 18px 20px;
  border: 1px dashed rgba(18, 58, 42, 0.18);
  border-radius: 18px;
  background: rgba(18, 58, 42, 0.04);
}

.formula-notes p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.results {
  display: grid;
  gap: 20px;
}

.result-card.result-primary {
  padding: 28px;
  background: linear-gradient(135deg, #123a2a, #1f6a46);
  color: #f4fff8;
  border-color: rgba(18, 58, 42, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.theme-emgea .result-card.result-primary,
.result-card.result-primary.emgea-primary {
  background: linear-gradient(135deg, #1564c0, #1c75bc 40%, #2a40f0);
  border-color: rgba(21, 100, 192, 0.28);
}

.result-card.result-primary .result-label,
.result-card.result-primary small {
  color: rgba(244, 255, 248, 0.82);
}

.result-card.result-primary strong {
  font-size: clamp(2rem, 5vw, 3.6rem);
  color: #ffffff;
}

.result-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.64);
}

.result-card strong {
  font-size: 1.45rem;
}

.result-raw {
  white-space: pre-wrap;
}

.auth-card {
  width: min(420px, calc(100% - 24px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 160px;
  margin-bottom: 18px;
}

.emgea-brand-auth {
  margin-bottom: 18px;
}

.emgea-brand-auth .emgea-wordmark {
  font-size: 2.4rem;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-button {
  width: 100%;
}

@media (max-width: 720px) {
  .layout {
    width: min(100% - 20px, 1120px);
    padding: 24px 0 40px;
  }

  .hero-actions {
    flex-direction: column;
  }

  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .brand-logo {
    width: 156px;
  }
}

.product-description {
  resize: vertical;
  font-family: inherit;
  font-size: 0.85rem;
  color: rgba(15, 23, 42, 0.7);
  background: rgba(241, 245, 249, 0.5);
  border-radius: 12px;
  padding: 10px 12px;
  width: 100%;
}

.result-warning strong {
  color: #b91c1c;
}

.result-warning {
  border: 1px solid rgba(185, 28, 28, 0.3);
}

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

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.admin-table th {
  background: rgba(241, 245, 249, 0.5);
  font-weight: 500;
  color: rgba(15, 23, 42, 0.7);
}

.admin-table tr.row-inactive {
  opacity: 0.5;
}

.view-toggle {
  display: flex;
  gap: 4px;
  margin: 16px 0;
  background: rgba(241, 245, 249, 0.6);
  padding: 4px;
  border-radius: 14px;
  width: fit-content;
}

.toggle-btn {
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  color: rgba(15, 23, 42, 0.7);
}

.toggle-btn.toggle-active {
  background: white;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
  color: rgba(15, 23, 42, 1);
  font-weight: 600;
}

.service-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 16px 0 24px;
}

.service-section {
  background: rgba(241, 245, 249, 0.35);
  border-radius: 14px;
  padding: 14px 16px;
}

.service-section-title {
  margin: 0 0 10px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(15, 23, 42, 0.55);
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.service-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}

.service-check:hover {
  background: rgba(255, 255, 255, 0.7);
}

.service-check input[type="checkbox"] {
  margin-top: 3px;
}

.match-results {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(15, 23, 42, 0.1);
}

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

.match-card {
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-card header {
  display: flex;
  flex-direction: column;
}

.match-card header strong {
  font-size: 1.05rem;
}

.match-card header span {
  color: rgba(15, 23, 42, 0.6);
  font-size: 0.85rem;
}

.match-card .match-meta {
  font-size: 0.82rem;
  color: rgba(15, 23, 42, 0.65);
}

.match-card dl {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 4px 10px;
  font-size: 0.85rem;
  margin: 0;
}

.match-card dt {
  color: rgba(15, 23, 42, 0.55);
}

.match-card dd {
  margin: 0;
  color: rgba(15, 23, 42, 0.85);
}

.service-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.service-check {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: white;
  transition: all 0.15s ease;
}

.service-check:hover {
  border-color: rgba(15, 23, 42, 0.2);
  background: rgba(241, 245, 249, 0.6);
}

.service-check-on {
  border-color: rgba(37, 99, 235, 0.5);
  background: rgba(219, 234, 254, 0.4);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.1);
}

.service-check input[type="checkbox"] {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: rgb(37, 99, 235);
}

.service-icon {
  font-size: 1.25rem;
  line-height: 1;
  width: 24px;
  text-align: center;
}

.service-label {
  font-size: 0.9rem;
  line-height: 1.35;
}

.theme-emgea .service-check-on {
  border-color: rgba(13, 71, 161, 0.5);
  background: rgba(187, 222, 251, 0.35);
  box-shadow: 0 1px 4px rgba(13, 71, 161, 0.1);
}

.theme-emgea .service-check input[type="checkbox"] {
  accent-color: rgb(13, 71, 161);
}

.extras {
  background: rgba(241, 245, 249, 0.6);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
}

.extras-title {
  display: block;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.7);
  margin-bottom: 6px;
}

.extras ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.extras li {
  display: flex;
  gap: 6px;
  align-items: center;
  color: rgba(15, 23, 42, 0.8);
}

.extras-exact {
  font-size: 0.82rem;
  color: rgb(22, 101, 52);
  background: rgba(187, 247, 208, 0.4);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0;
}
