/* Benmore platform UI component layer.

   Single source of truth for shared UI primitives across the platform.
   Visual language is Cloudflare-quiet: near-white surfaces, subtle
   borders, generous whitespace, brand color used only on primary
   CTAs and accent links. Every value resolves through a token in
   theme.css — no hex codes in this file.

   Rules:
   - One canonical size per role; variants behind modifier classes
     (.btn.primary, .btn.sm — not .blue-btn-large).
   - Light/dark parity is structural: both modes read the same tokens.
   - Page-level CSS is for LAYOUT (grid templates), never for redefining
     buttons/cards/badges/inputs. If you find a pattern recurring, add
     it here.
*/

/* ============================================================
   Buttons
   ============================================================ */
.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--h-btn);
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--fg);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
  box-sizing: border-box;
}
.btn:hover { border-color: var(--border-hover); background: var(--bg-subtle); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.55; cursor: not-allowed; pointer-events: none;
}

.btn.primary, .btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn.primary:hover, .btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-fg);
}

.btn.ghost, .btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-muted);
}
.btn.ghost:hover, .btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--fg);
  border-color: transparent;
}

.btn.danger, .btn-danger {
  background: var(--bg-elevated);
  color: var(--danger);
  border-color: var(--border-strong);
}
.btn.danger:hover, .btn-danger:hover {
  background: var(--danger);
  color: var(--danger-fg);
  border-color: var(--danger);
}

.btn.success {
  background: var(--bg-elevated);
  color: var(--success);
  border-color: var(--border-strong);
}
.btn.success:hover { background: var(--success); color: var(--success-fg); border-color: var(--success); }

.btn.sm { height: var(--h-btn-sm); padding: 0 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); gap: 4px; }
.btn.lg { height: var(--h-btn-lg); padding: 0 18px; font-size: var(--text-md); border-radius: var(--radius-md); }

/* Icon-only square button (the row of card-header actions: star, +, …, →) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--fg); border-color: var(--border-hover); }
.icon-btn.ghost { border-color: transparent; background: transparent; }
.icon-btn.ghost:hover { background: var(--bg-subtle); border-color: transparent; }
.icon-btn svg { width: 14px; height: 14px; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Cards — the universal container.

   <section class="card">
     <header class="card-head">
       <div class="card-head-l">
         <svg class="card-icon">...</svg>
         <h3 class="card-title">Domains</h3>
         <span class="count-chip">1</span>
       </div>
       <div class="card-head-r">
         <button class="icon-btn ghost">...</button>
         <button class="icon-btn ghost">...</button>
       </div>
     </header>
     <div class="card-body">...</div>
   </section>
   ============================================================ */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card.flat { background: var(--bg-subtle); }
.card.danger-zone { border-color: var(--danger-soft-border); }
.card.danger-zone .card-head { border-bottom-color: var(--danger-soft-border); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  min-height: 48px;
}
.card-head-l { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.card-head-r { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.card-icon { width: 16px; height: 16px; color: var(--fg-subtle); flex-shrink: 0; }
.card-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub { margin: 2px 0 0; font-size: var(--text-sm); color: var(--fg-muted); }
.count-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
}
.card-body { padding: 18px; flex: 1; }
.card-body.flush { padding: 0; }
.card-body.tight { padding: 12px 18px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

/* Clickable summary tile (dashboard app cards, overview metric cards). */
.card.tile {
  cursor: pointer;
  display: block;
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.card.tile:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }

/* Legacy class aliases — many existing pages still write `.s-card`,
   `.s-head`, `.s-body`. Map them to the canonical card. */
.s-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 14px; display: flex; flex-direction: column; }
.s-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); min-height: 48px; }
.s-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--fg);
}
.s-body { padding: 18px; }

/* Card grid — pages that show 2/3/4 cards across. */
.cards-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.cards-grid.two   { grid-template-columns: repeat(2, 1fr); }
.cards-grid.three { grid-template-columns: repeat(3, 1fr); }
.cards-grid.four  { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  .cards-grid.three, .cards-grid.four { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .cards-grid.two, .cards-grid.three, .cards-grid.four { grid-template-columns: 1fr; }
}

/* ============================================================
   Page header — breadcrumb + title + actions.

   <div class="page-header">
     <div class="page-header-text">
       <nav class="breadcrumb">Account home</nav>
       <h1 class="page-title">Richard's Account</h1>
       <p class="page-sub">Optional subtitle.</p>
     </div>
     <div class="page-actions">
       <button class="icon-btn">...</button>
       <button class="btn primary">+ Add</button>
     </div>
   </div>
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header-text { min-width: 0; flex: 1; }
.page-title {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  line-height: 1.15;
}
.page-sub { margin: 8px 0 0; font-size: var(--text-md); color: var(--fg-muted); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--fg); }
.breadcrumb .sep { color: var(--fg-subtle); }

/* Gradient-fill title (legacy `.gt` usage on dashboard pages). */
.gt {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--fg);
  background: none;
  -webkit-text-fill-color: currentColor;
}

