:root{
  --bg:#0f1724;
  --card:#0b1220;
  --muted:#94a3b8;
  --accent:#2563eb;
  --accent-2:#06b6d4;
  --glass: rgba(255,255,255,0.04);
  --glass-2: rgba(255,255,255,0.02);
  --success:#16a34a;
  --danger:#ef4444;
  --radius:12px;
  --max-width:980px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
               "Segoe UI", Roboto, "Helvetica Neue", Arial;
}
*{box-sizing:border-box}
html,body{
  height:100%;
  margin:0;
  background:linear-gradient(180deg,#071024 0%, #071a2b 100%);
  color:#e6eef6;
}
.app{
  min-height:100vh;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:28px 16px;
}
.container{
  width:100%;
  max-width:var(--max-width);
  background:linear-gradient(
    180deg,
    rgba(255,255,255,0.03),
    rgba(255,255,255,0.02)
  );
  border-radius:18px;
  padding:18px;
  box-shadow:0 8px 30px rgba(2,6,23,0.6);
  border:1px solid rgba(255,255,255,0.03);
  display:grid;
  grid-template-columns: 240px 1fr;
  gap:18px;
}

/* Sidebar / Tabs */
.sidebar{
  background:var(--card);
  border-radius:12px;
  padding:14px;
  min-height:420px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.brand{display:flex;align-items:center;gap:10px;margin-bottom:6px}
.logo{
  width:42px;height:42px;border-radius:10px;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  display:flex;align-items:center;justify-content:center;
  font-weight:700;color:white;
}
.brand h1{font-size:16px;margin:0;color:#dff1ff}
.small{font-size:12px;color:var(--muted);margin-top:2px}

/* Tab buttons */
.tab-btn{
  display:flex;gap:10px;align-items:center;
  padding:10px;border-radius:10px;border:1px solid transparent;
  background:transparent;color:var(--muted);
  cursor:pointer;font-weight:600;
}
.tab-btn:hover{background:var(--glass); color:#fff}
.tab-btn.active{
  background:linear-gradient(
    90deg,
    rgba(37,99,235,0.12),
    rgba(6,182,212,0.06)
  );
  color:white;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.tab-icon{
  width:28px;height:28px;border-radius:6px;
  background:rgba(255,255,255,0.03);
  display:flex;align-items:center;justify-content:center;
  color:var(--accent);font-size:14px;
}

/* Main content */
.main{
  display:flex;flex-direction:column;gap:14px;padding:6px;
}
.header{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
}
.title{font-size:18px;font-weight:700}
.controls{display:flex;gap:8px;align-items:center}
.search{
  padding:8px 12px;border-radius:10px;
  border:1px solid rgba(255,255,255,0.03);
  background:var(--glass);color:#fff;
}
.panel{
  background:linear-gradient(
    180deg,
    rgba(255,255,255,0.02),
    rgba(255,255,255,0.01)
  );
  border-radius:14px;padding:16px;
  border:1px solid rgba(255,255,255,0.03);
  min-height:420px;overflow:auto;
}

/* Layout helpers */
.calc-grid{display:grid;grid-template-columns: 1fr 1fr;gap:14px}
@media(max-width:880px){
  .container{grid-template-columns:1fr}
  .calc-grid{grid-template-columns:1fr}
}

/* Card */
.card{
  background:linear-gradient(
    180deg,
    rgba(255,255,255,0.01),
    rgba(255,255,255,0.00)
  );
  border-radius:12px;padding:12px;
  border:1px solid rgba(255,255,255,0.02);
}

/* Simple Calculator */
.calc-screen{
  height:60px;background:rgba(255,255,255,0.03);
  border-radius:10px;padding:10px;
  font-size:22px;color:#eef;
  display:flex;align-items:center;justify-content:flex-end;
  overflow-x:auto;
}
.kb{
  display:grid;grid-template-columns: repeat(4,1fr);
  gap:8px;margin-top:12px;
}
.kb button{
  padding:14px;border-radius:10px;border:none;
  background:var(--glass);color:#e6eef6;
  font-weight:700;font-size:16px;cursor:pointer;
}
.kb button.op{
  background:linear-gradient(90deg,var(--accent-2),var(--accent));
  color:white;
}
.kb button.equal{
  background:var(--accent); color:white; grid-column: span 2;
}
.kb button.clear{
  background:rgba(239,68,68,0.12); color:var(--danger);
}

/* Inputs / buttons */
.row{display:flex;gap:8px;align-items:center}
.input{
  width:100%; padding:10px;border-radius:8px;
  border:1px solid rgba(255,255,255,0.03);
  background:transparent;color:#e6eef6;
}
.small-muted{font-size:12px;color:var(--muted);margin-top:4px}
.result-box{
  background:linear-gradient(
    180deg,
    rgba(255,255,255,0.02),
    rgba(255,255,255,0.01)
  );
  padding:10px;border-radius:8px;
  border:1px solid rgba(255,255,255,0.02);
  color:#dbf4ff;
}
.btn{
  padding:8px 10px;border-radius:8px;border:none;
  background:var(--accent);color:white;cursor:pointer;
  font-size:13px;
}
.btn.ghost{
  background:transparent;
  border:1px solid rgba(255,255,255,0.08);
  color:#e6eef6;
}

/* Expense grid */
.exp-grid{
  display:grid;grid-template-columns: 1fr 1fr; gap:8px;
}
@media(max-width:500px){
  .exp-grid{grid-template-columns:1fr}
}

/* Lists */
.list{
  max-height:220px; overflow:auto;padding-right:6px;
}
.item{
  display:flex;justify-content:space-between;align-items:center;
  padding:8px;border-radius:8px;margin:6px 0;
  background:rgba(255,255,255,0.01);
}

/* Transitions */
.tab-btn, .kb button, .btn{transition: all .15s ease}

/* === SCIENTIFIC IMPROVEMENTS === */
.sci-top{
  margin-top:10px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.sci-screen{
  margin-bottom:8px;
  min-height:52px;
}
.kb-sci{
  display:grid;
  grid-template-columns: repeat(6,1fr);
  gap:6px;
  margin-top:8px;
}
.kb-sci .btn,
.kb-sci .btn.ghost{
  padding:10px;
  font-size:13px;
}
.sci-result{
  margin-top:6px;
  min-height:18px;
}
.sci-box{
  display:flex;
  flex-direction:column;
}
.sci-history-wrap{
  margin-top:10px;
}
.sci-history{
  max-height:140px;
  overflow:auto;
  font-size:12px;
  margin-top:4px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.04);
  padding:6px;
  background:rgba(15,23,42,0.6);
}
.sci-history-item{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:3px 0;
  border-bottom:1px dashed rgba(148,163,184,0.2);
}
.sci-history-item:last-child{border-bottom:none}

/* Expense table improvements */
.exp-table-wrap{
  margin-top:6px;
  max-height:260px;
  overflow:auto;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.04);
}
.exp-table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
}
.exp-table th,
.exp-table td{
  padding:6px 8px;
  border-bottom:1px solid rgba(148,163,184,0.15);
}
.exp-table th{
  background:rgba(15,23,42,0.7);
  position:sticky;
  top:0;
  z-index:1;
  text-align:left;
  font-weight:600;
}
.exp-table tr:nth-child(even){
  background:rgba(15,23,42,0.4);
}
.sortable{
  cursor:pointer;
}
.sortable::after{
  content:"⇅";
  font-size:10px;
  opacity:0.5;
  margin-left:4px;
}
.amount-pos{color:var(--success);font-weight:600}
.amount-neg{color:var(--danger);font-weight:600}
