:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #63717a;
  --line: #d8e1e6;
  --soft-line: #edf1f3;
  --teal: #0f766e;
  --teal-ink: #0b4d49;
  --coral: #d95f43;
  --amber: #b7791f;
  --blue: #315f9f;
  --green: #2f7d54;
  --shadow: 0 14px 36px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 248, 0.94);
  backdrop-filter: blur(10px);
}

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

.brand img {
  width: 40px;
  height: 40px;
}

.brand span {
  display: block;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.key-field {
  display: grid;
  gap: 4px;
  min-width: 250px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--teal);
}

main {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 22px 28px 36px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.metric strong {
  font-size: 2rem;
  line-height: 1;
}

.metric-open {
  border-top: 4px solid var(--blue);
}

.metric-critical {
  border-top: 4px solid var(--coral);
}

.metric-resolved {
  border-top: 4px solid var(--green);
}

.metric-apps {
  border-top: 4px solid var(--teal);
}

.workbench {
  display: grid;
  grid-template-columns: 260px minmax(420px, 1fr) 380px;
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--soft-line);
}

.panel-heading h2,
.mini-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.with-action {
  align-items: start;
}

.filters-panel,
.detail-panel {
  position: sticky;
  top: 92px;
}

.control-stack,
.mini-panel,
.detail-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
}

.mini-panel {
  border-top: 1px solid var(--soft-line);
}

.icon-button,
.command-button,
.secondary-button,
.row-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
}

.icon-button {
  width: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.icon-button svg,
.command-button svg,
.secondary-button svg,
.row-button svg {
  width: 18px;
  height: 18px;
}

.command-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
  padding: 8px 12px;
  font-weight: 800;
}

.secondary-button,
.row-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  font-weight: 750;
}

.secondary-button:hover,
.row-button:hover,
.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.command-button:hover {
  background: var(--teal-ink);
}

.severity-bars {
  min-width: 220px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.severity-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.75rem;
  font-weight: 800;
}

.severity-critical {
  background: #fff0ed;
  color: #a53922;
}

.severity-error {
  background: #fdf2e5;
  color: #9a5018;
}

.severity-warning {
  background: #fff8db;
  color: #7a5a0a;
}

.severity-info {
  background: #e8f4ff;
  color: #245080;
}

.status-new {
  background: #e8f4ff;
  color: #245080;
}

.status-acknowledged {
  background: #fff8db;
  color: #7a5a0a;
}

.status-resolved {
  background: #e8f6ef;
  color: #226344;
}

.status-ignored {
  background: #eceff2;
  color: #52616b;
}

.log-list {
  display: grid;
  max-height: 760px;
  overflow: auto;
}

.log-row {
  display: grid;
  grid-template-columns: 7px 1fr auto;
  gap: 12px;
  width: 100%;
  min-height: 88px;
  border: 0;
  border-bottom: 1px solid var(--soft-line);
  background: #ffffff;
  padding: 0 14px 0 0;
  text-align: left;
}

.log-row:hover,
.log-row.active {
  background: #f8fbfb;
}

.severity-strip {
  width: 7px;
  height: 100%;
}

.strip-critical {
  background: var(--coral);
}

.strip-error {
  background: var(--amber);
}

.strip-warning {
  background: #d7a80d;
}

.strip-info {
  background: var(--blue);
}

.log-main {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 12px 0;
}

.log-title {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-meta,
.detail-meta,
.app-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.log-side {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 8px;
  min-width: 112px;
}

.count-badge {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.detail-panel {
  min-height: 460px;
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.detail-title {
  padding: 14px 16px;
  border-bottom: 1px solid var(--soft-line);
}

.detail-title h2 {
  overflow-wrap: anywhere;
  margin: 0 0 8px;
  font-size: 1rem;
}

.detail-stack,
.kv-list {
  overflow: auto;
  max-height: 230px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
  color: #26323a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.apps-section {
  margin-top: 14px;
}

.apps-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  padding: 16px;
}

.app-list {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 540px;
  overflow: auto;
}

.app-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.app-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.app-row strong {
  overflow-wrap: anywhere;
}

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

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

.wide,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  min-height: 44px;
  display: none;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 750;
}

.toast.show {
  display: flex;
}

.toast.error {
  border-color: #f1b3a5;
  color: #8f321f;
}

@media (max-width: 1180px) {
  .workbench,
  .apps-layout {
    grid-template-columns: 1fr;
  }

  .filters-panel,
  .detail-panel {
    position: static;
  }

  .log-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
  }

  .top-actions {
    align-items: end;
  }

  .key-field {
    min-width: 0;
    flex: 1;
  }

  main {
    padding: 14px;
  }

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

  .app-form {
    grid-template-columns: 1fr;
  }

  .log-row {
    grid-template-columns: 6px 1fr;
  }

  .log-side {
    grid-column: 2;
    justify-items: start;
    grid-auto-flow: column;
    align-content: start;
    padding-bottom: 12px;
  }
}
