/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 18px;
  line-height: 1.5;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ===== Mobile container ===== */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: calc(100vh - 60px);
  padding-bottom: 80px;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #25509D;
  color: #fff;
  padding: 14px 16px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.header .subtitle {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.9;
  margin-left: 8px;
}

/* ===== User info bar ===== */
.user-info {
  background: #e8f5e9;
  padding: 10px 16px;
  font-size: 16px;
  color: #25509D;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #c8e6c9;
}
.user-info .emp-label {
  font-weight: 500;
}

/* ===== Cards ===== */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
}

/* ===== Buttons ===== */
.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: #25509D;
  color: #fff;
}
.btn-primary:hover, .btn-primary:active {
  background: #43a047;
}
.btn-secondary {
  background: #757575;
  color: #fff;
}
.btn-secondary:hover, .btn-secondary:active {
  background: #616161;
}
.btn-danger {
  background: #f44336;
  color: #fff;
}
.btn-danger:hover, .btn-danger:active {
  background: #d32f2f;
}
.btn-outline {
  background: #fff;
  color: #4CAF50;
  border: 2px solid #4CAF50;
}
.btn-outline:hover, .btn-outline:active {
  background: #e2e8ff;
}
.btn-sm {
  min-height: 40px;
  padding: 10px 16px;
  font-size: 16px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== Menu cards (home page) ===== */
.menu-card {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: 18px 20px;
  margin-bottom: 12px;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  touch-action: manipulation;
}
.menu-card:active {
  background: #e8f5e9;
  border-color: #25509D;
  transform: scale(0.98);
}
.menu-card .card-icon {
  font-size: 28px;
  margin-right: 12px;
  vertical-align: middle;
}
.menu-card .card-text {
  vertical-align: middle;
}

/* ===== Input fields ===== */
.input-group {
  margin-bottom: 14px;
}
.input-group label {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: #555;
  margin-bottom: 4px;
}
.input-field {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 12px 14px;
  font-size: 20px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #333;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.input-field:focus {
  border-color: #25509D;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}
.input-field::placeholder {
  color: #aaa;
  font-size: 18px;
}
.input-field:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

/* ===== Select fields ===== */
.select-field {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 12px 14px;
  font-size: 20px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23999' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;
  background-size: 14px;
  color: #333;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.select-field:focus {
  border-color: #25509D;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

/* ===== Product info display ===== */
.product-info {
  background: #e3f2fd;
  border: 2px solid #90caf9;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 18px;
  color: #1565c0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.product-info .product-name {
  font-weight: 600;
}
.product-info .product-range {
  font-size: 15px;
  color: #25509D;
  background: #e8f5e9;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.product-info.product-unknown {
  background: #fff3e0;
  border-color: #ffcc80;
  color: #e65100;
}

/* ===== Toast notification ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 420px;
  width: calc(100% - 32px);
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  z-index: 999;
  display: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
}
.toast-success {
  background: #e8f5e9;
  color: #25509D;
  border: 2px solid #a5d6a7;
}
.toast-error {
  background: #ffebee;
  color: #c62828;
  border: 2px solid #ef9a9a;
}
.toast-info {
  background: #e3f2fd;
  color: #1565c0;
  border: 2px solid #90caf9;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Bottom navigation bar ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 6px rgba(0,0,0,0.06);
  z-index: 200;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: #999;
  text-decoration: none;
  padding: 4px 12px;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
.nav-item .nav-icon {
  font-size: 24px;
}
.nav-item.active {
  color: #4CAF50;
}

/* ===== Action bar ===== */
.action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.action-bar .btn {
  flex: 1;
}

/* ===== Help text ===== */
.help-text {
  font-size: 14px;
  color: #999;
  margin-top: 4px;
}

/* ===== Login page ===== */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #25509D 0%, #1a3a70 100%);
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.login-title {
  font-size: 26px;
  font-weight: 700;
  color: #25509D;
  text-align: center;
  margin-bottom: 8px;
}
.login-subtitle {
  font-size: 15px;
  color: #888;
  text-align: center;
  margin-bottom: 24px;
}
.login-box .input-group {
  margin-bottom: 20px;
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 360px) {
  html { font-size: 16px; }
  .container { padding: 12px; padding-bottom: 76px; }
  .menu-card { min-height: 64px; padding: 14px 16px; font-size: 18px; }
}

/* =========================================================
   Management Page Styles (admin desktop/tablet)
   ========================================================= */

/* Management layout (wider) */
.manage-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 20px;
}

.manage-container .header {
  background: #1a73e8;
}

/* ===== 统一头部导航：左返回 / 中标题 / 右用户菜单 ===== */
.header-nav {
  justify-content: space-between !important;
  gap: 8px;
}
.header-nav h1 {
  flex: 1;
  text-align: center;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-back {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  min-height: 36px;
  flex-shrink: 0;
}
.header-back:active { background: rgba(255,255,255,0.3); }
.header-user {
  position: relative;
  color: #fff;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  background: rgba(255,255,255,0.15);
  user-select: none;
  flex-shrink: 0;
}
.header-user:hover { background: rgba(255,255,255,0.25); }
.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  color: #333;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  min-width: 140px;
  z-index: 300;
  overflow: hidden;
  text-align: left;
}
.user-dropdown.open { display: block; }
.user-dropdown-item {
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
}
.user-dropdown-item:hover { background: #f0f0f0; }

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.toolbar-left {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Management buttons */
.manage-container .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 36px;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 6px;
}
.manage-container .btn-primary {
  background: #1a73e8;
  color: #fff;
}
.manage-container .btn-primary:hover {
  background: #1557b0;
}
.manage-container .btn-success {
  background: #34a853;
  color: #fff;
}
.manage-container .btn-success:hover {
  background: #2d9249;
}
.manage-container .btn-danger {
  background: #ea4335;
  color: #fff;
}
.manage-container .btn-danger:hover {
  background: #d33426;
}
.manage-container .btn-warning {
  background: #fbbc04;
  color: #333;
}
.manage-container .btn-warning:hover {
  background: #e5ab00;
}
.manage-container .btn-outline {
  background: transparent;
  color: #555;
  border: 1px solid #ccc;
}
.manage-container .btn-outline:hover {
  background: #f0f0f0;
}
.manage-container .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.manage-container .btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 16px;
}
.manage-container table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.manage-container thead {
  background: #1a73e8;
  color: #fff;
}
.manage-container th {
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.manage-container td {
  padding: 10px 12px;
  font-size: 14px;
  border-bottom: 1px solid #eee;
}
.manage-container tbody tr:nth-child(even) {
  background: #f8f9ff;
}
.manage-container tbody tr:hover {
  background: #eef3ff;
}
.manage-container tbody tr:last-child td {
  border-bottom: none;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 10px;
}
.badge-active {
  background: #e6f4ea;
  color: #1e7e34;
}
.badge-inactive {
  background: #fce8e6;
  color: #c5221f;
}
.badge-pending {
  background: #fef7e0;
  color: #ea8600;
}

/* Action buttons in tables */
.action-cell {
  white-space: nowrap;
}
.action-cell .btn {
  margin-right: 4px;
}
.action-cell .btn:last-child {
  margin-right: 0;
}

/* Modal / Popup */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 92%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.08);
  animation: modalIn 0.22s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafbfc;
  position: sticky;
  top: 0;
  z-index: 2;
}
.modal-header h3, .modal-header span {
  font-size: 17px;
  font-weight: 700;
  color: #1f2937;
  letter-spacing: 0.3px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #9ca3af;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}
.modal-body {
  padding: 24px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #f0f0f0;
  background: #fafbfc;
}
.modal-footer .btn {
  min-width: 88px;
  min-height: 40px;
  font-size: 15px;
  border-radius: 8px;
}

/* Forms within management pages */
.manage-container .form-group {
  margin-bottom: 18px;
}
.manage-container .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.manage-container .form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  border: 1.5px solid #e2e5ea;
  border-radius: 10px;
  background: #fff;
  color: #1f2937;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
  -webkit-appearance: auto;
  appearance: auto;
}
.manage-container .form-control:hover {
  border-color: #c7cdd6;
}
.manage-container .form-control:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}
.manage-container .form-control::placeholder {
  color: #b0b7c3;
  font-size: 14px;
}
.manage-container select.form-control {
  cursor: pointer;
}

