:root{
  --layout-narrow:760px;
  --layout-standard:1120px;
  --layout-wide:1400px;

  --space-page-x:24px;
  --space-page-y:24px;
  --space-page-top:18px;
  --space-card:18px;
  --space-card-lg:28px;
  --space-section:20px;
  --space-field:12px;
  --space-label-gap:8px;

  --radius-card:20px;
  --radius-card-lg:24px;
  --radius-control:12px;
  --radius-pill:999px;

  --color-bg-page:#0d1324;
  --color-bg-page-alt:#09111f;
  --color-surface:rgba(18,25,51,0.92);
  --color-surface-2:#182244;
  --color-border:rgba(255,255,255,0.08);
  --color-text:#eef3ff;
  --color-text-muted:#aab7d6;
  --color-link:#c7d6f4;
  --color-accent:#7aa2ff;
  --color-accent-soft:#8fb4ff;
  --color-accent-strong:#60a5fa;
  --color-positive:#84e1bc;
  --color-warning:#ffd08a;
  --color-danger:#ff8f8f;
  --color-highlight:#f3b4ff;

  --shadow-card:0 10px 30px rgba(0,0,0,0.25);
  --shadow-card-lg:0 20px 60px rgba(0,0,0,.35);
  --shadow-primary:0 12px 28px rgba(122,162,255,0.22);

  --font-family-base:Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-family-fallback:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  --font-size-h1:clamp(30px,5vw,46px);
  --font-size-h1-compact:2rem;
  --font-size-h2:1.15rem;
  --font-size-body:1rem;
  --font-size-body-sm:0.92rem;
  --font-size-caption:0.88rem;

  --control-height:44px;
  --input-padding-x:14px;
  --input-padding-y:10px;
  --input-suffix-right:16px;
  --input-suffix-bottom:11px;

  --breakpoint-compact:640px;
  --breakpoint-tablet:820px;
  --breakpoint-desktop:1120px;
}

html{
  overflow-x:hidden;
}

.layout-narrow{
  max-width:var(--layout-narrow);
  margin:0 auto;
}

.layout-standard{
  max-width:var(--layout-standard);
  margin:0 auto;
}

.layout-wide{
  max-width:var(--layout-wide);
  margin:0 auto;
}

body.theme-content,
body.theme-calculator{
  margin:0;
  min-height:100vh;
  color:var(--color-text);
  font-family:var(--font-family-base);
}

body.theme-content{
  background:
    radial-gradient(circle at top, rgba(96,165,250,.18), transparent 34%),
    linear-gradient(180deg, #09111f, #0d1324 45%, #0a101c);
  display:flex;
  flex-direction:column;
  gap:24px;
  padding:32px var(--space-page-x);
}

body.theme-calculator{
  background:
    radial-gradient(circle at top, rgba(96,165,250,.18), transparent 34%),
    linear-gradient(180deg, #09111f, #0d1324 45%, #0a101c);
  position:relative;
  overflow-x:hidden;
  isolation:isolate;
}

.page-theme-calculator{
  position:relative;
  overflow-x:hidden;
  isolation:isolate;
}

.page-theme-calculator::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at 20% 25%, rgba(52,211,153,.14), transparent 20%),
    radial-gradient(circle at 80% 30%, rgba(96,165,250,.12), transparent 24%),
    radial-gradient(circle at 50% 80%, rgba(255,255,255,.05), transparent 30%);
  z-index:0;
  pointer-events:none;
}

.site-topnav{
  z-index:1000;
  background:rgba(17,24,39,.94);
  backdrop-filter:blur(12px);
  padding:7px 16px;
  min-height:57px;
  display:flex;
  gap:20px;
  align-items:center;
  flex-wrap:nowrap;
  border-bottom:1px solid #23304a;
  box-sizing:border-box;
  font-family:var(--font-family-fallback);
}

.site-topnav.site-topnav-fixed{
  position:fixed;
  top:0;
  left:0;
  right:0;
  width:100%;
}

.site-topnav.site-topnav-sticky{
  position:sticky;
  top:0;
}

.site-topnav .nav-links{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:nowrap;
  min-width:0;
}

.site-topnav .nav-dropdown{
  position:relative;
}

.site-topnav .nav-dropdown summary{
  list-style:none;
  color:#cfdcf4;
  text-decoration:none;
  padding:8px 28px 8px 14px;
  border-radius:10px;
  font-weight:600;
  font-size:15px;
  border:1px solid transparent;
  background:transparent;
  transition:color .18s ease, background .18s ease, border-color .18s ease;
  box-sizing:border-box;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  position:relative;
  min-height:42px;
  white-space:nowrap;
}

