:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #dde3ea;
  --brand: #176b5d;
  --brand-strong: #0f4f46;
  --danger: #b42318;
  --focus: #f2b84b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--brand-strong);
}

button.secondary {
  background: #eef2f6;
  color: var(--text);
}

button.secondary:hover {
  background: #e1e7ef;
}

button.danger {
  background: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input,
select {
  min-height: 38px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 3px solid rgba(242, 184, 75, 0.35);
  outline-offset: 1px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(31, 41, 51, 0.08);
}

.login-box h1,
.page-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.login-box p,
.page-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.field label {
  color: #344054;
  font-size: 14px;
}

.error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 14px;
}

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

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 0 20px;
}

.brand {
  font-weight: 700;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 14px 10px;
}

.nav-item {
  width: 100%;
  display: none;
  justify-content: center;
  margin-bottom: 6px;
  background: transparent;
  color: #344054;
  text-align: center;
}

.nav-item.visible {
  display: flex;
}

.nav-item.active {
  background: #e6f2ef;
  color: var(--brand-strong);
}

.content {
  min-width: 0;
  padding: 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin: 20px 0;
}

.toolbar .field {
  min-width: 180px;
  margin-top: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-top: 16px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.compact-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
}

.compact-form .wide {
  grid-column: span 2;
}

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

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

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

td.actions {
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  padding: 22px 0;
}

.muted {
  color: var(--muted);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.crumb {
  background: transparent;
  color: var(--brand);
  min-height: 30px;
  padding: 0 4px;
}

.crumb-separator {
  color: var(--muted);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #344054;
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.preview-box {
  min-height: 80px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 12px;
  white-space: pre-wrap;
}

.puzzle-list {
  display: grid;
  gap: 12px;
}

.puzzle-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.puzzle-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.puzzle-title {
  font-weight: 700;
}

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

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

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .topbar,
  .sidebar,
  .content {
    grid-column: 1;
  }

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item.visible {
    width: auto;
    white-space: nowrap;
  }

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

  .compact-form {
    grid-template-columns: 1fr;
  }

  .compact-form .wide {
    grid-column: auto;
  }
}
