/* ============================================================
   丝路智茧 · 蚕茧收购智能结算系统
   全局样式文件 (V2.4.0)
   适用页面: index.html / admin.html / operator.html / 
             leader.html / finance.html / farmer.html / reset.html
   ============================================================ */

/* ---------- CSS 变量定义 ---------- */
:root {
  --primary-dark: #1f3b1d;        /* 深绿，导航栏背景 */
  --primary-medium: #2e6b2e;      /* 中绿，主按钮背景 */
  --primary-light: #3a7330;       /* 浅绿，图标/强调 */
  --primary-bg: #f4f9ee;          /* 页面底色 */
  --card-bg: rgba(255, 255, 250, 0.88);  /* 卡片毛玻璃背景 */
  --border-light: #c8ddba;        /* 边框浅绿 */
  --border-dashed: #b1cf9e;       /* 虚线边框 */
  --text-dark: #1e4a1a;           /* 深色文字 */
  --text-medium: #2c5420;         /* 中等文字 */
  --text-muted: #4b6e3a;          /* 辅助文字 */
  --accent-gold: #e6d99c;         /* 点缀金色 */
  --danger: #b34e4e;              /* 危险按钮/警告 */
  --warning-bg: #f5e6c8;          /* 待支付标签背景 */
  --warning-text: #7a5c1a;        /* 待支付标签文字 */
  --success-bg: #3d8233;          /* 已结算标签背景 */
  --shadow-sm: 0 8px 20px rgba(30, 50, 10, 0.08);
  --shadow-md: 0 15px 30px -8px rgba(20, 40, 10, 0.12);
  --shadow-lg: 0 25px 45px -8px rgba(40, 60, 20, 0.28);
  --border-radius-card: 34px;
  --border-radius-btn: 40px;
  --border-radius-input: 34px;
  --transition-default: all 0.2s ease;
}

/* ---------- 全局重置 ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, 'Segoe UI', '微软雅黑', 'PingFang SC', sans-serif;
  background: var(--primary-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 导航栏 (毛玻璃) ---------- */
.navbar {
  background: rgba(31, 59, 29, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f5f7e5;
  padding: 0.9rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 20px rgba(30, 50, 10, 0.15);
  border-bottom: 2px solid #a6c89a;
}

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

.navbar-brand h2 {
  font-weight: 540;
  font-size: 1.8rem;
  letter-spacing: 1px;
  color: #f1fadc;
}

.navbar-brand i {
  font-size: 2rem;
  color: var(--accent-gold);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 25px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2a4e25;
  padding: 6px 18px;
  border-radius: 40px;
  box-shadow: inset 0 1px 3px #57854a;
  color: #f5f7e5;
}

.logout-btn {
  background: #4f3e2b;
  color: #f0e7d2;
  border: none;
  padding: 8px 22px;
  border-radius: 36px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-default);
  border: 1px solid #b9a577;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.logout-btn:hover {
  background: #6a4f34;
  color: white;
}

/* ---------- 主容器布局 ---------- */
.dashboard-container {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* 双栏工作台布局 (operator.html) */
.workbench-container {
  display: flex;
  flex: 1;
  padding: 1.8rem 2.2rem;
  gap: 2rem;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

.left-panel {
  flex: 1.1;
  min-width: 400px;
}

.right-panel {
  flex: 2;
  min-width: 550px;
}

/* ---------- 卡片通用样式 (毛玻璃核心) ---------- */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--border-radius-card);
  padding: 1.8rem 2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  margin-bottom: 2rem;
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 20px 35px -8px rgba(30, 60, 15, 0.16);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px dashed var(--border-dashed);
  padding-bottom: 14px;
  margin-bottom: 22px;
}

.card-header h3 {
  font-size: 1.5rem;
  font-weight: 580;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- KPI 卡片 (leader.html) ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 1.5rem 0.8rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  text-align: center;
}

.kpi-icon {
  font-size: 2rem;
  color: var(--primary-light);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1c4f15;
}

.kpi-label {
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 5px;
  font-size: 0.9rem;
}

