/* ==================== 销路宝业务管理系统 - 全局样式 ==================== */

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #34a853;
  --warning: #fbbc04;
  --danger: #ea4335;
  --accent: #1a73e8;
  --bg: #f5f7fa;
  --bg-light: #f8f9fa;
  --card-bg: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --sidebar-width: 240px;
  --header-height: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Login Page ===== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a73e8 0%, #4285f4 50%, #1557b0 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
  text-align: center;
  color: var(--primary);
  font-size: 28px;
  margin-bottom: 8px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
  background: white;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover { opacity: 0.9; }

.btn-warning {
  background: var(--warning);
  color: #333;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover { opacity: 0.9; }

.btn-outline {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover { background: var(--bg); }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== App Layout ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: #1a1f36;
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 20px;
  color: white;
  font-weight: 600;
}

.sidebar-header .domain {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  padding: 10px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 1px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.nav-item.active {
  background: rgba(26, 115, 232, 0.2);
  color: white;
  border-left-color: var(--primary);
}

.nav-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* Sub nav */
.nav-sub {
  padding-left: 20px;
}

.nav-sub .nav-item {
  padding: 7px 20px 7px 30px;
  font-size: 13px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
}

.sidebar-footer .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.sidebar-footer .logout-btn {
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  display: inline-block;
}

.sidebar-footer .logout-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.top-bar {
  background: white;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar .page-title {
  font-size: 18px;
  font-weight: 600;
}

.top-bar .breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-card .stat-icon.blue { background: #e8f0fe; color: var(--primary); }
.stat-card .stat-icon.green { background: #e6f4ea; color: var(--success); }
.stat-card .stat-icon.orange { background: #fef7e0; color: #f9ab00; }
.stat-card .stat-icon.red { background: #fce8e6; color: var(--danger); }

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tbody tr:hover {
  background: #f8f9fa;
}

table .actions {
  display: flex;
  gap: 6px;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.amount {
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  font-variant-numeric: tabular-nums;
}

.amount.income { color: #d93025; }
.amount.expense { color: #188038; }

/* Badges / Tags */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.badge-success { background: #e6f4ea; color: #188038; }
.badge-warning { background: #fef7e0; color: #b06000; }
.badge-danger { background: #fce8e6; color: #c5221f; }
.badge-info { background: #e8f0fe; color: #1967d2; }
.badge-default { background: #f1f3f4; color: #5f6368; }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .search-box {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.toolbar .search-box input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.toolbar .search-box input:focus {
  outline: none;
  border-color: var(--primary);
}

.toolbar .filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: white;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  font-size: 13px;
}

.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

.pagination .page-info {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-lg {
  max-width: 1000px;
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h3 { font-size: 16px; }
.modal-close {
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
  background: none;
  border: none;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: white;
}

/* Form grid for modals */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid.col-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

/* Summary bar */
.summary-bar {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.summary-item {
  flex: 1;
  text-align: center;
}

.summary-item .label {
  font-size: 12px;
  color: var(--text-secondary);
}

.summary-item .value {
  font-size: 18px;
  font-weight: 700;
}

.summary-item .value.red { color: #d93025; }
.summary-item .value.green { color: #188038; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h2, .sidebar-header .domain, .nav-section-title, .nav-item span, .sidebar-footer .user-info span { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .main-content { margin-left: 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4c4c4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  min-width: 250px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: #333; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.chart-container {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.chart-container h3 {
  margin-bottom: 16px;
  font-size: 15px;
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* Permission Matrix */
.perm-matrix {
  max-height: 55vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.perm-channel {
  margin-bottom: 16px;
}

.perm-channel-title {
  font-weight: 700;
  font-size: 14px;
  padding: 8px 0;
  border-bottom: 2px solid var(--primary);
  color: var(--primary);
  margin-bottom: 8px;
}

.perm-section {
  padding: 4px 0 4px 16px;
  border-bottom: 1px solid var(--border);
}

.perm-section-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 0;
  color: var(--text-primary);
}

.perm-func {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 4px 24px;
  font-size: 13px;
}

.perm-func-label {
  color: var(--text-secondary);
  min-width: 100px;
}

.perm-checkboxes {
  display: flex;
  gap: 16px;
}

.perm-cb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.perm-cb input[type="checkbox"] {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

@media (max-width: 1024px) {
  .chart-row { grid-template-columns: 1fr; }
}
