:root {
  --ink: #1a2332;
  --ink-soft: #4a5568;
  --muted: #7a8699;
  --line: #e4e9f0;
  --line-strong: #cfd8e3;
  --bg: #f0f3f7;
  --bg-elevated: #ffffff;
  --panel: #eef3f7;
  --brand: #0d7a6f;
  --brand-deep: #095a52;
  --brand-soft: #e6f5f3;
  --brand-mid: #2a9d8f;
  --accent: #c45c26;
  --accent-soft: #fdf0e9;
  --warn: #b45309;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ccc-blue: #5b7cfa;
  --shadow: 0 1px 2px rgba(26, 35, 50, 0.05), 0 10px 28px rgba(26, 35, 50, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font-ui: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-display: "Fraunces", "Noto Serif SC", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background:
    radial-gradient(70% 80% at 0% 0%, rgba(91, 124, 250, 0.08), transparent 50%),
    radial-gradient(60% 70% at 100% 0%, rgba(42, 157, 143, 0.1), transparent 45%),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  position: relative;
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

/* Top bar — full width workbench */
.topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(240px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  position: relative;
  z-index: 2;
  border-bottom: 1px solid rgba(228, 233, 240, 0.9);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  animation: fadeSlide 0.4s ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--brand-mid), var(--brand-deep));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(13, 122, 111, 0.28);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  box-shadow: var(--shadow);
  max-width: 560px;
  width: 100%;
  justify-self: stretch;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrap:focus-within {
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.15);
}

.search-wrap svg {
  flex-shrink: 0;
  color: var(--muted);
}

.search-wrap input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 11px 0;
  min-width: 0;
}

.search-wrap input::placeholder {
  color: #9aa6b5;
}

.search-clear {
  border: 0;
  background: var(--panel);
  color: var(--ink-soft);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  place-items: center;
  padding: 0;
  line-height: 1;
}

.search-clear.visible {
  display: grid;
}

/* Three-column board */
.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(340px, 1.2fr) minmax(280px, 0.85fr);
  gap: 12px;
  padding: 12px 16px 16px;
  position: relative;
  z-index: 1;
  animation: fadeSlide 0.45s ease 0.05s both;
}

.col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.col-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0%, #fafbfc 100%);
}

.col-kicker {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--brand-mid);
  font-weight: 700;
  text-transform: uppercase;
}

.col-title {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 750;
}

.col-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.block-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  border: 1px solid #f3d5c2;
  white-space: nowrap;
}

.filters {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}

.chip {
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 560;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--brand-mid);
  color: var(--brand);
}

.chip.active {
  background: var(--brand-soft);
  border-color: rgba(13, 122, 111, 0.35);
  color: var(--brand-deep);
}

.col-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px 14px;
  scroll-behavior: smooth;
}

.col-body::-webkit-scrollbar {
  width: 6px;
}

.col-body::-webkit-scrollbar-thumb {
  background: #c5d0dc;
  border-radius: 99px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(13, 122, 111, 0.28);
}

.card.open {
  border-color: rgba(13, 122, 111, 0.4);
}

.card-head {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 11px 12px;
  cursor: pointer;
}

.card-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  margin: 0 0 4px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 10.5px;
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 560;
}

.tag.note {
  color: var(--warn);
  background: #fff7ed;
}

.card-toggle {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--panel);
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: transform 0.2s;
  margin-top: 1px;
}

.card.open .card-toggle {
  transform: rotate(180deg);
  background: var(--brand-soft);
  color: var(--brand);
}

.card-body {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px dashed var(--line);
}

.card.open .card-body {
  display: block;
  animation: fadeSlide 0.22s ease both;
}

.content-text {
  margin: 10px 0;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12.5px;
}

.line-item {
  position: relative;
  padding: 8px 10px;
  margin: 6px 0;
  background: var(--panel);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand-mid);
  color: var(--ink);
  font-size: 12.5px;
}

.line-item.line-ok {
  border-left-color: var(--ok);
  background: #ecfdf3;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.btn:hover {
  border-color: var(--brand-mid);
  color: var(--brand-deep);
  background: var(--brand-soft);
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.primary:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: #fff;
}

.btn.copied {
  background: #ecfdf3;
  border-color: #abefc6;
  color: var(--ok);
}

.group {
  margin-bottom: 12px;
}

.group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 2px 8px;
}

.group-title h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-deep);
}

.group-title span {
  font-size: 11px;
  color: var(--muted);
}

.group.forbidden .card {
  border-color: #f9cbc7;
  background: linear-gradient(180deg, #fff 0%, #fffafa 100%);
}

.group.forbidden .tag {
  background: var(--danger-soft);
  color: var(--danger);
}

.group.forbidden .line-item:not(.line-ok) {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.order-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-form {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.order-form label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.order-form .field {
  display: flex;
  gap: 6px;
}

.order-form input {
  flex: 1;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
  background: #fff;
  min-width: 0;
}

.order-form input:focus {
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.12);
}

.placeholder-card {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(248, 250, 252, 0.9);
}

.placeholder-card.compact h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.placeholder-card.compact p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.hint-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.hint-list li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}

.hint-list li::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--brand-mid);
  flex-shrink: 0;
}

.state-box {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.state-box strong {
  display: block;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mark {
  background: #fef3c7;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mid width: stack order under scripts/knowledge */
@media (max-width: 1100px) {
  .board {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .col-orders {
    grid-column: 1 / -1;
    max-height: 240px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .search-wrap {
    max-width: none;
    justify-self: stretch;
  }
}

/* Narrow fallback */
@media (max-width: 720px) {
  .board {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow: auto;
  }

  .col {
    min-height: 420px;
  }

  .col-orders {
    max-height: none;
    min-height: 280px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
