/* 智慧化管理平台 - 现场执行人员小程序原型 */
:root {
  --primary: #3B82F6;
  --primary-dark: #2563EB;
  --primary-light: #EFF6FF;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --text: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --success: #22C55E;
  --success-bg: #F0FDF4;
  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.proto-entry {
  position: fixed;
  top: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: #2563EB;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  z-index: 9000;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.proto-entry:hover { color: #1D4ED8; }


body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: #E8ECF0;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.phone-shell {
  max-width: 390px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

/* 小程序顶栏 */
.mp-statusbar {
  height: 44px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.mp-statusbar.transparent {
  background: transparent;
  border: none;
  color: #fff;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

#pageHome {
  padding-top: 44px;
}

#pageMine {
  padding-top: 44px;
}

#pageHome .home-header {
  margin-top: -44px;
  padding-top: 52px;
}

#pageMine .mine-header {
  margin-top: -44px;
  padding-top: 52px;
}

.mp-statusbar .mp-capsule {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 87px;
  height: 32px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-around;
  font-size: 14px;
  color: #333;
}

.mp-statusbar.transparent .mp-capsule {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
}

.mp-back {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border: none;
  background: none;
  color: inherit;
}

/* 登录页 */
.login-page {
  min-height: 100vh;
  background: linear-gradient(165deg, #2563EB 0%, #3B82F6 45%, #60A5FA 100%);
  padding: 0 28px 40px;
  display: flex;
  flex-direction: column;
}

.login-hero {
  padding-top: 72px;
  text-align: center;
  color: #fff;
  margin-bottom: 48px;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: rgba(255,255,255,.2);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo-img { opacity: .95; }

/* 本地 PNG/SVG 图标 */
.icon-img { display: block; object-fit: contain; vertical-align: middle; }

.login-input-wrap .icon {
  display: inline-flex;
  align-items: center;
  margin-right: 10px;
  opacity: 0.65;
  flex-shrink: 0;
}

.login-hero h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.login-hero p {
  font-size: 14px;
  opacity: 0.85;
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.login-field {
  margin-bottom: 18px;
}

.login-field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.login-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: #FAFAFA;
  transition: border-color 0.2s;
}

.login-input-wrap:focus-within {
  border-color: var(--primary);
  background: #fff;
}

.login-input-wrap input {
  flex: 1;
  border: none;
  background: none;
  padding: 14px 0;
  font-size: 15px;
  outline: none;
}

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.btn-login {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-login:active { opacity: 0.9; transform: scale(0.99); }

.login-tip {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

.login-error.show { display: block; }

/* 主内容区 */
.app-main {
  padding-bottom: calc(56px + var(--safe-bottom));
  min-height: calc(100vh - 44px);
}

.page { display: none; }
.page.active { display: block; }

/* 共享渐变头部（首页 / 我的） */
.page-header-gradient {
  background: linear-gradient(180deg, #1D4ED8 0%, #2563EB 22%, #3B82F6 45%, #60A5FA 68%, #BFDBFE 88%, var(--bg) 100%);
  position: relative;
  overflow: hidden;
  color: #fff;
}

.page-header-gradient::before {
  content: '';
  position: absolute;
  top: -48px;
  right: -24px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.page-header-gradient::after {
  content: '';
  position: absolute;
  top: 40px;
  left: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.page-skyline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  opacity: 0.22;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 390 56' preserveAspectRatio='none'%3E%3Cpath fill='%23ffffff' d='M0 56V38h24v18h20V28h16v28h28V32h12v24h32V20h18v36h24V34h14v22h22V26h20v30h16V40h18v16h26V30h20v26h28V44h16v12H0z'/%3E%3C/svg%3E") bottom center / 100% 100% no-repeat;
  pointer-events: none;
}

/* 首页头部 */
.home-header {
  padding: 8px 16px 48px;
}

.home-brand {
  position: relative;
  z-index: 2;
}

.home-brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.home-brand p {
  font-size: 13px;
  opacity: 0.88;
}

.home-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  position: relative;
  z-index: 2;
}

.home-location {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
}

.home-loc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #86EFAC;
  box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.35);
}

.home-loc-arrow {
  font-size: 10px;
  opacity: 0.75;
  margin-left: -2px;
}

.home-weather {
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  opacity: 0.9;
}

.home-user-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.home-user-btn:active { opacity: 0.85; }

.home-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.home-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  z-index: 2;
  cursor: pointer;
}

.home-search-icon { color: rgba(255, 255, 255, 0.92); flex-shrink: 0; }

.home-search input {
  flex: 1;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.home-search input::placeholder { color: rgba(255, 255, 255, 0.82); }

.home-content {
  position: relative;
  z-index: 1;
  padding-bottom: 8px;
}

.notice-bar {
  margin: -24px 16px 16px;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 13px;
  color: var(--text-secondary);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 3;
}

.notice-bar .tag {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.notice-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 10px;
  flex-shrink: 0;
}

.notice-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#pageHome .stat-row {
  padding: 0 16px 16px;
}

.home-card {
  background: var(--card);
  margin: 0 16px 12px;
  border-radius: 16px;
  padding: 16px 12px 8px;
  box-shadow: var(--shadow);
}

.home-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  padding: 0 4px 12px;
  letter-spacing: -0.2px;
}

.home-card .menu-grid {
  margin: 0;
  padding: 0 0 8px;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.home-card-todo .order-card:last-child { margin-bottom: 4px; }

#pageHome .stat-card {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.home-card .menu-item {
  padding: 12px 4px 14px;
}

/* 统计卡片 */
.stat-row {
  display: flex;
  gap: 10px;
  padding: 16px 16px 12px;
}

.stat-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card .num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.warn .num { color: var(--warning); }
.stat-card.ok .num { color: var(--success); }
.stat-card.bad .num { color: var(--danger); }

/* 宫格菜单 */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 12px 16px;
  background: var(--card);
  margin: 0 16px 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 4px;
  cursor: pointer;
  border: none;
  background: none;
}

