/* =====================================================
   劳务资源评级看板 — 建筑工业风格
   Industrial slate + Safety orange palette
   ===================================================== */

:root {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-header: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #334155 100%);
  --bg-blueprint:
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(100,116,139,0.05) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(100,116,139,0.05) 32px);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #cbd5e1;
  --border-light: #e2e8f0;
  --border-strong: #64748b;
  --accent-color: #334155;
  --accent-hover: #1e293b;
  --accent-soft: rgba(100,116,139,0.12);
  --highlight-color: #ea580c;
  --highlight-hover: #c2410c;
  --highlight-soft: rgba(234,88,12,0.12);
  --success-color: #15803d;
  --success-soft: rgba(21,128,61,0.12);
  --warning-color: #ea580c;
  --warning-soft: rgba(234,88,12,0.12);
  --danger-color: #b91c1c;
  --danger-soft: rgba(185,28,28,0.10);
  --info-color: #1d4ed8;
  --info-soft: rgba(29,78,216,0.10);
  --shadow: 0 4px 16px rgba(15,23,42,0.10);
  --shadow-card: 0 1px 2px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-hover: 0 12px 28px rgba(15,23,42,0.16);
  --focus-ring: 0 0 0 3px rgba(234,88,12,0.40);
  --table-header-bg: #f1f5f9;
  --table-row-hover: #fef7f0;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --transition-fast: 150ms cubic-bezier(0.4,0,0.2,1);
  --transition-base: 240ms cubic-bezier(0.32,0.72,0,1);
  --transition-slow: 420ms cubic-bezier(0.32,0.72,0,1);
  --mono-font: "JetBrains Mono","Fira Code","Cascadia Code","Consolas",monospace;
}

[data-theme="dark"] {
  --bg-primary: #0b1220;
  --bg-secondary: #131a2b;
  --bg-card: #131a2b;
  --bg-header: linear-gradient(135deg, #020617 0%, #0f172a 55%, #1e293b 100%);
  --bg-blueprint:
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(148,163,184,0.05) 32px),
    repeating-linear-gradient(90deg, transparent, transparent 31px, rgba(148,163,184,0.05) 32px);
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --border-light: #1e293b;
  --border-strong: #94a3b8;
  --accent-color: #cbd5e1;
  --accent-hover: #e2e8f0;
  --accent-soft: rgba(203,213,225,0.10);
  --highlight-color: #fb923c;
  --highlight-hover: #fdba74;
  --highlight-soft: rgba(251,146,60,0.16);
  --success-color: #4ade80;
  --success-soft: rgba(74,222,128,0.16);
  --warning-color: #fb923c;
  --warning-soft: rgba(251,146,60,0.16);
  --danger-color: #f87171;
  --danger-soft: rgba(248,113,113,0.16);
  --info-color: #60a5fa;
  --info-soft: rgba(96,165,250,0.16);
  --shadow: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-hover: 0 12px 28px rgba(0,0,0,0.6);
  --focus-ring: 0 0 0 3px rgba(251,146,60,0.45);
  --table-header-bg: #1e2944;
  --table-row-hover: rgba(251,146,60,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei","PingFang SC","Inter",-apple-system,BlinkMacSystemFont,sans-serif;
  background: var(--bg-primary);
  background-image: var(--bg-blueprint);
  color: var(--text-primary);
  transition: background var(--transition-base), color var(--transition-base);
  overflow-x: hidden;
  font-feature-settings: "tnum" on, "lnum" on, "ss01" on;
  -webkit-font-smoothing: antialiased;
}

:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Header */
.header {
  background: var(--bg-header);
  color: #fff;
  padding: 22px 32px;
  position: relative;
  border-bottom: 1px solid rgba(234,88,12,0.4);
  box-shadow: inset 0 -3px 0 var(--highlight-color);
}
.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-blueprint);
  opacity: 0.5;
  pointer-events: none;
}
.header > * { position: relative; z-index: 1; }
.header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.header h1::before {
  content: '\258E';
  color: var(--highlight-color);
  margin-right: 8px;
  font-weight: 400;
}
.header p {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 8px;
  letter-spacing: 0.06em;
  font-family: var(--mono-font);
}

/* Tabs */
.tabs-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.tabs { display: flex; }
.tab-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
.tab {
  padding: 14px 22px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--text-secondary);
  min-height: 48px;
  letter-spacing: 0.02em;
  transition: all var(--transition-fast);
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--highlight-color);
  font-weight: 700;
}

.tab-actions select,
.tab-actions .theme-btn,
.tab-actions .export-btn {
  min-height: 38px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}
.tab-actions .theme-btn {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}
.tab-actions .theme-btn:hover,
.tab-actions .export-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Upload */
.upload-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-primary);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  position: relative;
}
.upload-btn {
  background: var(--highlight-color);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.upload-btn:hover {
  background: var(--highlight-hover);
  transform: translateY(-1px);
}
.upload-status {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono-font);
}
.upload-status.success { color: var(--success-color); }
.upload-status.error { color: var(--danger-color); }

/* Panels */
.panel { display: none; padding: 24px 28px; animation: panelIn var(--transition-slow) ease-out; }
.panel.active { display: block; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Overview Header */
.overview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-color);
  position: relative;
}
.overview-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--highlight-color);
}
.overview-header h3 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 12px;
}
.overview-header h3::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 24px;
  background: var(--highlight-color);
  border-radius: 1px;
}

