:root {
  /* 调色板 */
  --bg-dark: #0f172a;
  --bg-gradient-1: #1e293b;
  --bg-gradient-2: #0f172a;
  
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(148, 163, 184, 0.1);
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.5);
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: rgba(148, 163, 184, 0.2);
  --input-focus: rgba(59, 130, 246, 0.5);

  --font-sans: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(239, 68, 68, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar (Slim & Glassy) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.3);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding: 0 4px;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(to right, #60a5fa, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

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

.badge {
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 99px;
  color: var(--text-muted);
  font-weight: 500;
  backdrop-filter: blur(4px);
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

h2 {
  margin: 0 0 20px;
  font-size: 16px;
  color: var(--text-main);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

h2::before {
  content: '';
  display: block;
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
}

/* Inputs & Forms */
.row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  outline: none;
  font-family: var(--font-mono);
  font-size: 13px;
  transition: all 0.15s ease;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input[type="file"] {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
}

input[type="file"]::file-selector-button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-right: 12px;
  transition: background 0.2s;
}

input[type="file"]::file-selector-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
}

.spacer {
  flex: 1;
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.inline .input {
  width: 130px;
  padding: 6px 10px;
}

/* Buttons */
.btn {
  border: 1px solid var(--input-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* Icon Buttons (for table actions) */
.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Table */
.tableWrap {
  overflow-x: auto;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(148, 163, 184, 0.2) transparent; /* Firefox */
}

.tableWrap.menu-open {
  /* 打开颜色菜单时临时增加底部空间，避免菜单被裁剪/必须滚动 */
  padding-bottom: 140px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.01);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.cellInput { width: 100px; }
.sheetInput { width: 140px; }
.paramInput { width: 260px; }

/* Fill color picker: one input + dropdown arrow + custom menu */
.color-picker {
  position: relative;
  display: inline-block;
}

.color-picker .paramInput {
  padding-right: 38px; /* 给右侧箭头留空间 */
}

.color-picker-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
}

.color-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.color-menu.up {
  top: auto;
  bottom: calc(100% + 8px);
}

.color-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
}

.color-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.color-menu-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.color-code {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 12px;
}

/* Actions column layout */
.actions-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px; /* 增加间距 */
}

.sort-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sort-wrap .icon-btn {
  width: 20px;
  height: 20px;
}

.sort-wrap .icon-btn svg {
  width: 14px;
  height: 14px;
}

/* Status & Footer */
.status {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 0 8px;
}

.errorBox {
  margin-top: 16px;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.hidden { display: none; }

.footer {
  margin-top: 40px;
  text-align: center;
  border-top: 1px solid var(--card-border);
  padding-top: 24px;
}

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

.hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 12px;
  display: block;
}

/* 自定义文件上传区域 */
.upload-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.file-label input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.file-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.2s;
}

.file-label:hover .file-btn {
  background: rgba(255, 255, 255, 0.12);
}

.file-names {
  color: var(--text-muted);
  font-size: 13px;
}

.upload-area .hint {
  margin-top: 4px;
}
