:root {
  color-scheme: light;
  --bg: #f3efe3;
  --panel: #fffdf8;
  --ink: #1f2933;
  --muted: #64748b;
  --line: #ded7c8;
  --accent: #4f70d8;
  --accent-dark: #3151b8;
  --accent-2: #9a4f13;
  --shadow: 0 24px 70px rgba(31, 41, 51, .11);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: linear-gradient(135deg, #f7f2e6, var(--bg));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main { min-height: 100vh; }

h1 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: .96;
  letter-spacing: -.045em;
}

h2 { margin: 0; font-size: 1.15rem; }
p { margin: 0; color: var(--muted); }
a { color: inherit; }
button, input, select { font: inherit; }

button {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--accent-dark);
  color: #fff;
  cursor: pointer;
}

button.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .82);
  color: var(--ink);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 560px);
  display: grid;
  gap: 20px;
  padding: clamp(24px, 5vw, 46px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, .92);
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--accent-2);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

form { display: grid; gap: 8px; }
label { color: var(--ink); font-weight: 700; }
.login-row { display: flex; gap: 8px; }

input, select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

.error { color: #9f1239; font-weight: 700; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 20px;
  background: var(--accent);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255,255,255,.2);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: .06em;
  line-height: 1.25;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #fff;
  color: var(--accent-dark);
  font-size: .9rem;
  letter-spacing: 0;
}

.main-nav { display: grid; gap: 18px; margin-top: 24px; }

.nav-group { display: grid; gap: 7px; }
.nav-group p {
  margin: 8px 0 2px;
  color: rgba(255,255,255,.58);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.nav-link {
  display: block;
  border-radius: 8px;
  padding: 10px 12px;
  color: rgba(255,255,255,.84);
  text-decoration: none;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.16);
  color: #fff;
}

.page-shell {
  width: min(1280px, 100%);
  padding: 34px 22px 60px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.menu-toggle { display: none; }
.lede { margin-top: 18px; max-width: 840px; font-size: 1.05rem; }

.meta, .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 11px;
  background: rgba(255, 253, 248, .76);
  color: var(--muted);
  font-size: .9rem;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 13px;
  margin-top: 22px;
}

.card, .issue {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 14px 44px rgba(31, 41, 51, .07);
}

.card { border-radius: 14px; padding: 16px; }
.metric { font-size: 2rem; font-weight: 850; letter-spacing: -.05em; }
.label { margin-top: 4px; color: var(--muted); font-size: .9rem; }
.toolbar input { flex: 1 1 320px; }
.toolbar select { flex: 0 1 180px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 300px) 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.issue-menu {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 8px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  background: rgba(255, 253, 248, .82);
  color: var(--ink);
  text-align: left;
}

.menu-item.active {
  border-color: rgba(79, 112, 216, .45);
  background: var(--accent-dark);
  color: #fff;
}

.menu-item span { line-height: 1.25; }
.menu-item strong {
  flex: 0 0 auto;
  min-width: 2.2rem;
  border-radius: 8px;
  padding: 3px 8px;
  background: rgba(31, 41, 51, .08);
  text-align: center;
}
.menu-item.active strong { background: rgba(255, 255, 255, .2); }

.issues { display: grid; gap: 18px; }
.issue { border-radius: 14px; overflow: hidden; margin-top: 18px; }
.workspace .issue { margin-top: 0; }

.issue-head {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.compact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.issue-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.count { color: var(--accent-2); font-weight: 850; }
.action { color: var(--accent-dark); font-weight: 700; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #ece5d8;
}

th {
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #fbf8ef;
  white-space: nowrap;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  letter-spacing: inherit;
}

.sort-button.active { color: var(--accent-dark); }

.load-more {
  display: flex;
  justify-content: center;
  padding: 16px;
}

td.context { min-width: 270px; color: var(--muted); }
.empty, .loading { padding: 18px; color: var(--muted); }
.empty-inline { color: var(--muted); }

.api-login-prompt {
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.api-login-prompt h2 { color: var(--ink); }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: rgba(79, 112, 216, .08); }

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

.back-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  background: rgba(255, 253, 248, .82);
  color: var(--ink);
  text-decoration: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 14px 44px rgba(31, 41, 51, .07);
}

.detail-card dl {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(110px, .45fr) 1fr;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid #ece5d8;
}

.field-row dt {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
}

.field-row dd { margin: 0; }

.detail-tables { margin-top: 18px; }
.detail-table { margin-top: 14px; }

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(86vw, 310px);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 20px 0 60px rgba(31, 41, 51, .2);
  }
  .sidebar.open { transform: translateX(0); }
  .page-shell { padding: 24px 12px 42px; }
  .topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: start; }
  .menu-toggle { display: inline-flex; }
  .workspace { grid-template-columns: 1fr; }
  .issue-menu { position: static; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .login-row { display: grid; }
  .toolbar select { flex-basis: 100%; }
  .field-row { grid-template-columns: 1fr; gap: 4px; }
  th, td { padding: 9px 10px; }
}
