:root{
  --bg1:#0b1220;
  --bg2:#101b34;
  --card:rgba(255,255,255,.08);
  --card2:rgba(255,255,255,.06);
  --border:rgba(255,255,255,.14);
  --text:#eef2ff;
  --muted:rgba(238,242,255,.75);
  --muted2:rgba(238,242,255,.55);
  --accent:#8b5cf6;
  --accent2:#22d3ee;
  --good:#22c55e;
  --bad:#ef4444;
  --warning:#f59e0b;
  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --radius: 18px;
}

*{box-sizing:border-box;}
html,body{height:100%;scroll-behavior:smooth;}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(139,92,246,.35), transparent 60%),
    radial-gradient(700px 450px at 80% 20%, rgba(34,211,238,.25), transparent 55%),
    radial-gradient(650px 450px at 50% 100%, rgba(34,197,94,.18), transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
}

.container{
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding: 14px 18px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  transition: all 0.3s ease;
}

.topbar:hover{
  box-shadow: 0 12px 36px rgba(0,0,0,.4);
  background: rgba(255,255,255,.08);
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 240px;
}
.logo{
  width:40px;
  height:40px;
  border-radius:12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 10px 24px rgba(139,92,246,.3);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  transition: transform 0.3s ease;
}
.logo:hover{
  transform: scale(1.05) rotate(5deg);
}
.brandTitle{
  line-height:1.2;
}
.brandTitle b{
  display:block;
  font-size:15px;
  letter-spacing:.3px;
  font-weight:800;
}
.brandTitle span{
  display:block;
  font-size:12px;
  color:var(--muted2);
}

.topActions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  align-items:center;
}

.pill{
  border:1px solid var(--border);
  background: rgba(255,255,255,.05);
  color:var(--muted);
  padding:9px 13px;
  border-radius: 999px;
  font-size:12px;
  font-weight:600;
  transition: all 0.2s ease;
}

.pill:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.2);
}

.hero{
  margin: 18px 0 14px;
  display:grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 16px;
  align-items:stretch;
}

.heroCard{
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transition: all 0.3s ease;
}

.heroCard:hover{
  border-color: rgba(255,255,255,.2);
  box-shadow: 0 20px 70px rgba(0,0,0,.5);
}

.heroCard h1{
  margin: 0 0 10px 0;
  font-size: 28px;
  letter-spacing: .3px;
  font-weight:900;
  background: linear-gradient(135deg, var(--text), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.heroCard p{
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size:14px;
}

.statsGrid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:12px;
  margin-top:16px;
  padding-top:16px;
  border-top:1px solid var(--border);
}

.stat{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.statValue{
  font-size:18px;
  font-weight:900;
  color:var(--accent2);
}

.statLabel{
  font-size:11px;
  color:var(--muted2);
  text-transform:uppercase;
  letter-spacing:.05em;
}

.heroAside{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.05);
  padding: 18px;
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
  display:flex;
  flex-direction:column;
  gap:12px;
  transition: all 0.3s ease;
}

.heroAside:hover{
  border-color: rgba(255,255,255,.2);
  box-shadow: 0 16px 50px rgba(0,0,0,.45);
}

.kpi{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
}
.kpi b{
  font-size:19px;
  font-weight:900;
}
.kpi span{
  font-size:11px;
  color:var(--muted2);
  text-transform:uppercase;
  letter-spacing:.05em;
}
.divider{
  height:1px; 
  background: var(--border);
  margin: 6px 0;
}

.card{
  border:1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transition: all 0.3s ease;
}

.card:hover{
  border-color: rgba(255,255,255,.18);
}

.formSection{
  margin-bottom:20px;
}

.sectionTitle{
  margin: 16px 0 12px;
  font-size: 13px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight:800;
}

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

label{
  display:block;
  padding: 13px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  border-radius: 14px;
  transition: all 0.2s ease;
}

label:hover{
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.18);
}

label:focus-within{
  border-color: rgba(139,92,246,.6);
  background: rgba(255,255,255,.08);
  box-shadow: 0 0 0 3px rgba(139,92,246,.15);
}

label span{
  display:block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight:600;
}

.hint{
  color:var(--muted2);
  font-weight:400;
  font-size:11px;
}

input, select{
  width:100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(10,16,30,.6);
  color: var(--text);
  outline: none;
  font-size:14px;
  transition: all 0.2s ease;
}

input::placeholder{
  color: rgba(238,242,255,.45);
}

input:focus, select:focus{
  border-color: rgba(139,92,246,.8);
  box-shadow: 0 0 0 3px rgba(139,92,246,.2);
  background: rgba(10,16,30,.7);
}

input:invalid{
  border-color: rgba(239,68,68,.5);
}

.actions{
  margin-top: 18px;
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
}

.btn{
  border:0;
  cursor:pointer;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 800;
  font-size:14px;
  color: #0b1220;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 14px 28px rgba(139,92,246,.25);
  transition: all 0.2s ease;
  text-decoration:none;
  display:inline-block;
}

.btn:hover:not(:disabled){ 
  transform: translateY(-2px); 
  box-shadow: 0 18px 36px rgba(139,92,246,.35);
}

.btn:active:not(:disabled){ 
  transform: translateY(0px); 
}

.btn.secondary{
  background: rgba(255,255,255,.08);
  border:1px solid var(--border);
  color: var(--text);
  box-shadow:none;
}

.btn.secondary:hover:not(:disabled){
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.22);
  box-shadow: 0 8px 20px rgba(0,0,0,.2);
}

