/* ==========================================================================
   TimeTrack - 现代响应式与移动端深度适配样式表
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --bottom-nav-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 应用容器：移动端限制最大宽度以保持舒适视觉 */
.app-container {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-main);
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 20px);
}

/* 顶部导航栏 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-main);
}

.brand-text .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.date-badge {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 9999px;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #f8fafc;
  color: var(--primary);
  border-color: var(--primary);
}

/* 内容主区域 */
.main-content {
  padding: 16px;
  flex: 1;
}

/* Tab 切换逻辑 */
.tab-view {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 今日状态大卡片 */
.today-card {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-radius: var(--border-radius-lg);
  padding: 22px 20px;
  margin-bottom: 18px;
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4);
}

.today-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.today-header .eyebrow {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.today-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2px;
}

.status-tag {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.status-tag.status-none {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.status-tag.status-working {
  background: #10b981;
  color: #ffffff;
  animation: pulse 2s infinite;
}

.status-tag.status-done {
  background: #38bdf8;
  color: #0f172a;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.today-metrics {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--border-radius-md);
  padding: 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
}

.metric-item {
  flex: 1;
  text-align: center;
}

.metric-label {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 2px;
}

.metric-val {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.metric-val.highlight {
  font-size: 1.45rem;
  color: #fde047;
}

.metric-unit {
  font-size: 0.75rem;
  margin-left: 2px;
  color: rgba(255, 255, 255, 0.9);
}

.metric-divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
}

.today-hint {
  margin-top: 12px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-clock-buttons {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.btn-clock {
  flex: 1;
  padding: 13px 10px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, opacity 0.15s;
}

.btn-clock:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #ffffff;
  color: var(--primary);
}

.btn-accent {
  background: #10b981;
  color: #ffffff;
}

/* 通用卡片 */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

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

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

/* 表单样式 */
.time-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label-with-action label,
.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-quick-fill {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 {
  flex: 1;
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 动态预览卡片 */
.calc-preview {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.preview-label {
  color: var(--text-muted);
}

.preview-val {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary);
}

.preview-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 8px;
}

.preview-formula {
  font-size: 0.8rem;
  color: var(--text-light);
}

.btn-block {
  width: 100%;
  height: 48px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background-color 0.2s, transform 0.1s;
}

.form-actions .btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.form-actions .btn-primary:active {
  background-color: var(--primary-hover);
  transform: scale(0.99);
}

/* 统计看板网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.kpi-card.highlight-kpi {
  grid-column: span 2;
  background: linear-gradient(135deg, #ffffff, #f0fdf4);
  border: 1.5px solid #86efac;
}

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

.kpi-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 9999px;
  font-weight: 600;
}

.kpi-body {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 10px 0 6px 0;
}

.kpi-val {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.highlight-kpi .kpi-val {
  color: #15803d;
  font-size: 2.2rem;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.kpi-footer {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar-wrap {
  flex: 1;
  height: 7px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #3b82f6);
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 柱状图展示 */
.chart-container {
  overflow-x: auto;
  padding: 10px 0;
}

.chart-legend {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.bar-col {
  flex: 1;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.bar-pill {
  width: 100%;
  max-width: 22px;
  background: #cbd5e1;
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease, background-color 0.2s;
  min-height: 2px;
}

.bar-col.active .bar-pill {
  background: var(--primary);
}

.bar-col.overtime .bar-pill {
  background: #10b981;
}

.bar-val {
  position: absolute;
  top: -20px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.bar-label {
  position: absolute;
  bottom: -22px;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 表格样式 */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: #f8fafc;
}

/* 明细卡片列表 (移动端优化) */
.records-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-item {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  transition: transform 0.1s;
}

.record-item:active {
  transform: scale(0.99);
}

.record-date-block {
  display: flex;
  flex-direction: column;
}

.record-date {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.record-day {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.record-times {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.time-chip {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.record-hours-block {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.record-hours {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.record-hours.empty {
  font-size: 0.85rem;
  color: var(--warning);
}

.record-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.btn-action-sm {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-action-sm:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-action-sm.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* 底部移动端导航 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 720px;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-light);
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.2s;
}

.nav-item span {
  font-size: 0.75rem;
  font-weight: 600;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active svg {
  stroke-width: 2.4;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-error {
  background: rgba(220, 38, 38, 0.95);
}

.toast.toast-success {
  background: rgba(16, 185, 129, 0.95);
}

/* 桌面端宽度适配 */
@media (min-width: 768px) {
  .app-container {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.04);
  }
}

/* ==================== 8.5h 智能下班推算卡片 ==================== */
.btn-delete-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(254, 202, 202, 0.4);
  border-radius: var(--border-radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete-icon:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.badge-target {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 9999px;
  display: inline-block;
}

.prediction-card {
  border: 1.5px solid #93c5fd;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  position: relative;
  overflow: hidden;
}

.prediction-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #3b82f6, #10b981);
}

.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--border-radius-md);
  margin-bottom: 16px;
  transition: all 0.3s;
}

.alert-banner.alert-success {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #166534;
}

.alert-banner.alert-warning {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #92400e;
}

.alert-banner.alert-info {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  color: #1e40af;
}

.banner-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.banner-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
}

.banner-desc {
  font-size: 0.82rem;
  opacity: 0.9;
  margin-top: 3px;
}

.pred-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.pred-metric-box {
  background: #f1f5f9;
  border-radius: var(--border-radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.pred-metric-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.pred-metric-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}

.pred-metric-val.highlight-blue {
  color: var(--primary);
}

.pred-metric-val.highlight-target {
  color: #16a34a;
  font-size: 1.35rem;
}

.pred-metric-val small {
  font-size: 0.75rem;
  font-weight: 500;
}

.sim-simulator-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
}

.sim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sim-row label {
  font-size: 0.85rem;
  color: var(--text-main);
}

.sim-time-input {
  width: 120px;
  height: 38px;
  font-weight: 600;
  text-align: center;
}

.sim-result-summary {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
}

.sim-result-summary strong {
  color: var(--primary);
}

/* ==================== 按钮与危险交互 ==================== */
.btn-danger-outline {
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  padding: 0 16px;
  height: 48px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-danger-outline:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-outline {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline:hover {
  background: #f8fafc;
}

/* ==================== 模态弹窗 Modal ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s;
}

.modal-box {
  background: #ffffff;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-icon-danger {
  font-size: 1.5rem;
}

.modal-header h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

