:root {
  color-scheme: light;
  --bg: #f6f4f0;
  --surface: #ffffff;
  --ink: #1f1f21;
  --muted: #6f6a61;
  --line: #e4ded3;
  --green: #1f1f21;
  --gold: #c99121;
  --blue: #2563eb;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(31, 31, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: rgba(31, 31, 33, 0.96);
  border-bottom: 1px solid var(--line);
  color: #fff;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.product-mark {
  align-items: center;
  display: flex;
  gap: 12px;
}

.product-mark__logo {
  align-items: center;
  background: transparent;
  border-radius: 8px;
  color: var(--gold);
  display: grid;
  font-size: 20px;
  font-weight: 900;
  height: 40px;
  letter-spacing: 0;
  place-items: center;
  width: 84px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

.topbar p {
  color: #cfc7bb;
}

.save-note {
  color: #d7cec0;
  font-size: 12px;
  max-width: 260px;
  text-align: right;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.topbar__actions,
.card-head,
.section-head--row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.primary-button,
.ghost-button {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 8px;
  min-height: 38px;
  padding: 9px 14px;
  text-decoration: none;
}

.primary-button {
  background: var(--gold);
  border: 1px solid var(--gold);
  color: #fff;
}

.ghost-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 73px);
}

.sidebar {
  background: #1f1f21;
  border-right: 1px solid var(--line);
  padding: 18px;
}

.tab {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #d6d0c8;
  cursor: pointer;
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  padding: 11px 12px;
  text-align: left;
  width: 100%;
}

.tab.is-active {
  background: #2b2b2e;
  box-shadow: inset 3px 0 0 var(--gold);
  color: #fff;
}

.content {
  padding: 22px;
}

.filter-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
  padding: 14px;
}

.notice {
  background: #fff8eb;
  border: 1px solid #f1d7a2;
  border-radius: 8px;
  color: #6d4b09;
  margin-bottom: 16px;
  padding: 10px 12px;
}

.notice.is-ok {
  background: #edf8f0;
  border-color: #b9e5c3;
  color: #176230;
}

.notice.is-error {
  background: #fff1f0;
  border-color: #f3b4ae;
  color: var(--red);
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.section-head {
  margin-bottom: 18px;
}

.section-head--compact {
  margin-top: 18px;
}

.section-head p {
  margin-top: 6px;
}

.subtabs {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow: auto;
}

.subtab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 12px 14px;
  white-space: nowrap;
}

.subtab.is-active {
  border-bottom-color: var(--gold);
  color: var(--ink);
}

.settings-panel {
  display: none;
}

.settings-panel.is-active {
  display: block;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1.1;
  margin-top: 8px;
}

.metric strong::after {
  background: var(--gold);
  content: "";
  display: block;
  height: 3px;
  margin-top: 10px;
  width: 42px;
}

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

.card {
  padding: 16px;
}

.card-head {
  margin-bottom: 12px;
}

.form-grid {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 18px;
}

label {
  color: #32413b;
  display: grid;
  font-weight: 700;
  gap: 7px;
}

.span-2 {
  grid-column: span 2;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 9px;
}

input,
textarea {
  background: #fff;
  border: 1px solid #cfd9d4;
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

select {
  background: #fff;
  border: 1px solid #cfc7bb;
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

.inline-actions {
  display: flex;
  gap: 10px;
}

input[type="color"] {
  min-height: 40px;
  padding: 4px;
}

input[type="checkbox"] {
  height: 17px;
  min-height: 17px;
  width: 17px;
}

textarea {
  resize: vertical;
}

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

.table-wrap--embedded {
  box-shadow: none;
  margin-top: 14px;
}

table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

.table-wrap--narrow table {
  min-width: 620px;
}

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

th {
  background: #f8fbf9;
  color: #53615d;
  font-size: 12px;
  text-transform: uppercase;
}

td input {
  min-width: 120px;
}

.small-action {
  background: transparent;
  border: 0;
  color: var(--red);
  cursor: pointer;
  font-weight: 800;
  padding: 9px;
}

.code-block {
  background: #1f1f21;
  border-radius: 8px;
  color: #e9fff5;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  min-height: 130px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.event-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: 360px;
  overflow: auto;
}

.stack-card {
  margin-top: 16px;
}

.event-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.event-item strong {
  display: block;
  margin-bottom: 3px;
}

.event-item span {
  color: var(--muted);
  font-size: 12px;
}

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

  .sidebar {
    border-right: 0;
    display: flex;
    gap: 8px;
    overflow: auto;
    padding: 12px;
  }

  .tab {
    margin-bottom: 0;
    white-space: nowrap;
    width: auto;
  }

  .metric-grid,
  .split-grid,
  .embed-grid,
  .form-grid,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar__actions {
    width: 100%;
  }

  .primary-button,
  .ghost-button {
    justify-content: center;
    width: 100%;
  }

  .content {
    padding: 14px;
  }
}
