:root{
  --bg:#F2F2F7;
  --card:#FFFFFF;
  --text:#0B0B0F;
  --muted:#6B7280;
  --line:rgba(17,24,39,.12);
  --blue:#0A84FF;
  --green:#34C759;
  --shadow: 0 12px 30px rgba(0,0,0,.08);
  --shadow2: 0 4px 14px rgba(0,0,0,.06);
  --radius:16px;
  --radius2:14px;
  --pad:16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --sw1: rgba(10,132,255,.28);
  --sw2: rgba(52,199,89,.28);
  --sw3: rgba(10,132,255,.85);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "SF Pro Display", "Heebo", Arial, sans-serif;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--bg) 52%, var(--bg) 100%);
  color:var(--text);
}

.topbar{
  position: sticky;
  top:0;
  z-index:20;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + var(--safe-top)) 14px 10px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}

.brand{ display:flex; align-items:center; gap:10px; }
.appicon{
  width:36px; height:36px;
  border-radius: 11px;
  background: radial-gradient(120% 140% at 20% 10%, #FFFFFF 0%, rgba(255,255,255,.4) 25%, rgba(255,255,255,0) 60%),
              linear-gradient(135deg, var(--blue), #1F6FEB);
  box-shadow: var(--shadow);
  display:grid; place-items:center;
  font-weight:800;
  color:#fff;
  letter-spacing: .5px;
}

.titles .title{ font-weight:800; font-size: 16px; line-height: 1.1; }
.titles .subtitle{ font-size: 12px; color: var(--muted); margin-top:2px; }

.ghost{
  border:1px solid var(--line);
  background: rgba(255,255,255,.7);
  border-radius: 12px;
  padding: 12px 12px;
  font-weight: 700;
  cursor:pointer;
}
.ghost:active{ transform: scale(.98); }

.wrap{
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 14px calc(24px + var(--safe-bottom));
}

.tabbar{
  position: sticky;
  top: 64px;
  z-index: 10;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(10,132,255,.22);
  border-radius: 999px;
  padding: 6px;
  display:flex;
  gap: 6px;
  box-shadow: var(--shadow);
}

.tab{
  flex:1;
  border:0;
  background: transparent;
  padding: 12px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-weight:800;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  color: rgba(11,11,15,.65);
  position: relative;
  z-index: 2;
  transition: color .2s ease;
}
.tab .tab-emoji{ font-size: 18px; }
.tab.active{ color: var(--text); }
.tab:focus-visible{ outline: 3px solid rgba(10,132,255,.35); outline-offset: 3px; }
.tab:active{ transform: scale(.985); }

.tab-underline{
  position:absolute;
  inset:6px auto 6px auto;
  width: calc(50% - 9px);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,255,255,.88));
  border: 1px solid rgba(17,24,39,.08);
  box-shadow: var(--shadow);
  transition: transform .26s cubic-bezier(.2,.9,.2,1);
  z-index: 1;
}

.panel{ display:none; margin-top: 14px; }
.panel.active{ display:block; }

.panel-head{ margin: 14px 2px 10px; }
.h1{ margin:0; font-size: 18px; font-weight: 900; }
.h2{ margin:0 0 10px 0; font-size: 14px; font-weight: 900; }
.p{ margin: 6px 0 0 0; font-size: 13px; }
.muted{ color: var(--muted); }
.small{ font-size: 12px; margin-top: 10px; }

.grid2{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 900px){
  .grid2{ grid-template-columns: 1fr 1fr; }
}

.card{
  background: var(--card);
  border: 1px solid rgba(10,132,255,.22);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
}

.field{ display:block; margin-top: 12px; }
.label{ display:block; font-size: 13px; font-weight: 800; margin-bottom: 8px; }
.hint{ display:block; margin-top: 6px; font-size: 12px; color: var(--muted); }

input{
  width:100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(17,24,39,.14);
  background: rgba(242,242,247,.55);
  font-size: 16px;
  outline:none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus{
  border-color: rgba(10,132,255,.55);
  box-shadow: 0 0 0 4px rgba(10,132,255,.12);
  background: rgba(242,242,247,.25);
}

.row2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pill{
  margin-top: 12px;
  padding: 12px 12px;
  border-radius: 999px;
  border: 1px solid rgba(52,199,89,.30);
  background: rgba(52,199,89,.10);
  font-weight: 800;
  font-size: 13px;
  display:flex;
  align-items:center;
  gap:10px;
}
.dot{ width:9px; height:9px; border-radius: 99px; }
.dot.ok{ background: var(--green); }

.primary{
  margin-top: 14px;
  width: 100%;
  border: 0;
  padding: 14px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), #1F6FEB);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  cursor:pointer;
  box-shadow: 0 12px 28px rgba(10,132,255,.20);
}
.primary:active{ transform: scale(.985); }