.site-topnav .nav-dropdown summary::-webkit-details-marker{
  display:none;
}

.site-topnav .nav-dropdown summary::after{
  content:"▾";
  position:absolute;
  right:11px;
  font-size:12px;
  color:#9fb0cc;
  transform:translateY(1px);
}

.site-topnav .nav-dropdown summary:hover{
  color:#eef4ff;
  background:rgba(255,255,255,0.04);
  border-color:rgba(255,255,255,0.06);
}

.site-topnav .nav-dropdown summary:focus-visible{
  outline:none;
  border-color:rgba(96,165,250,.55);
  box-shadow:0 0 0 3px rgba(96,165,250,.14);
}

.site-topnav .nav-dropdown[open] summary,
.site-topnav .nav-dropdown.active summary{
  color:#ffffff;
  background:rgba(255,255,255,0.06);
  border-color:rgba(255,255,255,0.10);
}

.site-topnav .nav-dropdown-menu{
  position:absolute;
  top:calc(100% + 10px);
  left:0;
  min-width:230px;
  max-width:min(260px, calc(100vw - 32px));
  padding:8px;
  border-radius:16px;
  background:rgba(10,17,33,.96);
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 18px 40px rgba(0,0,0,.34);
  display:grid;
  gap:4px;
  backdrop-filter:blur(12px);
  box-sizing:border-box;
  overflow-x:hidden;
}

.site-topnav .nav-dropdown-menu a{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  width:100%;
  min-width:0;
  box-sizing:border-box;
  padding:9px 10px;
  font-size:14px;
  font-weight:600;
  line-height:1.35;
  white-space:normal;
}

.site-topnav .nav-dropdown-menu a.active{
  background:rgba(255,255,255,0.06);
  border-radius:12px;
}

.site-topnav .nav-item-copy{
  display:grid;
  gap:2px;
  min-width:0;
}

.site-topnav .nav-item-title{
  color:#eef4ff;
  font-size:14px;
  font-weight:700;
  line-height:1.2;
  white-space:normal;
  overflow-wrap:anywhere;
}

.site-topnav .nav-item-meta{
  color:#8fa3c7;
  font-size:12px;
  line-height:1.3;
  white-space:normal;
  overflow-wrap:anywhere;
}

.site-topnav .currency-picker{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:10px;
  color:#9fb0cc;
  font-size:13px;
  font-weight:600;
  white-space:nowrap;
  flex-shrink:0;
  min-height:42px;
}

.site-topnav .currency-picker select{
  width:auto;
  min-width:0;
  height:42px;
  background:#0f172a;
  color:#eef4ff;
  border:1px solid #23304a;
  border-radius:10px;
  padding:8px 12px;
  line-height:1.2;
  font-size:14px;
  font-weight:600;
  outline:none;
  box-shadow:none;
  box-sizing:border-box;
  appearance:none;
  -webkit-appearance:none;
}

.site-topnav .currency-picker select:focus{
  border-color:#60a5fa;
  box-shadow:none;
}

.site-topnav a{
  color:#cfdcf4;
  text-decoration:none;
  padding:8px 12px;
  border-radius:10px;
  font-weight:600;
  font-size:15px;
  border:1px solid transparent;
  background:transparent;
  transition:color .18s ease, background .18s ease, border-color .18s ease;
  box-sizing:border-box;
  min-height:42px;
  display:inline-flex;
  align-items:center;
}

.site-topnav .nav-links > a{
  white-space:nowrap;
}

.site-topnav a:hover{
  color:#eef4ff;
  background:rgba(255,255,255,0.04);
  border-color:rgba(255,255,255,0.06);
}

.site-topnav a:focus-visible{
  outline:none;
  border-color:rgba(96,165,250,.55);
  box-shadow:0 0 0 3px rgba(96,165,250,.14);
}

.site-topnav a.active{
  color:#ffffff;
  background:rgba(255,255,255,0.06);
  border-color:rgba(255,255,255,0.10);
  box-shadow:none;
}

.site-topnav .menu-toggle{
  display:none;
  margin-left:auto;
  min-width:44px;
  height:44px;
  padding:0 12px;
  border-radius:12px;
  border:1px solid #23304a;
  background:rgba(255,255,255,0.04);
  color:#cfdcf4;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  font-size:0;
  flex-shrink:0;
  gap:10px;
  box-sizing:border-box;
}

