/* ==========================================================================
   BUNKIO ADMIN — System B  ·  Admin component layer
   --------------------------------------------------------------------------
   Extends assets/bunkio.css (tokens + core components) with the admin app's
   layouts: sidebar shell, topbar, data tables, KPI stats, detail drawer,
   CSS charts, severity pills, queue & audit rows. Same three materials,
   same button grammar — the slate logomark + ADMIN chip mark the context.
   ========================================================================== */

/* ---------- SHELL: sidebar + main ----------------------------------------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.shell > * { min-width: 0; }

.side {
  position: sticky; top: 0; height: 100vh; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--line);
  padding: var(--s-4) var(--s-3);
  overflow-y: auto;
}
.side .logo { padding: var(--s-2) var(--s-3) var(--s-4); }

.admin-chip {
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.08em; padding: 3px 8px;
  border-radius: var(--r-pill); background: var(--ink-800); color: #fff; margin-left: 4px;
}
[data-theme="dark"] .admin-chip { background: var(--brand-600); }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-label {
  padding: var(--s-4) var(--s-3) 4px; font-size: 10.5px; font-weight: 800;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3);
}
.side-nav a {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
}
.side-nav a:hover { background: var(--surface-sunken); color: var(--text); text-decoration: none; }
.side-nav a.here { color: var(--brand-600); background: var(--brand-50); }
[data-theme="dark"] .side-nav a.here { background: rgba(82,101,240,0.16); color: #b7c2ff; }
.side-count {
  margin-left: auto; font-size: var(--fs-xs); font-weight: 700; color: var(--text-3);
  padding: 1px 8px; border-radius: var(--r-pill); background: var(--surface-sunken);
}
.side-count.warn { color: #92400e; background: var(--warn-50); border: 1px solid #fde68a; }
[data-theme="dark"] .side-count.warn { background: rgba(245,158,11,0.13); color: #fcd34d; border-color: rgba(245,158,11,0.3); }

.side-foot { border-top: 1px solid var(--line); padding: var(--s-4) var(--s-3) var(--s-2); display: flex; flex-direction: column; gap: var(--s-3); }
.side-me { display: flex; gap: 10px; align-items: center; }
.side-me .who { line-height: 1.25; }
.side-me .who b { display: block; font-size: var(--fs-sm); }
.side-me .who span { font-size: var(--fs-xs); color: var(--text-3); }

.env-chip {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: var(--r-pill);
  color: #065f46; background: var(--ok-50); border: 1px solid #a7f3d0;
}
.env-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok-500); }
[data-theme="dark"] .env-chip { background: rgba(16,185,129,0.13); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }

/* Slate identity for admin chrome */
.logo-mark.slate { background: linear-gradient(135deg, var(--ink-700), var(--ink-900)); }
.avatar.slate { background: linear-gradient(135deg, var(--ink-600), var(--ink-900)); }

