:root{
  --bg: #0b1220;
  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.12);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.68);
  --danger: #ff5b5b;
  --primary: #5aa7ff;
  --primary2: #2e7ef7;
  --ok: #2dd4bf;
  --shadow: 0 18px 40px rgba(0,0,0,0.35);
  --radius: 14px;
  --radius-sm: 10px;
}

*{ box-sizing:border-box; }
html, body { height: 100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 700px at 20% 0%, rgba(90,167,255,0.20), transparent 60%),
  radial-gradient(1200px 700px at 80% 10%, rgba(45,212,191,0.16), transparent 60%),
  var(--bg);
  color: var(--text);
}

a{ color: var(--primary); }

.hidden { display:none !important; }

.container{
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 18px 42px;
}

.app-header{
  position: sticky;
  top:0;
  z-index:10;
  backdrop-filter: blur(10px);
  background: linear-gradient(to bottom, rgba(11,18,32,0.90), rgba(11,18,32,0.55));
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 14px;
}

.brand{
  display:flex;
  gap: 12px;
  align-items:center;
}
.logo{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display:grid;
  place-items:center;
  background: rgba(90,167,255,0.16);
  border: 1px solid rgba(90,167,255,0.25);
  box-shadow: var(--shadow);
}
h1{
  margin:0;
  font-size: 16px;
  letter-spacing: 0.2px;
}
.sub{
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.app-footer{
  padding: 10px 18px 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align:center;
}

.panel{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-soft{
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.screen{ animation: fadeIn 160ms ease-out; }
@keyframes fadeIn{ from{opacity:0; transform: translateY(4px)} to{opacity:1; transform:none} }

h2{ margin: 0 0 6px; font-size: 18px; }
h3{ margin: 0 0 10px; font-size: 14px; }
.hint{ margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height:1.4; }

.divider{
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.section-title{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-title h3{ margin:0; }
.section-title p{ margin:0; }

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

@media (max-width: 980px){
  .grid-3{ grid-template-columns: 1fr; }
}
@media (max-width: 780px){
  .grid-2{ grid-template-columns: 1fr; }
  .app-header{ position: static; }
}

.field label{
  display:block;
  font-size: 12px;
  color: rgba(255,255,255,0.78);
  margin-bottom: 6px;
}
.field input, .field select{
  width:100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.18);
  color: var(--text);
  outline: none;
}
.field input:focus, .field select:focus{
  border-color: rgba(90,167,255,0.55);
  box-shadow: 0 0 0 4px rgba(90,167,255,0.12);
}
.field input:disabled{
  opacity: 0.65;
}

.error{
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
}
.help{
  color: rgba(255,255,255,0.70);
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
}

.actions{
  margin-top: 16px;
  display:flex;
  justify-content:flex-end;
  gap: 10px;
}

.btn{
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.22);
}
.btn:active{ transform: translateY(1px); }

.btn-primary{
  background: linear-gradient(180deg, rgba(90,167,255,0.40), rgba(46,126,247,0.32));
  border-color: rgba(90,167,255,0.50);
}
.btn-primary:hover{ background: linear-gradient(180deg, rgba(90,167,255,0.52), rgba(46,126,247,0.40)); }

.btn-secondary{
  background: rgba(45,212,191,0.12);
  border-color: rgba(45,212,191,0.35);
}
.btn-danger{
  background: rgba(255,91,91,0.12);
  border-color: rgba(255,91,91,0.35);
}
.btn-ghost{
  background: transparent;
  border-color: rgba(255,255,255,0.18);
}

.segmented{
  display:flex;
  gap: 8px;
}
.seg{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.14);
  border-radius: 12px;
  cursor:pointer;
  user-select:none;
}
.seg input{ accent-color: var(--primary); }
.muted{ color: var(--muted); }

.checkbox{
  display:flex;
  align-items:center;
  gap: 10px;
  cursor:pointer;
  user-select:none;
  color: rgba(255,255,255,0.78);
  font-size: 12px;
}
.checkbox input{ accent-color: var(--primary); }

.rate-grid{
  display:flex;
  flex-direction:column;
  gap: 10px;
}
.rate-row{
  display:grid;
  grid-template-columns: 72px 180px 1fr;
  align-items:center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.14);
  border: 1px solid rgba(255,255,255,0.10);
}
.rate-year{
  font-weight: 600;
  font-size: 12px;
  color: rgba(255,255,255,0.84);
}
.field.compact{
  position: relative;
  display:flex;
  align-items:center;
  gap: 8px;
}
.field.compact input{ padding-right: 34px; }
.suffix{
  position:absolute;
  right: 12px;
  color: rgba(255,255,255,0.70);
  font-size: 12px;
}
.note{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.22);
  color: var(--muted);
  background: rgba(0,0,0,0.12);
  font-size: 12px;
}
.mt{ margin-top: 12px; }

