:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --blue:#1d4ed8;
  --blue2:#0ea5e9;
  --good:#16a34a;
  --warn:#f59e0b;
  --bad:#ef4444;
  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --radius:14px;
}

/* Reset / base */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--text);
  background:var(--bg);
  overflow-x:hidden; /* evita bugs horizontales */
}

/* Avoid iPhone zoom on inputs */
input, button, select, textarea{ font-size:16px; }

a{ color:inherit; text-decoration:none; }
.muted{ color:var(--muted); }
.small{ font-size:12px; }
.h3{ margin:0 0 10px 0; font-size:16px; }

/* Auth background */
.app-bg{
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(29,78,216,.15), transparent),
    radial-gradient(900px 500px at 90% 10%, rgba(14,165,233,.12), transparent),
    var(--bg);
}

/* Buttons */
.btn{
  border:1px solid var(--line);
  background:#fff;
  padding:12px 14px;
  border-radius:12px;
  cursor:pointer;
  font-weight:700;
  line-height:1;
  white-space:nowrap;
}
.btn:hover{ filter:brightness(.98); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

.btn.primary{
  background: linear-gradient(90deg, var(--blue), #2563eb);
  border-color:transparent;
  color:#fff;
}
.btn.ghost{ background:#fff; }
.btn.sm{ padding:8px 10px; border-radius:10px; font-size:13px; }

/* =========================
   AUTH (LOGIN / REGISTER)
   ========================= */
.auth-wrap{
  min-height:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:26px 14px;
  gap:14px;
}

.auth-card{
  width:min(440px, 100%);
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow: var(--shadow);
  padding:18px;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  margin-bottom:14px;
}
.brand-dot{
  width:16px; height:16px; border-radius:6px;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
}
.brand-title{ font-weight:900; font-size:16px; }
.brand-sub{ color:var(--muted); font-size:13px; margin-top:2px; }

.lbl{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin:10px 0 6px;
}

.inp{
  width:100%;
  display:block;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  outline:none;
  background:#fff;
}
.inp:focus{
  border-color: rgba(29,78,216,.5);
  box-shadow:0 0 0 4px rgba(29,78,216,.10);
}

.row{
  display:flex;
  gap:10px;
  margin-top:10px;
}

.sep{ height:1px; background:var(--line); margin:14px 0; }

.linkbtn{
  border:none;
  background:transparent;
  color:var(--blue);
  font-weight:900;
  cursor:pointer;
  padding:0;
}

.msg{
  margin-top:12px;
  font-size:12px;
  color:var(--bad);
  min-height:16px;
}

.auth-foot{ font-size:12px; }

/* Alerts */
.alert{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  margin-top:10px;
  font-size:12px;
}
.alert.warn{
  border-color: rgba(245,158,11,.25);
  background: rgba(245,158,11,.08);
}
.alert.ok{
  border-color: rgba(22,163,74,.25);
  background: rgba(22,163,74,.08);
}
.alert.info{
  border-color: rgba(14,165,233,.25);
  background: rgba(14,165,233,.08);
}

/* =========================
   PORTAL LAYOUT
   ========================= */
.portal{ background:var(--bg); }

/* topbar ALWAYS on top (important for drawer) */
.topbar{
  height:56px;
  background: linear-gradient(90deg, var(--blue), #2563eb);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 14px;

  position:sticky;
  top:0;
  z-index:2000;
}

.topbar-left, .topbar-right{
  display:flex;
  align-items:center;
  gap:10px;
}

.brand-mini{ display:flex; align-items:center; gap:10px; }

.topbar-pill{
  background: rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.20);
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
}

/* Desktop shell */
.shell{
  display:grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

.sidebar{
  background:#fff;
  border-right:1px solid var(--line);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.nav{ display:flex; flex-direction:column; gap:6px; }

.nav-item{
  padding:10px 10px;
  border-radius:12px;
  border:1px solid transparent;
  color: var(--text);
  font-weight:900;
  font-size:14px;
}
.nav-item:hover{ background:#f8fafc; }
.nav-item.active{
  background: rgba(29,78,216,.08);
  border-color: rgba(29,78,216,.18);
  color: var(--blue);
}

.sidebar-foot{
  margin-top:auto;
  border-top:1px solid var(--line);
  padding-top:12px;
}

.status-chip{
  margin-top:6px;
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  font-size:12px;
  background:#fff;
  font-weight:900;
}
.status-chip.ok{
  border-color: rgba(22,163,74,.25);
  background: rgba(22,163,74,.08);
  color: var(--good);
}

.content{
  padding:16px;
  max-width:1100px;
  margin:0 auto;
  width:100%;
}

.page-head{ margin-bottom:8px; }
.page-head h1{ margin:0; font-size:22px; }
.subhead{ color:var(--muted); margin-top:4px; font-size:13px; }

.card{
  background:#fff;
  border:1px solid var(--line);
  border-radius: var(--radius);
  padding:14px;
  box-shadow: 0 1px 0 rgba(15,23,42,.03);
}

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}

.kv{
  display:grid;
  grid-template-columns: 140px 1fr;
  gap:8px 10px;
  align-items:center;
  margin-top:10px;
}
.k{ color:var(--muted); font-size:12px; }
.v{ font-weight:900; font-size:13px; }

.footer{ margin-top:16px; font-size:12px; color:var(--muted); }

/* Toast */
.toast{
  position:fixed;
  left:50%;
  bottom:20px;
  transform:translateX(-50%);
  background:#0b1220;
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  opacity:0;
  transition:opacity .18s ease, transform .18s ease;
  box-shadow: var(--shadow);
  font-size:13px;
  z-index:9999;
}
.toast.show{
  opacity:1;
  transform:translateX(-50%) translateY(-3px);
}

/* =====================
   MOBILE MENU (3 lines)
   ===================== */
.menu-btn{
  display:none; /* desktop hidden */
  border:1px solid rgba(255,255,255,.25);
  background:rgba(255,255,255,.15);
  color:#fff;
  width:40px;
  height:38px;
  border-radius:12px;
  cursor:pointer;

  position:relative;
  z-index:2300; /* above overlay */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.menu-ico{ width:18px; height:12px; position:relative; }
.menu-ico span{
  position:absolute; left:0; right:0;
  height:2px; background:#fff;
}
.menu-ico span:nth-child(1){ top:0; }
.menu-ico span:nth-child(2){ top:5px; }
.menu-ico span:nth-child(3){ top:10px; }

/* Overlay (single definition, no duplicates) */
.drawer-overlay{
  display:none;
  position:fixed;
  inset:56px 0 0 0;
  background:rgba(0,0,0,.45);
  z-index:2100;
}
.drawer-overlay.show{ display:block; }

/* =========================
   RESPONSIVE (PHONE/TABLET)
   ========================= */
@media (max-width: 920px){
  .shell{ grid-template-columns: 1fr; }
  .grid2{ grid-template-columns: 1fr; }

  .menu-btn{ display:flex; align-items:center; justify-content:center; }

  /* Drawer: use TRANSFORM (best on iPhone) */
  .sidebar{
    position:fixed;
    top:56px;
    left:0;
    width:280px;
    height:calc(100dvh - 56px);
    background:#fff;
    overflow:auto;
    -webkit-overflow-scrolling:touch;

    transform: translateX(-110%);
    transition: transform .22s ease;
    will-change: transform;

    z-index:2200;
    box-shadow: 0 14px 40px rgba(15,23,42,.18);
    border-right:1px solid var(--line);
  }

  /* iOS fallback */
  @supports (-webkit-touch-callout: none) {
    .sidebar{
      height:calc(-webkit-fill-available - 56px);
    }
  }

  .sidebar.open{
    transform: translateX(0);
  }
}

/* Auth mobile */
@media (max-width: 520px){
  .auth-card{ padding:16px; }
  .row{ flex-direction:column; }
  .btn{ width:100%; }
}