/* 弹窗表单宽屏双列 */
@media (min-width: 640px) {
  .modal .modal-body.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
  }
  .modal .modal-body.form-grid .form-group.full {
    grid-column: 1 / -1;
  }
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 16px;
  gap: 0;
}
.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}
.tab:hover {
  color: #1a73e8;
}
.tab.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
}

/* Date inputs */
.manage-container input[type="date"] {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  min-height: auto;
}
.manage-container input[type="date"]:focus {
  outline: none;
  border-color: #1a73e8;
}

/* Alert messages in manage pages */
.manage-container .alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 14px;
}
.manage-container .alert-success {
  background: #e8f5e9;
  color: #1e7e34;
  border: none;
}
.manage-container .alert-error {
  background: #ffebee;
  color: #c5221f;
  border: none;
  position: relative;
  padding-right: 40px;
}
.manage-container .alert-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: transparent;
  color: #c5221f;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.manage-container .alert-close:hover { color: #8e1614; }

/* Loading / Empty state */
.manage-container .loading {
  text-align: center;
  padding: 40px 0;
  color: #999;
  font-size: 14px;
}
.manage-container .empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}
.manage-container .empty-state p {
  font-size: 14px;
}

/* Filter row */
.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-row .form-control {
  width: auto;
  min-width: 150px;
}