/* 概览卡片 (财务/蚕农) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.2rem;
  margin-bottom: 1rem;
}

.stat-item {
  background: #e5efdb;
  border-radius: 24px;
  padding: 1.2rem 0.8rem;
  text-align: center;
  border: 1px solid #bdd6a8;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #1c4f15;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 5px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.overview-item {
  background: rgba(255, 255, 250, 0.9);
  border-radius: 28px;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border-light);
  backdrop-filter: blur(6px);
}

.overview-icon {
  font-size: 2rem;
  color: var(--primary-light);
  margin-bottom: 10px;
}

.overview-value {
  font-size: 2rem;
  font-weight: 700;
  color: #1c4f15;
}

.overview-label {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 5px;
}

/* ---------- 表格通用 ---------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: 22px;
  background: #fdfdf3;
  padding: 2px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.02);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 800px;
}

th {
  text-align: left;
  padding: 14px 12px;
  background: #d4e8ca;
  color: #1d4017;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid #d0e0c0;
  color: #1f3a17;
}

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

tr:hover td {
  background: #f6feee;
}

/* ---------- 状态标签 ---------- */
.badge {
  background: #e0ebd6;
  padding: 4px 12px;
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 550;
  display: inline-block;
}

.badge-success {
  background: var(--success-bg);
  color: white;
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-unsettled {
  background: #e0ebd6;
  color: #2e5c1e;
}

.badge-settled {
  background: var(--success-bg);
  color: white;
}

.badge-pending {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-role {
  background: #e0ebd6;
  padding: 5px 14px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 560;
  color: #28541e;
}

/* ---------- 按钮体系 ---------- */
.btn {
  padding: 10px 24px;
  border-radius: var(--border-radius-btn);
  border: none;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-default);
  font-size: 0.95rem;
  box-shadow: 0 6px 14px rgba(40,80,20,0.1);
}

.btn-primary {
  background: var(--primary-medium);
  color: white;
  border: 1px solid #5e9650;
  box-shadow: 0 6px 14px rgba(40,80,20,0.2);
}

.btn-primary:hover {
  background: #3e853a;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #5a7148;
  color: white;
  border: 1px solid #7a9a62;
}

.btn-secondary:hover {
  background: #4a5f3a;
}

.btn-outline {
  background: transparent;
  color: #2e5c1e;
  border: 1.5px solid #9fbb8e;
  box-shadow: none;
}

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

.btn-danger {
  background: var(--danger);
  color: white;
  border: 1px solid #d98b8b;
}

.btn-danger:hover {
  background: #c45d5d;
}

.btn-warning {
  background: #ab8e4c;
  border: 1px solid #dbbc6e;
  color: #202010;
}

.action-btn {
  background: none;
  border: 1px solid #b1c9a2;
  padding: 6px 14px;
  margin: 0 5px 5px 0;
  border-radius: 30px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-default);
  color: #2c5722;
  background: #f5faea;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.action-btn:hover {
  background: #bcddac;
  border-color: #6b9a55;
}

.action-btn.disabled-btn,
.action-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
  background: #e0e0d0;
  border-color: #bbb;
}