/* Section heading inside a page body — between page-header and a
   collection of cards. */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 24px 0 12px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--fg);
}
.section-head .actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Badges / pills / tags
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--neutral-soft-bg);
  color: var(--neutral-soft-fg);
  border: 1px solid var(--neutral-soft-border);
  white-space: nowrap;
}
.badge.success, .b-green  { background: var(--success-soft-bg); color: var(--success-soft-fg); border-color: var(--success-soft-border); }
.badge.warning, .b-amber  { background: var(--warning-soft-bg); color: var(--warning-soft-fg); border-color: var(--warning-soft-border); }
.badge.danger,  .b-red    { background: var(--danger-soft-bg);  color: var(--danger-soft-fg);  border-color: var(--danger-soft-border); }
.badge.info,    .b-blue   { background: var(--info-soft-bg);    color: var(--info-soft-fg);    border-color: var(--info-soft-border); }
.badge.primary, .b-purple { background: var(--primary-soft-bg); color: var(--primary-soft-fg); border-color: var(--primary-soft-border); }
.badge.neutral, .b-gray   { background: var(--neutral-soft-bg); color: var(--neutral-soft-fg); border-color: var(--neutral-soft-border); }
.badge .dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; flex-shrink: 0; }

/* Bigger uppercase pill — used for plan labels, status callouts. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--neutral-soft-bg);
  color: var(--neutral-soft-fg);
  border: 1px solid var(--neutral-soft-border);
}
.pill.primary { background: var(--primary-soft-bg); color: var(--primary-soft-fg); border-color: var(--primary-soft-border); }
.pill.success { background: var(--success-soft-bg); color: var(--success-soft-fg); border-color: var(--success-soft-border); }
.pill.warning { background: var(--warning-soft-bg); color: var(--warning-soft-fg); border-color: var(--warning-soft-border); }
.pill.danger  { background: var(--danger-soft-bg);  color: var(--danger-soft-fg);  border-color: var(--danger-soft-border); }
.pill .dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; }

/* ============================================================
   Tables
   ============================================================ */
.tbl, table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.tbl th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 500;
  font-size: var(--text-xs);
  color: var(--fg-subtle);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font-size: var(--text-sm);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--bg-subtle); }
.tbl.mono td { font-family: var(--font-mono); font-size: var(--text-xs); }

/* ============================================================
   Inputs
   ============================================================ */
.ipt, input.ipt, textarea.ipt, .input {
  height: var(--h-input);
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--fg);
  font-family: inherit;
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  box-sizing: border-box;
}
.ipt:hover, .input:hover { border-color: var(--border-hover); }
.ipt:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-bg); }
.ipt::placeholder, .input::placeholder { color: var(--fg-subtle); }
textarea.ipt { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; min-height: 80px; }

.sel, select.sel {
  height: var(--h-input);
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7a85' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 8px center;
  color: var(--fg);
  font-family: inherit;
  font-size: var(--text-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.sel:hover { border-color: var(--border-hover); }
.sel:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-bg); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: var(--text-xs); font-weight: 500; color: var(--fg-muted); }
.field .hint { font-size: var(--text-xs); color: var(--fg-subtle); }
.field .err  { font-size: var(--text-xs); color: var(--danger-soft-fg); }
.field.invalid .ipt, .field.invalid .input, .field.invalid .sel { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft-bg); }

.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row .ipt, .form-row .input, .form-row .sel, .form-row .field { flex: 1; min-width: 160px; }

/* Search input (sidebar, command palette). */
.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  cursor: text;
  width: 100%;
  box-sizing: border-box;
}
.search-input:hover { border-color: var(--border-hover); }
.search-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-bg); }
.search-input svg { width: 14px; height: 14px; color: var(--fg-subtle); flex-shrink: 0; }
.search-input input {
  flex: 1; min-width: 0; border: none; background: transparent; outline: none;
  font-family: inherit; font-size: var(--text-sm); color: var(--fg); padding: 0;
}
.search-input input::placeholder { color: var(--fg-subtle); }
.search-input .kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-subtle);
  padding: 1px 6px; border-radius: 3px; background: var(--bg-subtle);
  border: 1px solid var(--border); flex-shrink: 0;
}

