/* BlurredBox AGD — app shell layout */

/* hidden attribute must win over any display rule (inline or class) */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "rail topbar"
    "rail main";
  height: 100vh;
}

/* ---- Left rail ---- */
.rail {
  grid-area: rail;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-3);
  gap: var(--sp-1);
  overflow-y: auto;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-5);
}

.rail-brand img { width: 26px; height: 29px; }

.rail-brand .brand-name {
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.rail-brand .brand-sub {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

.rail-section {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
}

.rail a.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 7px var(--sp-3);
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--fs-base);
  position: relative;
}

.rail a.nav-item:hover { background: var(--surface-2); color: var(--text); }

.rail a.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-hi);
  font-weight: 550;
}

.rail a.nav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.nav-icon { width: 15px; height: 15px; flex: none; opacity: 0.9; }

.nav-badge {
  margin-left: auto;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.rail-foot {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ---- Top strip ---- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  min-width: 0;
}

.topbar .spacer { flex: 1; }

/* ---- Main ---- */
.main {
  grid-area: main;
  overflow-y: auto;
  min-width: 0;
}

.view {
  padding: var(--sp-6);
  max-width: 1600px;
}

.view-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}

.view-head h1 {
  font-size: var(--fs-xl);
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
}

.view-head .sub { color: var(--text-dim); font-size: var(--fs-base); }

.view-head .head-actions { margin-left: auto; display: flex; gap: var(--sp-3); align-items: center; }

/* Grids */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--sp-5);
  align-items: start;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--sp-4);
}

/* Degraded / reconnect strips */
.banner-slot { position: sticky; top: 0; z-index: 30; }

.banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border);
}

.banner.warn { background: var(--warn-dim); color: var(--warn); }
.banner.danger { background: var(--danger-dim); color: var(--danger); }

/* Login */
.login-wrap {
  height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(123, 76, 240, 0.12), transparent 60%),
    radial-gradient(900px 500px at 20% 110%, rgba(76, 125, 240, 0.10), transparent 60%),
    var(--bg);
}

.login-card {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-7);
  box-shadow: var(--shadow-pop);
}

/* Responsive */
@media (max-width: 1440px) {
  .two-col { grid-template-columns: 1fr 300px; }
}

@media (max-width: 1279px) {
  #app { grid-template-columns: 64px 1fr; }
  .rail .brand-name, .rail .brand-sub, .rail .nav-label, .rail-section, .rail-foot { display: none; }
  .rail a.nav-item { justify-content: center; padding: 8px 0; }
  .nav-badge { position: absolute; top: 1px; right: 6px; margin: 0; }
  .two-col { grid-template-columns: 1fr; }
  .view { padding: var(--sp-5); }
}
