/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e9ecef;
  --border-strong: #dee2e6;
  --text: #212529;
  --text-secondary: #6c757d;
  --text-tertiary: #adb5bd;
  --accent: #4361ee;
  --accent-bg: #edf2ff;
  --accent-hover: #3a56d4;
  --danger: #dc3545;
  --danger-bg: #fdf2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --radius: 8px;
  --radius-sm: 4px;
  --sidebar-w: 220px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

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

/* ===== Login ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.login-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.login-input:focus { border-color: var(--accent); }
.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
}

/* ===== App Shell ===== */
.app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}
.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.nav-item {
  display: block;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.version-tag {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  letter-spacing: 0.5px;
}
.version-tag.outdated {
  color: #c0392b;
  font-weight: 600;
}
.version-tag.outdated::after {
  content: ' (需刷新)';
}

.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px;
  min-width: 0;
}

/* ===== Section ===== */
.section { max-width: 1200px; }
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* ===== Table Card ===== */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.table-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: right;
  white-space: nowrap;
}
th {
  background: #f5f6f8;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}
th:first-child, td:first-child {
  text-align: left;
  font-weight: 500;
  background: #f5f6f8;
}
td.editable {
  background: var(--surface);
}
td.editable input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 13px;
  text-align: right;
  outline: none;
  padding: 0;
}
td.editable input:focus {
  background: var(--accent-bg);
  border-radius: 2px;
}

/* 门店明细页：可编辑输入框 + 合计行 */
.detail-input {
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  padding: 3px 6px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.detail-input:hover {
  border-color: var(--border-strong);
  background: var(--bg);
  cursor: text;
}
.detail-input:focus {
  border-color: var(--accent);
  background: var(--surface);
}
tfoot .total-row td {
  border-top: 2px solid var(--border-strong);
  background: #f5f6f8;
  font-weight: 600;
}
.row-del-btn {
  padding: 2px 10px !important;
  line-height: 1.2;
}

/* ===== Fixed Column Headers (整体情况分析表) ===== */
th.col-fixed {
  font-weight: 600;
  color: var(--text);
  background: #f0f1f3;
  white-space: nowrap;
  text-align: center;
}

/* ===== Store Name (linked, read-only) ===== */
td.store-name-cell {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

/* ===== Total Row ===== */
tr.total-row td {
  border-top: 2px solid var(--border-strong);
  background: #f5f6f8;
  font-weight: 600;
  color: var(--text);
}
td.row-total {
  color: var(--accent);
  font-weight: 700;
}
td.total-cell {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }
.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}
.btn-text:hover { color: var(--danger); }

/* ===== File Upload ===== */
.file-upload {
  position: relative;
  overflow: hidden;
}
.file-upload input[type=file] {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ===== Store Detail ===== */
.store-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.store-detail-back {
  margin-bottom: 16px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ===== Placeholder ===== */
.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-tertiary);
  font-size: 15px;
}

/* ===== 智能导入工具栏 ===== */
.smart-import-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: linear-gradient(90deg, #f0f7ff 0%, #e8f4ff 100%);
  border: 1px solid #c8e1ff;
  border-radius: 8px;
  flex-wrap: wrap;
}

.smart-import-hint {
  font-size: 12px;
  color: #6e7d8c;
  flex: 1;
  min-width: 200px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; right: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-header { padding: 12px 16px; }
  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding: 0;
  }
  .nav-item {
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 10px 16px;
    white-space: nowrap;
  }
  .nav-item.active {
    border-left: none;
    border-bottom-color: var(--accent);
  }
  .sidebar-footer { display: none; }
  .content {
    margin-left: 0;
    margin-top: 100px;
    padding: 16px;
  }
}
