:root {
  color-scheme: dark;
  --bg: #050914;
  --surface: #0b1424;
  --surface-soft: #111e31;
  --surface-strong: #17263d;
  --border: rgba(125, 215, 255, 0.22);
  --border-strong: rgba(125, 215, 255, 0.44);
  --text: #eef7ff;
  --muted: #98aac2;
  --cyan: #28d7ff;
  --blue: #4794ff;
  --green: #55df9c;
  --amber: #ffd166;
  --red: #ff6b7a;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  padding-bottom: 245px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(40, 215, 255, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(85, 223, 156, 0.08), transparent 30%),
    radial-gradient(circle at center top, rgba(71, 148, 255, 0.12), transparent 40%),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 70px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 18px 0;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-icon {
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 18px rgba(40, 215, 255, 0.42));
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 30, 49, 0.94), rgba(9, 17, 30, 0.96));
  box-shadow: var(--shadow);
  padding: 18px;
  animation: riseIn 360ms ease both;
}

.info-card {
  grid-column: auto;
}

.card-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  min-height: 48px;
  padding: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.card-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
}

.toggle-icon {
  border: 1px solid rgba(40, 215, 255, 0.24);
  border-radius: var(--radius);
  padding: 6px 9px;
  color: var(--cyan);
  background: rgba(40, 215, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
}

.card-body {
  padding-top: 14px;
}

.step {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--cyan);
  background: rgba(40, 215, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 800;
}

.info-card p {
  color: var(--muted);
  line-height: 1.55;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field label {
  display: flex;
  align-items: center;
  min-height: 34px;
  gap: 8px;
  color: #d9e9f7;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.25;
}

.field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(152, 170, 194, 0.22);
  border-radius: var(--radius);
  outline: none;
  padding: 0 12px;
  color: var(--text);
  background: #07111f;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(40, 215, 255, 0.15);
}

.help-button {
  display: inline-grid;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--cyan);
  background: rgba(40, 215, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
}

.panel-total-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  border: 1px solid rgba(40, 215, 255, 0.18);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(7, 17, 31, 0.58);
}

.panel-total-box h3 {
  margin-bottom: 0;
  color: var(--cyan);
  font-size: 0.84rem;
  line-height: 1.2;
}

.panel-total-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.panel-total-grid div {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(152, 170, 194, 0.16);
  border-radius: var(--radius);
  padding: 7px 8px;
  background: rgba(17, 30, 49, 0.72);
}

.panel-total-grid span {
  color: var(--muted);
  font-size: 0.72rem;
}

.panel-total-grid strong {
  color: var(--green);
  font-size: 0.92rem;
}

.panel-final {
  border: 1px solid rgba(85, 223, 156, 0.24);
  border-radius: var(--radius);
  padding: 8px;
  color: #eafff4;
  background: rgba(85, 223, 156, 0.08);
  font-size: 0.9rem;
  font-weight: 900;
}

.panel-formula {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.42;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segmented-control label,
.radio-stack label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(152, 170, 194, 0.22);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(7, 17, 31, 0.9);
  cursor: pointer;
}

.segmented-control input,
.radio-stack input {
  accent-color: var(--cyan);
}

.segmented-control label:has(input:checked),
.radio-stack label:has(input:checked) {
  border-color: var(--cyan);
  color: var(--text);
  background: rgba(40, 215, 255, 0.1);
}

.manual-options {
  margin-top: 16px;
}

.radio-stack {
  display: grid;
  gap: 8px;
}

.formula-box,
.tip-band {
  border-radius: var(--radius);
  padding: 12px;
}

.formula-box {
  margin-top: 8px;
  color: #d8edff;
  background: rgba(7, 17, 31, 0.86);
  line-height: 1.65;
}

.formula-line {
  display: block;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  padding: 0 15px;
  color: var(--text);
  font-weight: 800;
}

.primary-button {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #03101c;
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--border-strong);
  background: rgba(40, 215, 255, 0.08);
}

.danger-button {
  border: 1px solid rgba(255, 107, 122, 0.35);
  background: rgba(255, 107, 122, 0.12);
}

.fixed-bottom-stack {
  position: fixed;
  right: 16px;
  bottom: 14px;
  left: 16px;
  z-index: 20;
  display: grid;
  gap: 8px;
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  pointer-events: none;
}

.fixed-bottom-stack > * {
  pointer-events: auto;
}

.floating-install {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(40, 215, 255, 0.26);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(5, 13, 24, 0.95);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(12px);
  font-size: 0.78rem;
}

.floating-install[hidden] {
  display: none;
}

.floating-install .primary-button {
  min-height: 36px;
  white-space: nowrap;
}

.floating-result {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 8px 14px;
  border: 1px solid rgba(85, 223, 156, 0.32);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(5, 13, 24, 0.95);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
}

.floating-result-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.floating-label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.floating-total {
  display: block;
  color: var(--green);
  font-size: 1.35rem;
  line-height: 1.2;
  white-space: nowrap;
}

.floating-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.floating-metrics strong {
  color: var(--cyan);
}

.floating-message {
  grid-column: 1 / -1;
  margin: 0;
  color: #d8edff;
  font-size: 0.86rem;
  line-height: 1.35;
}

.floating-details {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.86rem;
}

.floating-details summary {
  width: fit-content;
  color: var(--cyan);
  cursor: pointer;
  font-weight: 800;
}

.tip-band {
  margin-top: 16px;
  border: 1px solid rgba(255, 209, 102, 0.24);
  background: rgba(255, 209, 102, 0.08);
}

.tip-band p {
  margin-bottom: 0;
  color: #ffecc0;
}

.help-modal {
  width: min(460px, calc(100% - 32px));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.help-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  padding: 22px;
}

.modal-content p {
  color: var(--muted);
  line-height: 1.55;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  min-height: 36px;
  color: var(--muted);
  background: transparent;
  font-size: 1.4rem;
}

.help-example {
  display: grid;
  gap: 4px;
  margin: 16px 0;
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(40, 215, 255, 0.08);
}

.help-example span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.help-example strong {
  color: var(--cyan);
  font-size: 1.2rem;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 24px, 720px);
    padding-top: 18px;
  }

  .hero,
  .layout {
    display: grid;
    grid-template-columns: 1fr;
  }

}

@media (max-width: 560px) {
  .field-grid,
  .segmented-control {
    grid-template-columns: 1fr;
  }

  .panel-fields-grid,
  .panel-total-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-fields-grid {
    gap: 10px;
  }

  .panel-fields-grid .field label {
    align-items: flex-start;
    min-height: 48px;
    font-size: 0.78rem;
  }

  .brand-icon {
    width: 52px;
    height: 52px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .card {
    padding: 14px;
  }

  body {
    padding-bottom: 285px;
  }

  .card-title {
    font-size: 0.98rem;
  }

  .fixed-bottom-stack {
    grid-template-columns: 1fr;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
  }

  .floating-install {
    display: grid;
    justify-items: stretch;
  }

  .floating-install .primary-button {
    width: 100%;
  }

  .floating-result {
    grid-template-columns: 1fr;
  }

  .floating-result-main {
    align-items: flex-start;
    justify-content: space-between;
  }

  .floating-total {
    font-size: 1.16rem;
  }

}
