:root{
  --bg:#0b0f14;
  --card:#0f172a;
  --muted:#94a3b8;
  --text:#e5e7eb;
  --line:rgba(255,255,255,.08);
  --c1:#22d3ee; /* cyan */
  --c2:#a78bfa; /* purple */
  --c3:#34d399; /* green */
  --danger:#f87171;
}

/* ---------------------------
   Mobile-safe foundation
---------------------------- */
*{
  box-sizing:border-box;
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial;
  min-width:0; /* IMPORTANT: prevents grid/flex children overflow */
}

html, body{
  width:100%;
  max-width:100%;
  overflow-x:hidden; /* locks sideways scroll on mobile */
}

img, svg, video, canvas{
  max-width:100%;
  height:auto;
}

a{color:inherit;text-decoration:none}

body.bg{
  margin:0;
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(167,139,250,.16), transparent 60%),
    radial-gradient(1200px 600px at 80% 0%, rgba(34,211,238,.14), transparent 55%),
    radial-gradient(900px 500px at 70% 85%, rgba(52,211,153,.08), transparent 55%),
    var(--bg);
  color:var(--text);
}

/* Safe area padding (iOS notch) */
.container, .topbar{
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right:max(16px, env(safe-area-inset-right));
}

/* ---------------------------
   Layout
---------------------------- */
.container{
  max-width:1200px;
  margin:24px auto;
  padding-top:0;
  padding-bottom:0;
}

.grid{
  display:grid;
  grid-template-columns:1fr 1.4fr;
  gap:16px;
}

/* Stack on smaller screens */
@media(max-width:980px){
  .container{
    margin:16px auto;
    padding-left:max(12px, env(safe-area-inset-left));
    padding-right:max(12px, env(safe-area-inset-right));
  }
  .grid{ grid-template-columns:1fr; }
}

/* ---------------------------
   Topbar
---------------------------- */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding-top:14px;
  padding-bottom:14px;
  border-bottom:1px solid var(--line);
  position:sticky;
  top:0;
  z-index:50;
  width:100%;
  max-width:100%;
  background:rgba(11,15,20,.72);
  backdrop-filter: blur(12px);
}

.brand{
  font-weight:800;
  letter-spacing:.4px;
  display:flex;
  gap:10px;
  align-items:center;
}

.brand .dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background:linear-gradient(90deg,var(--c1),var(--c2));
  box-shadow:0 0 18px rgba(34,211,238,.25);
  flex:0 0 auto;
}

.nav{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap; /* prevents overflow */
  justify-content:flex-end;
}

@media(max-width:720px){
  .topbar{
    gap:10px;
    align-items:flex-start;
    flex-direction:column;
  }
  .nav{
    width:100%;
    justify-content:flex-start;
  }
}

.pill{
  padding:6px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  color:var(--muted);
  max-width:100%;
  overflow-wrap:anywhere;
}

/* ---------------------------
   Cards / typography
---------------------------- */
.card{
  background:linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012));
  border:1px solid var(--line);
  border-radius:18px;
  padding:16px;
  max-width:100%;
}

.glow{
  box-shadow:
    0 0 0 1px rgba(255,255,255,.02) inset,
    0 18px 50px rgba(0,0,0,.58),
    0 0 28px rgba(34,211,238,.10),
    0 0 38px rgba(167,139,250,.10);
}

h1,h2{margin:0 0 10px 0}
.muted{color:var(--muted);margin:0 0 14px 0}
.small{font-size:12px;color:var(--muted)}
.hr{height:1px;background:var(--line);margin:12px 0}

/* ---------------------------
   Forms
---------------------------- */
label{
  display:block;
  margin:10px 0 6px 0;
  color:var(--muted);
  font-size:13px;
  max-width:100%;
}

.input, .select, .textarea{
  width:100%;
  max-width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(15,23,42,.62);
  color:var(--text);
  outline:none;
}

.textarea{
  min-height:92px;
  resize:vertical;
}

.input:focus,.select:focus,.textarea:focus{
  border-color:rgba(34,211,238,.58);
  box-shadow:0 0 0 3px rgba(34,211,238,.12);
}

/* Two-column rows collapse on mobile */
.row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  max-width:100%;
}

@media(max-width:720px){
  .row{ grid-template-columns:1fr; }
}

/* Avoid iOS zoom on focus */
@media (max-width: 980px){
  input, select, textarea { font-size: 16px; }
}

/* ---------------------------
   Buttons / badges / toasts
---------------------------- */
.btn{
  border:1px solid var(--line);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  background:rgba(255,255,255,.02);
  max-width:100%;
  overflow-wrap:anywhere;
}

.btn-primary{
  background:linear-gradient(90deg, rgba(34,211,238,.22), rgba(167,139,250,.22));
  border-color:rgba(34,211,238,.35);
}
.btn-primary:hover{filter:brightness(1.08)}

.btn-ghost{background:transparent}

.btn-danger{
  border-color:rgba(248,113,113,.35);
  background:rgba(248,113,113,.06);
}

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

.toast{
  margin:10px 0;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  max-width:100%;
  overflow-wrap:anywhere;
}
.toast.ok{border-color:rgba(52,211,153,.35);box-shadow:0 0 20px rgba(52,211,153,.10)}
.toast.bad{border-color:rgba(248,113,113,.35);box-shadow:0 0 20px rgba(248,113,113,.10)}

.badge{
  padding:4px 8px;
  border:1px solid var(--line);
  border-radius:999px;
  color:var(--muted);
  font-size:12px;
  max-width:100%;
  overflow-wrap:anywhere;
}
.badge.ok{border-color:rgba(52,211,153,.35)}
.badge.warn{border-color:rgba(250,204,21,.25)}
.badge.bad{border-color:rgba(248,113,113,.35)}

/* ---------------------------
   Tables (mobile-friendly)
   - Page never scrolls sideways
   - Table area can scroll horizontally if needed
---------------------------- */
.table{
  margin-top:10px;
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  max-width:100%;
}

/* Wrap to allow internal horizontal scroll on small screens */
.table{
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure header/rows keep their grid width but don’t force page overflow */
.thead,.trow{
  display:grid;
  grid-template-columns:1.2fr 1fr 1.3fr .9fr .9fr;
  gap:10px;
  padding:10px 12px;
  min-width:760px; /* allows internal table scroll instead of page scroll */
}

.thead{
  background:rgba(255,255,255,.03);
  color:var(--muted);
  font-size:13px;
  position:sticky;
  top:0;
  z-index:1;
}

.trow{
  border-top:1px solid var(--line);
  align-items:center;
}

/* On wide screens, table fits without scroll */
@media(min-width:980px){
  .thead,.trow{ min-width:0; }
}

/* ---------------------------
   Login center
---------------------------- */
.center{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
}
/* =========================
   Login page centering fix
   ========================= */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px; /* mobile safe */
}

.login-card {
  width: 100%;
  max-width: 420px; /* desktop width */
}

/* On very small phones, allow a bit more breathing room */
@media (max-width: 420px) {
  .login-card {
    max-width: 100%;
  }
}