.site-topnav .menu-toggle:hover{
  color:#eef4ff;
  background:rgba(255,255,255,0.06);
  border-color:rgba(255,255,255,0.10);
}

.site-topnav .menu-toggle:focus-visible{
  outline:none;
  border-color:rgba(96,165,250,.55);
  box-shadow:0 0 0 3px rgba(96,165,250,.14);
}

.site-topnav .menu-toggle-icon{
  display:block;
  width:18px;
  height:2px;
  background:currentColor;
  border-radius:999px;
  position:relative;
  transform:translateY(0);
}

.site-topnav .menu-toggle-icon::before,
.site-topnav .menu-toggle-icon::after{
  content:"";
  position:absolute;
  left:0;
  width:18px;
  height:2px;
  background:currentColor;
  border-radius:999px;
}

.site-topnav .menu-toggle-icon::before{top:-5px}
.site-topnav .menu-toggle-icon::after{top:5px}

.site-topnav .menu-toggle-text{
  font-size:13px;
  font-weight:700;
  line-height:1;
}

.site-topnav .topnav-panel{
  flex:1;
  min-width:0;
  display:flex;
  align-items:center;
  gap:20px;
  box-sizing:border-box;
}

.site-footer{
  margin-top:auto;
  padding:20px;
  text-align:center;
  color:var(--color-text-muted);
  font-size:14px;
  border-top:1px solid var(--color-border);
}

.site-footer a{
  color:var(--color-link);
  text-decoration:none;
}

.site-footer a:hover{
  text-decoration:underline;
}

.site-footer .footer-admin-link{
  color:inherit;
  text-decoration:none;
}

.site-footer .footer-admin-link:hover{
  text-decoration:underline;
}

.page-shell{
  width:100%;
  padding:var(--space-page-top) var(--space-page-x) var(--space-page-y);
  box-sizing:border-box;
}

.calculator-layout{
  display:grid;
  grid-template-columns:380px 1fr;
  gap:var(--space-section);
  align-items:stretch;
}

.calculator-layout > *{
  min-width:0;
}

.calculator-sidebar{
  display:grid;
  grid-template-rows:auto 1fr;
  gap:var(--space-section);
  align-items:stretch;
  height:100%;
  position:relative;
  z-index:4;
}

.calculator-main{
  display:grid;
  gap:var(--space-section);
  min-width:0;
  overflow-anchor:none;
}

.calculator-metrics{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:14px;
  grid-auto-rows:86px;
  align-items:stretch;
  overflow-anchor:none;
}

.calculator-charts{
  display:grid;
  grid-template-columns:1fr;
  gap:20px;
  overflow-anchor:none;
}

.calculator-tables{
  display:grid;
  grid-template-columns:1.1fr 0.9fr;
  gap:20px;
}

.content-surface{
  padding:var(--space-card-lg);
  border-radius:var(--radius-card-lg);
  border:1px solid var(--color-border);
  background:rgba(18,26,43,.92);
  box-shadow:var(--shadow-card-lg);
  backdrop-filter:blur(10px);
}

.page-stack{
  display:grid;
  gap:var(--space-section);
}

.page-intro{
  display:grid;
  gap:12px;
  margin-bottom:20px;
}

.page-title{
  margin:0;
  font-size:var(--font-size-h1);
  line-height:1.05;
  letter-spacing:-0.03em;
  color:var(--color-text);
}

.page-title-compact{
  font-size:var(--font-size-h1-compact);
}

.page-subtitle{
  margin:0;
  color:var(--color-text-muted);
  line-height:1.6;
  font-size:var(--font-size-body);
}

.section-title{
  margin:0;
  font-size:1.1rem;
  line-height:1.25;
  color:var(--color-text);
}

.section-divider{
  margin-top:22px;
  padding-top:18px;
  border-top:1px solid rgba(255,255,255,.08);
}

.prose{
  color:#c7d4ec;
}

.prose p{
  margin:0 0 14px;
  line-height:1.7;
}

.prose ul{
  margin:0 0 14px 20px;
  padding:0;
  line-height:1.7;
}

.prose a{
  color:var(--color-link);
  font-weight:700;
  text-decoration:underline;
  text-decoration-thickness:1px;
  text-underline-offset:2px;
  text-decoration-color:rgba(199,214,244,.55);
}

