:root {
  --navy-900: #0f2742;
  --navy-800: #14304f;
  --navy-700: #1a3a5c;
  --navy-600: #244c75;
  --navy-50:  #f4f7fb;
  --navy-100: #e7eef6;
  --navy-200: #cdd9e8;
  --navy-300: #9eb1c8;
  --navy-500: #4b6685;

  --red-600: #a90e26;
  --red-500: #c8102e;
  --red-400: #e23a51;
  --red-50:  #fdecef;

  --bg: #f6f8fb;
  --surface: #ffffff;
  --ink: #0e1a2b;
  --ink-soft: #4a5b73;
  --border: #e3e8ef;
  --border-strong: #cbd4df;

  --shadow-sm: 0 1px 2px rgba(15, 39, 66, 0.06);
  --shadow-md: 0 6px 24px -8px rgba(15, 39, 66, 0.20);
  --shadow-lg: 0 20px 50px -20px rgba(15, 39, 66, 0.40);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-tabular: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 100% -10%, rgba(26, 58, 92, 0.06), transparent 60%),
    radial-gradient(800px 420px at -10% 110%, rgba(200, 16, 46, 0.05), transparent 60%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Topbar (brand block) */
.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 22px 4px;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.brand-logo {
  width: auto;
  max-height: 80px;
  height: 80px;
  display: block;
  border-radius: 6px;
}
.brand-name {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--navy-700);
  line-height: 1.1;
}
.brand-sub {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
}
.topbar-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar-link {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
}
.topbar-link:hover { color: var(--navy-700); }

.admin-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  background: var(--red-500);
  padding: 4px 10px;
  border-radius: 999px;
}

/* Container */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card-head { margin-bottom: 16px; }
.card-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--navy-700);
}
.card-sub {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

/* Form */
.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-700);
  letter-spacing: -0.005em;
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--navy-50);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  transition: border-color 120ms, background 120ms, box-shadow 120ms;
  min-height: 50px;
}
.input-wrap:focus-within {
  border-color: var(--navy-700);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(26, 58, 92, 0.10);
}
.input-wrap input,
.input-wrap select {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--font-tabular);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  padding: 12px 4px;
  min-width: 0;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
.input-wrap input[type='text'] { letter-spacing: -0.005em; }
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-wrap input[type='number'] { -moz-appearance: textfield; }
.input-wrap .prefix,
.input-wrap .suffix {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.input-wrap .prefix { padding-right: 6px; }
.input-wrap .suffix { padding-left: 6px; }

.input-wrap-select {
  padding-right: 36px;
  cursor: pointer;
}
.input-wrap-select::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.input-wrap-select select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

/* Field locked state (calculator client view) */
.field.locked .input-wrap {
  background: #f1f4f8;
  border-color: var(--border);
  border-style: dashed;
}
.field.locked input {
  color: var(--ink-soft);
  cursor: not-allowed;
}
.field.locked label::after {
  content: '🔒';
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.55;
}
.field.editable .input-wrap {
  border-color: var(--red-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.15);
}
.field.editable label {
  color: var(--red-600);
}
.field.editable label::after {
  content: '✎';
  margin-left: 6px;
  font-size: 11px;
  color: var(--red-500);
}

/* Product banner (under topbar / above result) */
.product-banner {
  display: none;
  background: linear-gradient(90deg, rgba(26, 58, 92, 0.06), transparent);
  border-left: 3px solid var(--navy-700);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 8px;
}
.product-banner.has-value { display: block; }
.product-banner-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.product-banner-value {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: var(--navy-700);
  margin-top: 2px;
}

/* Breakdown */
.breakdown { padding: 18px 22px; }
.breakdown-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.step {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.step:last-child { border-bottom: 0; }
.step-label {
  grid-row: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-700);
}
.step-formula {
  grid-row: 2;
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.step-value {
  grid-row: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--navy-700);
  font-variant-numeric: tabular-nums;
}

/* Result */
.result {
  background: linear-gradient(140deg, var(--navy-700), var(--navy-900));
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.result::before {
  content: '';
  position: absolute;
  inset: -50% -10% auto auto;
  width: 320px;
  height: 320px;
  background: radial-gradient(closest-side, rgba(200, 16, 46, 0.25), transparent 70%);
  pointer-events: none;
}
.result::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red-500) 0%, var(--red-500) 33%, #fff 33%, #fff 66%, var(--navy-700) 66%, var(--navy-700) 100%);
}
.result-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 6px;
}
.result-value {
  display: block;
  font-size: clamp(40px, 9vw, 56px);
  font-weight: 800;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  line-height: 1.05;
}
.result-currency {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: #ffd5d5;
}
.result-note {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

/* Buttons */
.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.actions-form { grid-column: 1 / -1; margin-top: 4px; }
.actions-row { justify-content: flex-start; margin-top: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 80ms ease, background 120ms, border-color 120ms, color 120ms, box-shadow 120ms;
  min-height: 48px;
  user-select: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--navy-700);
  color: #fff;
  border-color: var(--navy-700);
}
.btn-primary:hover { background: var(--navy-800); border-color: var(--navy-800); }

.btn-accent {
  background: var(--red-500);
  color: #fff;
  border-color: var(--red-500);
}
.btn-accent:hover { background: var(--red-600); border-color: var(--red-600); }
.btn-accent.is-success { background: #1f7a3a; border-color: #1f7a3a; }

.btn-secondary {
  background: #fff;
  color: var(--navy-700);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--navy-700); }

.btn-ghost {
  background: transparent;
  color: var(--navy-700);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--navy-100); }

/* Link box (admin) */
.link-box {
  background: var(--navy-50);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 4px;
  overflow-x: auto;
}
.generated-link {
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 13px;
  color: var(--navy-700);
  word-break: break-all;
  white-space: pre-wrap;
}

/* Tips */
.tips-list {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 14px;
}
.tips-list li { margin-bottom: 6px; }
.tips-list li::marker { color: var(--red-500); }

/* Footer */
.footer {
  text-align: center;
  padding: 22px 16px 36px;
  color: var(--ink-soft);
  font-size: 13px;
}
.footer-brand {
  font-weight: 700;
  color: var(--navy-700);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
}
.footer-sub {
  margin: 6px 0 0;
  font-size: 11px;
  color: #94a3b8;
}
.footer-sub a {
  color: #94a3b8;
  text-decoration: none;
}
.footer-sub a:hover { color: var(--navy-700); }

/* Floating admin button */
.floating-admin {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 150ms, color 150ms;
}
.floating-admin:hover { opacity: 1; color: var(--navy-700); }
@media (max-width: 480px) { .floating-admin { display: none; } }

/* Visibility helpers */
.hidden { display: none !important; }

/* Mobile */
@media (max-width: 540px) {
  .form { grid-template-columns: 1fr; }
  .card { padding: 18px; border-radius: var(--radius-md); }
  .container { padding: 8px 12px 60px; }
  .topbar { padding: 16px 16px 0; }
  .brand-logo { height: 70px; max-height: 70px; }
  .brand-name { font-size: 19px; }
  .actions-row { justify-content: stretch; }
  .actions-row .btn { flex: 1; min-width: 0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.result-value.is-animating { transition: none; }