/* ---------- TOPBAR --------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--s-4);
  height: 64px; padding: 0 var(--s-8);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); white-space: nowrap; }
.crumb b { color: var(--text); font-weight: 700; }
.crumb .sep { color: var(--text-3); font-weight: 400; }
.topbar .gsearch { flex: 1; max-width: 420px; margin-left: auto; }
.topbar .gsearch .input { padding: 9px 14px; }
.bell { position: relative; }
.bell .ping {
  position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger-500); border: 2px solid var(--surface); box-shadow: 0 0 0 2px rgba(229,72,77,0.25);
}

.content { padding: var(--s-8); max-width: 1240px; }

/* ---------- KPI STATS ------------------------------------------------------ */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .l { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.stat .n { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -0.02em; }
.trend-up { color: var(--ok-600); font-size: var(--fs-xs); font-weight: 700; }
.trend-down { color: var(--danger-500); font-size: var(--fs-xs); font-weight: 700; }

/* ---------- DATA TABLE ------------------------------------------------------
   Generalized from the campaign table: hairline rows, uppercase micro headers,
   sunken hover, brand-tinted selection. Wrap in .card with overflow:auto. */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th {
  text-align: left; font-size: var(--fs-xs); font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl tbody tr.rowlink:hover td { background: var(--surface-sunken); }
.tbl tr.sel td { background: var(--brand-50); }
[data-theme="dark"] .tbl tr.sel td { background: rgba(82,101,240,0.12); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Identity cell: avatar + name + sub-line */
.id-cell { display: flex; gap: 10px; align-items: center; min-width: 0; }
.id-cell .g-avatar { width: 34px; height: 34px; font-size: var(--fs-xs); }
.id-cell .who { min-width: 0; line-height: 1.3; }
.id-cell .who b { display: block; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id-cell .who span { font-size: var(--fs-xs); color: var(--text-3); }

.g-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: var(--fs-sm);
  border: 2px solid var(--surface); box-shadow: var(--e1);
}

/* Colored type pill (campaign/listing types) */
.type-pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 700;
  padding: 4px 10px; border-radius: var(--r-pill); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}

/* ---------- QUEUE ROWS (needs-attention pattern) --------------------------- */
.q-row { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.q-row:last-child { border-bottom: 0; }
.q-ico {
  width: 42px; height: 42px; border-radius: var(--r-md); flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--matte-raised); border: 1px solid var(--line);
  box-shadow: var(--e1), var(--highlight);
}

/* ---------- SEVERITY PILLS (trust & safety) -------------------------------- */
.sev { display: inline-flex; align-items: center; gap: 6px; font: 700 var(--fs-xs)/1 var(--font); padding: 5px 11px; border-radius: var(--r-pill); border: 1px solid transparent; }
.sev .dot { width: 7px; height: 7px; border-radius: 50%; }
.sev.low  { color: #075985; background: var(--info-50); border-color: #bae6fd; } .sev.low .dot { background: var(--info-500); }
.sev.med  { color: #92400e; background: var(--warn-50); border-color: #fde68a; } .sev.med .dot { background: var(--warn-500); }
.sev.high { color: #7f1d1d; background: var(--danger-50); border-color: #fecaca; } .sev.high .dot { background: var(--danger-500); }
.sev.crit { color: #fff; background: linear-gradient(135deg, var(--danger-400), var(--danger-600)); box-shadow: 0 2px 8px rgba(229,72,77,0.35), inset 0 1px 0 rgba(255,255,255,0.25); } .sev.crit .dot { background: #fff; }
[data-theme="dark"] .sev.low  { background: rgba(14,165,233,0.12); color: #7dd3fc; border-color: rgba(14,165,233,0.3); }
[data-theme="dark"] .sev.med  { background: rgba(245,158,11,0.12); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
[data-theme="dark"] .sev.high { background: rgba(229,72,77,0.12); color: #fca5a5; border-color: rgba(229,72,77,0.3); }

/* ---------- DETAIL DRAWER ---------------------------------------------------
   Right-hand inspector for a selected row. Glass-strong so it floats over the
   table but stays readable; e4 because it's the topmost transient surface. */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw; z-index: 90;
  display: flex; flex-direction: column;
  background: var(--glass-strong-bg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-left: 1px solid var(--glass-border); box-shadow: var(--e4);
  transform: translateX(103%); transition: transform 0.28s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-6) var(--s-3); }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 var(--s-6) var(--s-6); }
.drawer-foot { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); }

/* Key-value rows inside drawers/cards */
.kv { display: flex; justify-content: space-between; gap: var(--s-4); padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-3); font-weight: 600; }
.kv .v { font-weight: 600; text-align: right; }

/* ---------- CSS CHARTS ------------------------------------------------------ */
/* Column chart — stacked pairs read bottom-up: base (brand) + alt (sunrise) */
.cols { display: flex; align-items: stretch; gap: 10px; height: 170px; }
.cols .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; min-width: 0; }
.cols .c i {
  border-radius: 5px; min-height: 3px;
  background: linear-gradient(180deg, var(--brand-400), var(--brand-600));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
.cols .c i.alt { background: linear-gradient(180deg, var(--sunrise-300), var(--sunrise-500)); }
.cols .c i.dim { background: linear-gradient(180deg, var(--ink-300), var(--ink-400)); }
.cols .c .cl { text-align: center; font-size: 10px; font-weight: 700; color: var(--text-3); margin-top: 5px; }
.cols .c.now i { outline: 2px solid var(--brand-300); outline-offset: 1px; }

/* Horizontal bar rows (top markets, funnels) */
.hbar { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xs); }
.hbar .hl { width: 110px; flex: none; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .bar { flex: 1; height: 12px; border-radius: var(--r-pill); background: var(--surface-sunken); box-shadow: var(--e-inset); position: relative; overflow: hidden; }
.hbar .bar i { position: absolute; inset: 0; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--brand-400), var(--brand-600)); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3); }
.hbar .bar i.warm { background: linear-gradient(90deg, var(--sunrise-300), var(--sunrise-500)); }
.hbar .hv { width: 64px; flex: none; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Donut (GMV split) */
.donut { position: relative; width: 150px; height: 150px; border-radius: 50%; box-shadow: var(--e2); flex: none; }
.donut::after { content: ''; position: absolute; inset: 22%; border-radius: 50%; background: var(--surface); box-shadow: var(--e-inset); }
.donut .mid { position: absolute; inset: 22%; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.donut .mid b { font-size: var(--fs-lg); }
.donut .mid span { font-size: 10px; color: var(--text-3); font-weight: 700; text-transform: uppercase; }

/* Sparkline (from host dashboard) */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 26px; }
.spark i { width: 5px; border-radius: 2px 2px 0 0; background: linear-gradient(180deg, var(--brand-400), var(--brand-600)); opacity: 0.9; }

/* Slim meter (occupancy-style) */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--surface-sunken); box-shadow: var(--e-inset); overflow: hidden; position: relative; }
.meter i { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--state-booked); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3); }
.meter i.ok { background: var(--state-approved); }
.meter i.warn { background: var(--state-pending); }

