/* 施工经营协作工作台 —— 浅色主题 + 响应式 + 移动端适配 */

:root {
  --bg: #f2f5fa;
  --panel: #ffffff;
  --panel2: #f7f9fd;
  --line: #e3eaf3;
  --line2: #cdd8e6;
  --txt: #243044;
  --txt-soft: #4a5a72;
  --muted: #7a8aa0;
  --pri: #2563eb;
  --pri-soft: #eaf1fe;
  --up: #16a34a;
  --down: #dc2626;
  --warn: #d97706;
  --info: #2563eb;
  --cyan: #0891b2;
  --purple2: #7c3aed;
  --sb1: #ffffff;
  --sb2: #f7f9fd;
  --tb: rgba(255, 255, 255, 0.9);
  --radius: 10px;
  --brand: #006835;
  --brand-soft: rgba(0, 104, 53, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.boot-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- 整体布局 ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: linear-gradient(180deg, var(--sb1), var(--sb2));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  font-weight: 500;
  color: var(--txt);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pri);
  flex: 0 0 8px;
}
.logo .mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: 0 0 26px;
  display: block;
}
.logo small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

.nav-group {
  padding: 10px 8px 0;
}
.ng-t {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 10px 4px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  margin: 1px 0;
  border-radius: 8px;
  color: var(--txt-soft);
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover {
  background: var(--pri-soft);
  color: var(--pri);
}
.tab.active {
  background: var(--pri);
  color: #fff;
}
.tab .el-icon {
  font-size: 15px;
}

.sb-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--txt-soft);
  margin-bottom: 8px;
}
.sb-user .avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--pri);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex: 0 0 26px;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  background: var(--tb);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 {
  font-size: 15px;
  font-weight: 500;
  margin: 0;
}
.topbar .spacer {
  flex: 1;
}

/* 抽屉相关（默认桌面态全部隐藏/不显示） */
.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  margin-left: -6px;
  border: none;
  background: transparent;
  color: var(--txt);
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
}
.menu-btn:active {
  background: var(--hover, rgba(0, 0, 0, 0.06));
}
.drawer-mask {
  display: none;
}
.only-mobile {
  display: none !important;
}
.top-user {
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--txt-soft);
  font-size: 12px;
  max-width: 42%;
}
.top-user .tu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-user .avatar.sm {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: var(--pri);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.content {
  padding: 16px;
  flex: 1;
}

/* ---------- 卡片与工具条 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.card > h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card > h3 .sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar .spacer {
  flex: 1;
}

/* ---------- KPI ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  border-top: 2px solid var(--kc, var(--pri));
}
.kpi .k-label {
  font-size: 12px;
  color: var(--muted);
}
.kpi .k-val {
  font-size: 20px;
  font-weight: 500;
  margin-top: 4px;
  color: var(--kc, var(--txt));
}
.kpi .k-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- 数字 ---------- */
.num {
  font-variant-numeric: tabular-nums;
}
.up {
  color: var(--up);
}
.down {
  color: var(--down);
}
.muted {
  color: var(--muted);
}

/* ---------- 移动端卡片列表 ---------- */
.mcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.mcard .mc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mcard .mc-title {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.mcard .mc-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
  color: var(--txt-soft);
}
.mcard .mc-row .v {
  font-variant-numeric: tabular-nums;
}
.mcard .mc-foot {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- 底部 TabBar ---------- */
.tabbar {
  display: none;
}

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef4ff 0%, #f6f8fc 100%);
  padding: 16px;
}
.login-box {
  width: 380px;
  max-width: 100%;
  background: var(--panel);
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 8px 32px rgba(20, 40, 80, 0.08);
}
.login-box .brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: block;
  margin-bottom: 14px;
  box-shadow: 0 6px 16px var(--brand-soft);
}
.login-box h2 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 500;
}
.login-box .sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 18px;
}

/* ---------- 表格 ---------- */
.tbl-wrap {
  overflow-x: auto;
}

/* ============================================================
   移动端适配
   ============================================================ */