/* ============================================================
   Stat tile (overview, analytics, performance). Cloudflare uses a
   subtle sparkline behind/below the number — the .stat-bg slot is
   optional.

   <article class="stat">
     <div class="stat-head">
       <svg class="stat-icon">...</svg>
       <span class="stat-label">Cache rate</span>
     </div>
     <div class="stat-value">18.4%</div>
     <div class="stat-delta up">↗ 1481.5%</div>
     <div class="stat-bg"><svg class="sparkline">...</svg></div>
   </article>
   ============================================================ */
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 12px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 96px;
}
.stat.clickable { cursor: pointer; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.stat.clickable:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
.stat-head { display: flex; align-items: center; gap: 6px; color: var(--fg-subtle); }
.stat-icon { width: 14px; height: 14px; color: var(--fg-subtle); flex-shrink: 0; }
.stat-label { font-size: var(--text-xs); font-weight: 500; color: var(--fg-subtle); }
.stat-value {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  line-height: 1.1;
}
.stat-delta { font-size: var(--text-xs); margin-top: 2px; display: inline-flex; align-items: center; gap: 2px; }
.stat-delta.up    { color: var(--success-soft-fg); }
.stat-delta.down  { color: var(--danger-soft-fg); }
.stat-delta.flat  { color: var(--fg-subtle); }
.stat-bg {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 36px;
  pointer-events: none;
  opacity: 0.7;
}
.stat-bg svg { width: 100%; height: 100%; display: block; }
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Stat that sits inside a card-body (with a divider between label-row
   on the left and value on the right — see Cloudflare Security card). */
.stat-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 1fr;
  gap: 12px;
  align-items: stretch;
}
.stat-row + .stat-row { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.stat-row .stat-l { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.stat-row .stat-r { display: flex; flex-direction: column; justify-content: center; min-width: 0; }

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  margin: 8px 0;
}
.empty-icon { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--fg-subtle); }
.empty-t { font-size: var(--text-md); font-weight: 600; color: var(--fg); margin: 0 0 4px; }
.empty-s { font-size: var(--text-sm); color: var(--fg-muted); margin: 0 0 12px; }
.empty-actions { display: inline-flex; gap: 8px; justify-content: center; }

/* ============================================================
   Modal / dialog
   ============================================================ */
.modal-bg {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: var(--text-xl); font-weight: 600; color: var(--fg); margin: 0 0 6px; }
.modal-body  { font-size: var(--text-md); color: var(--fg-muted); line-height: 1.6; margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============================================================
   Alert banner (.banner) — Cloudflare-style top-of-page alert with
   left icon, bold first-line + muted second-line, far-right CTA link.

   <div class="banner danger">
     <span class="banner-icon">!</span>
     <div class="banner-text">
       <strong>Your account has an overdue balance.</strong>
       <span>Visit billing for more information.</span>
     </div>
     <a href="/billing" class="banner-cta">Go to billing</a>
   </div>

   Legacy .flash class is also kept for backwards compat.
   ============================================================ */
.banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid;
  margin-bottom: 20px;
}
.banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  color: var(--bg-elevated);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.banner-text { flex: 1; min-width: 0; font-size: var(--text-sm); }
.banner-text strong { display: block; color: var(--fg); font-weight: 600; }
.banner-text span { display: block; margin-top: 4px; color: var(--fg-muted); }
.banner-cta {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  flex-shrink: 0;
  padding-top: 1px;
}
.banner-cta:hover { text-decoration: underline; }
.banner.danger  { background: var(--danger-soft-bg);  border-color: var(--danger-soft-border); }
.banner.danger  .banner-icon { background: var(--danger); }
.banner.warning { background: var(--warning-soft-bg); border-color: var(--warning-soft-border); }
.banner.warning .banner-icon { background: var(--warning); }
.banner.success { background: var(--success-soft-bg); border-color: var(--success-soft-border); }
.banner.success .banner-icon { background: var(--success); }
.banner.info    { background: var(--info-soft-bg);    border-color: var(--info-soft-border); }
.banner.info    .banner-icon { background: var(--info); }