/* RESULTS */
.results-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
}
.results-actions{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.kpi-grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
@media (max-width: 980px){
  .kpi-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px){
  .kpi-grid{ grid-template-columns: 1fr; }
}

.kpi{
  background: var(--panel2);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.25);
}
.kpi .label{
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  margin-bottom: 6px;
  display:flex;
  align-items:center;
  gap: 8px;
}
.kpi .value{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.kpi .subvalue{
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.68);
}

/* KPI tooltip */
.tip{
  position: relative;
  display:inline-grid;
  place-items:center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.12);
  color: rgba(255,255,255,0.80);
  font-size: 12px;
  line-height: 1;
  cursor: help;
  user-select:none;
}
.tip:focus{ outline: none; box-shadow: 0 0 0 4px rgba(90,167,255,0.12); border-color: rgba(90,167,255,0.55); }
.tip::after{
  content: attr(data-tip);
  position:absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  width: min(420px, 80vw);
  padding: 10px 10px;
  border-radius: 12px;
  background: rgba(11,18,32,0.96);
  border: 1px solid rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.90);
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events:none;
  transition: opacity .12s ease, transform .12s ease;
  z-index: 50;
}
.tip::before{
  content:"";
  position:absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-bottom-color: rgba(11,18,32,0.96);
  opacity: 0;
  transition: opacity .12s ease;
  z-index: 51;
}
.tip:hover::after,
.tip:focus::after{
  opacity: 1;
  transform: translateX(-50%) translateY(2px);
}
.tip:hover::before,
.tip:focus::before{
  opacity: 1;
}

/* CHARTS (stable height) */
.charts{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 980px){
  .charts{ grid-template-columns: 1fr; }
}
.chart-card{
  background: rgba(0,0,0,0.14);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  padding: 12px;
  height: 320px;
  display:flex;
  flex-direction:column;
}
.chart-card h3{
  margin: 0 0 10px;
}
.chart-card canvas{
  display:block;
  width:100% !important;
  height: 100% !important;
  flex: 1 1 auto;
}

/* NPV mini table */
.npv-note{
  display:flex;
  align-items:center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.table-mini{
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  overflow:auto;
  background: rgba(0,0,0,0.14);
}
.table-mini table{
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}
.table-mini thead th{
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(11,18,32,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.16);
  padding: 10px 8px;
  text-align: right;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}
.table-mini thead th:first-child,
.table-mini tbody td:first-child { text-align: left; }
.table-mini tbody td{
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 8px;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  color: rgba(255,255,255,0.86);
}

/* LARGE TABLE */
.table-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.table-wrap{
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  overflow:auto;
  max-height: 520px;
  background: rgba(0,0,0,0.14);
}
table{
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}
thead th{
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(11,18,32,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.16);
  padding: 10px 8px;
  text-align: right;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}
thead th:first-child, tbody td:first-child { text-align: left; }
tbody td{
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 8px;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  color: rgba(255,255,255,0.86);
}
tbody tr:hover td{
  background: rgba(255,255,255,0.04);
}
.footnote{
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}