/* ---------- AUDIT LOG ------------------------------------------------------- */
.audit { display: flex; gap: var(--s-3); padding: 10px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); align-items: baseline; }
.audit:last-child { border-bottom: 0; }
.audit .at { flex: none; width: 92px; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.audit .actor { font-weight: 700; }
.audit code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 11.5px; color: var(--text-2); background: var(--surface-sunken); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }

/* ---------- MISC ------------------------------------------------------------ */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--text-3); }

.health { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.health:last-child { border-bottom: 0; }
.health .hdot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(16,185,129,0.15); background: var(--ok-500); }
.health .hdot.warn { background: var(--warn-500); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
.health .lat { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Legend swatch (charts) */
.lg-sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; box-shadow: inset 0 1px 0 rgba(255,255,255,0.3); }

/* ---------- ICON PICKER ------------------------------------------------------
   The Icon/Emoji/SVG picker: trigger reads as a pressed well showing the current
   glyph; the panel is glass-strong (like all floating option surfaces) with
   tabbed sources — Emoji, the Lucide-style line-icon registry, and Custom SVG.
   Stores ONE string: an emoji glyph, an icon registry name, or svg:<markup>. */
.ip-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: var(--r-md); cursor: pointer; text-align: left;
  background: var(--surface-sunken); border: 1px solid var(--line); box-shadow: var(--e-inset);
  font: 550 var(--fs-sm)/1.3 var(--font); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ip-trigger:hover { border-color: var(--brand-300); }
.ip-trigger .cur {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--matte-raised); border: 1px solid var(--line);
  box-shadow: var(--e1), var(--highlight);
}
.ip-trigger .cur svg { width: 18px; height: 18px; }
.ip-trigger .meta { flex: 1; min-width: 0; }
.ip-trigger .meta span { display: block; font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; }
.ip-trigger::after { content: '▾'; color: var(--text-3); font-size: 11px; }

