/* ═══════════════════════════════════════════════════════════════════════
   APP CHROME — sidebar + topbar shared across Broker OS screens
   Depends on foundations.css
   ═══════════════════════════════════════════════════════════════════════ */

body.app-body { font-size: var(--text-table); background: var(--surface-primary); }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sb-brand {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-6) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.sb-brand img { width: 28px; height: 28px; border-radius: var(--r-2); }
.sb-brand .txt { line-height: 1.1; }
.sb-brand .txt b { display: block; font-size: 14px; letter-spacing: -0.01em; font-weight: 700; }
.sb-brand .txt small { display: block; font-size: 9px; letter-spacing: var(--tracking-caps); color: var(--text-tertiary); text-transform: uppercase; margin-top: 2px; }

.sb-search { padding: var(--s-5); border-bottom: 1px solid var(--border-subtle); }
.sb-search-input {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--surface-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-3);
  font-size: var(--text-caption);
  color: var(--text-tertiary);
}
.sb-search-input .kbd { margin-left: auto; display: inline-flex; gap: 2px; }
.sb-search-input .kbd span {
  padding: 1px 5px;
  background: white;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

.sb-nav { padding: var(--s-5) var(--s-4) var(--s-9); flex: 1; }
.sb-group { margin-bottom: var(--s-7); }
.sb-group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-tertiary);
  padding: 0 var(--s-4);
  margin-bottom: var(--s-3);
  font-weight: 600;
}
.sb-item {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-3);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1px;
  cursor: pointer;
  transition: all var(--dur-fast);
  text-decoration: none;
}
.sb-item:hover { background: var(--surface-secondary); color: var(--text-primary); }
.sb-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.sb-item svg { width: 15px; height: 15px; opacity: 0.7; flex-shrink: 0; }
.sb-item.active svg { opacity: 1; }
.sb-item .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--surface-secondary);
  padding: 1px 6px;
  border-radius: var(--r-full);
}
.sb-item.active .count { background: var(--brand-100); color: var(--brand-700); }
.sb-item .dot { width: 6px; height: 6px; border-radius: 50%; margin-left: auto; }

.sb-user {
  padding: var(--s-5);
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--s-4);
}
.sb-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gradient-brand);
  color: white; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.sb-user-info { flex: 1; line-height: 1.2; }
.sb-user-info b { display: block; font-size: 12px; font-weight: 600; }
.sb-user-info small { display: block; font-size: 10px; color: var(--text-tertiary); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-5) var(--s-8);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
  display: flex; align-items: center; gap: var(--s-4);
}
.topbar h1 .badge-inline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  padding: 3px var(--s-4);
  background: var(--surface-secondary);
  border-radius: var(--r-full);
}
.topbar-right { display: flex; align-items: center; gap: var(--s-5); }
.topbar-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-3);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  position: relative;
  background: none; border: none; cursor: pointer;
}
.topbar-btn:hover { background: var(--surface-secondary); color: var(--text-primary); }
.topbar-btn .notif-dot {
  position: absolute; top: 3px; right: 3px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red-500);
  border: 1px solid white;
}

.content { padding: var(--s-8); }

/* Reusable panels */
.panel {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-4);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.panel-hd {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4);
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: var(--s-4);
}
.panel-title .count-pill {
  background: var(--surface-secondary);
  padding: 1px 7px;
  border-radius: var(--r-full);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}
.panel-actions { display: flex; gap: var(--s-3); align-items: center; font-size: 11px; color: var(--text-tertiary); }
.panel-actions a { color: var(--text-link); font-weight: 600; }

/* Reusable table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table th {
  text-align: left;
  padding: var(--s-4) var(--s-6);
  background: var(--surface-primary);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-tertiary);
  font-weight: 600;
}
.table th.n, .table td.n { text-align: right; font-variant-numeric: tabular-nums; }
.table td {
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--brand-25); }

/* Page head */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--s-8);
  gap: var(--s-8);
}
.page-head h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-head h2 small {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  display: block;
  margin-top: 4px;
  letter-spacing: 0;
}
.page-head-actions { display: flex; gap: var(--s-4); align-items: center; }

/* Chart tiny sparkline */
.spark { display: inline-block; vertical-align: middle; }

/* Empty state utility (already in components) */

/* Sidebar item svg helper for pages that build their own icons */
.icn { width: 15px; height: 15px; }
