/* ==========================================================================
   华夏工匠 · 飞书 PC 端设计语言 + iOS 清爽质感
   主色：低饱和商务蓝 #3370FF  背景 #f5f6f8
   ========================================================================== */
:root {
  --primary: #3370ff;
  --primary-hover: #1f5ce6;
  --primary-soft: #eef3ff;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --text-2: #51565d;
  --text-3: #8f959e;
  --border: #e5e6eb;
  --border-soft: #f0f1f5;
  --danger: #f53f3f;
  --success: #00b42a;
  --warning: #ff7d00;
  --info: #3370ff;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(31, 35, 41, 0.04), 0 4px 16px rgba(31, 35, 41, 0.06);
  --shadow-lg: 0 8px 32px rgba(31, 35, 41, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d0d3da; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b8bcc4; }
::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ============================ 侧边栏 ============================ */
.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, #4b83ff, #2f5fe0);
  color: #fff; font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(51, 112, 255, 0.28);
}
.logo-title { font-size: 15px; font-weight: 600; line-height: 1.2; }
.logo-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-2); cursor: pointer;
  transition: all .18s ease; font-size: 14px; user-select: none;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--border-soft); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }

/* 分段控件（状态筛选） */
.seg { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; }
.seg-btn { padding: 6px 16px; border: none; background: transparent; border-radius: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; transition: all .15s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: #fff; color: var(--primary); font-weight: 500; box-shadow: 0 1px 3px rgba(31,35,41,.1); }

.sidebar-footer { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.btn-backup {
  width: 100%; padding: 10px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 13px; cursor: pointer;
  transition: background .18s;
}
.btn-backup:hover { background: var(--primary-hover); }
.btn-backup.ghost { background: #fff; color: var(--text-2); border: 1px solid var(--border); }
.btn-backup.ghost:hover { background: var(--border-soft); }

/* 制作人商标（KEYuano）：飞书+iOS 风格，圆角胶囊，低饱和商务蓝 */
.brand-tag {
  margin-top: 2px; text-align: center;
  font-size: 11px; font-weight: 600; letter-spacing: 2px;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 8px; padding: 6px 0;
  box-shadow: 0 1px 2px rgba(31, 35, 41, 0.04);
  user-select: none;
}

/* ============================ 顶部栏 ============================ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0;
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
}
.page-title { font-size: 17px; font-weight: 600; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; }

.search-box {
  position: relative; display: flex; align-items: center;
  width: 320px; max-width: 40vw;
}
.search-box svg {
  position: absolute; left: 12px; width: 16px; height: 16px; fill: var(--text-3); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 9px 36px 9px 36px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; transition: all .18s;
  background: var(--bg);
}
.search-box input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,255,.1); }
.search-clear {
  position: absolute; right: 10px; width: 20px; height: 20px;
  border: none; background: #d0d3da; color: #fff; border-radius: 50%;
  cursor: pointer; font-size: 14px; line-height: 1;
}

.btn-group { display: flex; align-items: center; gap: 8px; }
.btn {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer;
  transition: all .18s; white-space: nowrap;
}
.btn:hover { background: var(--border-soft); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: #fff; color: var(--text-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #d93636; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ============================ 内容区 ============================ */
.content { flex: 1; overflow: auto; padding: 24px; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border-soft);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.card-title .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* ============================ 仪表盘 ============================ */
.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.dash-card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border-soft);
  padding: 22px; cursor: pointer; transition: all .18s;
}
.dash-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.dash-card .icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.dash-card .icon svg { width: 20px; height: 20px; }
.dash-card .num { font-size: 28px; font-weight: 700; line-height: 1; }
.dash-card .label { font-size: 13px; color: var(--text-3); margin-top: 8px; }
.dash-card .sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.ic-blue { background: var(--primary-soft); color: var(--primary); }
.ic-orange { background: #fff4e8; color: var(--warning); }
.ic-green { background: #e8ffea; color: var(--success); }
.ic-red { background: #ffece8; color: var(--danger); }

/* ============================ 表格 ============================ */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 100%; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: #fafbfc; text-align: left; padding: 12px 14px;
  font-weight: 500; color: var(--text-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: default;
  border-right: 1px solid var(--border-soft);
}
thead th:last-child { border-right: none; }
thead th .th-inner { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
thead th .resize-handle {
  width: 6px; height: 100%; cursor: col-resize; flex-shrink: 0;
}
tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--border-soft);
  color: var(--text-2); vertical-align: middle; word-break: break-word;
}
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
.col-idx { color: var(--text-3); }

/* 状态行样式：报事已完工置灰 / 物料已到货标红 */
tbody tr.row-done td { color: var(--text-3); opacity: .55; }
tbody tr.row-done:hover { background: #fafbfc; }
tbody tr.row-arrived td { background: #fff1f0; color: var(--danger); }
tbody tr.row-arrived:hover { background: #ffe9e7; }

/* 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; line-height: 1.5;
  white-space: nowrap;
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-blue { background: #eef3ff; color: #3370ff; }
.tag-green { background: #e8ffea; color: #00b42a; }
.tag-red { background: #ffece8; color: #f53f3f; }
.tag-orange { background: #fff4e8; color: #ff7d00; }
.tag-gray { background: #f2f3f5; color: #6b7280; }

/* 链接按钮 */
.link-btn {
  color: var(--primary); cursor: pointer; text-decoration: none;
  font-size: 13px; white-space: nowrap; background: none; border: none;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.link-btn.disabled { color: var(--text-3); cursor: not-allowed; }

/* 操作列 */
.op-cell { display: flex; align-items: center; gap: 12px; white-space: nowrap; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--text-3); font-size: 13px;
}
.empty svg { width: 44px; height: 44px; fill: #d0d3da; margin-bottom: 12px; }

/* 搜索高亮 */
mark { background: #fff3c4; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ============================ 抽屉 ============================ */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 100;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 92vw;
  background: #fff; z-index: 101;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.25,.8,.25,1);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.drawer.show { transform: translateX(0); }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 17px; font-weight: 600; }
.drawer-close {
  width: 32px; height: 32px; border: none; background: var(--border-soft);
  border-radius: 8px; cursor: pointer; font-size: 18px; color: var(--text-2);
  line-height: 1; transition: all .15s;
}
.drawer-close:hover { background: var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* 表单 */
.form-group { margin-bottom: 18px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 8px; display: block; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none; transition: all .18s;
  background: #fff; color: var(--text); font-family: inherit;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(51,112,255,.1); }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.6; }
input[type="date"].form-control { color-scheme: light; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* 附件插槽 */
.attach-slot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1.5px dashed var(--border); border-radius: 8px;
  background: var(--bg); transition: all .18s;
}
.attach-slot.has-file { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }
.attach-icon { width: 30px; height: 30px; flex-shrink: 0; }
.attach-icon svg { width: 30px; height: 30px; }
.attach-info { flex: 1; min-width: 0; }
.attach-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-empty-text { font-size: 13px; color: var(--text-3); }
.attach-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* 单选组 */
.radio-group { display: flex; gap: 10px; }
.radio-pill {
  flex: 1; text-align: center; padding: 10px; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-2);
  transition: all .18s; user-select: none;
}
.radio-pill:hover { border-color: var(--primary); }
.radio-pill.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 500; }

/* ============================ Toast ============================ */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: #fff; color: var(--text); padding: 12px 20px; border-radius: 10px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft);
  font-size: 14px; z-index: 200; opacity: 0; transition: all .3s cubic-bezier(.25,.8,.25,1);
  display: flex; align-items: center; gap: 8px; max-width: 60vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

/* ============================ 确认弹窗 ============================ */
.confirm-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: none; align-items: center; justify-content: center; z-index: 150;
}
.confirm-mask.show { display: flex; }
.confirm-box {
  background: #fff; border-radius: var(--radius-lg); padding: 24px;
  width: 360px; max-width: 90vw; box-shadow: var(--shadow-lg);
}
.confirm-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.confirm-msg { font-size: 14px; color: var(--text-2); margin-bottom: 22px; line-height: 1.6; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* 备注查看弹窗 */
.remark-content {
  font-size: 14px; color: var(--text-1); line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg-2, #f7f8fa); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 22px; max-height: 60vh; overflow-y: auto;
}
.confirm-box.wide { width: 480px; }

/* 响应式 */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================ 登录页 ============================ */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(160deg, #f0f4ff 0%, #f5f6f8 60%, #eef3ff 100%);
}
.login-card {
  width: 380px; max-width: 100%;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft);
  padding: 36px 32px 28px;
}
.login-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 28px; }
.login-logo .logo-mark { width: 56px; height: 56px; border-radius: 14px; font-size: 28px; }
.login-title { font-size: 20px; font-weight: 700; margin-top: 14px; color: var(--text); }
.login-sub { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.login-form .form-label { margin-bottom: 8px; }
.login-form .radio-group { margin-bottom: 4px; }
.btn-block { width: 100%; padding: 11px; font-size: 14px; margin-top: 6px; }
.login-links { margin-top: 14px; text-align: center; }
.login-link { font-size: 13px; color: #3370ff; text-decoration: none; }
.login-link:hover { text-decoration: underline; }
.login-tip { margin-top: 14px; text-align: center; font-size: 13px; color: var(--text-3); }
.login-tip.error { color: var(--danger); }
.login-brand { margin-top: 22px; }

/* ============================ 移动端响应式 ============================ */
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center;
    padding: 8px 10px; border-right: none; border-bottom: 1px solid var(--border);
    overflow-x: auto; gap: 6px;
  }
  .sidebar .logo { padding: 4px 8px; flex-shrink: 0; }
  .sidebar .logo-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 8px; }
  .sidebar .logo-text { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 10px; font-size: 13px; }
  .sidebar-footer { display: none; }
  /* 主区高度由 flex 自适应，避免顶栏两行后内容区溢出 */
  .main { height: auto; flex: 1; min-height: 0; }

  /* 顶栏两行布局：第一行标题+操作按钮，第二行搜索框全宽 */
  .topbar {
    height: auto; min-height: 52px; padding: 8px 12px;
    flex-wrap: wrap; row-gap: 8px; align-items: center;
  }
  .page-title { font-size: 15px; flex-shrink: 0; }
  .topbar-actions {
    flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap;
    gap: 6px 8px;
  }
  .search-box { width: 100%; max-width: none; flex: 1 1 100%; min-width: 0; }
  .search-box input { padding: 10px 32px 10px 34px; font-size: 13px; border-radius: 8px; }
  .search-box svg { left: 11px; width: 15px; height: 15px; }
  .btn-group { flex-wrap: wrap; gap: 6px; }
  .btn { padding: 10px 14px; font-size: 13px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { padding: 5px 10px; font-size: 12px; min-height: 30px; }

  .content { padding: 12px; }

  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dash-card { padding: 16px; }
  .dash-card .num { font-size: 22px; }

  /* 表格：惯性滚动 + 压缩留白 */
  .table-wrap {
    overflow: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  }
  thead th, tbody td { padding: 10px 12px; }

  .drawer { width: 100%; max-width: 100%; }
  .drawer-header, .drawer-body, .drawer-footer { padding: 16px; }
  .drawer-close { width: 38px; height: 38px; font-size: 20px; }
  .card { padding: 14px; }

  /* 表单触屏友好：输入框高度不低于 44px */
  .form-control { padding: 12px 14px; font-size: 15px; border-radius: 9px; }
  .form-label { font-size: 14px; margin-bottom: 8px; }
  textarea.form-control { min-height: 90px; }
  .radio-pill { padding: 12px 10px; font-size: 14px; }
  .attach-slot { padding: 12px; }
  .attach-actions .btn { min-height: 36px; padding: 8px 12px; }

  /* 状态分段控件：可换行避免挤压 */
  .seg { flex-wrap: wrap; }
  .seg-btn { padding: 8px 14px; font-size: 13px; }

  /* 登录 / 注册页 */
  .login-body { padding: 16px; }
  .login-card { padding: 28px 20px 22px; }
  .login-logo { margin-bottom: 22px; }
  .btn-block { padding: 12px; font-size: 15px; }
  .login-link { font-size: 14px; }
}

/* 窄屏（≤480px，覆盖 375px）细节压缩 */
@media (max-width: 480px) {
  .content { padding: 10px; }
  .card { padding: 12px; }
  .card-title { font-size: 14px; margin-bottom: 12px; }
  .dash-grid { gap: 8px; }
  .dash-card { padding: 13px 12px; }
  .dash-card .num { font-size: 20px; }
  .dash-card .icon { width: 34px; height: 34px; margin-bottom: 10px; }
  .dash-card .icon svg { width: 17px; height: 17px; }
  .dash-card .label { font-size: 12px; }
  .dash-card .sub { font-size: 11px; }

  /* 筛选控件：窄屏下全宽排列（覆盖 app.js 内联固定宽度 160/180px） */
  .content .card select.form-control,
  .content .card input[type="date"].form-control {
    width: 100% !important; max-width: 100%;
  }

  thead th, tbody td { padding: 9px 8px; font-size: 12px; }
  .tag { padding: 2px 8px; font-size: 11px; }

  .topbar { padding: 8px 10px; }
  .page-title { font-size: 14px; }
  .btn { padding: 9px 12px; font-size: 12px; }

  .drawer-header, .drawer-body, .drawer-footer { padding: 14px; }
  .drawer-title { font-size: 16px; }

  .toast { max-width: 86vw; font-size: 13px; padding: 11px 16px; }
  .confirm-box { padding: 20px; }
  .confirm-msg { font-size: 13px; }
  .login-card { padding: 26px 16px 20px; }
}

/* 触屏设备（无 hover）：清除鼠标悬停粘滞，避免点击后高亮残留 */
@media (hover: none) {
  .dash-card:hover { transform: none; box-shadow: var(--shadow); }
  .nav-item:hover { background: transparent; }
  .btn:hover, .btn-primary:hover, .btn-ghost:hover, .btn-danger:hover { background: inherit; }
  .btn-primary:hover { background: var(--primary); }
  .btn-danger:hover { background: var(--danger); }
  tbody tr:hover { background: transparent; }
  .radio-pill:hover { border-color: var(--border); }
  .drawer-close:hover { background: var(--border-soft); }
  .link-btn:hover { text-decoration: none; }
  .btn-backup:hover { background: var(--primary); }
  .btn-backup.ghost:hover { background: #fff; }
  .login-link:hover { text-decoration: none; }
  .seg-btn:hover { color: var(--text-2); }
}

