:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --line: #d8dee9;
  --line-strong: #b7c0d0;
  --text: #172033;
  --muted: #667085;
  --blue: #0b5cab;
  --blue-soft: #e8f1ff;
  --red: #b42318;
  --red-soft: #fee4e2;
  --amber: #b54708;
  --amber-soft: #ffefd2;
  --green: #067647;
  --green-soft: #dcfae6;
  --gray-soft: #eef2f6;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

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

a:hover {
  text-decoration: underline;
}

.boot,
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.login-card {
  width: min(440px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0b5cab, #00a3a3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--gray-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  max-width: 340px;
}

.user-pill span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--blue);
}

.btn.primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.content {
  padding: 20px;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
}

.field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 10px;
  background: white;
  color: var(--text);
}

.field.search {
  grid-column: span 2;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.kpi span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.kpi strong {
  font-size: 24px;
  display: block;
  margin-top: 6px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

thead {
  background: #edf1f7;
}

th {
  color: #4d5668;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fbff;
}

.case-link {
  font-weight: 700;
}

.subject {
  max-width: 360px;
  font-weight: 600;
}

.summary {
  min-width: 280px;
  max-width: 460px;
  color: #344054;
  line-height: 1.35;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.critical {
  background: var(--red-soft);
  color: var(--red);
}

.badge.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.info {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.good {
  background: var(--green-soft);
  color: var(--green);
}

.badge.neutral {
  background: var(--gray-soft);
  color: #475467;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(16, 24, 40, 0.28);
  z-index: 20;
}

.drawer-backdrop.open {
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(820px, 92vw);
  height: 100vh;
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 30;
  transform: translateX(102%);
  transition: transform 160ms ease;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-title h2 {
  margin: 0;
  font-size: 22px;
}

.drawer-subtitle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.sync-pill.live {
  background: #e3fcef;
  color: #17633a;
}

.sync-pill.stored {
  background: #eef3f8;
  color: #516078;
}

.sync-pill.failed {
  background: #fff0d9;
  color: #9a4b00;
}

.drawer-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.drawer-body {
  overflow: auto;
  padding: 18px 20px 28px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 10px 4px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-soft);
  margin-bottom: 12px;
}

.report-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.pre {
  white-space: pre-wrap;
  line-height: 1.45;
  color: #263247;
}

.formatted-report {
  line-height: 1.5;
  color: #263247;
  overflow-wrap: anywhere;
}

.formatted-report a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.formatted-report a:hover {
  text-decoration: underline;
}

.formatted-report code,
.report-card code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #eef3f8;
  color: #172033;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.94em;
}

.slack-emoji {
  display: inline-block;
  min-width: 1.2em;
  margin-right: 2px;
}

.empty {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.status-line {
  min-height: 18px;
  color: var(--muted);
  margin: 10px 0 0;
}

@media (max-width: 1200px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
  .field.search {
    grid-column: span 3;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }
  .content {
    padding: 12px;
  }
  .filter-grid,
  .kpis {
    grid-template-columns: 1fr;
  }
  .field.search {
    grid-column: span 1;
  }
  .table-wrap {
    overflow-x: auto;
  }
}