.prose a:hover{
  text-decoration-color:currentColor;
}

.surface-card{
  background:var(--color-surface);
  border:1px solid var(--color-border);
  border-radius:var(--radius-card);
  box-shadow:var(--shadow-card);
}

.surface-card-soft{
  background:rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.07);
  border-radius:16px;
}

.surface-card-strong{
  background:rgba(24,34,68,0.95);
  border:1px solid var(--color-border);
  border-radius:18px;
}

.metric-card{
  background:rgba(24,34,68,0.95);
  border:1px solid var(--color-border);
  border-radius:18px;
  padding:14px;
  min-width:0;
  height:86px;
  min-height:86px;
  max-height:86px;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  overflow:hidden;
  overflow-anchor:none;
}

.metric-label{
  display:block;
  color:var(--color-text-muted);
  font-size:0.85rem;
  margin-bottom:6px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  flex:0 0 auto;
}

.metric-value{
  display:block;
  font-size:1.35rem;
  font-weight:800;
  line-height:1.15;
  height:calc(1.35rem * 1.15);
  min-height:calc(1.35rem * 1.15);
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-variant-numeric:tabular-nums;
  flex:0 0 auto;
  text-shadow:0 10px 24px rgba(0,0,0,.2);
}

.metric-value.compact{
  font-size:1.05rem;
  line-height:1.15;
  height:calc(1.05rem * 1.15);
  min-height:calc(1.05rem * 1.15);
  letter-spacing:-0.02em;
}

.result-card{
  display:grid;
  gap:8px;
  padding:12px;
  border-radius:16px;
  background:linear-gradient(180deg, rgba(22,33,63,.92), rgba(11,16,31,.82));
  border:1px solid rgba(122,162,255,.18);
  min-width:0;
  align-self:start;
  justify-self:stretch;
  margin-top:0;
}

.result-label{
  color:var(--color-text-muted);
  font-size:12px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.result-value{
  font-size:clamp(30px, 4.4vw, 46px);
  line-height:.95;
  font-weight:900;
  letter-spacing:-.04em;
  color:#f8fbff;
  overflow-wrap:anywhere;
}

.result-value.compact{
  font-size:clamp(24px, 3.6vw, 34px);
  line-height:1;
  letter-spacing:-.03em;
}

.result-meta{
  display:grid;
  gap:4px;
}

.table-grid{
  display:grid;
  gap:20px;
}

.table-scroll{
  max-height:420px;
  overflow:auto;
  border-radius:14px;
}

.data-table{
  width:100%;
  min-width:0;
  border-collapse:collapse;
  font-size:0.9rem;
}

.data-table th,
.data-table td{
  padding:9px 6px;
  border-bottom:1px solid var(--color-border);
  text-align:left;
}

.data-table th{
  color:var(--color-text-muted);
  font-weight:600;
  position:sticky;
  top:0;
  background:rgba(18,25,51,0.98);
}

.controls,
.form-stack{
  display:grid;
  gap:var(--space-field);
  position:relative;
  z-index:2;
}

.row,
.form-row{
  display:grid;
  gap:6px;
  position:relative;
  min-width:0;
}

.row label,
.form-row label{
  color:var(--color-text-muted);
  font-size:var(--font-size-body-sm);
  display:inline-flex;
  align-items:center;
  gap:var(--space-label-gap);
  width:fit-content;
}

.info-tip{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  border-radius:50%;
  border:1px solid rgba(255,255,255,0.16);
  background:rgba(255,255,255,0.04);
  color:#d6e1f8;
  font-size:11px;
  font-weight:800;
  line-height:1;
  cursor:help;
}

.info-tip::after{
  content:attr(data-tip);
  position:absolute;
  left:calc(100% + 10px);
  top:50%;
  transform:translateY(-50%);
  width:min(240px, 52vw);
  padding:10px 12px;
  border-radius:12px;
  background:rgba(9,16,31,0.96);
  border:1px solid rgba(122,162,255,0.26);
  color:#eef3ff;
  font-size:12px;
  font-weight:500;
  line-height:1.45;
  box-shadow:0 12px 28px rgba(0,0,0,0.28);
  opacity:0;
  pointer-events:none;
  visibility:hidden;
  transition:opacity .16s ease;
  z-index:30;
}

.info-tip:hover::after,
.info-tip:focus-visible::after{
  opacity:1;
  visibility:visible;
}

.input-suffix,
.input-affix{
  position:absolute;
  right:var(--input-suffix-right);
  bottom:var(--input-suffix-bottom);
  color:var(--color-text-muted);
  font-size:14px;
  font-weight:700;
  pointer-events:none;
}

.btns,
.button-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:8px;
}