/* Search */
.search-box input {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-width: 220px;
  transition: border-color var(--transition-fast);
}
.search-box input:focus {
  border-color: var(--highlight-color);
  box-shadow: 0 0 0 2px var(--highlight-soft);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  transition: box-shadow var(--transition-base), transform var(--transition-base), border-color var(--transition-base);
  position: relative;
  overflow: hidden;
}
.chart-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 22px;
  right: 22px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-color), var(--highlight-color));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform var(--transition-slow);
}
.chart-container:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.chart-container:hover::before { transform: scaleX(1); }
.chart-container h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-container h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--highlight-color);
  border-radius: 1px;
}
.chart-box { width: 100%; height: 320px; }
.chart-box.tall { height: 400px; }
.chart-full { grid-column: 1 / -1; }

/* Cards / KPI */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  cursor: default;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-color);
  opacity: 0;
  transition: opacity var(--transition-base), width var(--transition-base);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}
.card:hover::before { opacity: 1; width: 6px; }
.card.card-a::before { background: var(--success-color); opacity: 1; width: 6px; }
.card.card-b::before { background: var(--info-color); opacity: 1; width: 6px; }
.card.card-c::before { background: var(--warning-color); opacity: 1; width: 6px; }
.card.card-danger::before { background: var(--danger-color); opacity: 1; width: 6px; }
.card.card-highlight {
  border-color: rgba(234,88,12,0.3);
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--highlight-soft) 200%);
}
.card .label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-family: var(--mono-font);
}
.card .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.card .sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-family: var(--mono-font);
}

/* Filters */
.filters {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--highlight-color);
}
.filters label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.10em;
  font-family: var(--mono-font);
}
.filters select {
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  min-height: 38px;
  font-weight: 500;
  transition: border-color var(--transition-fast);
}
.filters select:focus {
  border-color: var(--highlight-color);
  box-shadow: 0 0 0 2px var(--highlight-soft);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  font-size: 13px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}
th {
  background: var(--table-header-bg);
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  border-bottom: 2px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th:hover { background: var(--highlight-soft); }
th .sort-arrow { margin-left: 4px; opacity: 0.4; font-size: 10px; }
th.sorted .sort-arrow { opacity: 1; color: var(--highlight-color); }
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
tr { transition: background var(--transition-fast); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--table-row-hover); }
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono-font);
  font-weight: 500;
}
.text-ellipsis {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rating Badges */
.rating {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-family: var(--mono-font);
}
.rating-a { background: var(--success-soft); color: var(--success-color); border: 1px solid rgba(21,128,61,0.3); }
.rating-b { background: var(--info-soft); color: var(--info-color); border: 1px solid rgba(29,78,216,0.3); }
.rating-c { background: var(--warning-soft); color: var(--warning-color); border: 1px solid rgba(234,88,12,0.3); }
.rating-stop { background: var(--danger-soft); color: var(--danger-color); border: 1px solid rgba(185,28,28,0.3); }

/* Detail Layout */
.detail-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}
.detail-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-header h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}
.sidebar-header .search-box input {
  width: 100%;
  min-width: 0;
  margin-bottom: 8px;
  padding: 6px 12px;
  font-size: 12px;
}
.sidebar-filters {
  display: flex;
  gap: 6px;
}
.sidebar-filters select {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
}
.company-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.company-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 4px;
  border-left: 3px solid transparent;
}
.company-item:hover {
  background: var(--highlight-soft);
  border-left-color: var(--highlight-color);
}
.company-item.active {
  background: var(--highlight-soft);
  border-left-color: var(--highlight-color);
  font-weight: 600;
}
.company-item .ci-region {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono-font);
  letter-spacing: 0.08em;
}
.company-item .ci-name {
  font-size: 13px;
  color: var(--text-primary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.company-item .ci-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Detail Main */
.detail-main {
  overflow-y: auto;
  padding: 4px;
}
.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.detail-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-section h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--highlight-color);
  border-radius: 1px;
}

/* Score Gauge */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.score-item {
  text-align: center;
  padding: 14px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
.score-item .score-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono-font);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.score-item .score-value {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.score-item .score-value.good { color: var(--success-color); }
.score-item .score-value.mid { color: var(--warning-color); }
.score-item .score-value.bad { color: var(--danger-color); }
.score-item .score-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}
.score-item .score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-slow);
}

/* Money Cards */
.money-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.money-item {
  padding: 14px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}
.money-item .money-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono-font);
  margin-bottom: 4px;
}
.money-item .money-value {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono-font);
}
.money-item .money-value.negative { color: var(--danger-color); }
.money-item .money-value.positive { color: var(--success-color); }
.money-item .money-value.zero { color: var(--text-muted); }

/* Project Tags */
.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.project-tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--info-soft);
  color: var(--info-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}
.project-tag.completed {
  background: var(--success-soft);
  color: var(--success-color);
}
.project-tag.active-tag {
  background: var(--warning-soft);
  color: var(--warning-color);
}

/* Risk Banner */
.risk-banner {
  background: var(--danger-soft);
  border-left: 4px solid var(--danger-color);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--danger-color);
  font-weight: 600;
}
.note-banner {
  background: var(--highlight-soft);
  border-left: 4px solid var(--highlight-color);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 13px;
  gap: 10px;
  height: 100%;
}
.empty-state .icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--highlight-soft);
  border: 2px solid var(--highlight-color);
  border-radius: 50%;
  color: var(--highlight-color);
  font-size: 20px;
  font-weight: 800;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 0;
  border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover { background: var(--highlight-color); }

/* Responsive */
@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .chart-full { grid-column: 1; }
  .header { flex-direction: column; gap: 10px; text-align: center; }
  .tabs-bar { flex-wrap: wrap; padding: 8px 12px; }
  .tabs { flex-wrap: wrap; }
  .tab { padding: 10px 14px; font-size: 12px; }
  .detail-layout { grid-template-columns: 1fr; height: auto; }
  .detail-sidebar { max-height: 300px; }
  .overview-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
