:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #dde3ee;
  --text: #10223a;
  --muted: #617287;
  --brand: #0f766e;
  --warn: #d14343;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #e8f7f5 0%, var(--bg) 36%);
  color: var(--text);
  font: 14px/1.5 "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
}

.hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.auth-card h2 {
  margin: 0 0 4px;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.auth-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.auth-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.lang-btn {
  min-width: 44px;
  height: 36px;
  border: none;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.lang-btn:last-child {
  border-right: none;
}

.lang-btn.active {
  background: var(--brand);
  color: #fff;
}

.header h1 {
  margin: 0;
}

.header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.tool-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.tab {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.panel {
  display: none;
  gap: 14px;
}

.panel.active {
  display: grid;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

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

.form-grid h2 {
  grid-column: 1 / -1;
  margin: 0 0 6px;
}

.form-hint {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  background: #fff;
}

.form-grid input[readonly] {
  background: #f3f6fb;
  color: #1e3550;
}

.form-grid textarea {
  resize: vertical;
  min-height: 80px;
}

.full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

button {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}

a {
  color: var(--brand);
}

.task-status-select {
  min-width: 120px;
  margin-right: 6px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-weight: 500;
}

.delete-btn {
  background: var(--warn);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.data-box {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #0f172a;
  color: #d6f3ff;
}

.mono {
  font-family: "JetBrains Mono", "SF Mono", Menlo, monospace;
}

.hide {
  display: none !important;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  height: 420px;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 2px;
}

.slot-card {
  border-radius: 10px;
  border: 1px solid #c9d3e3;
  background: #ffffff;
  color: #132744;
  padding: 8px 10px;
  height: 128px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
}

.slot-card.normal {
  border-color: #9ac7aa;
  background: #eaf8ef;
}

.slot-card.bad {
  border-color: #f1a3a3;
  background: #fdeaea;
}

.slot-card.empty {
  border-color: #d7e0ef;
  background: #ffffff;
}

.slot-card h4 {
  margin: 0 0 5px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-card p {
  margin: 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-scroll {
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-table {
  min-width: 1320px;
  background: #fff;
}

.detail-table th,
.detail-table td {
  white-space: nowrap;
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.dashboard-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px 10px;
}

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

.dashboard-item strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: var(--text);
  word-break: break-all;
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 2px;
}

.deck-card {
  border: 1px solid #cbd8ea;
  border-radius: 10px;
  background: #f5f9ff;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
}

.deck-card.normal {
  border-color: #d7e0ef;
  background: #ffffff;
}

.deck-card.bad {
  border-color: #f1a3a3;
  background: #fdeaea;
}

.deck-card.empty {
  border-color: #d7e0ef;
  background: #ffffff;
}

.deck-card h4 {
  margin: 0 0 5px;
  font-size: 13px;
}

.deck-card p {
  margin: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.scan-modal.hidden {
  display: none;
}

.scan-modal-content {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
}

.scan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.scan-header h3 {
  margin: 0;
  font-size: 16px;
}

.scan-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.scan-body {
  padding: 18px;
}

.scan-video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.scan-video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-region {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border: 2px solid #0f766e;
  border-radius: 12px;
  overflow: hidden;
}

.scan-region::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  width: 20px;
  height: 20px;
  border-top: 3px solid #0f766e;
  border-left: 3px solid #0f766e;
}

.scan-region::after {
  content: "";
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-bottom: 3px solid #0f766e;
  border-right: 3px solid #0f766e;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #0f766e;
  animation: scanMove 2s linear infinite;
}

@keyframes scanMove {
  0% { top: 0; opacity: 1; }
  100% { top: 100%; opacity: 0.5; }
}

.scan-hint {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px;
}

.scan-result {
  margin-top: 14px;
  display: grid;
  gap: 6px;
}

.scan-result label {
  color: var(--muted);
  font-size: 13px;
}

.scan-result input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: monospace;
  background: #f3f6fb;
}

.scan-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.scan-actions button {
  flex: 1;
  padding: 10px;
  font-size: 14px;
}

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

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

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: 380px;
    max-height: 380px;
  }

  .deck-grid {
    grid-template-columns: 1fr;
    max-height: 260px;
  }
}
