:root {
  --bg: #f5efe4;
  --paper: #fffaf1;
  --ink: #18242f;
  --muted: #576675;
  --line: rgba(24, 36, 47, 0.12);
  --accent: #b8562f;
  --accent-strong: #8e3818;
  --accent-soft: #f0d0b8;
  --teal: #145c62;
  --danger: #9f2d2d;
  --shadow: 0 14px 40px rgba(54, 43, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(184, 86, 47, 0.14), transparent 30%),
    radial-gradient(circle at bottom right, rgba(20, 92, 98, 0.16), transparent 25%),
    linear-gradient(135deg, #efe3cf 0%, var(--bg) 42%, #f7f2ea 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.sidebar {
  padding: 1.5rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.86);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  color: #fffaf1;
  background: linear-gradient(135deg, var(--accent-strong), var(--teal));
  box-shadow: var(--shadow);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

h1,
h2 {
  margin: 0;
}

.panel {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 6px 18px rgba(54, 43, 28, 0.06);
}

.panel-soft {
  background: linear-gradient(180deg, rgba(240, 208, 184, 0.36), rgba(255, 255, 255, 0.78));
}

.panel-tall {
  min-height: 320px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

form {
  display: grid;
  gap: 0.75rem;
}

input,
select,
textarea,
button,
.button-link {
  border-radius: 14px;
  border: 1px solid var(--line);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.72rem 0.82rem;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

button,
.button-link {
  padding: 0.78rem 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

.ghost {
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
}

.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.content {
  padding: 1.5rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.2rem;
  border-radius: 28px;
  background:
    linear-gradient(125deg, rgba(255, 250, 241, 0.9), rgba(240, 208, 184, 0.72)),
    linear-gradient(180deg, rgba(20, 92, 98, 0.12), transparent);
  box-shadow: var(--shadow);
}

.hero-copy,
.hint {
  color: var(--muted);
}

.hero-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-content: start;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.metric-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.metric-card strong {
  font-size: 1.7rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr 0.9fr;
  gap: 1rem;
}

.column {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.budget-list,
.validation-list,
.version-list,
.tree-view,
.diff-result,
.table-wrap {
  display: grid;
  gap: 0.75rem;
}

.budget-item,
.validation-item,
.version-item,
.tree-node {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.budget-item.active {
  border-color: rgba(184, 86, 47, 0.55);
  box-shadow: inset 0 0 0 1px rgba(184, 86, 47, 0.14);
}

.budget-item button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
}

.tree-node {
  position: relative;
}

.tree-children {
  margin-top: 0.7rem;
  margin-left: 1rem;
  padding-left: 0.8rem;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 0.6rem;
}

.tree-code,
.capsule {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.8rem;
}

.capsule.warning {
  background: #f4dd8b;
}

.capsule.error {
  background: #efc1c1;
}

.stacked-form,
.top-gap {
  margin-top: 0.9rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.95rem;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(255, 250, 241, 0.95);
}

.table-wrap {
  max-height: 440px;
  overflow: auto;
}

.empty-state {
  min-height: 120px;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.mono {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

@media (max-width: 720px) {
  .content,
  .sidebar {
    padding: 1rem;
  }

  .hero {
    flex-direction: column;
  }

  .hero-actions,
  .metrics,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
