:root {
  --bg: #f6f1e8;
  --panel: #fffdf8;
  --ink: #11110f;
  --muted: #6f695f;
  --line: #ded7cc;
  --soft: #eee8df;
  --sidebar: #11110f;
  --sidebar-muted: #aaa59b;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  background: var(--sidebar);
  color: white;
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.04em;
  margin-bottom: 32px;
}
.brand span {
  display: block;
  margin-top: 4px;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--sidebar-muted);
}
.nav {
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  color: white;
  background: rgba(255,255,255,.1);
  font-weight: 700;
  cursor: default;
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,.12);
}
#userEmail {
  color: var(--sidebar-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
  margin-bottom: 10px;
}
#signOut {
  border: 1px solid rgba(255,255,255,.18);
  color: white;
  background: transparent;
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
}

main {
  min-width: 0;
  padding: 36px clamp(20px, 4vw, 56px) 56px;
}
.page-head,
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
}
.page-head h1,
.detail-head h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 54px);
  line-height: .98;
  letter-spacing: -0.055em;
}
.page-head p,
.detail-head p {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
.database-status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.database-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.database-card {
  width: 100%;
  min-width: 0;
  min-height: 245px;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 8px 30px rgba(47, 40, 31, .035);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.database-card:hover {
  transform: translateY(-2px);
  border-color: #bdb4a8;
  box-shadow: 0 15px 42px rgba(47, 40, 31, .08);
}
.database-card:focus-visible {
  outline: 3px solid rgba(17,17,15,.16);
  outline-offset: 3px;
}
.database-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}
.database-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 30px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 11px;
  font-weight: 800;
}
.database-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.database-card h2 {
  margin: 0 0 10px;
  font-size: 21px;
  letter-spacing: -0.035em;
}
.database-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}
.database-includes {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--soft);
  font-size: 11px;
  color: #49453f;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.database-includes span {
  display: block;
  margin-bottom: 5px;
  color: #9a9287;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 9px;
  font-weight: 800;
}
.database-open {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 800;
}

.database-detail { min-width: 0; }
.back-button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 13px;
  margin-bottom: 26px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.back-button:hover { background: var(--panel); }
.detail-eyebrow {
  margin-bottom: 8px;
  color: #8a8277;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 10px;
  font-weight: 800;
}
.detail-tables {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -8px 0 24px;
}
.detail-tables > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-right: 4px;
}
.detail-tables code,
.data-note code {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 5px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}
.loading-panel,
.empty-state,
.data-note {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 18px 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.loading-panel.compact,
.empty-state.compact { border-radius: 0 0 14px 14px; }
.data-note { margin-bottom: 16px; }

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.table-wrap.nested {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  font-size: 12px;
}
.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--soft);
  text-align: left;
  vertical-align: top;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1ebe2;
  color: #6a6359;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(245,240,232,.6); }
.data-table td strong { display: block; font-size: 12px; margin-bottom: 3px; }
.data-table td small { display: block; color: var(--muted); line-height: 1.4; }
.data-table a { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

.accelerator-list {
  display: grid;
  gap: 12px;
}
.accelerator-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.accelerator-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 17px 18px;
  text-align: left;
  cursor: pointer;
}
.accelerator-toggle:hover { background: rgba(245,240,232,.7); }
.accelerator-main { min-width: 0; }
.accelerator-main strong {
  display: block;
  font-size: 15px;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.accelerator-main span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.accelerator-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
  font-size: 11px;
}
.accelerator-meta b { font-size: 12px; }
.source-state {
  border-radius: 999px;
  padding: 5px 8px;
  font-weight: 800;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.source-state.active { background: #e8f3e3; color: #35572c; }
.source-state.inactive { background: #eee9e2; color: #777066; }
.chevron { transition: transform .16s ease; font-size: 14px; }
.accelerator-toggle.open .chevron { transform: rotate(180deg); }
.accelerator-startups { background: #fffdfa; }
.accelerator-summary {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.accelerator-table td:first-child { min-width: 220px; }
.link-stack { white-space: nowrap; }
.link-stack a { display: block; margin-bottom: 5px; }

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(40,35,29,.08);
}
.auth-card .brand {
  color: var(--ink);
  margin-bottom: 22px;
}
.auth-card .brand span { color: var(--muted); }
.auth-card h2 { margin: 0 0 8px; }
.auth-card p { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.auth-card input {
  width: 100%;
  margin-bottom: 10px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
}
.primary, .ghost-border {
  width: 100%;
  border-radius: 10px;
  padding: 11px 13px;
  cursor: pointer;
  font-weight: 700;
}
.primary { border: 1px solid var(--ink); background: var(--ink); color: white; }
.ghost-border { margin-top: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); }
#authMessage { margin-top: 12px; color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
  .database-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    min-height: auto;
    height: auto;
    position: static;
    padding: 16px;
  }
  .brand { margin-bottom: 14px; }
  .sidebar-foot {
    margin-top: 16px;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  #userEmail { margin: 0; }
  main { padding: 24px 16px 40px; }
  .page-head,
  .detail-head { align-items: flex-start; flex-direction: column; }
  .database-grid { grid-template-columns: 1fr; }
  .database-card { min-height: 225px; }
  .accelerator-toggle { align-items: flex-start; flex-direction: column; gap: 12px; }
  .accelerator-meta { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .data-table { min-width: 720px; }
}