:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #182033;
  --muted: #657184;
  --line: #dce3ed;
  --accent: #0f766e;
  --blue: #2563eb;
  --gold: #a16207;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --done: #166534;
  --done-soft: #dcfce7;
  --shadow: 0 14px 32px rgba(24, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.10), transparent 300px),
    var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.auth {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-size: 28px;
}

.auth-card p {
  margin: 0 0 8px;
  color: var(--muted);
}

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

.auth-card input,
.search-box,
.modal input,
.modal textarea,
.modal select,
.credential-value,
.company-note {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.auth-card input,
.search-box,
.modal input,
.modal select {
  height: 42px;
  padding: 0 12px;
}

.auth-card input:focus,
.search-box:focus,
.modal input:focus,
.modal textarea:focus,
.modal select:focus,
.credential-value:focus,
.company-note:focus {
  border-color: rgba(15, 118, 110, 0.64);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.auth-actions,
.toolbar,
.control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-actions {
  justify-content: flex-end;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.1;
  letter-spacing: 0;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.toolbar {
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.icon-button,
.small-button,
.small-icon {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  border-radius: 8px;
}

.primary-button {
  min-width: 84px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.20);
}

.ghost-button,
.icon-button {
  min-width: 42px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
}

.small-button,
.small-icon,
.drag-handle {
  color: var(--muted);
  background: #f4f6fa;
}

.small-button {
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.small-icon,
.drag-handle {
  width: 30px;
  min-height: 30px;
  border-radius: 7px;
  font-size: 16px;
}

.drag-handle {
  display: inline-grid;
  place-items: center;
  cursor: grab;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 0 0 18px;
}

.control-actions {
  justify-content: flex-end;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.column {
  min-height: 560px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.column.drop-target {
  outline: 2px solid rgba(15, 118, 110, 0.45);
  outline-offset: 2px;
}

.column-header,
.column-tools,
.company-head,
.company-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.column-header,
.company-head {
  justify-content: space-between;
}

.column-header {
  padding: 2px 2px 12px;
}

.column-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  margin: 0;
  font-size: 17px;
}

.dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.column[data-category="innovation"] .dot {
  background: var(--blue);
}

.column[data-category="specialized"] .dot {
  background: var(--gold);
}

.count {
  display: inline-grid;
  min-width: 34px;
  height: 28px;
  place-items: center;
  color: var(--muted);
  background: #f0f3f8;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.company-list {
  min-height: 470px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.company {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(24, 32, 51, 0.07);
}

.company.complete {
  border-color: rgba(22, 101, 52, 0.28);
  background: linear-gradient(180deg, rgba(220, 252, 231, 0.42), #fff 116px);
}

.company.dragging {
  opacity: 0.55;
}

.company-name {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.35;
  user-select: text;
}

.company-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.company-note {
  min-height: 42px;
  margin: 7px 0 12px;
  padding: 8px 10px;
  color: var(--muted);
  background: #f7f9fc;
  border-color: transparent;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

.company-meta,
.credential-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.company-meta {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.status-pill {
  width: fit-content;
  padding: 4px 8px;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.company.complete .status-pill {
  color: var(--done);
  background: var(--done-soft);
}

.materials-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.credential-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  padding: 6px 8px;
  background: #f7f9fc;
  border-radius: 8px;
}

.credential-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.credential-value {
  overflow: hidden;
  background: transparent;
  border-color: transparent;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  padding: 4px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: text;
}

.progress-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.progress {
  height: 8px;
  overflow: hidden;
  background: #edf1f6;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.2s ease;
}

.progress-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-panel[hidden] {
  display: none;
}

.file-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-item {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  gap: 8px;
  align-items: start;
  min-height: 30px;
}

.file-item input {
  width: 18px;
  height: 18px;
  margin: 5px 0 0;
  accent-color: var(--accent);
}

.file-name {
  min-width: 0;
  padding-top: 4px;
  color: var(--ink);
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.55;
  user-select: text;
}

.file-item input:checked + .file-name {
  color: var(--muted);
  text-decoration: line-through;
}

.add-file {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  margin-top: 10px;
}

.add-file input {
  height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.empty {
  display: grid;
  min-height: 170px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  border: 1px dashed #c7d0dd;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
}

.backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: start;
  justify-items: center;
  overflow: auto;
  padding: 20px;
  background: rgba(15, 23, 42, 0.40);
  z-index: 10;
}

.backdrop.open {
  display: grid;
}

.modal {
  width: min(580px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.28);
}

.modal-header {
  position: sticky;
  top: -20px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 0 0 12px;
  margin-bottom: 16px;
  background: #fff;
}

.modal h2 {
  margin: 0;
  font-size: 20px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.modal textarea {
  min-height: 100px;
  max-height: 240px;
  resize: vertical;
  padding: 10px 12px;
}

#companyFiles,
#defaultFilesEdit {
  min-height: 150px;
}

.modal-actions {
  position: sticky;
  bottom: -20px;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px -20px -20px;
  padding: 14px 20px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: none;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 14px;
  color: #fff;
  background: #172033;
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
  font-size: 14px;
  z-index: 20;
}

.toast.show {
  display: block;
}

@media (max-width: 1020px) {
  .topbar,
  .controls,
  .board {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .control-actions {
    justify-content: flex-start;
  }

  .column {
    min-height: 360px;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 16px;
  }

  .toolbar,
  .control-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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