:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --line: rgba(27, 39, 51, 0.14);
  --text: #15212d;
  --muted: #5c6a77;
  --accent: #116f5b;
  --accent-strong: #0b5847;
  --blue: #2d5f93;
  --amber: #8a6200;
  --danger: #aa3347;
  --shadow: 0 8px 24px rgba(20, 32, 44, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "IBM Plex Sans KR", system-ui, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(17, 111, 91, 0.07), transparent 260px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 28px));
  margin: 14px auto 24px;
  display: grid;
  gap: 10px;
}

.top-bar,
.panel,
.toolbar,
.metric-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.top-eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 2px;
  font-size: 24px;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

.top-actions,
.detail-actions,
.payload-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.primary-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  min-width: 40px;
  padding: 0 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.icon-btn:hover,
.primary-btn:hover {
  border-color: rgba(17, 111, 91, 0.44);
  color: var(--accent);
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-btn:hover {
  color: #fff;
  background: var(--accent-strong);
}

.status-line {
  min-height: 20px;
  margin: 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.status-line.error {
  color: var(--danger);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric-cell {
  padding: 12px;
}

.metric-cell p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.metric-cell strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  padding: 12px;
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr) 110px auto;
  align-items: end;
  gap: 10px;
}

.field-wrap {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(400px, 0.88fr);
  gap: 10px;
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 10px;
}

.panel {
  padding: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chip {
  background: #eef3f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #354454;
  font-size: 12px;
  padding: 4px 10px;
  white-space: nowrap;
}

.events-list,
.installations-list {
  display: grid;
  gap: 8px;
}

.events-list {
  max-height: min(72vh, 880px);
  overflow: auto;
  padding-right: 2px;
}

.event-row,
.installation-row,
.repo-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.event-row {
  padding: 10px;
  cursor: pointer;
}

.event-row:hover,
.event-row.selected {
  border-color: rgba(17, 111, 91, 0.46);
  background: #f3fbf8;
}

.event-row-head,
.event-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.event-row-title {
  margin: 6px 0 2px;
  font-weight: 700;
  line-height: 1.35;
}

.event-row-meta,
.event-row-sub {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.provider-github {
  background: #edf2f9;
  color: var(--blue);
}

.provider-gitlab {
  background: #fff5df;
  color: var(--amber);
}

.provider-atlassian {
  background: #eaf2ff;
  color: #174f9b;
}

.detail-grid {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 0;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.detail-grid dt,
.detail-grid dd {
  margin: 0;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.detail-grid dt {
  background: #f4f7f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-grid dd {
  word-break: break-word;
}

.detail-grid dt:nth-last-child(2),
.detail-grid dd:last-child {
  border-bottom: 0;
}

.payload-head {
  justify-content: space-between;
  margin-bottom: 8px;
}

.payload-view {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #101820;
  color: #dbe9ef;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.installation-row {
  padding: 10px;
  display: grid;
  gap: 6px;
}

.installation-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.repo-row {
  padding: 8px 10px;
}

.repo-row + .repo-row {
  margin-top: 6px;
}

.repo-row a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.empty-state {
  border: 1px dashed rgba(27, 39, 51, 0.22);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .metrics-grid,
  .content-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .content-grid {
    align-items: stretch;
  }

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

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 16px, 1440px);
    margin-top: 8px;
  }

  .top-bar {
    align-items: flex-start;
  }

  h1 {
    font-size: 20px;
  }

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

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid dt {
    border-bottom: 0;
  }
}
