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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #1f2937;
  line-height: 1.5;
}

/* Header → Topbar */
.topbar {
  height: 48px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-text {
  font-size: 16px;
  font-weight: 600;
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.topbar-right #last-update {
  opacity: 0.8;
}
.btn-refresh {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}
.btn-refresh:hover {
  background: rgba(255,255,255,0.35);
}

/* User Info */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.25);
}
.user-name {
  font-weight: 600;
  font-size: 13px;
}
.user-role {
  font-size: 11px;
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 10px;
}
.btn-logout {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}
.btn-logout:hover {
  background: rgba(220,38,38,0.6);
}

/* App Layout */
.app-layout {
  display: flex;
  margin-top: 48px;
  min-height: calc(100vh - 48px);
}

/* Sidebar */
.sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  position: fixed;
  top: 48px;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 90;
  transition: transform 0.3s ease;
}
.sidebar-nav {
  padding: 12px 0;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: #4b5563;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.nav-item:hover {
  background: #f0f7ff;
  color: #2563eb;
}
.nav-item.active {
  background: #eff6ff;
  color: #2563eb;
  border-left-color: #2563eb;
  font-weight: 600;
}
.nav-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 200px;
  padding: 20px 24px;
  min-width: 0;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 48px 0 0 0;
  background: rgba(0,0,0,0.3);
  z-index: 85;
  display: none;
}
.sidebar-overlay.show { display: block; }