.menu-item:active { opacity: 0.7; }

.menu-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.menu-icon .menu-grid-icon { display: block; }

.menu-item span {
  font-size: 12px;
  color: var(--text);
}

/* Tab 筛选 */
.filter-tabs {
  display: flex;
  background: var(--card);
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  flex-shrink: 0;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
}

.filter-tab.active {
  color: var(--primary);
  font-weight: 600;
}

.filter-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

.chip-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  background: var(--card);
}

.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
}

.chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* 列表卡片 */
.list-wrap { padding: 12px 16px 16px; }

.stat-row + .list-wrap,
.chip-row + .list-wrap {
  padding-top: 16px;
}

.order-card, .inspect-card, .task-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  padding-right: 8px;
}

.status-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  font-weight: 500;
}

.status-tag.danger { background: var(--danger-bg); color: var(--danger); }
.status-tag.warning { background: var(--warning-bg); color: var(--warning); }
.status-tag.success { background: var(--success-bg); color: var(--success); }
.status-tag.primary { background: var(--primary-light); color: var(--primary); }

.cat-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.photo-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.photo-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  background: linear-gradient(135deg, #E5E7EB, #D1D5DB);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #F3F4F6;
}

.card-time {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-card {
  padding: 6px 16px;
  border-radius: 20px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}

.btn-card.outline {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-card:active { opacity: 0.85; }

/* 底部导航 */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 390px;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  padding-top: 6px;
}

.tabbar-item .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin-bottom: 2px;
  position: relative;
  width: 24px;
  height: 24px;
}

.tabbar-item .tabbar-icon {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.tabbar-item .tabbar-icon-on { display: none; }

.tabbar-item.active .tabbar-icon-off { display: none; }

.tabbar-item.active .tabbar-icon-on { display: block; }

.tabbar-item.active { color: var(--primary); }

.tabbar-item .badge-dot {
  position: relative;
}

.tabbar-item .badge-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* 我的 */
.mine-header {
  padding: 8px 16px 40px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 2;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.profile-info h3 { font-size: 20px; margin-bottom: 4px; }
.profile-info p { font-size: 13px; opacity: 0.85; }

.mine-header .stats-mini {
  margin: 20px 0 0;
}

.menu-list {
  margin: 12px 16px 16px;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.menu-list-item {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #F3F4F6;
  cursor: pointer;
  font-size: 15px;
}

.menu-list-item:last-child { border-bottom: none; }
.menu-list-item:active { background: #F9FAFB; }

.menu-list-item .left { flex: 1; display: flex; align-items: center; gap: 12px; }
.menu-list-item .arrow { color: var(--text-muted); }

.stats-mini {
  display: flex;
  margin: -24px 16px 0;
  padding: 0;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.stats-mini .item {
  flex: 1;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow);
}

.stats-mini .item .n { font-size: 20px; font-weight: 700; color: var(--primary); }
.stats-mini .item .t { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* 详情页 */
.detail-page { background: var(--bg); min-height: calc(100vh - 44px); padding-bottom: 80px; }

.detail-section {
  background: var(--card);
  margin-bottom: 12px;
  padding: 16px;
}

.detail-section h4 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid #F9FAFB;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-secondary); }
.detail-row .v { color: var(--text); text-align: right; max-width: 60%; }

.detail-actions {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 390px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  z-index: 50;
}

.detail-actions .btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-default { background: #F3F4F6; color: var(--text); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }

/* 表单页 */
.form-page { padding: 16px; padding-bottom: 100px; }

.form-group {
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px 16px;
  margin-bottom: 12px;
}

.form-item {
  padding: 14px 0;
  border-bottom: 1px solid #F3F4F6;
}

.form-item:last-child { border-bottom: none; }

.form-item label {
  display: block;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.form-item label .req { color: var(--danger); }

.form-item input,
.form-item select,
.form-item textarea {
  width: 100%;
  border: none;
  font-size: 15px;
  outline: none;
  background: none;
  color: var(--text);
}

.form-item textarea { min-height: 80px; resize: none; }

.upload-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-box {
  width: 72px;
  height: 72px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
}

.form-submit {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 390px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--card);
}

.form-submit button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.toast.show { opacity: 1; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.sub-page { display: none; }
.sub-page.active { display: block; }

.hidden { display: none !important; }
