:root {
  --bg: #f6f1e8;
  --bg-soft: #ece2d4;
  --surface: #fffaf2;
  --surface-strong: #fff;
  --text: #1f1b16;
  --muted: #625b50;
  --accent: #c84f2f;
  --accent-soft: #f2b893;
  --danger: #9f1d1d;
  --border: #e3d7c8;
  --shadow: 0 16px 40px rgba(78, 51, 28, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 10% 20%, #ffeedb, transparent 40%),
    radial-gradient(circle at 80% 10%, #f9d9ba, transparent 45%),
    linear-gradient(180deg, var(--bg) 0%, #efe4d5 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  position: relative;
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  z-index: -1;
  filter: blur(42px);
  opacity: 0.55;
  animation: floaty 11s ease-in-out infinite;
}

.bg-glow-1 {
  width: 280px;
  height: 280px;
  background: #f3a272;
  left: -90px;
  top: 120px;
}

.bg-glow-2 {
  width: 340px;
  height: 340px;
  background: #cf7c5b;
  right: -120px;
  bottom: 10%;
  animation-delay: 1.3s;
}

.page-wrap {
  width: min(1150px, 92vw);
  margin: 34px auto 60px;
  display: grid;
  gap: 20px;
  overflow-x: auto;
}

.module-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  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: #cc613d;
  border-color: #8f3f24;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(204, 97, 61, 0.2), 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 #cc613d;
  outline-offset: 2px;
}

.hero {
  background: linear-gradient(130deg, #fff6ea 0%, #ffe8d2 100%);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
  animation: enter 0.7s ease;
}

.hero h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.7rem, 2.4vw, 2.6rem);
}

.hero p {
  margin-top: 8px;
  color: var(--muted);
}

.hero-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.import-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.6fr 1fr auto;
  gap: 10px;
}

.shortcut-hint {
  margin: 10px 2px 0;
  font-size: 0.84rem;
  color: #7a6f62;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;
  gap: 20px;
  align-items: start;
  min-width: 1080px;
}

.workspace-grid > .dashboard-column {
  grid-column: 1;
}

.workspace-grid > .forms-column {
  grid-column: 2;
}

.workspace-grid > .inventory-column {
  grid-column: 3;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.workspace-grid.form-hidden {
  grid-template-columns: 4fr 1fr;
}

.workspace-grid.form-hidden > .dashboard-column {
  grid-column: 1;
}

.workspace-grid.form-hidden > .inventory-column {
  grid-column: 2;
}

.forms-column,
.dashboard-column,
.inventory-column {
  min-height: 100%;
}

.form-stack,
.dashboard-stack {
  display: grid;
  gap: 14px;
}

.forms-column.collapsed {
  display: grid;
  align-content: start;
}

.forms-closed-state h2 {
  margin: 0 0 6px;
  font-family: "Fraunces", serif;
}

.inventory-actions {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.subpanel {
  border: 1px solid #e3d7c8;
  border-radius: 14px;
  background: linear-gradient(170deg, #fff9f2 0%, #ffffff 100%);
  padding: 14px;
}

.panel {
  background: color-mix(in hsl, var(--surface), white 32%);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
  animation: enter 0.6s ease;
}

.panel h2 {
  margin-top: 0;
  font-family: "Fraunces", serif;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.stacked-mobile {
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.compact-field {
  width: min(320px, 100%);
}

.field-label {
  color: #5f564b;
  font-size: 0.82rem;
  font-weight: 700;
}

.row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr 1fr;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfbca8;
  border-radius: 11px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-strong);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

.btn {
  border: none;
  border-radius: 11px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.btn,
.module-link,
.chip,
.inventory-link,
.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,
.chip:active,
.inventory-link:active,
.row-actions button:active,
.line-actions button:active {
  transform: translateY(1px) scale(0.97);
}

.click-bounce {
  animation: click-bounce 0.26s ease;
}

.btn.secondary {
  background: #a54c34;
  text-decoration: none;
  display: inline-block;
}

.btn.small {
  padding: 8px 10px;
  font-size: 0.9rem;
}

.btn.danger {
  background: var(--danger);
}

.chip-row {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid #cfae95;
  background: #fff2e3;
  color: #6a3425;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
}

.chip.active {
  background: #d46c45;
  color: #fff;
  border-color: #d46c45;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(165deg, #fff8f0 0%, #fff 100%);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.card h3 {
  margin: 0;
  font-size: 1.02rem;
}

.badge {
  background: var(--accent-soft);
  color: #5f230f;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.url,
.meta,
.notes,
.secret-value {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  word-break: break-word;
}

.secret-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  --tag-hue: 30;
  border: 1px solid hsl(var(--tag-hue) 72% 62% / 0.45);
  background: hsl(var(--tag-hue) 88% 92%);
  color: hsl(var(--tag-hue) 56% 28%);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 600;
}

.empty-pill {
  --tag-hue: 20;
  opacity: 0.75;
}

.empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 17, 10, 0.5);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.overlay[hidden] {
  display: none !important;
}

.settings-panel {
  border: 1px solid #d9c7b5;
  background: linear-gradient(170deg, #fff6ec 0%, #fffdf9 100%);
}

.inventory-column h2 {
  margin-bottom: 4px;
}

.inventory-group {
  margin-top: 14px;
}

.inventory-filter-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inventory-group h3 {
  font-family: "Fraunces", serif;
  margin: 0 0 8px;
  font-size: 1.02rem;
}

.inventory-list,
.inventory-sublist {
  margin: 0;
  padding-left: 18px;
}

.inventory-list {
  display: grid;
  gap: 8px;
}

.inventory-sublist {
  margin-top: 4px;
  color: var(--muted);
  display: grid;
  gap: 3px;
}

.inventory-link {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.inventory-link:hover {
  color: #8c3c27;
}

.inventory-link.active {
  color: #b24428;
  font-weight: 700;
}

.inventory-empty {
  list-style: none;
  margin-left: -18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-card {
  width: min(420px, 100%);
  background: #fff8f0;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-card h2 {
  margin-top: 0;
  font-family: "Fraunces", serif;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.inline-check input {
  width: auto;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes click-bounce {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.94);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-18px) scale(1.04);
  }
}

@media (max-width: 900px) {
  .workspace-grid,
  .workspace-grid.form-hidden {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .workspace-grid > .dashboard-column,
  .workspace-grid > .forms-column,
  .workspace-grid > .inventory-column,
  .workspace-grid.form-hidden > .dashboard-column,
  .workspace-grid.form-hidden > .inventory-column {
    grid-column: 1;
  }

  .workspace-grid > .inventory-column {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    flex-direction: column;
  }

  .import-row {
    grid-template-columns: 1fr;
  }
}