/* 登录页专用按钮 */
.login-btn {
  width: 100%;
  background: var(--primary-medium);
  border: none;
  padding: 16px 20px;
  border-radius: 48px;
  font-size: 1.3rem;
  font-weight: 650;
  color: white;
  letter-spacing: 1.8px;
  cursor: pointer;
  box-shadow: 0 14px 20px -6px rgba(50, 90, 30, 0.3), 0 2px 0 #1f3a1a inset, 0 -2px 8px rgba(255,255,220,0.4) inset;
  border: 1px solid #5e8c4a;
  transition: var(--transition-default);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.login-btn:hover {
  background: #4f8442;
  transform: scale(1.01);
  box-shadow: 0 16px 24px -8px #3a5e2a;
}

/* ---------- 表单元素 ---------- */
.input-group {
  margin-bottom: 1.6rem;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 560;
  color: var(--text-medium);
  font-size: 0.98rem;
}

.input-field {
  width: 100%;
  padding: 14px 20px;
  background: #fefef7;
  border: 1.5px solid #cbdbb8;
  border-radius: var(--border-radius-input);
  font-size: 1rem;
  outline: none;
  transition: var(--transition-default);
  color: #1e3a1e;
  font-weight: 450;
  box-shadow: inset 2px 2px 6px rgba(0,0,0,0.02);
}

.input-field:focus {
  border-color: #4f7a3f;
  box-shadow: 0 0 0 4px rgba(79, 122, 63, 0.18), inset 0 1px 3px #fff;
  background: #fffffc;
}

.form-control {
  width: 100%;
  padding: 12px 18px;
  border-radius: 34px;
  border: 1.5px solid #c1d6b0;
  background: #fffffc;
  font-size: 1rem;
}

.readonly-field {
  background: #edf3e5;
  color: #1e4018;
  font-weight: 500;
}

.filter-select {
  padding: 8px 22px;
  border-radius: 34px;
  border: 1.5px solid var(--border-dashed);
  background: white;
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
  align-items: flex-end;
}

.filter-item {
  flex: 1;
  min-width: 140px;
}

.filter-item label {
  display: block;
  font-size: 0.8rem;
  color: #3a5e2a;
  margin-bottom: 4px;
}

/* 上传区域 */
.upload-area {
  border: 2px dashed #9fbb8e;
  border-radius: 28px;
  padding: 22px;
  text-align: center;
  margin: 20px 0;
  background: #fafef5;
  cursor: pointer;
  transition: var(--transition-default);
}

.upload-area:hover {
  background: #e8f3de;
}

/* 模态框 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-card {
  background: #fbfdf5;
  border-radius: 44px;
  padding: 2rem 2.5rem;
  width: 480px;
  box-shadow: 0 30px 50px rgba(20,40,5,0.3);
  border: 1px solid #aec89b;
}

.modal-card h4 {
  font-size: 1.8rem;
  color: #1c4f15;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 15px;
  margin-top: 25px;
  justify-content: flex-end;
}

/* ---------- 标签与徽章 ---------- */
.item-tag {
  background: #e5efdb;
  padding: 6px 14px 6px 18px;
  border-radius: 34px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  border: 1px solid #b7d2a2;
}

.item-tag i {
  color: #8f5e5e;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition-default);
}

.item-tag i:hover {
  color: #c0392b;
  transform: scale(1.1);
}

.town-badge {
  background: var(--primary-light);
  color: white;
  padding: 5px 18px;
  border-radius: 40px;
  font-size: 0.9rem;
}

/* ---------- 图表容器 ---------- */
.chart-container {
  width: 100%;
  height: 260px;
  margin-top: 15px;
}

.chart-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: 28px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

/* ---------- 提示信息 ---------- */
.toast-msg {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: #f0f7e5;
  padding: 12px 28px;
  border-radius: 60px;
  font-weight: 500;
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  z-index: 1001;
  display: none;
}

.toast-error {
  background: #fce8e6;
  color: #b13e3e;
  padding: 12px 18px;
  border-radius: 48px;
  border: 1px solid #f5b5a8;
  display: none;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(6px);
}

.toast-error.show {
  display: flex;
}

.hint-text {
  font-size: 0.8rem;
  color: #5a7a4a;
  margin-top: 4px;
}

.text-muted {
  color: #6b7a5e;
}

/* ---------- 辅助布局 ---------- */
.data-config-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.config-panel {
  background: #fafef5;
  border-radius: 28px;
  padding: 1.5rem;
  border: 1px solid var(--border-light);
}

.total-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  padding: 10px 0;
}

.welcome-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #e2efd6;
  border-radius: 28px;
  padding: 1.2rem 2rem;
  margin-bottom: 2rem;
  border: 1px solid #bdd6a8;
}

.info-footer {
  margin-top: 25px;
  padding: 15px 20px;
  background: #eaf1e3;
  border-radius: 24px;
  color: #2e4a1f;
  border: 1px solid var(--border-light);
}

/* ---------- 响应式设计 ---------- */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1000px) {
  .workbench-container {
    flex-direction: column;
  }
  .left-panel, .right-panel {
    min-width: auto;
  }
  .chart-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .data-config-row {
    grid-template-columns: 1fr;
  }
  .navbar {
    padding: 0.9rem 1.2rem;
  }
  .dashboard-container {
    padding: 1.5rem 1rem;
  }
}

@media (max-width: 600px) {
  .login-card {
    padding: 2.2rem 1.5rem;
  }
}

/* ---------- 打印样式 (小票) ---------- */
@media print {
  body * {
    visibility: hidden;
  }
  .print-receipt, .print-receipt * {
    visibility: visible;
  }
  .print-receipt {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}