/* ===== CSS Variables ===== */
:root {
  --color-primary: #1677ff;
  --color-primary-light: #e6f0ff;
  --color-success: #00b96b;
  --color-warning: #faad14;
  --color-danger: #ff4d4f;
  --color-info: #722ed1;

  --color-bg: #f0f2f5;
  --color-card-bg: #ffffff;
  --color-text: #1f1f1f;
  --color-text-secondary: #8c8c8c;
  --color-border: #f0f0f0;

  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
}

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

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: var(--color-card-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  font-size: 24px;
}

.header-subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-clock {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
  letter-spacing: 1px;
}

.header-updated {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.updated-label {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.updated-time {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: #4096ff;
  border-color: #4096ff;
}

.btn-refresh:active {
  transform: scale(0.96);
}

.btn-refresh.spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== Grid Layout ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px 28px;
  max-width: 1600px;
  margin: 0 auto;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

/* ===== Card ===== */
.card {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-icon {
  font-size: 18px;
}

.card-body {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
  max-height: 420px;
}

/* ===== Badge ===== */
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-attendance {
  background: #f6ffed;
  color: var(--color-success);
}

.badge-automation {
  background: #f9f0ff;
  color: var(--color-info);
}

/* ===== Todo List ===== */
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.todo-item:last-child {
  border-bottom: none;
}

.todo-priority {
  width: 4px;
  min-height: 40px;
  border-radius: 2px;
  flex-shrink: 0;
}

.todo-priority.high { background: var(--color-danger); }
.todo-priority.medium { background: var(--color-warning); }
.todo-priority.low { background: var(--color-success); }

.todo-content {
  flex: 1;
  min-width: 0;
}

.todo-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.todo-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.todo-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.todo-tag.pending { background: #fff7e6; color: #d46b08; }
.todo-tag.processing { background: #e6f0ff; color: var(--color-primary); }
.todo-tag.done { background: #f6ffed; color: var(--color-success); }

.todo-deadline {
  color: var(--color-danger);
  font-weight: 500;
}

.todo-deadline.normal {
  color: var(--color-text-secondary);
  font-weight: normal;
}

/* ===== Attendance ===== */
.attendance-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.att-stat {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  background: #fafafa;
}

.att-stat .att-num {
  display: block;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.att-stat .att-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.att-present { background: #f6ffed; }
.att-present .att-num { color: var(--color-success); }
.att-late { background: #fffbe6; }
.att-late .att-num { color: var(--color-warning); }
.att-absent { background: #fff2f0; }
.att-absent .att-num { color: var(--color-danger); }
.att-leave { background: #f9f0ff; }
.att-leave .att-num { color: var(--color-info); }

.attendance-detail {
  max-height: 200px;
  overflow-y: auto;
}

.att-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.att-member:last-child {
  border-bottom: none;
}

.att-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.att-name {
  flex: 1;
  font-weight: 500;
}

.att-status-tag {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.att-status-tag.present { background: #f6ffed; color: var(--color-success); }
.att-status-tag.late { background: #fffbe6; color: #d46b08; }
.att-status-tag.absent { background: #fff2f0; color: var(--color-danger); }
.att-status-tag.leave { background: #f9f0ff; color: var(--color-info); }

.att-time {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 120px;
  text-align: right;
}

/* ===== Calendar ===== */
.cal-day-group {
  margin-bottom: 12px;
}

.cal-day-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 6px;
  padding-left: 4px;
}

.cal-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fafafa;
  margin-bottom: 6px;
  transition: background 0.15s;
}

.cal-event:hover {
  background: #f0f0f0;
}

.cal-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  padding-top: 1px;
}

.cal-event-content {
  flex: 1;
  min-width: 0;
}

.cal-event-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}

.cal-event-meta {
  font-size: 11px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Automation ===== */
.auto-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.auto-item:last-child {
  border-bottom: none;
}

.auto-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.auto-status-dot.active { background: var(--color-success); box-shadow: 0 0 6px rgba(0, 185, 107, 0.4); }
.auto-status-dot.paused { background: var(--color-text-secondary); }
.auto-status-dot.error { background: var(--color-danger); }

.auto-content {
  flex: 1;
  min-width: 0;
}

.auto-name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.auto-schedule {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.auto-next {
  font-size: 12px;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 100px;
}

/* ===== Goals ===== */
.goals-section {
  margin-bottom: 20px;
}

.goals-section:last-child {
  margin-bottom: 0;
}

.goals-subtitle {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-text);
}

.goal-item {
  margin-bottom: 14px;
}

.goal-item:last-child {
  margin-bottom: 0;
}

.goal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.goal-title {
  font-size: 13px;
  font-weight: 500;
}

.goal-percent {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.goal-progress {
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}

.goal-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  background: linear-gradient(90deg, var(--color-primary), #4096ff);
}

.goal-progress-bar.high { background: linear-gradient(90deg, var(--color-success), #52c41a); }
.goal-progress-bar.medium { background: linear-gradient(90deg, var(--color-warning), #ffc53d); }
.goal-progress-bar.low { background: linear-gradient(90deg, var(--color-danger), #ff7875); }

.goal-category {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f0f0f0;
  color: var(--color-text-secondary);
  margin-left: 6px;
}

/* ===== Loading & Empty ===== */
.loading-placeholder {
  text-align: center;
  padding: 40px 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.empty-placeholder {
  text-align: center;
  padding: 30px 0;
  color: var(--color-text-secondary);
  font-size: 13px;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.footer-sep {
  color: var(--color-border);
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .span-2 { grid-column: span 2; }
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .span-2 { grid-column: span 1; }
  .header {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }
  .header-right {
    flex-wrap: wrap;
    justify-content: center;
  }
  .attendance-summary {
    flex-wrap: wrap;
  }
  .att-stat {
    min-width: 45%;
  }
}

/* ===== Scrollbar ===== */
.card-body::-webkit-scrollbar {
  width: 4px;
}

.card-body::-webkit-scrollbar-track {
  background: transparent;
}

.card-body::-void-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 2px;
}

.card-body::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 2px;
}

.card-body::-webkit-scrollbar-thumb:hover {
  background: #bfbfbf;
}
