:root {
  --bg: #f6f7f4;
  --text: #15201c;
  --muted: #63716b;
  --line: #dfe5dd;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-2: #7c3aed;
  --warn: #c2410c;
  --shadow: 0 18px 50px rgba(21, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

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

button,
input {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

h2 .help {
  margin-left: 6px;
  vertical-align: middle;
}

.title-help {
  transform: translateY(-1px);
}

.controls,
#keyForm {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  height: 40px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--accent);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 16px;
}

.tab,
.segment,
.task-segment {
  height: 34px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
}

.tab.active,
.segment.active,
.task-segment.active {
  background: var(--text);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.key-panel,
.panel,
.metrics article,
.status {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.key-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}

.key-panel p,
.panel-title span,
.status {
  color: var(--muted);
}

#apiKey {
  width: min(460px, 70vw);
}

.status {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.status.error {
  color: var(--warn);
  border-color: rgba(194, 65, 12, 0.35);
}

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

.gitlab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.inline-config {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inline-config input {
  min-width: 300px;
}

.inline-config p {
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 9px;
}

.project-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 4px;
}

.project-tab {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
  white-space: nowrap;
}

.project-tab.active {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.gitlab-toolbar p,
.config-list p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.config-list {
  display: grid;
  gap: 8px;
}

.metrics article {
  min-width: 0;
  min-height: 104px;
  border-radius: 8px;
  padding: 16px;
  overflow: hidden;
}

.metrics span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.metric-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.metrics strong {
  display: block;
  max-width: 100%;
  font-size: clamp(22px, 1.8vw, 28px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  min-width: 0;
}

.panel-title span {
  min-width: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.wide canvas {
  width: 100%;
  max-height: 280px;
}

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

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  min-width: 0;
}

.bar-meta strong,
.bar-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #edf1ef;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1160px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  max-width: 520px;
  overflow-wrap: anywhere;
}

#gitlabTable td:last-child,
#taskTable td:last-child {
  min-width: 360px;
  max-width: 620px;
  white-space: normal;
  line-height: 1.5;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.th-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  position: relative;
}

.help {
  display: inline-grid;
  place-items: center;
  flex: 0 0 16px;
  position: relative;
  width: 16px;
  height: 16px;
  border: 1px solid #a8b3ae;
  border-radius: 50%;
  color: #63716b;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  text-transform: none;
}

.tooltip {
  position: fixed;
  z-index: 1000;
  width: min(360px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15201c;
  color: #fff;
  box-shadow: 0 14px 34px rgba(21, 32, 28, 0.18);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  text-transform: none;
  white-space: pre-line;
  opacity: 1;
  pointer-events: none;
}

.tooltip[hidden] {
  display: none;
}

.member {
  display: grid;
  gap: 3px;
}

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

@media (max-width: 1080px) {
  .metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 24px, 1440px);
    padding-top: 18px;
  }

  .topbar,
  .key-panel {
    display: grid;
    align-items: stretch;
  }

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

  .metrics strong {
    font-size: 23px;
  }

  #apiKey,
  input {
    width: 100%;
    min-width: 0;
  }
}
