/* ==============================
   佐敦涂料 — 共享 Shell 样式
   Multi-page architecture v4.0
   ============================== */

/* ── CSS Variables (same as main style.css) ── */
:root {
  --accent: #8b6914;
  --accent2: #2e7d32;
  --accent-light: #f5ead6;
  --bg-primary: #faf8f5;
  --bg-secondary: #f0ebe3;
  --bg-card: #ffffff;
  --bg-hover: #faf6ee;
  --bg-input: #fdfcfa;
  --border: #e8dcc8;
  --text-primary: #1a1612;
  --text-secondary: #6b6054;
  --text-muted: #a89d8e;
  --success: #2e7d32;
  --warning: #e65100;
  --danger: #c62828;
  --info: #1565c0;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell Layout ── */
.shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar (desktop) ── */
.shell-sidebar {
  width: 220px;
  background: linear-gradient(180deg, #f5ead6 0%, #fdf6ec 100%);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.shell-sidebar .logo {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.shell-sidebar .logo h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.shell-sidebar .logo small {
  font-size: 11px;
  color: var(--text-muted);
}

.shell-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}
@media (hover: hover) {
  .nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }
}
.nav-item.active {
  background: rgba(139, 105, 20, 0.08);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item.nav-child {
  padding-left: 36px;
  font-size: 13px;
  opacity: 0.85;
}
.nav-item.nav-child .icon {
  font-size: 14px;
  width: 20px;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.shell-user {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.shell-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--accent-light);
}
.shell-user .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.shell-user .role {
  font-size: 11px;
  color: var(--text-muted);
}
.shell-user .logout {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}
@media (hover: hover) {
  .shell-user .logout:hover { color: var(--danger); }
}

/* ── Main content ── */
.shell-main {
  flex: 1;
  margin-left: 220px;
  min-height: 100vh;
}

.shell-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.shell-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.shell-header .breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
}

.shell-content {
  padding: 20px 24px;
  max-width: 1200px;
}