.btn:disabled{
  opacity:.5;
  cursor:not-allowed;
  transform:none;
}

.btn.btnSmall{
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}

.result{
  margin-top: 18px;
  border:1px solid rgba(255,255,255,.12);
  background: var(--card2);
  border-radius: 16px;
  padding: 16px;
  transition: all 0.3s ease;
}

.result:hover{
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
}

.resultRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex-wrap:wrap;
}

.price{
  font-size: 32px;
  font-weight: 900;
  letter-spacing: .5px;
  background: linear-gradient(135deg, var(--good), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.priceDetails{
  margin-top:8px;
  color:var(--muted2);
  font-size:13px;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 9px 12px;
  border-radius: 999px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.25);
  color: var(--muted);
  font-size:12px;
  font-weight:600;
}

.dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background: var(--muted2);
  animation: pulse 2s ease-in-out infinite;
}

.dot.good{ 
  background: var(--good); 
}

.dot.bad{ 
  background: var(--bad); 
}

@keyframes pulse{
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.rawDetails{
  margin-top: 14px;
}

.rawDetails summary{
  cursor:pointer;
  padding:8px 12px;
  border-radius:10px;
  background: rgba(255,255,255,.05);
  border:1px solid var(--border);
  font-size:12px;
  font-weight:600;
  color:var(--muted);
  transition: all 0.2s ease;
  user-select: none;
}

.rawDetails summary:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.2);
}

.rawDetails[open] summary{
  margin-bottom:10px;
  background: rgba(255,255,255,.1);
}

.raw{
  margin:0;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.35);
  color: rgba(238,242,255,.9);
  overflow:auto;
  max-height: 300px;
  font-size: 12px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  line-height:1.5;
}

.cardHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom: 12px;
}

.historyList{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding: 14px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.2);
  max-height: 240px;
  overflow:auto;
}

.historyItem{
  padding: 12px 14px;
  border-radius: 12px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  transition: all 0.2s ease;
}

.historyItem:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.18);
  transform: translateX(4px);
}

.historyPrice b{
  font-size:16px;
  font-weight:900;
  color:var(--accent2);
}

.historyMeta{
  display:flex;
  gap:6px;
  font-size:11px;
  color:var(--muted2);
}

.emptyState, .errorState{
  padding:20px;
  text-align:center;
  color:var(--muted2);
  font-size:13px;
}

.footer{
  margin-top: 20px;
  padding:16px;
  color: var(--muted2);
  font-size: 12px;
  text-align:center;
  border-top:1px solid var(--border);
}

.footer a{
  color:var(--accent2);
  text-decoration:none;
  transition: color 0.2s ease;
}

.footer a:hover{
  color:var(--accent);
  text-decoration:underline;
}

.spin{
  width: 14px;
  height:14px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: rgba(255,255,255,.95);
  display:inline-block;
  animation: sp 0.8s linear infinite;
}

@keyframes sp{
  to{transform: rotate(360deg);}
}

/* Notifications */
.notification{
  position:fixed;
  top:20px;
  right:20px;
  padding:14px 18px;
  border-radius:12px;
  background: rgba(10,16,30,.95);
  border:1px solid var(--border);
  color:var(--text);
  font-size:14px;
  font-weight:600;
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
  backdrop-filter: blur(16px);
  z-index:9999;
  opacity:0;
  transform: translateX(100px);
  transition: all 0.3s ease;
}

.notification.show{
  opacity:1;
  transform: translateX(0);
}

.notification-success{
  border-left:4px solid var(--good);
}

.notification-error{
  border-left:4px solid var(--bad);
}

.notification-info{
  border-left:4px solid var(--accent2);
}

/* Custom scrollbar */
.historyList::-webkit-scrollbar, .raw::-webkit-scrollbar{
  width:8px;
  height:8px;
}

.historyList::-webkit-scrollbar-track, .raw::-webkit-scrollbar-track{
  background: rgba(0,0,0,.2);
  border-radius:8px;
}

.historyList::-webkit-scrollbar-thumb, .raw::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.2);
  border-radius:8px;
}

.historyList::-webkit-scrollbar-thumb:hover, .raw::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,.3);
}

/* Responsive */
@media (max-width: 1000px){
  .hero{ 
    grid-template-columns: 1fr; 
  }
  .statsGrid{
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px){
  .grid{ 
    grid-template-columns: repeat(2, minmax(0,1fr)); 
  }
  .topbar{ 
    flex-direction:column; 
    align-items:flex-start; 
  }
  .topActions{ 
    width:100%;
    justify-content:flex-start; 
  }
  .brand{
    min-width:auto;
  }
  .statsGrid{
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px){
  .grid{ 
    grid-template-columns: 1fr; 
  }
  .cardHeader{ 
    flex-direction:column; 
    align-items:stretch; 
  }
  .btn.btnSmall{ 
    width:100%; 
    text-align:center; 
  }
  .actions{
    flex-direction:column;
    align-items:stretch;
  }
  .actions .btn{
    width:100%;
  }
  .statsGrid{
    grid-template-columns: 1fr;
  }
  .resultRow{
    flex-direction:column;
    align-items:flex-start;
  }
  .notification{
    left:20px;
    right:20px;
  }
}

/* Loading skeleton */
@keyframes shimmer{
  0%{ background-position: -1000px 0; }
  100%{ background-position: 1000px 0; }
}

.skeleton{
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.1) 50%, rgba(255,255,255,.05) 75%);
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* Focus visible for accessibility */
*:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}