/* Sendwire Analytics — a dark, information-dense admin surface.
 * No framework, no external fonts: fast, self-contained, CSP-friendly. */

:root {
  --bg: #0d0e12;
  --panel: #16181f;
  --panel-2: #1c1f28;
  --border: #262932;
  --text: #e7e9ee;
  --dim: #9aa1ad;
  --faint: #6b7280;
  --accent: #6d8bff;
  --accent-soft: #6d8bff22;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--dim); font-weight: 500; }
:root { --sidebar-w: 250px; }

/* ------------------------------------------------------------------ shell */
html, body { height: 100%; overflow: hidden; }
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* sidebar */
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; border-bottom: 1px solid var(--border); }
.sb-brand .logo { width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto; background: linear-gradient(135deg, var(--accent), #9b6dff); display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 14px; box-shadow: 0 0 0 1px #ffffff14 inset; }
.sb-brand .name { font-weight: 600; letter-spacing: .2px; }
.sb-brand .name small { display: block; color: var(--faint); font-size: 11px; font-weight: 500; letter-spacing: .3px; }
.sb-nav { flex: 1 1 auto; overflow-y: auto; padding: 10px 10px 16px; }
.nav-label { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--dim); cursor: pointer; position: relative; font-weight: 500; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-item .ico { width: 16px; text-align: center; flex: 0 0 auto; opacity: .9; }
.nav-item .count { margin-left: auto; color: var(--faint); font-family: var(--mono); font-size: 12px; }
.proj-switch { margin: 8px 6px 4px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); display: flex; align-items: center; gap: 10px; cursor: pointer; }
.proj-switch:hover { border-color: #333846; }
.proj-switch .meta { min-width: 0; }
.proj-switch .meta b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-switch .meta span { display: block; color: var(--faint); font-size: 11px; }
.proj-switch .chev { margin-left: auto; color: var(--faint); }
.back-link { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; padding: 6px 12px 2px; cursor: pointer; }
.back-link:hover { color: var(--text); }
.sb-foot { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; }
.sb-foot .av { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-size: 12px; }

/* topbar */
.topbar { display: flex; align-items: center; gap: 14px; padding: 13px 22px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #111319, var(--bg)); }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 13px; }
.crumbs a { cursor: pointer; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { opacity: .5; }
.crumbs .here { color: var(--text); font-weight: 600; }
.spacer { flex: 1; }
select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-family: inherit; }
select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--panel-2); border-color: #333846; }
.btn.primary { background: var(--accent); border-color: transparent; color: #0b1020; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.icon { padding: 7px 9px; }
.range { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--panel); }
.range button { background: transparent; border: 0; color: var(--dim); font: inherit; font-size: 12.5px; padding: 6px 11px; cursor: pointer; border-right: 1px solid var(--border); }
.range button:last-child { border-right: 0; }
.range button.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.range button:hover:not(.active) { background: var(--panel-2); color: var(--text); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.status .led { width: 7px; height: 7px; border-radius: 50%; }
.status.live { color: var(--good); } .status.live .led { background: var(--good); box-shadow: 0 0 0 3px #3fb95022; }
.status.wait { color: var(--warn); } .status.wait .led { background: var(--warn); box-shadow: 0 0 0 3px #d2992222; }

/* ------------------------------------------------------------------- view */
.content { flex: 1; overflow-y: auto; padding: 22px; }
.view { max-width: 1200px; }
.page-head { display: flex; align-items: center; gap: 12px; margin: 0 0 4px; }
.page-head h2 { margin: 0; }
/* Hamburger + mobile drawer: the sidebar is a slide-in overlay below 760px. */
.btn.menu { display: none; }
.scrim { display: none; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .btn.menu { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: 264px;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 2px 0 24px #000a;
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: #0009; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
.loading, .empty { color: var(--faint); padding: 40px; text-align: center; }

/* KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi .label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value.good { color: var(--good); }
.kpi .value.warn { color: var(--warn); }
.kpi .value.bad { color: var(--bad); }
.kpi .sub { color: var(--faint); font-size: 12px; margin-top: 2px; }

/* panels + section headings */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); margin: 0 0 12px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* chart */
.chart { width: 100%; height: 180px; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--dim); margin-top: 8px; }
.chart-legend .k { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* tables + bar meters */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--border); }
td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); color: var(--dim); }
.name-cell { display: flex; flex-direction: column; gap: 2px; max-width: 340px; }
.name-cell > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { position: relative; }
.meter .bar { position: absolute; inset: 0; background: var(--accent-soft); border-radius: 4px; z-index: 0; }
.meter .lbl { position: relative; z-index: 1; padding: 2px 4px; }

.clickable { cursor: pointer; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11px; font-family: var(--mono); border: 1px solid var(--border); color: var(--dim); }
.pill.bad { color: var(--bad); border-color: #f8514955; background: #f851491a; }
.pill.warn { color: var(--warn); border-color: #d2992255; }
.pill.good { color: var(--good); border-color: #3fb95055; }
.type-tag { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.mono { font-family: var(--mono); }
.err { color: var(--bad); padding: 20px; }

/* issue detail */
.issue-detail .stack { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: var(--mono); font-size: 12px; overflow-x: auto; color: var(--dim); }
.issue-detail .frame { white-space: pre-wrap; padding: 1px 0; }
.issue-detail .frame.sym { border-left: 2px solid var(--accent); padding-left: 8px; margin: 0 0 0 -10px; }
.issue-detail .frame-fn { color: var(--text); }
.issue-detail .frame.sym .frame-fn { color: var(--accent); }
.issue-detail .frame-loc { color: var(--faint); }
.back { color: var(--accent); cursor: pointer; font-size: 13px; margin-bottom: 12px; display: inline-block; }
.back:hover { text-decoration: underline; }

/* Inline user-label editor (Users tab) */
.label-input {
  width: 100%;
  max-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 4px 8px;
  transition: border-color 0.15s ease;
}
.label-input::placeholder { color: var(--faint); }
.label-input:focus { outline: none; border-color: var(--accent); }
.label-input.saving { border-color: var(--warn); }
.label-input.saved { border-color: var(--good); }
.label-input.save-err { border-color: var(--bad); }

/* Semantic colouring for plain numeric cells (e.g. crash-free per release) */
td.num.good { color: var(--good); }
td.num.warn { color: var(--warn); }
td.num.bad { color: var(--bad); }

/* Issue facets */
.facets { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.facets select, .facets input {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-family: var(--sans); font-size: 13px; padding: 5px 8px;
}
.facets input { min-width: 180px; }
.facets select:focus, .facets input:focus { outline: none; border-color: var(--accent); }

/* Sparkline + mini buttons */
.spark { display: inline-block; vertical-align: middle; opacity: 0.9; }
button.mini {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--dim); font-family: var(--sans); font-size: 11px; padding: 2px 8px; cursor: pointer;
}
button.mini:hover { background: var(--border); color: var(--text); }
button.mini:disabled { opacity: 0.5; cursor: default; }
button.mini.danger { color: var(--bad); border-color: #f8514955; }
button.mini.danger:hover { background: #f851491a; color: var(--bad); }

/* Issue detail head + banner */
.issue-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.issue-actions { display: flex; gap: 8px; flex-shrink: 0; }
.banner { border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 13px; }
.banner.bad { color: var(--bad); background: #f851491a; border: 1px solid #f8514955; }

/* Breadcrumbs timeline */
.crumbs { list-style: none; margin: 0; padding: 0; }
.crumb {
  display: flex; align-items: center; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.crumb:last-child { border-bottom: none; }
.crumb .ci { width: 18px; text-align: center; color: var(--dim); flex-shrink: 0; }
.crumb .ct { flex-shrink: 0; min-width: 84px; }
.crumb .cl { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb .cw { flex-shrink: 0; font-size: 11px; }
.crumb.crash { background: #f851491a; border-radius: 6px; }
.crumb.crash .ci, .crumb.crash .cl { color: var(--bad); }

/* Projects manager */
.proj-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.proj-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.proj-card.deleted { opacity: 0.62; }
.proj-head { display: flex; align-items: center; gap: 10px; }
.proj-logo { border-radius: 8px; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; background: var(--bg); border: 1px solid var(--border); flex-shrink: 0; }
.proj-logo.empty { color: var(--faint); }
.proj-status { min-height: 20px; }
.key-row { display: flex; align-items: center; gap: 8px; }
.keycode { font-family: var(--mono); font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.keycode.big { font-size: 13px; padding: 8px 10px; color: var(--text); }
.proj-actions { display: flex; gap: 8px; margin-top: 2px; }

.proj-form { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
.proj-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
.proj-form input, .proj-form select { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: var(--sans); font-size: 14px; padding: 8px 10px; }
.proj-form input:focus, .proj-form select:focus { outline: none; border-color: var(--accent); }
.logo-field { display: flex; align-items: center; gap: 10px; }
.logo-field input { flex: 1; }
.filebtn { cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; }
.proj-form-actions { display: flex; gap: 8px; margin-top: 4px; }

.snippet { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; color: var(--dim); white-space: pre; margin: 6px 0 10px; }
.snippet code { color: var(--text); }
.waiting { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 12px 14px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); color: var(--dim); font-size: 14px; }
.waiting.got { color: var(--good); border-color: #3fb95055; background: #3fb9501a; }
.spin { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

@media (max-width: 640px) {
  .kpi .value { font-size: 22px; }
  .view { padding: 14px; }
}