.ip {
  width: 100%; max-width: 400px; padding: var(--s-3); border-radius: var(--r-lg);
  background: var(--glass-strong-bg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); box-shadow: var(--e4), var(--highlight);
}
.ip .tabs { display: flex; width: 100%; margin-bottom: var(--s-3); }
.ip .tabs button { flex: 1; }
.ip-search { margin-bottom: var(--s-3); }
.ip-search .input { padding: 8px 12px; }
.ip-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 210px; overflow-y: auto; padding: 3px; }
.ip-cat {
  grid-column: 1 / -1; padding: 8px 4px 3px; font-size: 10px; font-weight: 800;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3);
}
.ip-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); font-size: 18px; cursor: pointer; border: 0; background: transparent;
  color: var(--text-2); transition: background 0.12s, transform 0.12s;
}
.ip-cell:hover { background: var(--surface-sunken); transform: scale(1.12); }
.ip-cell.sel { background: var(--brand-50); box-shadow: inset 0 0 0 2px var(--brand-400); color: var(--brand-600); }
[data-theme="dark"] .ip-cell.sel { background: rgba(82,101,240,0.16); }
.ip-cell svg { width: 19px; height: 19px; }
.ip-foot {
  display: flex; align-items: center; gap: var(--s-2);
  border-top: 1px solid var(--line); margin-top: var(--s-3); padding-top: var(--s-3);
  font-size: var(--fs-xs); color: var(--text-3);
}
.ip-foot .cur {
  width: 30px; height: 30px; border-radius: var(--r-sm); flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: var(--matte-raised); border: 1px solid var(--line); box-shadow: var(--e1), var(--highlight);
}
.ip-foot .cur svg { width: 16px; height: 16px; }
.ip-svg-drop {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-sunken);
  padding: var(--s-4); text-align: center; color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
}

/* ---------- MAPPING MATRIX ---------------------------------------------------
   Grid of allowed combinations (asset↔listing mappings, hierarchy rules). */
.mx { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.mx th {
  font-size: 10px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center;
}
.mx th:first-child, .mx td:first-child { text-align: left; white-space: nowrap; }
.mx td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.mx tr:last-child td { border-bottom: 0; }
.mx tbody tr:hover td { background: var(--surface-sunken); }
.mxk {
  display: inline-flex; width: 22px; height: 22px; border-radius: 7px; cursor: pointer;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: transparent;
  background: var(--surface-sunken); border: 1px solid var(--line); box-shadow: var(--e-inset);
  transition: all 0.15s;
}
.mxk:hover { border-color: var(--brand-300); }
.mxk.on {
  color: #fff; background: var(--state-booked); border-color: transparent;
  box-shadow: 0 2px 6px rgba(65,82,224,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* ---------- RESPONSIVE ------------------------------------------------------ */
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; height: auto; flex-direction: row; align-items: center;
    gap: var(--s-2); padding: 8px var(--s-4); overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .side .logo { padding: 0 var(--s-2) 0 0; flex: none; }
  .side-nav { flex-direction: row; flex: none; }
  .side-nav a { white-space: nowrap; flex: none; padding: 7px 11px; }
  .side-label, .side-foot { display: none; }
  .topbar { position: static; padding: 0 var(--s-4); height: 56px; }
  .crumb { display: none; }
  .topbar .gsearch { margin-left: 0; }
  .content { padding: var(--s-4); }
  .drawer { width: 100vw; max-width: 100vw; }
}

/* Link back to the design system — quiet, below the profile in the side footer */
.side-sys {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-md);
  font: 600 var(--fs-xs)/1.2 var(--font); color: var(--text-3);
  border: 1px dashed var(--line-strong);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.side-sys:hover { color: var(--brand-600); border-color: var(--brand-300); background: var(--brand-50); text-decoration: none; }
[data-theme="dark"] .side-sys:hover { background: rgba(82,101,240,0.12); color: #b7c2ff; }
