/* U Mobile Intelligence Console - app shell, layout, typography. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0 0 var(--sp-sm); line-height: 1.22; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 20px; letter-spacing: -0.01em; }
h3 { font-size: 16px; }
p  { margin: 0 0 var(--sp-md); }
a  { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.dim  { color: var(--text-tertiary); }
.sec  { color: var(--text-secondary); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-sunk);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--sp-sm);
  padding: var(--sp-md); border-bottom: 1px solid var(--border);
}
.brand__mark {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; flex: 0 0 28px;
}
.brand__mark svg { width: 16px; height: 16px; }
.brand__text { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
.brand__sub { font-size: 10px; color: var(--text-tertiary); letter-spacing: .08em; text-transform: uppercase; }

.sidebar__nav { flex: 1; padding: var(--sp-sm) 0 var(--sp-lg); }
.nav-group__label {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-dim); padding: var(--sp-md) var(--sp-md) var(--sp-xs);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--sp-md); color: var(--text-secondary);
  font-size: 13px; border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-dim); color: var(--text); border-left-color: var(--accent); }
.nav-item svg { width: 15px; height: 15px; flex: 0 0 15px; }
/* Only the label flexes. Scoping this to `.nav-item span` would also catch the
   dot and the badge - and beat their own class rules on specificity, which
   stretches a 6px dot into an 80px ellipse. */
.nav-item__label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item--tour { color: var(--accent); }
.nav-item__badge {
  flex: 0 0 auto;
  font-size: 10px; letter-spacing: .06em; padding: 2px 6px;
  border-radius: var(--r-pill); border: 1px solid var(--accent-line); color: var(--accent);
}
.nav-item__dot {
  width: 6px; height: 6px; min-width: 6px; border-radius: 50%; flex: 0 0 6px;
}
.dot--observed  { background: var(--prov-observed); }
.dot--official  { background: var(--prov-official); }
.dot--simulated { background: var(--prov-simulated); }

.sidebar__foot { border-top: 1px solid var(--border); padding: var(--sp-md); }
.sidebar__partners { display: flex; align-items: center; gap: var(--sp-md); margin-bottom: var(--sp-md); opacity: .85; }
.sidebar__user { display: flex; align-items: center; gap: var(--sp-sm); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.sidebar__user-name { font-size: 12px; font-weight: 600; }
.sidebar__user-sub  { font-size: 11px; color: var(--text-tertiary); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  border-bottom: 1px solid var(--border); background: var(--bg);
  display: flex; align-items: center; gap: var(--sp-md);
  padding: 0 var(--sp-lg); position: sticky; top: 0; z-index: 20;
  min-width: 0; overflow: hidden;
}
/* The title yields before anything else. Without min-width:0 a flex child will
   not shrink below its content, which pushed the Ask button off the right edge
   on the one page carrying two provenance badges. */
.topbar__title {
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__spacer { flex: 1 1 auto; min-width: 0; }
.topbar > .btn { flex: 0 0 auto; }
.topbar .badge { flex: 0 0 auto; }
/* Below this width the badges are the first thing to go - the page they
   describe carries the same information in its banner. */
@media (max-width: 700px) {
  .topbar .badge { display: none; }
  .topbar { padding: 0 var(--sp-md); }
}
.menu-toggle { display: none; background: none; border: 0; color: var(--text); cursor: pointer; }
.content { padding: var(--sp-lg); max-width: var(--content-max); width: 100%; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: var(--sp-md); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid-2-1, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px)  { .grid-2, .grid-4 { grid-template-columns: 1fr; } }

.flex { display: flex; }
.gap-sm { gap: var(--sp-sm); } .gap-md { gap: var(--sp-md); }
.mt-lg { margin-top: var(--sp-lg); } .mb-lg { margin-bottom: var(--sp-lg); }
.mb-md { margin-bottom: var(--sp-md); } .mt-md { margin-top: var(--sp-md); }
.col-right { text-align: right; }

/* ---------- Responsive sidebar ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: block; }
  .content { padding: var(--sp-md); }
}
