:root{
  --bg:#0b1220; --panel:#0f172a; --panel-2:#111827;
  --text:#e5e7eb; --muted:#94a3b8; --muted-2:#9ca3af;
  --accent:#60a5fa; --border:#1f2937; --border-2:#334155;
  --radius:16px; --space:clamp(12px,2vw,20px);
  --fs-hero:clamp(20px,3.2vw,28px); --fs-h2:clamp(16px,2.4vw,20px);
  --fs-body:clamp(13px,1.7vw,15px);
  --header-h:72px; /* desktop default */
}

@media(max-width:900px){ :root{ --header-h:64px; } }

*{box-sizing:border-box}
html,body{height:100%}
html{scroll-behavior:smooth}
body{
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  margin:0; color:var(--text); background:var(--bg); font-size:var(--fs-body); line-height:1.5;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  -webkit-tap-highlight-color:transparent;
  padding-top:0; /* header is sticky, so no extra offset */
}
body.menu-open{ overflow:hidden; }

/* Header / Nav */
header{
  display:flex;align-items:center;justify-content:space-between;
  padding:var(--space); border-bottom:1px solid var(--border);
  position:sticky; top:0; background:var(--bg); z-index:1000;
  min-height:var(--header-h);
}
.brand{display:flex;gap:12px;align-items:center}
.logo{font-size:28px}
h1{margin:0;color:#f3f4f6;font-size:var(--fs-hero);letter-spacing:.2px}
.tag{color:#93c5fd;margin:2px 0 0 0;font-size:12px}

/* NAV */
#nav{display:flex;align-items:center;gap:10px;flex-wrap:nowrap;position:relative;z-index:1001}
#nav .mode{min-width:112px;height:44px}
#nav .links{display:flex;gap:10px;flex-wrap:wrap}
#nav a,#nav button{
  color:var(--muted-2); text-decoration:none; padding:10px 14px; height:44px;
  display:inline-flex; align-items:center;
  border:1px solid var(--border); border-radius:999px; background:transparent; cursor:pointer;
  transition:border-color .15s ease,color .15s ease,background .15s ease;
}
#nav a:hover,#nav button:hover{color:var(--text); border-color:var(--border-2)}
.icon-btn{font-size:18px; line-height:1; padding:10px 14px; height:44px}

/* Desktop collapse (burger can hide links if desired) */
#nav.collapsed .links{display:none}

/* Mobile dropdown (<=900px) — fixed sheet right below header */
@media(max-width:900px){
  #nav{align-items:center}
  /* Hide inline links on mobile */
  #nav .links{ display:none; }

  /* Show as fixed sheet when open */
  #nav.open .links{
    display:flex; flex-direction:column;
    position:fixed; left:0; right:0; top:var(--header-h);
    background:var(--panel); border-top:1px solid var(--border); border-bottom:1px solid var(--border);
    padding:12px; gap:8px; z-index:999; box-shadow:0 12px 32px rgba(0,0,0,.35);
  }

  /* Make links full width for easy tapping */
  #nav.open .links a{
    width:100%; justify-content:center;
  }
}

main{padding:var(--space); max-width:1200px; margin:0 auto}
.cards{
  display:grid; gap:var(--space);
  grid-template-columns:repeat(auto-fit, minmax(170px,1fr));
  margin-bottom:var(--space);
}
.card{
  background:var(--panel); border:1px solid var(--border);
  border-radius:var(--radius); padding:16px; min-height:110px;
  box-shadow:0 10px 20px rgba(0,0,0,.25);
}
.card h3{margin:0 0 8px 0;color:var(--muted);font-weight:600}
.card div{font-size:clamp(22px,3.2vw,28px); color:var(--accent)}

h2{color:#f3f4f6; margin:24px 0 12px 0; font-size:var(--fs-h2)}
.legend{color:var(--muted); font-size:12px; margin-top:6px}

.two-col{display:grid; grid-template-columns:1fr 1fr; gap:var(--space)}
@media(max-width:1100px){ .two-col{grid-template-columns:1fr} }

canvas{
  display:block; width:100%; height:260px; background:var(--panel);
  border:1px solid var(--border); border-radius:12px; padding:6px;
}

.table-wrap{overflow-x:auto; border-radius:12px; border:1px solid var(--border); background:var(--panel)}
table{width:100%; border-collapse:collapse; min-width:680px}
th,td{padding:12px 14px; border-bottom:1px solid var(--border); color:#cbd5e1}
th{text-align:left; color:var(--muted); font-weight:600; background:var(--panel)}
tr:hover td{background:var(--panel-2)}

/* Status pill + toast */
.status-pill{
  display:inline-block; margin-left:8px; padding:6px 10px; border-radius:999px;
  font-size:12px; border:1px solid var(--border); color:var(--muted-2); background:var(--panel);
}
#toast{
  position:fixed; left:50%; transform:translateX(-50%); bottom:18px;
  background:var(--panel); color:var(--text); border:1px solid var(--border);
  border-radius:10px; padding:10px 14px; opacity:0; pointer-events:none;
  transition:opacity .25s ease, bottom .25s ease; z-index:2000;
}
#toast.show{opacity:1; bottom:26px}

footer{padding:26px; text-align:center; color:var(--muted); border-top:1px solid var(--border); margin-top:40px}
a:focus,button:focus{outline:2px solid var(--accent); outline-offset:2px}
button{touch-action:manipulation}