/* KPI Cards */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px 24px;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: center;
}
.kpi-card .kpi-icon {
  font-size: 28px;
  margin-bottom: 6px;
}
.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0;
}
.kpi-card .kpi-label {
  font-size: 13px;
  color: #6b7280;
}
.kpi-value.blue { color: #2563eb; }
.kpi-value.green { color: #059669; }
.kpi-value.orange { color: #d97706; }
.kpi-value.red { color: #dc2626; }
.kpi-value.purple { color: #7c3aed; }

/* Tabs (legacy, kept for compatibility) */
.tab-bar { display: none; }
.tab-btn { display: none; }

/* Tab Content */
.tab-content {
  /* no extra padding, handled by main-content */
}

/* Chart Cards */
.chart-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.chart-row.single {
  grid-template-columns: 1fr;
}
.chart-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.chart-card.full {
  width: 100%;
}
.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
}
.chart-box {
  height: 280px;
}
.chart-box-tall {
  height: 360px;
}

/* Table */
.table-section {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-top: 16px;
}
.table-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
}
.table-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.filter-select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
  cursor: pointer;
}
.filter-select:focus {
  border-color: #3B82F6;
}

.gran-btn {
  padding: 4px 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.15s;
}
.gran-btn:hover { border-color: #3B82F6; color: #3B82F6; }
.gran-btn.active { background: #3B82F6; color: #fff; border-color: #3B82F6; }

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: #f9fafb;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
  user-select: none;
}
tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}
tbody tr:hover {
  background: #f0f7ff;
}
.cell-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Group rows (multi-lot projects) */
.group-header {
  background: #f0f4ff;
  border-left: 3px solid #3B82F6;
}
.group-header:hover {
  background: #e0eaff;
}
.group-header td {
  font-weight: 500;
}
.group-toggle {
  display: inline-block;
  width: 14px;
  font-size: 11px;
  color: #3B82F6;
  transition: transform 0.15s;
}
.group-lot-count {
  font-size: 12px;
  color: #6b7280;
  font-weight: 400;
}
.group-child {
  background: #fafbfc;
}
.group-child:hover {
  background: #f0f7ff;
}
.group-child td:first-child {
  padding-left: 28px;
}

/* Phase Pipeline */
.pp {
  min-width: 150px;
}
.pp-track {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
}
.pp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}
.pp-dot.done {
  background: #3B82F6;
}
.pp-dot.now {
  width: 10px;
  height: 10px;
  background: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.pp-bar {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  min-width: 12px;
}
.pp-bar.done {
  background: #3B82F6;
}
.pp-label {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}
.lot-default {
  color: #9ca3af;
}

/* Source Link */
.source-link {
  color: #3B82F6;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
}
.source-link:hover {
  text-decoration: underline;
  color: #1d4ed8;
}

/* Mini Table (smaller padding) */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.mini-table thead th {
  background: #f9fafb;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
.mini-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}
.mini-table tbody tr:hover {
  background: #f0f7ff;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-primary { background: #c7d2fe; color: #3730a3; }
.badge-muted { background: #f3f4f6; color: #6b7280; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-sky { background: #e0f2fe; color: #0369a1; }
.badge-indigo { background: #e0e7ff; color: #3730a3; }
.badge-stone { background: #f5f5f4; color: #57534e; }
.badge-slate { background: #f1f5f9; color: #475569; }

/* Priority row colors — 左侧细线指示，背景极淡 */
tr.priority-high { border-left: 3px solid #22c55e; background-color: rgba(34,197,94,0.04) !important; }
tr.priority-high:hover { background-color: rgba(34,197,94,0.08) !important; }
tr.priority-high.group-header { border-left: 3px solid #22c55e !important; background-color: rgba(34,197,94,0.04) !important; }
tr.priority-high.group-header:hover { background-color: rgba(34,197,94,0.08) !important; }
tr.priority-medium { border-left: 3px solid #eab308; background-color: rgba(234,179,8,0.04) !important; }
tr.priority-medium:hover { background-color: rgba(234,179,8,0.08) !important; }
tr.priority-medium.group-header { border-left: 3px solid #eab308 !important; background-color: rgba(234,179,8,0.04) !important; }
tr.priority-medium.group-header:hover { background-color: rgba(234,179,8,0.08) !important; }
tr.priority-low { border-left: 3px solid #f87171; background-color: rgba(248,113,113,0.04) !important; }
tr.priority-low:hover { background-color: rgba(248,113,113,0.08) !important; }
tr.priority-low.group-header { border-left: 3px solid #f87171 !important; background-color: rgba(248,113,113,0.04) !important; }
tr.priority-low.group-header:hover { background-color: rgba(248,113,113,0.08) !important; }

/* Tooltip (hover notes for CEO/PM) */
.has-tooltip {
  position: relative;
  cursor: default;
}
.cell-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.cell-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
}
.has-tooltip:hover .cell-tooltip {
  display: block;
}

/* Daily Reports */
.report-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.report-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.report-item:hover {
  background: #f0f7ff;
}
.report-date {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  padding: 4px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.report-info {
  flex: 1;
  min-width: 0;
}
.report-title {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-summary {
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-arrow {
  flex-shrink: 0;
  color: #9ca3af;
  font-size: 16px;
}

/* Person Section */
.person-section {
  margin-bottom: 24px;
}
.person-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 8px;
}
.person-stat {
  font-size: 13px;
  font-weight: 400;
  color: #6b7280;
}

/* Todo Section */
.todo-section {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}
.todo-section h3 {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 12px;
}

/* Empty hint */
.empty-hint {
  text-align: center;
  color: #9ca3af;
  padding: 40px;
  font-size: 14px;
}

/* Action Buttons */
.btn-add {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-add:hover {
  background: #1d4ed8;
}
.btn-action {
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-edit {
  background: #dbeafe;
  color: #1d4ed8;
}
.btn-edit:hover { opacity: 0.8; }
.btn-delete {
  background: #fee2e2;
  color: #991b1b;
}
.btn-delete:hover { opacity: 0.8; }

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #374151; }
.modal-content .form-group {
  padding: 0 24px;
  margin-top: 16px;
}
.modal-content .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.modal-content .form-group input,
.modal-content .form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}
.modal-content .form-group input:focus,
.modal-content .form-group select:focus {
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px;
}
.btn-cancel {
  padding: 8px 20px;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.btn-cancel:hover { background: #e5e7eb; }
.btn-submit {
  padding: 8px 24px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn-submit:hover { background: #1d4ed8; }


/* Dashboard KPI Cards */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.dash-kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
}
.dash-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.dash-kpi-card.accent-blue::before { background: #2563eb; }
.dash-kpi-card.accent-green::before { background: #059669; }
.dash-kpi-card.accent-orange::before { background: #d97706; }
.dash-kpi-card.accent-red::before { background: #dc2626; }
.dash-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.dash-kpi-label {
  font-size: 13px;
  color: #6b7280;
}
.dash-kpi-icon {
  font-size: 22px;
  opacity: 0.5;
}
.dash-kpi-value {
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 4px;
}
.dash-kpi-sub {
  font-size: 12px;
  color: #9ca3af;
}

/* Dashboard Chart Grid */
.dash-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

/* Dashboard List Grid */
.dash-list-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.dash-list-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  max-height: 380px;
  overflow-y: auto;
}
.dash-list-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-list-item {
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.dash-list-item:last-child { border-bottom: none; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar-toggle { display: block; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .main-content {
    margin-left: 0;
    padding: 12px;
  }
  .kpi-strip, .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi-card {
    padding: 14px 10px;
  }
  .kpi-card .kpi-value {
    font-size: 20px;
  }
  .kpi-card .kpi-label {
    font-size: 12px;
  }
  .dash-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-row, .dash-chart-grid {
    grid-template-columns: 1fr;
  }
  .dash-list-grid {
    grid-template-columns: 1fr;
  }
  /* 表格区域 */
  .table-section {
    padding: 10px;
    border-radius: 8px;
  }
  .table-toolbar {
    gap: 8px;
  }
  .table-toolbar .search-input,
  .table-toolbar input[type="text"] {
    width: 100% !important;
    min-width: 0;
  }
  .table-toolbar .filter-select,
  .table-toolbar select {
    min-width: 0;
    flex: 1;
  }

  /* 表格滑动提示 */
  .table-wrapper {
    position: relative;
  }
  .table-wrapper::after {
    content: '← 滑动查看更多 →';
    display: block;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    padding: 6px 0 2px;
    border-top: 1px solid #f3f4f6;
  }
  .table-wrapper.scrolled::after {
    display: none;
  }
  table {
    font-size: 12px;
  }
  table th, table td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  /* 图表区域 */
  .chart-card {
    padding: 12px;
  }
  .chart-box {
    height: 220px;
  }

  /* 顶栏按钮 */
  .topbar-right .btn-refresh {
    padding: 4px 10px;
    font-size: 12px;
  }

  /* 模态框 */
  .modal-content {
    width: 92%;
    margin: 10px auto;
    max-height: 90vh;
    overflow-y: auto;
  }
}