@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  /* 顶部不再放横向菜单条：侧栏改为左侧抽屉，由顶栏汉堡键 / 底部「更多」唤起 */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 78%;
    max-width: 300px;
    height: 100vh;
    flex: none;
    z-index: 200;
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 24px rgba(15, 30, 60, 0.18);
    /* iOS 全屏 PWA（viewport-fit=cover）：抽屉贴顶贴底，需让出刘海与底部横条 */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .drawer-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 40, 0.42);
    z-index: 190;
    animation: drawer-fade 0.18s ease;
  }
  @keyframes drawer-fade {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  .logo {
    border-bottom: 1px solid var(--line);
    padding: 14px 14px 12px;
    flex: 0 0 auto;
  }
  .logo .mark {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    border-radius: 7px;
  }
  .nav-group {
    display: block;
    padding: 8px 0;
  }
  .ng-t {
    display: block;
  }
  /* 抽屉里菜单项做成整行大热区，手指好点 */
  .tab {
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .sb-foot {
    display: block;
  }
  .main {
    height: auto;
  }

  /* 顶栏：单行 —— 汉堡键 + 页面标题 + 用户（点用户同样开抽屉） */
  .menu-btn {
    display: inline-flex;
  }
  .only-desktop {
    display: none !important;
  }
  .only-mobile {
    display: flex !important;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
  .content {
    padding: 12px;
    padding-bottom: 76px;
  }
  .topbar {
    height: auto;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar h1 {
    font-size: 15px;
  }
  /* 2026-09-15 改版：手机端导航只留底部 tabbar，顶栏仅剩页面标题；
     抽屉唯一入口 = tabbar 末位「更多」（覆盖 ≤900px 块的显示规则） */
  .menu-btn {
    display: none;
  }
  .only-mobile {
    display: none !important;
  }
  .card {
    padding: 12px;
    margin-bottom: 12px;
  }
  .kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi .k-val {
    font-size: 18px;
  }
  .toolbar {
    gap: 8px;
  }
  .toolbar .el-button {
    min-height: 42px;
  }
  .toolbar .el-input,
  .toolbar .el-select {
    width: 100% !important;
  }
  .toolbar .el-input__inner,
  .toolbar .el-select .el-input__inner {
    height: 42px;
    font-size: 15px;
  }
  .tbl-wrap {
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  /* 底部导航 */
  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--panel);
    border-top: 1px solid var(--line);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar .tb-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 0 6px;
    font-size: 11px;
    color: var(--muted);
    text-decoration: none;
    min-height: 54px;
  }
  .tabbar .tb-item .el-icon {
    font-size: 19px;
  }
  .tabbar .tb-item.active {
    color: var(--pri);
  }
  /* 触控热区 */
  .el-button {
    min-height: 40px;
  }
  .el-button--small {
    min-height: 36px;
  }
  .el-input__inner,
  .el-textarea__inner,
  .el-select .el-input__inner {
    font-size: 15px;
  }
  .el-dialog {
    width: 96% !important;
    margin: 4vh auto !important;
  }
  .login-box {
    padding: 20px;
  }
}

/* ============================================================
   施工日记 · 费用明细行 + 凭证照片
   ============================================================ */
.exp-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel2);
  padding: 8px;
  margin-bottom: 8px;
}
.exp-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.exp-row .exp-cat { width: 130px; }
.exp-row .exp-amt { width: 130px; }
.exp-row .exp-note { flex: 1; min-width: 150px; }

.exp-photos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.exp-ph {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.exp-ph img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.exp-ph-del {
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  border-radius: 0 6px 0 6px;
  cursor: pointer;
}

/* 凭证大图预览 */
.ph-viewer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ph-viewer img {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
}
.ph-close {
  position: absolute;
  top: 10px;
  right: 16px;
  font-size: 30px;
  color: #fff;
  cursor: pointer;
  z-index: 1;
}
.ph-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 44px;
  color: #fff;
  opacity: 0.7;
  cursor: pointer;
  padding: 0 14px;
  z-index: 1;
}
.ph-prev { left: 2px; }
.ph-next { right: 2px; }
.ph-count {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 13px;
  opacity: 0.8;
}

@media (max-width: 768px) {
  /* 手机上五个控件一行会挤成一团：类别与金额各占半行，说明独占整行 */
  .exp-row .exp-cat,
  .exp-row .exp-amt { width: calc(50% - 4px); }
  .exp-row .exp-note { width: 100%; flex: none; }
  /* 手指更好点，删除叉也要看得清 */
  .exp-ph { width: 76px; height: 76px; }
  .exp-ph-del { width: 22px; height: 22px; line-height: 20px; font-size: 16px; }
}