button.primary,
button.secondary,
.button-primary,
.button-secondary{
  border:0;
  border-radius:var(--radius-control);
  padding:12px 16px;
  font-size:0.95rem;
  font-weight:700;
  cursor:pointer;
  transition:transform .18s ease, box-shadow .18s ease, filter .18s ease, background .18s ease;
}

button.primary,
.button-primary{
  background:var(--color-accent);
  color:#071022;
  box-shadow:var(--shadow-primary);
}

button.secondary,
.button-secondary{
  background:#26335f;
  color:var(--color-text);
  border:1px solid rgba(255,255,255,0.06);
}

button.primary:hover,
button.secondary:hover,
.button-primary:hover,
.button-secondary:hover{
  transform:translateY(-1px);
  filter:brightness(1.03);
}

button.primary:hover,
.button-primary:hover{
  box-shadow:0 16px 34px rgba(122,162,255,0.28);
}

button.primary:focus-visible,
button.secondary:focus-visible,
.button-primary:focus-visible,
.button-secondary:focus-visible{
  outline:none;
  box-shadow:0 0 0 3px rgba(96,165,250,.18);
}

.text-muted{
  color:var(--color-text-muted);
}

.status-positive{
  color:var(--color-positive);
}

.status-warning{
  color:var(--color-warning);
}

.status-danger{
  color:var(--color-danger);
}

.status-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:5px 9px;
  border-radius:var(--radius-pill);
  font-size:0.74rem;
  font-weight:800;
  letter-spacing:.01em;
  white-space:nowrap;
}

.status-pill-positive{
  color:#071022;
  background:var(--color-positive);
}

.status-pill-muted{
  color:#dbe6fb;
  background:rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.08);
}

.delta-positive{
  color:var(--color-positive);
}

.delta-warning{
  color:var(--color-warning);
}

.ad-card{
  display:grid;
  gap:10px;
}

.ad-card-label{
  color:var(--color-text-muted);
  font-size:0.72rem;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.ad-card-shell{
  min-height:320px;
}

@media (max-width: 820px){
  .site-topnav{
    display:grid;
    grid-template-columns:1fr auto;
    gap:12px;
    padding:12px 14px;
    align-items:center;
  }

  .site-topnav .menu-toggle{
    display:inline-flex;
    align-items:center;
    grid-column:2;
    grid-row:1;
    margin-left:0;
  }

  .site-topnav .topnav-panel{
    grid-column:1 / -1;
    width:100%;
    display:none;
    flex-direction:column;
    align-items:stretch;
    gap:12px;
    padding-top:12px;
    border-top:1px solid #23304a;
    position:relative;
    z-index:2;
  }

  .site-topnav.open .topnav-panel{
    display:flex !important;
  }

  .site-topnav .nav-links{
    width:100%;
    gap:8px;
    flex-direction:column;
    align-items:stretch;
  }

  .site-topnav .nav-dropdown{
    width:100%;
  }

  .site-topnav .nav-dropdown summary{
    width:100%;
    justify-content:space-between;
  }

  .site-topnav .nav-dropdown-menu{
    position:static;
    min-width:0;
    max-width:100%;
    margin-top:8px;
    width:100%;
    box-shadow:none;
    background:rgba(255,255,255,0.03);
  }

  .site-topnav a{
    display:block;
    width:100%;
  }

  .site-topnav .nav-dropdown-menu a{
    display:flex;
    width:100%;
    justify-content:space-between;
    padding:10px 12px;
    align-items:flex-start;
  }

  .site-topnav .nav-item-copy{
    gap:2px;
  }

  .site-topnav .nav-dropdown-menu a > span:last-child{
    font-size:14px;
    line-height:1;
    padding-top:2px;
    flex-shrink:0;
  }

  .site-topnav .currency-picker{
    margin-left:0;
    width:100%;
    justify-content:space-between;
  }

  .calculator-layout{
    display:flex;
    flex-direction:column;
    gap:20px;
    align-items:stretch;
  }

  .calculator-metrics{
    grid-template-columns:1fr;
    grid-auto-rows:84px;
  }

  .calculator-tables{
    grid-template-columns:1fr;
    gap:16px;
  }
}