/* ── Mobile: bottom tab bar ── */
.shell-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 4px 0;
  padding-bottom: calc(4px + env(safe-area-inset-bottom));
}
.shell-bottom-nav .tabs {
  display: flex;
  justify-content: space-around;
}
.shell-bottom-nav .tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  position: relative;
}
.shell-bottom-nav .tab-item .icon { font-size: 20px; }
.shell-bottom-nav .tab-item.active {
  color: var(--accent);
  font-weight: 600;
}
.shell-bottom-nav .tab-item .dot {
  position: absolute;
  top: 4px;
  right: calc(50% - 14px);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
@media (hover: hover) {
  .card:hover { box-shadow: var(--shadow-lg); }
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.card-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
@media (hover: hover) {
  .card-link:hover { text-decoration: underline; }
}

/* ── Search Item ── */
.search-item { min-height: 44px; padding: 12px 16px; }

/* ── Record List ── */
.record-list { display: flex; flex-direction: column; gap: 8px; }

.record-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
@media (hover: hover) {
  .record-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
  }
}
.record-item .info { flex: 1; min-width: 0; }
.record-item .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.record-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Status Badge ── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.status-done     { background: #e8f5e9; color: var(--success); }
.status-progress { background: #fff3e0; color: var(--warning); }
.status-pending  { background: var(--bg-secondary); color: var(--text-muted); }
.status-rejected { background: #ffebee; color: var(--danger); }
.status-lost     { background: #efebe9; color: #795548; }

/* ── Pipeline ── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  position: relative;
}
.pipeline-step .dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  z-index: 1;
  transition: all 0.2s;
}
.pipeline-step.done .dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.pipeline-step.in_progress .dot {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
  animation: pulse 2s ease infinite;
}
.pipeline-step.rejected .dot {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.pipeline-step.lost .dot {
  background: #795548;
  border-color: #795548;
  color: #fff;
}
.pipeline-step .label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
}
.pipeline-step.done .label,
.pipeline-step.in_progress .label {
  color: var(--text-primary);
  font-weight: 600;
}

/* 可爱日期标签 */
.pipeline-step .step-date {
  font-size: 9px;
  line-height: 1;
  margin-top: 3px;
  padding: 2px 5px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}
.pipeline-step.done .step-date {
  background: rgba(76, 175, 80, 0.12);
  color: #2e7d32;
}
.pipeline-step.in_progress .step-date {
  background: rgba(255, 152, 0, 0.15);
  color: #e65100;
  font-weight: 600;
}
.pipeline-step.rejected .step-date {
  background: rgba(244, 67, 54, 0.12);
  color: #c62828;
}

.pipeline-line {
  width: 24px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}
.pipeline-line.done { background: var(--success); }

/* ═══════════════════════════════════════ */
/* 项目管线表格视图（每行一项目，每列一阶段） */
/* ═══════════════════════════════════════ */
.pipe-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #fff);
}
.pipe-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  min-width: 720px;
}
.pipe-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-muted, #f7f5f0);
  font-weight: 600;
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.pipe-table td {
  padding: 10px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.pipe-table tbody tr:last-child td { border-bottom: none; }
.pipe-table tbody tr:hover { background: rgba(0, 0, 0, 0.02); }

.pipe-table th.pipe-addr,
.pipe-table td.pipe-addr {
  text-align: left;
  padding-left: 12px;
  font-weight: 600;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--surface, #fff);
  z-index: 1;
}
.pipe-table thead th.pipe-addr {
  background: var(--bg-muted, #f7f5f0);
  z-index: 2;
}

.pipe-cell {
  min-width: 64px;
  /* 压制全局 .status-done/.status-pending 等工具类的 background，统一底色 */
  background: transparent !important;
}

/* 当前阶段标签（dashboard 多一列） */
.pipe-table td.pipe-current {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 8px;
  white-space: nowrap;
  color: #e65100;
  background: rgba(255,152,0,0.08);
  border-radius: 6px;
  min-width: 48px;
}
.pipe-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: #f0efea;
  line-height: 1;
}
.pipe-cell.status-done .pipe-dot { background: #4caf50; color: #fff; }
.pipe-cell.status-in_progress .pipe-dot {
  background: #ff9800; color: #fff;
  animation: pipePulse 1.6s ease-in-out infinite;
}
.pipe-cell.status-rejected .pipe-dot { background: #f44336; color: #fff; }
.pipe-cell.status-lost .pipe-dot { background: #9e9e9e; color: #fff; }

.pipe-cute {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.1;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.pipe-cell.status-done .pipe-cute { color: #2e7d32; }
.pipe-cell.status-in_progress .pipe-cute { color: #e65100; font-weight: 600; }
.pipe-cell.status-rejected .pipe-cute { color: #c62828; }

@keyframes pipePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,152,0,0.5); }
  50%     { box-shadow: 0 0 0 4px rgba(255,152,0,0); }
}

/* 移动端可横滑，首列固定 */
@media (max-width: 640px) {
  .pipe-table { font-size: 11px; min-width: 640px; }
  .pipe-table td.pipe-addr, .pipe-table th.pipe-addr { max-width: 140px; }
  .pipe-cell { min-width: 54px; }
  .pipe-dot { width: 20px; height: 20px; font-size: 11px; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 81, 0, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(230, 81, 0, 0); }
}

/* ── Sub-tabs ── */
.sub-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  overflow-x: auto;
}
.sub-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
@media (hover: hover) {
  .sub-tab:hover { background: rgba(255,255,255,0.5); }
}
.sub-tab.active {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
@media (hover: hover) {
  .btn-primary:hover { background: #7a5c12; }
}
.btn-ghost {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
@media (hover: hover) {
  .btn-ghost:hover { background: var(--border); }
}
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .msg { font-size: 14px; line-height: 1.6; }

/* ── Form elements ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 105, 20, 0.1);
}

/* ── Section Title ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Login Overlay ── */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════
   Responsive Breakpoints
   ══════════════════════════════════ */

/* Tablet: collapse sidebar, keep desktop-ish */
@media (max-width: 1023px) {
  .shell-sidebar {
    transform: translateX(-100%);
  }
  .shell-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .shell-main {
    margin-left: 0;
  }
  .shell-header .menu-btn {
    display: flex;
  }
}

/* Mobile: bottom nav */
@media (max-width: 767px) {
  .shell-sidebar { display: none; }
  .shell-bottom-nav { display: block; }
  .shell-main { margin-left: 0; padding-bottom: 72px; }
  .shell-content { padding: 16px; }
  .shell-header { padding: 12px 16px; }
  .shell-header h2 { font-size: 16px; }

  .pipeline-step { min-width: 52px; }
  .pipeline-step .dot { width: 24px; height: 24px; font-size: 12px; }
  .pipeline-line { width: 16px; }

  .btn-sm { min-height: 44px; padding: 10px 16px; }
  .record-item { padding: 12px 14px; }
  .sub-tab { min-height: 44px; }
  .card { padding: 14px; }
}

/* ── Hamburger menu button ── */
.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
}

/* Sidebar overlay (tablet) */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ── More Panel (mobile bottom sheet) ── */
.more-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}
.more-panel.open { pointer-events: auto; }

.more-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.25s ease;
}
.more-panel.open .more-panel-backdrop {
  background: rgba(0,0,0,0.45);
}

.more-panel-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 12px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
}
.more-panel.open .more-panel-sheet {
  transform: translateY(0);
}

.more-panel-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.more-panel-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.more-panel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.more-panel-item .icon { font-size: 26px; line-height: 1; }
.more-panel-item.active { color: var(--accent); font-weight: 600; }
@media (hover: hover) {
  .more-panel-item:hover { background: var(--bg-hover); color: var(--text-primary); }
}

/* tab-item button reset */
.shell-bottom-nav .tab-item[type="button"] {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
