:root {
  --bg: #f4efe7;
  --surface: #fffaf1;
  --surface-strong: #ffffff;
  --text: #1f1b16;
  --muted: #665f54;
  --accent: #c95434;
  --accent-soft: #f5c6a8;
  --border: #e0d3c4;
  --shadow: 0 14px 36px rgba(74, 46, 23, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 14% 16%, #ffe9d1, transparent 36%),
    radial-gradient(circle at 84% 8%, #f7dcc0, transparent 42%),
    linear-gradient(180deg, var(--bg) 0%, #ebdfd0 100%);
}

.gh-shell {
  width: min(1220px, 94vw);
  margin: 28px auto 56px;
  display: grid;
  gap: 16px;
}

.module-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.module-link {
  text-decoration: none;
  color: #4a3a2d;
  background: #efe3d4;
  border: 1px solid #ccb39b;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-block;
  box-shadow: 0 2px 0 rgba(89, 64, 40, 0.14);
}

.module-link:hover {
  background: #f6e7d5;
  border-color: #b89272;
}

.module-link.active,
.module-link[aria-current="page"] {
  background: var(--accent);
  border-color: #8f3f24;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(201, 84, 52, 0.22), 0 4px 12px rgba(143, 63, 36, 0.28);
}

.module-link.active:hover,
.module-link[aria-current="page"]:hover {
  filter: brightness(1.03);
}

.module-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gh-hero,
.panel {
  background: color-mix(in hsl, var(--surface), white 30%);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.gh-hero {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.gh-hero-copy {
  min-width: 0;
}

.gh-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.gh-hero h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.7rem, 2.8vw, 2.6rem);
}

.gh-hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.gh-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.gh-nav {
  position: sticky;
  top: 16px;
}

.gh-nav h2 {
  margin-top: 0;
  font-family: "Fraunces", serif;
}

.gh-nav-head {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.gh-nav-toggle {
  display: none;
  flex-shrink: 0;
}

.gh-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.gh-tab {
  width: 100%;
  text-align: left;
  border-radius: 10px;
  border: 1px solid #d8c4b0;
  background: #fff4e6;
  color: #613724;
  padding: 9px 10px;
  font: inherit;
  font-weight: 600;
}

.gh-tab:disabled {
  opacity: 0.6;
}

.gh-main {
  display: grid;
  gap: 16px;
}

.gh-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.gh-analytics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.analytics-card {
  border: 1px solid #e7d7c5;
  border-radius: 12px;
  background: linear-gradient(170deg, #fff8ef 0%, #fff 100%);
  padding: 12px;
}

.analytics-card h3 {
  margin: 0 0 8px;
  font-family: "Fraunces", serif;
  font-size: 1rem;
}

.bar-list {
  display: grid;
  gap: 7px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.bar-label {
  font-size: 0.83rem;
  color: #5a5045;
  margin-bottom: 3px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #f3e4d2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d86c47 0%, #c3492e 100%);
}

.bar-value {
  font-size: 0.8rem;
  color: #6d3c29;
  font-weight: 700;
}

.metric {
  border: 1px solid #ead7c2;
  border-radius: 12px;
  background: linear-gradient(165deg, #fff9f0 0%, #ffffff 100%);
  padding: 12px;
}

.metric .label {
  color: var(--muted);
  font-size: 0.83rem;
}

.metric .value {
  margin-top: 6px;
  font-size: 1.4rem;
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-label {
  color: #5f564b;
  font-size: 0.82rem;
  font-weight: 700;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid #cfbca8;
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.gh-form {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  border: 1px solid #ebddce;
  border-radius: 12px;
  padding: 12px;
  background: #fff8ef;
}

.grid {
  display: grid;
  gap: 8px;
}

.grid.two {
  grid-template-columns: 1fr 1fr;
}

.grid.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.btn.secondary {
  background: #9a4a34;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn,
.module-link,
.gh-tab,
.detail-tab,
.row-actions button,
.line-actions button {
  transition: transform 0.14s ease, filter 0.18s ease, box-shadow 0.18s ease;
  transform-origin: center;
}

.btn:active,
.module-link:active,
.gh-tab:active,
.detail-tab:active,
.row-actions button:active,
.line-actions button:active {
  transform: translateY(1px) scale(0.97);
}

.click-bounce {
  animation: click-bounce 0.26s ease;
}

@keyframes click-bounce {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.94);
  }
  100% {
    transform: scale(1);
  }
}

.table-wrap {
  margin-top: 12px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #eadfce;
  vertical-align: top;
}

tbody tr.selected-row {
  background: linear-gradient(90deg, rgba(201, 84, 52, 0.1) 0%, rgba(255, 244, 230, 0.85) 100%);
}

tbody tr.selected-row td {
  border-bottom-color: rgba(201, 84, 52, 0.24);
}

.org-deeplink {
  border: 0;
  padding: 0;
  background: transparent;
  color: #7d3018;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.org-deeplink:hover {
  text-decoration: underline;
}

th {
  color: #5f564b;
  font-size: 0.84rem;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-block;
}

.badge.high {
  background: #d4f1df;
  color: #1d6840;
}

.badge.medium {
  background: #ffefc8;
  color: #7b5a14;
}

.badge.low {
  background: #f8ddd8;
  color: #7e2d1f;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  border: 1px solid #d1b69b;
  background: #fff5e7;
  color: #673722;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.detail-header-copy {
  min-width: 0;
}

.detail-header h2 {
  margin: 0;
  font-family: "Fraunces", serif;
}

.detail-tabs {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-tab {
  border: 1px solid #d4b89d;
  background: #fff2e3;
  color: #653926;
  border-radius: 999px;
  padding: 7px 11px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.detail-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tab-pane {
  margin-top: 12px;
}

.stack-form {
  display: grid;
  gap: 8px;
  border: 1px solid #ebdecd;
  border-radius: 10px;
  padding: 10px;
  background: #fff8ef;
}

.grid.four {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.grid.four .check-row {
  min-height: 42px;
  border: 1px solid #d7c3ad;
  border-radius: 9px;
  background: #fff;
  margin: 0;
  padding: 0 10px;
  align-self: end;
}

.compact-form .check-row {
  justify-content: center;
  border: 1px solid #d7c3ad;
  border-radius: 9px;
  background: #fff;
  margin: 0;
}

.list-block {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.compact-list {
  margin-top: 4px;
  gap: 6px;
}

.compact-list .list-item {
  padding: 8px;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.attachment-row .meta {
  margin: 0;
}

.list-item {
  border: 1px solid #ecdccc;
  border-radius: 10px;
  background: #fffdf9;
  padding: 10px;
}

.list-item .title {
  font-weight: 700;
}

.line-actions {
  margin-top: 6px;
  display: flex;
  gap: 8px;
}

.line-actions button {
  border: 1px solid #d8bea2;
  border-radius: 8px;
  background: #fff5e8;
  color: #6a3d27;
  font: inherit;
  padding: 5px 8px;
  cursor: pointer;
}

.overview-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.overview-box {
  border: 1px solid #e8d7c5;
  border-radius: 10px;
  background: #fffdf8;
  padding: 10px;
}

.overview-box .k {
  color: var(--muted);
  font-size: 0.82rem;
}

.overview-box .v {
  margin-top: 4px;
  font-weight: 700;
}

.tab-pane h3 {
  margin: 12px 0 6px;
  font-family: "Fraunces", serif;
}

.research-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 8px;
  margin-bottom: 10px;
}

.research-filter-grid {
  grid-template-columns: 1fr 1fr;
}

.inline-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px 10px;
  align-items: center;
  margin-top: 6px;
}

.inline-meta-secondary {
  margin-top: 4px;
}

.inline-meta-row .meta {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.mini-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 700;
}

.mini-pill.high {
  background: #d4f1df;
  color: #1d6840;
}

.mini-pill.medium {
  background: #ffefc8;
  color: #7b5a14;
}

.mini-pill.low {
  background: #f8ddd8;
  color: #7e2d1f;
}

.source-type-pill {
  background: #efe4ff;
  color: #5d3aa3;
}

.attachment-hint {
  margin: 2px 0 0;
  font-size: 0.83rem;
}

.overview-attachment .v,
.research-source-link {
  overflow-wrap: anywhere;
}

.overview-attachment .v {
  word-break: break-word;
}

.timeline-pill {
  background: #e8f1ff;
  color: #295799;
  text-transform: capitalize;
}

.tag-chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.tag-chip {
  border-radius: 999px;
  border: 1px solid #dfc9b0;
  background: #fff4e6;
  color: #6a3d27;
  padding: 3px 8px;
  font-size: 0.74rem;
}

.research-source-link {
  color: #9f4328;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px dashed rgba(159, 67, 40, 0.45);
}

.research-source-link:hover {
  color: #7d3018;
  border-bottom-color: rgba(125, 48, 24, 0.7);
}

.pin-mark {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ffe5a8;
  color: #7d5600;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

.top-gap {
  margin-top: 12px;
}

.import-ok {
  color: #1f6b42;
}

.import-warning {
  color: #87540f;
}

.import-error {
  color: #8b2c1d;
}

#gh-import-row-controls {
  margin-top: 4px;
}

.preview-include {
  width: 18px;
  height: 18px;
}

@media (max-width: 980px) {
  .gh-layout {
    grid-template-columns: 1fr;
  }

  .gh-nav {
    position: static;
  }

  .gh-nav-toggle {
    display: inline-flex;
    align-items: center;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .toolbar,
  .research-toolbar {
    grid-template-columns: 1fr;
  }

  .gh-analytics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .gh-shell {
    width: min(100vw, 100%);
    margin: 0;
    padding: 12px;
  }

  .gh-hero,
  .panel {
    border-radius: 16px;
    padding: 14px;
  }

  .gh-hero,
  .detail-header {
    flex-direction: column;
  }

  .gh-nav-head {
    flex-direction: column;
    align-items: stretch;
  }

  .gh-nav-toggle {
    width: 100%;
  }

  table {
    min-width: 0;
  }

  table thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    margin-bottom: 10px;
    border: 1px solid #eadfce;
    border-radius: 14px;
    overflow: hidden;
    background: #fffdf9;
  }

  td {
    border-bottom: 1px solid #efe4d7;
    padding: 9px 10px;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .row-actions button {
    flex: 1 1 0;
    min-width: 84px;
  }

  .detail-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .detail-tab {
    white-space: nowrap;
  }

  .toolbar {
    gap: 8px;
  }

  .toolbar .btn {
    width: 100%;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
  }
}