/* Legacy alias */
.flash {
  padding: 12px 16px; border-radius: var(--radius-lg); font-size: var(--text-sm);
  margin-bottom: 16px; border: 1px solid transparent;
}
.flash.ok   { background: var(--success-soft-bg); color: var(--success-soft-fg); border-color: var(--success-soft-border); }
.flash.warn { background: var(--warning-soft-bg); color: var(--warning-soft-fg); border-color: var(--warning-soft-border); }
.flash.err  { background: var(--danger-soft-bg);  color: var(--danger-soft-fg);  border-color: var(--danger-soft-border); }
.flash.info { background: var(--info-soft-bg);    color: var(--info-soft-fg);    border-color: var(--info-soft-border); }

/* ============================================================
   Top bar — slim header above the page body. Account/breadcrumb on
   the left, Ask AI / Support / avatar on the right.
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.topbar-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-r { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.topbar-account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--fg);
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
}
.topbar-link:hover { background: var(--bg-subtle); color: var(--fg); }
.topbar-link svg { width: 14px; height: 14px; }
.topbar-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  cursor: pointer;
}
.topbar-avatar:hover { background: var(--bg-inset); color: var(--fg); }
.topbar-avatar svg { width: 16px; height: 16px; }

/* ============================================================
   Sidebar — Cloudflare-style: white background, search at top,
   section labels (small uppercase), items with optional chevron.
   ============================================================ */
.sb {
  width: 232px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 50;
  overflow: hidden;
}
.sb-head { padding: 12px 12px 8px; }
.sb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.sb-brand img { width: 18px; height: 18px; border-radius: var(--radius-sm); flex-shrink: 0; }
.sb-brand-text {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-search { padding: 6px 12px 8px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 0 12px; }
.sb-nav::-webkit-scrollbar { width: 0; }
.sb-section {
  padding: 14px 18px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-subtle);
  letter-spacing: 0.04em;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 18px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.sb-item:hover { background: var(--bg-subtle); color: var(--fg); }
.sb-item.active { background: var(--bg-subtle); color: var(--fg); }
.sb-item svg.sb-ic { width: 14px; height: 14px; color: var(--fg-subtle); flex-shrink: 0; }
.sb-item.active svg.sb-ic { color: var(--fg-muted); }
.sb-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item-chevron { width: 12px; height: 12px; color: var(--fg-subtle); opacity: 0.7; flex-shrink: 0; }
.sb-item-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--radius-full);
  background: var(--primary-soft-bg); color: var(--primary-soft-fg);
  border: 1px solid var(--primary-soft-border);
}
.sb-foot {
  padding: 8px 0 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.sb-foot form { margin: 0; padding: 0; }

/* App selector chip (inside sidebar head). */
.app-sel {
  position: relative;
  padding: 0 12px 8px;
}
.app-sel-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--fg);
  font-family: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
}
.app-sel-btn:hover { border-color: var(--border-hover); }
.app-sel-btn svg { width: 12px; height: 12px; color: var(--fg-subtle); flex-shrink: 0; }
.app-sel-btn .app-sel-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sel-dd {
  position: absolute;
  left: 12px; right: 12px; top: 100%; margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  max-height: 320px; overflow-y: auto;
  z-index: 60;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.app-sel-dd a {
  display: block;
  padding: 8px 12px;
  font-size: var(--text-sm);
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.app-sel-dd a:hover { background: var(--bg-subtle); }
.app-sel-dd a:last-child { border-bottom: none; }

/* ============================================================
   Code / monospace surface
   ============================================================ */
.code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: var(--fg);
}
.code-block {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--fg);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ============================================================
   Tabs / segmented control
   ============================================================ */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.tab {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.tab:hover { color: var(--fg); }
.tab.active { background: var(--bg-elevated); color: var(--fg); box-shadow: var(--shadow-sm); }

/* Page-level tabs (the underline-style row above audit-log table in
   the Cloudflare screenshot: All / Dashboard / API). */
.page-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.page-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  font-family: inherit;
}
.page-tab:hover { color: var(--fg); }
.page-tab.active { color: var(--fg); border-bottom-color: var(--primary); }

/* ============================================================
   Utility — keep narrow, semantic, additive only.
   ============================================================ */
.muted   { color: var(--fg-muted); }
.subtle  { color: var(--fg-subtle); }
.mono    { font-family: var(--font-mono); }
.row     { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.col     { display: flex; flex-direction: column; gap: 8px; }
.spacer  { flex: 1; }
.hidden  { display: none !important; }

@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.pulse   { animation: pulse 2s infinite; }