.result{
  border: 1px solid rgba(10,132,255,.18);
  background: linear-gradient(180deg, rgba(10,132,255,.08), rgba(10,132,255,.04));
  border-radius: var(--radius2);
  padding: 14px;
}
.result-label{ font-size: 13px; font-weight: 900; color: rgba(11,11,15,.75); }
.result-value{ margin-top: 6px; font-size: 28px; font-weight: 1000; letter-spacing: .2px; }

.kpis{
  margin-top: 12px;
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 520px){
  .kpis{ grid-template-columns: 1fr 1fr 1fr; }
}
.kpi{
  border: 1px solid rgba(10,132,255,.22);
  background: rgba(242,242,247,.55);
  border-radius: var(--radius2);
  padding: 12px;
}
.kpi-label{ font-size: 12px; font-weight: 800; color: var(--muted); }
.kpi-value{ margin-top: 6px; font-size: 16px; font-weight: 900; }

.alert{
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px 12px;
  border: 1px solid rgba(255,59,48,.22);
  background: rgba(255,59,48,.08);
  color: rgba(255,59,48,.95);
  font-weight: 800;
  font-size: 13px;
}

.chart-card{ margin-top: 12px; }
.chart-head{
  display:flex;
  align-items:flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.legend{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}
.leg{ display:flex; align-items:center; gap:7px; }
.swatch{ width:12px; height:12px; border-radius: 6px; }
.sw1{ background: var(--sw1); border: 1px solid rgba(10,132,255,.35); }
.sw2{ background: var(--sw2); border: 1px solid rgba(52,199,89,.35); }
.sw3{ background: var(--sw3); }

.chart-wrap{
  position: relative;
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(10,132,255,.22);
  background: radial-gradient(120% 90% at 20% 0%, rgba(10,132,255,.06), rgba(255,255,255,0) 55%),
              linear-gradient(180deg, rgba(242,242,247,.55), rgba(255,255,255,.1));
  overflow: hidden;
}
canvas{ width: 100%; height: auto; display:block; }

.tooltip{
  position: absolute;
  pointer-events: none;
  min-width: 180px;
  max-width: 240px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(17,24,39,.14);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 10px 10px;
  font-size: 12px;
  line-height: 1.35;
}
.tip-title{ font-weight: 1000; margin-bottom: 6px; }
.tip-row{ display:flex; justify-content: space-between; gap:10px; }
.tip-row span:last-child{ font-weight: 900; }

.footer{
  margin-top: 16px;
  padding: 10px 2px;
  display:flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}


.tabhint{
  margin: 10px 4px 0;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px dashed rgba(10,132,255,.28);
  background: rgba(10,132,255,.06);
  color: rgba(11,11,15,.72);
  font-weight: 900;
  font-size: 12px;
  text-align: center;
}


/* One-time nudge animation to hint tabs are clickable */
@keyframes kvhNudge {
  0%   { transform: translateX(0); }
  18%  { transform: translateX(-6px); }
  36%  { transform: translateX(6px); }
  54%  { transform: translateX(-4px); }
  72%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}
.tabbar.nudge{
  animation: kvhNudge 900ms cubic-bezier(.2,.9,.2,1) 0ms 2;
}

@keyframes kvhPulse {
  0%{ transform: scale(1); }
  50%{ transform: scale(1.01); }
  100%{ transform: scale(1); }
}
.tabhint.pulse{
  animation: kvhPulse 800ms ease-in-out 0ms 2;
}


/* ---- Tabbar: make it very obvious (blue buttons) ---- */
.tabbar{
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  gap: 10px !important;
}

.tab{
  border: 2px solid rgba(10,132,255,.35) !important;
  background: rgba(10,132,255,.08) !important;
  color: rgba(10,60,140,.95) !important;
  padding: 14px 14px !important;
  border-radius: 18px !important;
  box-shadow: 0 10px 22px rgba(10,132,255,.10) !important;
  font-size: 15px !important;
}

.tab .tab-emoji{ font-size: 18px !important; }
.tab .tab-label{ font-weight: 1000 !important; }

.tab.active{
  background: linear-gradient(135deg, var(--blue), #1F6FEB) !important;
  color: #fff !important;
  border-color: rgba(10,132,255,.18) !important;
  box-shadow: 0 14px 30px rgba(10,132,255,.22) !important;
}

.tab:active{ transform: scale(.985) !important; }

.tab-underline{
  display:none !important;
}

.tabhint{
  border-style: solid !important;
  border-color: rgba(10,132,255,.22) !important;
  background: rgba(10,132,255,.05) !important;
}
