:root {
  color-scheme: light;
  --bg: #f3f3f3;
  --panel: #ffffff;
  --panel-soft: #fbfbfb;
  --text: #1d1d1f;
  --muted: #6d6d72;
  --border: #e2e2e2;
  --nav: #ededed;
  --nav-active: #dedede;
  --accent: #0f9eca;
  --accent-2: #0078d4;
  --danger: #e32831;
  --warning: #f39b16;
  --success: #2d7d16;
  --purple: #6b54b8;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --radius: 4px;
  font-family: "Segoe UI", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17191d;
  --panel: #202329;
  --panel-soft: #252932;
  --text: #f2f4f8;
  --muted: #a4adba;
  --border: #353a44;
  --nav: #111318;
  --nav-active: #2c323c;
  --accent: #30b7dd;
  --accent-2: #58a6ff;
  --danger: #ff6b73;
  --warning: #ffb454;
  --success: #7ccf62;
  --purple: #a99bff;
  --shadow: 0 1px 6px rgba(0, 0, 0, .32);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.app-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.app-icon,
.brand-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #82c341, #f6c348);
  color: #0f2e10;
  font-weight: 800;
}

.app-badge strong {
  display: block;
  font-size: 14px;
}

.app-badge span {
  display: inline-flex;
  margin-top: 3px;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.nav-stack {
  padding-top: 16px;
  overflow-y: auto;
}

.nav-link,
.nav-sub {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  min-height: 32px;
  padding: 6px 12px;
  border-left: 3px solid transparent;
}

.nav-link.active,
.nav-sub.active {
  background: var(--nav-active);
  border-left-color: var(--accent-2);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  color: var(--muted);
}

.nav-sub {
  padding-left: 37px;
  font-size: 12px;
}

.collapse-button {
  margin-top: auto;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: default;
  text-align: right;
  padding-right: 12px;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.crumbs,
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.crumbs {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumbs strong {
  color: var(--text);
}

.top-link {
  color: var(--text);
  font-size: 12px;
}

.theme-toggle,
.icon-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffd4c9;
  color: #923200;
  font-size: 11px;
  font-weight: 700;
}

.content {
  padding: 22px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.filter {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.filter select,
.filter input,
.search-box input,
.field input,
.field select,
.field textarea {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 5px 8px;
}

.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #f5df9d;
  background: #fff8dc;
  color: #4b3a00;
  box-shadow: var(--shadow);
}

[data-theme="dark"] .notice {
  background: #332b14;
  border-color: #69531a;
  color: #ffe6a2;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card.pad {
  padding: 16px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-title h2,
.card-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.help {
  color: var(--muted);
  border: 1px solid var(--border);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 126px;
  gap: 18px;
  align-items: center;
}

.chart-box {
  position: relative;
  height: 190px;
}

.chart-box.short {
  height: 150px;
}

.chart-box.tiny {
  height: 92px;
}

.side-kpis {
  display: grid;
  gap: 14px;
  align-self: stretch;
  align-content: center;
}

.kpi-label {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
}

.kpi-value {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 650;
}

.kpi-value.blue {
  color: var(--accent);
}

.kpi-value.purple {
  color: var(--purple);
}

.kpi-value.orange {
  color: var(--warning);
}

.mini-kpis {
  display: flex;
  gap: 80px;
  margin-top: 14px;
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.reports-card {
  overflow: hidden;
  transition: opacity .12s ease;
}

.reports-card.is-loading {
  opacity: .68;
}

.reports-card table {
  min-width: 920px;
}

.reports-header {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.reports-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.report-filters .filter {
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
}

.report-filters input {
  width: 190px;
}

.report-filters select {
  max-width: 180px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.sort-link {
  color: var(--muted);
}

.sort-link:hover {
  color: var(--accent-2);
}

td {
  font-size: 12px;
}

tr:hover td {
  background: var(--panel-soft);
}

.issue-title-link {
  display: block;
  color: inherit;
}

.back-link {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent-2);
}

.issue-page-head {
  align-items: flex-start;
}

.issue-subtitle {
  margin-top: 4px;
  max-width: 960px;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.issue-actions {
  margin-bottom: 14px;
}

.stack-card {
  overflow: hidden;
}

.stack-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.copy-status {
  color: var(--success);
  font-size: 12px;
  min-width: 48px;
}

.copy-source {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.copy-source.copy-source-visible {
  position: static;
  left: auto;
  width: 100%;
  height: 150px;
  opacity: 1;
  pointer-events: auto;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
}

.stack-trace {
  margin: 0;
  max-height: 430px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
}

.issue-breakdowns {
  margin-top: 14px;
}

.purple {
  color: var(--purple);
}

.purple-fill {
  background: var(--purple);
}

.version-fill {
  background: #bd9719;
}

.muted {
  color: var(--muted);
}

.trend-up,
.status-open {
  color: var(--success);
}

.status-resolved {
  color: var(--accent);
}

.status-ignored {
  color: var(--muted);
}

.danger {
  color: var(--danger);
}

.warning {
  color: var(--warning);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: end;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--border);
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.split-view {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 0;
  margin: -22px;
}

.event-rail {
  height: calc(100vh - 38px);
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.event-rail a {
  display: block;
  color: var(--text);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-rail a.active {
  background: var(--nav-active);
  border-left: 3px solid var(--accent-2);
}

.event-detail {
  padding: 22px;
}

.search-box {
  margin-bottom: 14px;
}

.search-box input {
  width: 100%;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--muted);
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
button.button {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
}

.button.primary {
  border-color: var(--accent-2);
  background: var(--accent-2);
  color: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(140deg, rgba(15, 158, 202, .12), transparent 42%),
    var(--bg);
}

.auth-card {
  width: min(420px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 8px 0 0;
  font-size: 22px;
}

.auth-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.auth-card label {
  color: var(--muted);
  font-size: 12px;
}

.auth-card input {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  padding: 7px 9px;
}

.auth-card button {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent-2);
  color: #fff;
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  min-height: auto;
}

.validation-summary,
span[data-valmsg-for] {
  color: var(--danger);
  font-size: 12px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .sidebar .app-badge div:last-child,
  .nav-link span:last-child,
  .nav-sub {
    display: none;
  }

  .nav-link {
    justify-content: center;
    padding: 7px;
  }

  .grid.two,
  .grid.three,
  .chart-row,
  .split-view,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .event-rail {
    height: auto;
    max-height: 220px;
  }

  .content {
    padding: 14px;
  }

  .split-view {
    margin: -14px;
  }

  .event-detail {
    padding: 14px;
  }

  .mini-kpis {
    gap: 24px;
  }
}

@media (max-width: 640px) {
  .page-head {
    display: grid;
  }

  .filters {
    justify-content: stretch;
  }

  .filter,
  .filter select,
  .filter input {
    width: 100%;
  }
}
