:root {
  color-scheme: light;
  --ink: #171a16;
  --muted: #64685d;
  --paper: #f5f3ea;
  --panel: #fffefa;
  --line: #d8d2c1;
  --teal: #0f7c80;
  --teal-dark: #09565a;
  --clay: #c84e2f;
  --mint: #e2f1ee;
  --shadow: 0 18px 48px rgba(23, 26, 22, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(15, 124, 128, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(15, 124, 128, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
}

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

button,
.file-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  border-color: var(--teal);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button[hidden] {
  display: none;
}

.app-header {
  min-height: 154px;
  padding: 28px clamp(18px, 4vw, 44px) 18px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(23, 26, 22, 0.12);
  background: rgba(245, 243, 234, 0.86);
  backdrop-filter: blur(8px);
}

.app-header h1 {
  margin: 4px 0 0;
  font-size: clamp(3rem, 7vw, 5.7rem);
  line-height: 0.88;
  max-width: 660px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
}

nav,
.non-goals,
.row-actions,
.output-actions,
.saved-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

nav span,
nav a,
.non-goals span,
.status-pill {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 900;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(330px, 0.8fr) minmax(460px, 1.6fr);
  gap: 18px;
  padding: 18px clamp(14px, 3vw, 40px) 40px;
  align-items: start;
}

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.data-dock,
.control-room {
  padding: 18px;
}

.output-stage {
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.3rem;
}

.file-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

textarea {
  width: 100%;
  height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  line-height: 1.42;
}

.row-actions {
  margin: 12px 0;
}

.table-wrap {
  max-height: 270px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid #eee7d9;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.7rem;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 39px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

.saved-panel {
  margin: 14px 0;
  padding: 12px;
  background: var(--mint);
  border-radius: 8px;
}

.saved-panel input,
.saved-panel select {
  flex: 1 1 150px;
}

.primary-action {
  width: 100%;
  min-height: 48px;
  background: var(--clay);
  color: #fff;
  border: 0;
  margin: 0 0 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}

.stats-grid div {
  padding: 12px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.stats-grid div:last-child {
  border-right: 0;
}

.stats-grid strong {
  display: block;
  font-size: 1.35rem;
}

.stats-grid span {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 900;
}

.warning-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.warning-box ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.sheet-preview {
  display: grid;
  gap: 18px;
  margin-top: 14px;
}

.sheet-frame {
  background: #dbd7c8;
  padding: 16px;
  border-radius: 8px;
  overflow: auto;
}

.sheet {
  width: min(100%, 860px);
  height: auto;
  display: block;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 8px 28px rgba(23, 26, 22, 0.14);
}

.label-title {
  font-size: 17px;
  font-weight: 900;
  fill: var(--ink);
}

.label-caption {
  font-size: 12px;
  font-weight: 800;
  fill: var(--teal-dark);
}

.label-payload {
  font-size: 9px;
  fill: var(--muted);
}

footer {
  padding: 18px 40px 32px;
  color: var(--muted);
  display: flex;
  gap: 12px;
  align-items: center;
}

.legal-page main {
  max-width: 760px;
  margin: 80px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.legal-page h1 {
  font-size: 2.8rem;
  line-height: 0.98;
}

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

  .output-stage {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .app-header h1 {
    font-size: 3.2rem;
  }

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

  .output-stage {
    grid-column: auto;
  }

  .control-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

  textarea {
    height: 190px;
  }

  .sheet-frame {
    padding: 8px;
  }
}
