:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1e2428;
  --muted: #697178;
  --line: #d9dedb;
  --green: #1f8a5b;
  --green-bg: #e6f4ec;
  --amber: #a66700;
  --amber-bg: #fff1d2;
  --red: #b32929;
  --red-bg: #ffe1df;
  --blue: #286fb7;
  --blue-bg: #e4f0fb;
  --shadow: 0 18px 45px rgba(32, 39, 44, 0.09);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(246, 245, 241, 0.92)),
    var(--bg);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 4vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
}

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

#rootPath {
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
}

.search {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.search input {
  width: min(360px, 42vw);
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  outline: none;
}

.search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 111, 183, 0.14);
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
}

#refreshButton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 14px;
  font-size: 2.4rem;
  line-height: 1;
}

.metric.clean {
  background: var(--green-bg);
}

.metric.dirty {
  background: var(--amber-bg);
}

.metric.warn {
  background: var(--blue-bg);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 6px 0 18px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(82px, auto));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.segmented button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active {
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 7px 18px rgba(32, 39, 44, 0.1);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.project-card {
  display: grid;
  gap: 16px;
  min-height: 254px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.project-name {
  margin: 0 0 7px;
  font-size: 1.22rem;
  overflow-wrap: anywhere;
}

.project-path {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.status-pill {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
}

.status-clean {
  color: var(--green);
  background: var(--green-bg);
}

.status-dirty {
  color: var(--amber);
  background: var(--amber-bg);
}

.status-behind {
  color: var(--blue);
  background: var(--blue-bg);
}

.status-conflict {
  color: var(--red);
  background: var(--red-bg);
}

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

.meta {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.meta strong {
  display: block;
  margin-top: 8px;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.commit {
  display: grid;
  gap: 6px;
}

.commit p {
  margin: 0;
  line-height: 1.5;
}

.commit-subject {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 26px;
}

.chip {
  padding: 5px 8px;
  border-radius: 999px;
  color: #344047;
  background: #edf0ef;
  font-size: 0.76rem;
  font-weight: 800;
}

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

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .topbar,
  .toolbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .search input {
    width: 100%;
  }

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

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

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

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