:root {
  --bg: #f4f1ea;
  --ink: #201a12;
  --muted: #6d6256;
  --card: rgba(255, 255, 255, 0.78);
  --stroke: rgba(32, 26, 18, 0.12);
  --accent: #d86b2d;
  --accent-2: #0c7c6f;
  --danger: #b4473d;
  --shadow: 0 18px 40px rgba(26, 22, 16, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, rgba(216, 107, 45, 0.12), transparent 55%),
    radial-gradient(circle at 85% 15%, rgba(12, 124, 111, 0.12), transparent 50%),
    linear-gradient(140deg, #f7f3ec 0%, #efe7db 100%);
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 6vw 10px;
}

.brand {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.brand span {
  color: var(--accent);
}

.meta {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  padding: 16px 6vw 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  position: relative;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.panel-help {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

.panel-help__icon {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  background: rgba(32, 26, 18, 0.06);
  color: var(--muted);
  cursor: pointer;
  box-shadow: none;
  transform: none;
}

.panel-help__icon:hover {
  background: rgba(12, 124, 111, 0.16);
  color: var(--accent-2);
  box-shadow: none;
  transform: none;
}

.panel-help__icon:focus-visible {
  outline: 2px solid rgba(12, 124, 111, 0.5);
  outline-offset: 2px;
}

.panel-help__tooltip {
  position: absolute;
  top: 22px;
  right: 0;
  width: 240px;
  max-width: 70vw;
  background: white;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
  opacity: 0;
  transform: translateY(-4px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.panel-help:hover .panel-help__tooltip,
.panel-help:focus-within .panel-help__tooltip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.panel-help__tooltip a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
  display: inline-block;
  margin-top: 6px;
}

.docs-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.docs-nav {
  position: sticky;
  top: 22px;
  align-self: start;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  padding: 12px;
}

.docs-nav__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
  width: 100%;
}

.docs-nav a {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
}

.docs-nav a:hover {
  background: rgba(12, 124, 111, 0.14);
  color: var(--accent-2);
}

.docs-content {
  display: grid;
  gap: 16px;
}

.docs-section {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  padding: 14px;
}

.docs-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.docs-section p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink);
}

.docs-section p.subtle {
  color: var(--muted);
}

.docs-section code {
  font-family: "JetBrains Mono", "Courier New", monospace;
  background: rgba(32, 26, 18, 0.08);
  border-radius: 6px;
  padding: 1px 4px;
  font-size: 12px;
}

.docs-list {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink);
}

.docs-list li {
  margin-bottom: 6px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

label {
  font-size: 13px;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
  background: white;
  color: var(--ink);
}

button {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.secondary {
  background: var(--accent-2);
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(216, 107, 45, 0.2);
}

.stack form {
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--stroke);
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: rgba(32, 26, 18, 0.08);
}

.tag.success {
  background: rgba(12, 124, 111, 0.18);
  color: #0c7c6f;
}

.tag.failed {
  background: rgba(216, 107, 45, 0.18);
  color: #b9521c;
}

.tag.running {
  background: rgba(62, 124, 216, 0.18);
  color: #2f5f9f;
}

.tag.queued {
  background: rgba(32, 26, 18, 0.08);
  color: var(--ink);
}

.tag.aborting {
  background: rgba(216, 107, 45, 0.2);
  color: #b9521c;
}

.tag.aborted {
  background: rgba(32, 26, 18, 0.16);
  color: #4b3f34;
}

.status-btn {
  border: none;
  font: inherit;
}

.status-btn.abortable {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.status-btn__abort {
  display: none;
}

.status-btn.abortable:hover {
  background: rgba(180, 71, 61, 0.2);
  color: var(--danger);
  box-shadow: 0 6px 16px rgba(180, 71, 61, 0.2);
  transform: none;
}

.status-btn.abortable:hover .status-btn__label {
  display: none;
}

.status-btn.abortable:hover .status-btn__abort {
  display: inline;
}

.status-btn.abortable:focus-visible {
  outline: 2px solid rgba(180, 71, 61, 0.5);
  outline-offset: 2px;
}

.progress {
  position: relative;
  height: 8px;
  min-width: 140px;
  border-radius: 999px;
  background: rgba(32, 26, 18, 0.12);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.2s ease;
}

.progress__meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mono {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 12px;
  color: var(--muted);
}

.exports-list a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
}

.log {
  background: rgba(32, 26, 18, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.sheet-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.sheet-tab {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  background: rgba(32, 26, 18, 0.06);
  color: var(--ink);
  box-shadow: none;
  transform: none;
}

.sheet-tab:hover {
  background: rgba(12, 124, 111, 0.15);
  box-shadow: none;
  transform: none;
}

.sheet-tab.active {
  background: var(--accent-2);
  color: white;
  box-shadow: 0 8px 18px rgba(12, 124, 111, 0.2);
}

.formula-bar {
  display: grid;
  grid-template-columns: 110px minmax(160px, 1fr) minmax(220px, 2fr);
  gap: 12px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.8);
  margin-bottom: 12px;
}

.formula-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.formula-cell--wide {
  min-width: 0;
}

.formula-label {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.formula-cell span:not(.formula-label) {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 12px;
  white-space: nowrap;
  overflow: auto;
}

.sheet-view {
  display: none;
}

.sheet-view.active {
  display: block;
}

.sheet-grid {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  overflow: auto;
  max-height: 70vh;
}

.sheet-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  width: max-content;
  min-width: 100%;
  color: var(--ink);
}

.sheet-table th,
.sheet-table td {
  border-right: 1px solid var(--stroke);
  border-bottom: 1px solid var(--stroke);
  padding: 6px 8px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-table th {
  background: rgba(32, 26, 18, 0.06);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.sheet-table th.sheet-row {
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(32, 26, 18, 0.08);
}

.sheet-table th.sheet-corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
  background: rgba(32, 26, 18, 0.12);
}

.sheet-table td {
  background: white;
  cursor: pointer;
}

.sheet-table td:hover {
  box-shadow: inset 0 0 0 1px rgba(12, 124, 111, 0.4);
}

.sheet-table td.selected {
  outline: 2px solid rgba(12, 124, 111, 0.5);
  outline-offset: -1px;
  box-shadow: inset 0 0 0 1px rgba(12, 124, 111, 0.6);
}

.sheet-table tr.sheet-row-sep td,
.sheet-table tr.sheet-row-sep th.sheet-row {
  border-bottom: 3px solid #000;
}

.footer {
  padding: 0 6vw 40px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 680px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  button {
    width: 100%;
  }
  button.sheet-tab {
    width: auto;
  }
  .formula-bar {
    grid-template-columns: 1fr;
  }
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-nav {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .docs-nav a {
    display: inline-flex;
    align-items: center;
  }
}
