:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --ink: #19201d;
  --muted: #65706b;
  --line: #d9e1dc;
  --accent: #1f7a62;
  --accent-dark: #155845;
  --warn: #b86222;
  --danger: #a64038;
  --shadow: 0 16px 36px rgba(25, 32, 29, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #17221e;
  color: #f6fbf8;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.06)),
    conic-gradient(from 210deg, #49b893, #e6b765, #366b8d, #49b893);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #a9bbb3;
  font-size: 13px;
  margin-top: 2px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c9d6d0;
  padding: 0 12px;
  text-align: left;
}

.nav-tab span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-tab.is-active,
.nav-tab:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.auth-panel {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.auth-panel label {
  color: #c9d6d0;
}

.auth-panel input {
  margin-top: 6px;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.topbar h1,
.section-head h2,
.drop-panel h2,
.panel h2 {
  margin: 4px 0 0;
  letter-spacing: 0;
}

.topbar h1 {
  max-width: 760px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.02;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions,
.pager,
.field-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.tab-panel,
.panel,
.drop-panel,
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 94px;
  padding: 18px;
}

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

.metric strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 30px;
  line-height: 1;
}

.metric small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.tab-panel {
  display: none;
  padding: 20px;
}

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

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.button,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.button.primary {
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary,
.icon-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  max-width: 320px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

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

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

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

td {
  color: #2d3733;
}

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
}

.editor,
.panel,
.drop-panel {
  padding: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.45;
}

.editor {
  display: grid;
  gap: 14px;
  align-content: start;
}

.field-row {
  align-items: start;
}

.field-row label {
  flex: 1;
}

.token-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.token-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 0 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.panel-stack {
  display: grid;
  gap: 18px;
}

.item-list,
.task-list {
  display: grid;
  gap: 10px;
}

.item,
.task-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.item-header,
.task-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.item-title {
  font-weight: 800;
}

.item-meta,
.task-body,
.empty-cell {
  color: var(--muted);
  font-size: 13px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.drop-panel {
  min-height: 220px;
}

.drop-panel input {
  margin: 20px 0;
}

canvas {
  display: block;
  width: 100%;
  min-height: 150px;
  margin: 6px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f3f7f5);
}

.status-success {
  color: var(--accent-dark);
}

.status-failure {
  color: var(--danger);
}

.status-working {
  color: var(--warn);
}

@media (max-width: 960px) {
  .app-shell,
  .split-layout,
  .upload-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

  .topbar,
  .section-head,
  .field-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .nav-tabs {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 30px;
  }

  .pager,
  .topbar-actions {
    flex-wrap: wrap;
  }
}
