/* ═══════════════════════════════════════════════════════════
   Layout — app shell, rail, topbar, grids, responsive
   RTL: rail sits on the right; collapses to bottom bar on phones.
═══════════════════════════════════════════════════════════ */

.app-shell {
  display: grid;
  grid-template-columns: 1fr var(--rail);
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 100% -10%, color-mix(in oklch, var(--accent) 7%, transparent), transparent 60%),
    var(--bg);
}

/* ── Rail (sidebar) ──────────────────────────────────── */
.rail {
  grid-column: 2;
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 1rem .8rem;
  gap: .4rem;
}
.rail-brand { display: flex; align-items: center; gap: .65rem; padding: .4rem .5rem 1rem; }
.rail-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), var(--accent-3));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.1rem;
  box-shadow: var(--shadow-1); flex-shrink: 0;
}
.rail-brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.rail-brand-txt b { font-size: .92rem; }
.rail-brand-txt span { font-size: .68rem; color: var(--text-3); font-family: var(--font-mono); }

.rail-nav { display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; }
.rail-sec { font-size: .68rem; color: var(--text-4); font-weight: 700; letter-spacing: .08em; padding: .9rem .6rem .35rem; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .6rem; border-radius: var(--r1);
  color: var(--text-2); font-weight: 600; font-size: .88rem; cursor: pointer;
  border: 1px solid transparent;
  transition: background .14s var(--ease), color .14s var(--ease);
  position: relative;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.nav-item.on .nav-ico { color: var(--accent); }
.nav-ico { width: 20px; height: 20px; display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; }
.nav-item .nav-count {
  margin-inline-start: auto; font-size: .7rem; font-family: var(--font-mono);
  background: var(--surface-3); color: var(--text-2); padding: .05rem .45rem; border-radius: var(--r-full); min-width: 22px; text-align: center;
}
.nav-item.warn .nav-count { background: var(--danger-soft); color: var(--danger); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: .55rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.sync-line { display: flex; align-items: center; gap: .5rem; font-size: .72rem; color: var(--text-3); padding: 0 .4rem; }

/* ── Main column ─────────────────────────────────────── */
.main { grid-column: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 1.4rem;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.2rem; }
.topbar-sub { font-size: .74rem; color: var(--text-3); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.menu-btn { display: none; }

.content { padding: 1.4rem; max-width: 1500px; width: 100%; margin: 0 auto; flex: 1; }
.view-stack { display: flex; flex-direction: column; gap: 1.2rem; min-height: 0; }
.content { display: flex; flex-direction: column; }
.content > .view-stack { flex: 1; }

/* ── Stat grid ───────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .35rem; box-shadow: var(--shadow-1);
  position: relative; overflow: hidden;
}
.stat-label { font-size: .76rem; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.stat-val { font-size: 1.9rem; font-weight: 800; font-family: var(--font-mono); letter-spacing: -.02em; line-height: 1; }
.stat-meta { font-size: .72rem; color: var(--text-3); }
.stat-accent { color: var(--accent); }

/* ── Section grid helpers ───────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; }
.grid-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem; }
.split-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.2rem; align-items: start; }

/* ── Gun card ────────────────────────────────────────── */
.gun-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2);
  padding: .9rem 1rem; display: flex; flex-direction: column; gap: .7rem; box-shadow: var(--shadow-1);
  transition: border-color .15s var(--ease), transform .1s var(--ease);
}
.gun-card:hover { border-color: var(--border-2); }
.gun-card-top { display: flex; align-items: center; justify-content: space-between; }
.gun-id { font-family: var(--font-mono); font-weight: 800; font-size: 1.3rem; }
.gun-tier { display: flex; gap: .4rem; flex-wrap: wrap; }
.gun-amlist { display: flex; flex-direction: column; gap: .3rem; }
.gun-amrow { display: flex; align-items: center; justify-content: space-between; font-size: .8rem; }
.gun-amrow .lbl { color: var(--text-2); }
.gun-wear { display: flex; gap: .4rem; flex-wrap: wrap; padding-top: .5rem; border-top: 1px solid var(--border-soft); }
.wear-pill { display:flex; flex-direction:column; gap:.1rem; align-items:center; flex:1; min-width: 56px; }
.wear-pill .n { font-family: var(--font-mono); font-weight: 700; font-size: .95rem; }
.wear-pill .t { font-size: .62rem; color: var(--text-3); }

/* progress bar */
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; }

/* ── Activity feed ───────────────────────────────────── */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: .7rem; padding: .65rem .2rem; border-bottom: 1px solid var(--border-soft); }
.feed-item:last-child { border-bottom: none; }
.feed-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; font-size: .85rem; }
.feed-txt { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.feed-txt .t { font-size: .82rem; }
.feed-txt .s { font-size: .7rem; color: var(--text-3); font-family: var(--font-mono); }

/* empty state */
.empty { text-align: center; color: var(--text-3); padding: 2.5rem 1rem; font-size: .9rem; }
.empty .big { font-size: 2rem; margin-bottom: .5rem; opacity: .5; }

/* scrim for mobile drawer */
.scrim { display: none; }

/* ── Boot + login ────────────────────────────────────── */
.boot {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  color: var(--text-3); font-size: .9rem; background: var(--bg);
}
.boot-logo {
  width: 60px; height: 60px; border-radius: 17px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-3)); box-shadow: var(--shadow-2);
  animation: bootPulse 1.4s var(--ease) infinite;
}
@keyframes bootPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.92); opacity: .7; } }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 80% -10%, color-mix(in oklch, var(--accent) 16%, transparent), transparent 60%),
    radial-gradient(700px 400px at 10% 110%, color-mix(in oklch, var(--accent) 10%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r3);
  box-shadow: var(--shadow-pop); padding: 2.2rem 1.8rem;
  display: flex; flex-direction: column; align-items: center; gap: .9rem; text-align: center;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-3)); box-shadow: var(--shadow-2); margin-bottom: .3rem;
}
.login-title { font-size: 1.3rem; }
.login-sub { font-size: .76rem; color: var(--text-3); font-family: var(--font-mono); margin: 0; letter-spacing: .03em; }
.login-foot { font-size: .7rem; color: var(--text-4); margin: .3rem 0 0; display: flex; align-items: center; gap: .35rem; }
.login-card input, .login-card .btn { width: 100%; }

/* ═══════════ Responsive ═══════════ */
@media (max-width: 1100px) {
  .split-2 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  :root { --rail: 280px; }
  .app-shell { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }

  /* rail becomes a right-side drawer */
  .rail {
    position: fixed; inset: 0 0 0 auto; z-index: 90;
    width: var(--rail); max-width: 86vw;
    transform: translateX(100%);
    transition: transform .25s var(--ease);
    box-shadow: var(--shadow-pop);
  }
  .rail.open { transform: translateX(0); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 85; backdrop-filter: blur(2px); }

  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
  .topbar h1 { font-size: 1.05rem; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat { padding: .8rem .85rem; }
  .stat-val { font-size: 1.5rem; }
  .grid-teams { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .topbar-actions .btn span.lbl { display: none; }
  .topbar-actions .btn { padding: .5rem .6rem; }
  .modal-body { padding: .9rem; }
  .content { padding: .8rem; }
  .view-stack { gap: .9rem; }
}

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