/* Summary cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.manage-container .card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.manage-container .card .card-label {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}
.manage-container .card .card-value {
  font-size: 24px;
  font-weight: 700;
  color: #1a73e8;
}

/* User info in manage header */
.manage-container .user-info {
  background: transparent;
  padding: 0;
  font-size: 13px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: none;
}

/* Responsive management */
@media (max-width: 768px) {
  .manage-container {
    padding: 10px 12px;
  }
  .manage-container .header {
    font-size: 16px;
    padding: 10px 14px;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-left, .toolbar-right {
    flex-wrap: wrap;
  }
  .filter-row {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-row .form-control {
    width: 100%;
  }
  .manage-container th,
  .manage-container td {
    padding: 8px 10px;
    font-size: 13px;
  }
  .modal {
    width: 95%;
    max-width: 95%;
  }
}

/* ===== 可视化图表（通用，所有看板/流水页共用）===== */
.dash-charts, .ops-charts { display: flex; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.dash-chart-card {
  flex: 1 1 320px; min-width: 300px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
.dash-chart-title, .ops-chart-title { font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.dash-chart, .ops-chart { width: 100%; height: 240px; }
@media (max-width: 640px) { .dash-chart, .ops-chart { height: 220px; } }

/* ===== 核心指标卡片 ===== */
.kpi-cards { display: flex; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.kpi-card {
  flex: 1 1 180px; min-width: 150px; border-radius: 10px; padding: 14px 16px; color: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,.08);
}
.kpi-label { font-size: 12px; opacity: .92; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi-blue { background: linear-gradient(135deg,#4f46e5,#6366f1); }
.kpi-green { background: linear-gradient(135deg,#16a34a,#22c55e); }
.kpi-red { background: linear-gradient(135deg,#dc2626,#ef4444); }
.kpi-amber { background: linear-gradient(135deg,#d97706,#f59e0b); }

/* ===== 侧边栏高亮入口 ===== */
.nav-highlight {
  background: linear-gradient(135deg,#4f46e5,#6366f1);
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(79,70,229,.35);
}
.nav-highlight:hover { background: linear-gradient(135deg,#4338ca,#4f46e5); color:#fff !important; }
.nav-highlight .icon { filter: none; }
