/* ============================================================
   app.css — Monday.com-style design system
   WeChat AI Customer Service Admin Dashboard
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --color-bg: #f6f7fb;
  --color-sidebar-bg: #ffffff;
  --color-sidebar-border: #e6e9ef;
  --color-sidebar-active-bg: #cce5ff;
  --color-sidebar-active-text: #0073ea;
  --color-sidebar-hover-bg: #f0f4ff;
  --color-sidebar-text: #323338;
  --color-sidebar-text-muted: #676879;

  --color-header-bg: #ffffff;
  --color-header-border: #e6e9ef;

  --color-primary: #0073ea;
  --color-primary-hover: #0060c0;
  --color-primary-light: #cce5ff;

  --color-text-primary: #323338;
  --color-text-secondary: #676879;
  --color-text-muted: #9699a6;

  --color-border: #e6e9ef;
  --color-card-bg: #ffffff;
  --color-table-header-bg: #f5f6f8;
  --color-row-hover: #f0f4ff;

  /* Status badge colors */
  --badge-pending: #c4c4c4;
  --badge-success: #00c875;
  --badge-failed: #e2445c;
  --badge-timeout: #fdab3d;

  /* Category badge colors */
  --badge-complaint: #e2445c;
  --badge-merchant: #0073ea;
  --badge-promo: #a25ddc;
  --badge-other: #676879;

  /* Group header accent colors */
  --group-pending: #c4c4c4;
  --group-success: #00c875;
  --group-failed: #e2445c;
  --group-complaint: #e2445c;
  --group-merchant: #0073ea;
  --group-promo: #a25ddc;
  --group-other: #676879;
  --group-default: #fdab3d;

  --sidebar-width: 240px;
  --header-height: 64px;
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-radius-pill: 20px;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);

  --font-family: 'Figtree', 'Roboto', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.15s ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-md);
  background: linear-gradient(135deg, #0073ea 0%, #a25ddc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.3;
}

.sidebar-section {
  padding: 12px 12px 4px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 8px;
  margin-bottom: 4px;
}

.sidebar-nav {
  list-style: none;
  padding: 0 12px;
  flex: 1;
}

.sidebar-nav-item {
  margin-bottom: 2px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--border-radius-md);
  color: var(--color-sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.sidebar-nav-link:hover {
  background: var(--color-sidebar-hover-bg);
  color: var(--color-primary);
}

.sidebar-nav-link.active {
  background: var(--color-sidebar-active-bg);
  color: var(--color-sidebar-active-text);
  font-weight: 600;
}

.sidebar-nav-link .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--color-sidebar-border);
  margin: 12px 12px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--color-sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--border-radius-md);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0073ea, #a25ddc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  padding: 4px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  transition: color var(--transition);
}

.logout-btn:hover { color: var(--badge-failed); }

/* ---------- Main Content Area ---------- */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Top Header ---------- */
.top-header {
  height: var(--header-height);
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-header-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Page Body ---------- */
.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: #f5f6f8;
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: #ecedf2; }

.btn-danger {
  background: #fff0f2;
  color: var(--badge-failed);
  border: 1px solid #ffd0d7;
}
.btn-danger:hover { background: #ffe0e5; }

.btn-ghost {
  background: none;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-sidebar-hover-bg); color: var(--color-primary); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--border-radius-sm);
}

.btn-icon {
  padding: 7px 10px;
  font-size: 15px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-card-bg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

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

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.card-body {
  padding: 20px;
}

/* ---------- Stat Cards (Monday number cards) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-card-bg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color, var(--color-primary));
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-text-primary);
  line-height: 1.1;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.stat-card .stat-icon {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 28px;
  opacity: 0.15;
}

/* ---------- Badge Pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--border-radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
}

.badge-pending  { background: var(--badge-pending); color: #fff; }
.badge-success  { background: var(--badge-success); }
.badge-failed   { background: var(--badge-failed); }
.badge-timeout  { background: var(--badge-timeout); }

.badge-complaint { background: var(--badge-complaint); }
.badge-merchant  { background: var(--badge-merchant); }
.badge-promo     { background: var(--badge-promo); }
.badge-other     { background: var(--badge-other); }

.badge-merchant-info  { background: #0073ea; }
.badge-promo-info     { background: #a25ddc; }

/* ---------- Tables ---------- */
.table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  background: var(--color-card-bg);
}

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

.monday-table thead th {
  background: var(--color-table-header-bg);
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.monday-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f1f4;
  color: var(--color-text-primary);
  vertical-align: middle;
}

.monday-table tbody tr:last-child td { border-bottom: none; }

.monday-table tbody tr {
  transition: background var(--transition);
}

.monday-table tbody tr:hover td {
  background: var(--color-row-hover);
  cursor: pointer;
}

/* ---------- Monday Group Headers ---------- */
.group-header-row td {
  background: var(--color-table-header-bg) !important;
  cursor: default !important;
  padding: 6px 14px;
  border-left: 4px solid var(--group-color, var(--color-primary));
}

.group-header-row:hover td { background: var(--color-table-header-bg) !important; }

.group-header-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-toggle {
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: transform var(--transition);
  border-radius: var(--border-radius-sm);
}

.group-toggle.collapsed { transform: rotate(-90deg); }
.group-toggle:hover { background: var(--color-border); }

.group-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--group-color, var(--color-primary));
}

.group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-border);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ---------- Filters Bar ---------- */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--color-card-bg);
  border-bottom: 1px solid var(--color-border);
}

.filter-select,
.filter-input,
.filter-date {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  font-size: 13px;
  color: var(--color-text-primary);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.filter-select:focus,
.filter-input:focus,
.filter-date:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0,115,234,0.12);
}

.filter-select { min-width: 130px; }
.filter-input { min-width: 180px; }

/* ---------- Forms / Inputs ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  font-size: 14px;
  color: var(--color-text-primary);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0,115,234,0.12);
}

textarea.form-control {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
}

select.form-control { cursor: pointer; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,36,50,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--color-card-bg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 20px;
  animation: modalIn 0.18s ease;
}

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

.modal-xl {
  max-width: 960px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--color-text-muted);
  border-radius: var(--border-radius-sm);
  padding: 4px 8px;
  transition: color var(--transition), background var(--transition);
}

.modal-close:hover { color: var(--badge-failed); background: #fff0f2; }

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-card-bg);
}

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

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  cursor: pointer;
}

.page-btn:hover { background: var(--color-sidebar-hover-bg); border-color: var(--color-primary); color: var(--color-primary); }
.page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Avatar ---------- */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fdab3d, #e2445c);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Upload Area ---------- */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: 32px 24px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--color-primary);
  background: #f0f8ff;
}

.upload-zone-icon { font-size: 36px; margin-bottom: 10px; }
.upload-zone-text { font-size: 14px; color: var(--color-text-secondary); }
.upload-zone-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }

/* ---------- Detail Panel (message detail) ---------- */
.detail-panel {
  background: #f8f9fc;
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.detail-panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.detail-panel-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

/* ---------- Meta row (label: value pairs) ---------- */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 13px;
}

.meta-item { display: flex; flex-direction: column; gap: 3px; }
.meta-label { font-weight: 600; color: var(--color-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.meta-value { color: var(--color-text-primary); }

/* ---------- Alert / Toast ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.alert-error   { background: #fff0f2; color: #c0002e; border: 1px solid #ffd0d7; }
.alert-success { background: #e6faf2; color: #007a47; border: 1px solid #b3f0d5; }
.alert-info    { background: #e8f3ff; color: #004fa0; border: 1px solid #b3d4ff; }
.alert-warning { background: #fff8e6; color: #8a5800; border: 1px solid #ffd97a; }

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

.toast {
  background: #323338;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--border-radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}

.toast.toast-success { background: #00c875; }
.toast.toast-error   { background: #e2445c; }
.toast.toast-warning { background: #fdab3d; color: #323338; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------- Empty State ---------- */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 14px; font-weight: 500; }
.empty-state-sub  { font-size: 13px; margin-top: 6px; }

/* ---------- Loading Spinner ---------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--color-text-muted);
  gap: 12px;
  font-size: 14px;
}

/* ---------- Code / monospace ---------- */
.code-block {
  background: #f5f6f8;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--color-text-primary);
}

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: 16px 0;
}

/* ---------- Login Page ---------- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f4ff 0%, #f6f7fb 60%, #fff0f8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 40px 32px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-md);
  background: linear-gradient(135deg, #0073ea 0%, #a25ddc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
}

.login-logo-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-text-primary);
}

.login-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.login-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.login-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}

/* ---------- Chart containers ---------- */
.chart-container {
  position: relative;
  width: 100%;
}

/* ---------- Preview Table (knowledge) ---------- */
.preview-table-wrap {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table th {
  background: var(--color-table-header-bg);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--color-border);
}

.preview-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f1f4;
  color: var(--color-text-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Utility classes ---------- */
.flex    { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-muted { color: var(--color-text-muted); font-size: 12px; }
.text-sm    { font-size: 13px; }
.font-bold  { font-weight: 700; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; display: inline-block; }
.text-right { text-align: right; }

/* ============================================================
   Monday 还原增强层（全局顶栏 / 整格状态 / 分组色条 / 汇总条）
   ============================================================ */

:root { --topbar-height: 48px; }

/* ---------- 全局产品顶栏（monday 顶部全宽栏）---------- */
.global-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--color-bg);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}
.global-topbar-left { display: flex; align-items: center; gap: 12px; }
.global-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; color: var(--color-text-primary); }
.global-logo-dots {
  width: 22px; height: 22px; border-radius: 6px;
  background:
    radial-gradient(circle at 30% 30%, #e2445c 0 30%, transparent 31%),
    radial-gradient(circle at 70% 30%, #fdab3d 0 30%, transparent 31%),
    radial-gradient(circle at 50% 72%, #00c875 0 30%, transparent 31%),
    #fff;
  border: 1px solid var(--color-border);
}
.global-plans {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--color-border); background: #fff;
  font-size: 13px; font-weight: 600; color: #5034ff;
  transition: background var(--transition), box-shadow var(--transition);
}
.global-plans:hover { box-shadow: var(--shadow-sm); background: #faf9ff; }
.global-plans svg { color: #5034ff; }
.global-topbar-right { display: flex; align-items: center; gap: 2px; }
.topbar-icon-btn {
  position: relative;
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: #676879;
  transition: background var(--transition), color var(--transition);
}
.topbar-icon-btn svg { width: 20px; height: 20px; display: block; }
.topbar-icon-btn:hover { background: rgba(0,0,0,0.05); color: var(--color-text-primary); }
.topbar-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 15px; height: 15px; padding: 0 4px;
  background: #e2445c; color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
  border: 2px solid var(--color-bg);
}
.topbar-avatar { margin-left: 6px; cursor: pointer; }
.topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #0073ea, #a25ddc);
  color: #fff; font-weight: 700; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* 顶栏存在时，整体下移 */
body.has-topbar .sidebar { top: var(--topbar-height); }
body.has-topbar .app-shell { padding-top: var(--topbar-height); }
body.has-topbar .top-header { top: var(--topbar-height); }

/* ---------- 列头：monday 为正常大小写、浅灰 ---------- */
.monday-table thead th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--color-text-secondary);
  font-weight: 500;
  padding: 12px 14px;
}

/* 数据行更高、更通透 */
.monday-table tbody td { padding: 0 14px; height: 46px; }

/* ---------- monday 整格填色状态/分类单元格 ---------- */
.status-cell {
  color: #fff !important;
  font-weight: 600;
  font-size: 12.5px;
  text-align: center;
  white-space: nowrap;
  padding: 0 10px !important;
  border-bottom: 2px solid #fff !important;
  letter-spacing: 0.02em;
}
/* 鼠标悬停整行时状态格保持本色（内联背景已优先，此处确保不被 hover 覆盖）*/
.monday-table tbody tr:hover td.status-cell { filter: brightness(0.96); }

/* ---------- 分组左侧连续色条（成员行）---------- */
.monday-table tbody tr.msg-row td:first-child {
  border-left: 4px solid var(--group-color, transparent);
}
.group-header-row td { border-top: 8px solid var(--color-bg); }
.group-header-row:first-child td { border-top: none; }

/* ---------- 分组汇总条（状态分布堆叠）---------- */
.group-summary-row td {
  background: #fcfcfd !important;
  cursor: default !important;
  padding: 8px 14px !important;
  height: auto !important;
  border-left: 4px solid var(--group-color, transparent);
  border-bottom: 1px solid var(--color-border);
}
.group-summary-row:hover td { background: #fcfcfd !important; }
.group-summary {
  display: flex; align-items: center; gap: 12px;
}
.group-summary-label { font-size: 11px; color: var(--color-text-muted); min-width: 56px; }
.summary-bar {
  flex: 1; max-width: 280px;
  display: flex; height: 14px; border-radius: 7px; overflow: hidden;
  background: #eef0f4;
}
.summary-seg { height: 100%; }
.summary-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--color-text-secondary); }
.summary-legend span { display: inline-flex; align-items: center; gap: 5px; }
.summary-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* ---------- 工具条（monday 风格 ghost 按钮组）---------- */
.toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 10px 12px;
}
.toolbar .btn-ghost { border-color: transparent; }
.toolbar .btn-ghost:hover { background: var(--color-sidebar-hover-bg); }

/* ---------- Responsive adjustments ---------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-wrapper { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .meta-grid  { grid-template-columns: 1fr; }
  .global-topbar-left .global-plans { display: none; }
}

/* ============================================================
   严格对齐 monday 看板：工具栏 / 标签页 / 分组色条 / 列头 / 汇总
   ============================================================ */

/* ---------- 看板标签页（Main Table）---------- */
.board-tabs {
  display: flex; align-items: center; gap: 2px;
  border-bottom: 1px solid var(--color-border);
  padding: 0 4px;
  background: #fff;
}
.board-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px; font-size: 14px; font-weight: 500;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer;
}
.board-tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.board-tab-add { padding: 8px 10px; color: var(--color-text-muted); cursor: pointer; }

/* ---------- 看板工具栏 ---------- */
.board-toolbar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 10px 4px; background: #fff;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px; border-radius: 6px;
  background: none; border: none; font-size: 14px; font-weight: 500;
  color: var(--color-text-secondary); transition: background var(--transition);
}
.tool-btn:hover { background: var(--color-sidebar-hover-bg); color: var(--color-text-primary); }
.tool-btn svg { width: 17px; height: 17px; }
.tool-sep { width: 1px; height: 20px; background: var(--color-border); margin: 0 4px; }
.new-task-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 8px 0 14px; border-radius: 6px;
  background: var(--color-primary); color: #fff; border: none;
  font-size: 14px; font-weight: 600; margin-right: 6px;
}
.new-task-btn:hover { background: var(--color-primary-hover); }
.new-task-btn .caret { border-left: 1px solid rgba(255,255,255,.35); padding-left: 8px; margin-left: 2px; }

/* ---------- monday 分组块：左侧圆角色条 + 内容 ---------- */
.board-group { display: flex; margin-bottom: 26px; }
.group-rail {
  width: 6px; border-radius: 6px; flex-shrink: 0; margin-right: 8px;
  background: var(--gc, var(--color-primary));
}
.group-main { flex: 1; min-width: 0; }
.group-title-row { display: flex; align-items: center; gap: 8px; padding: 2px 2px 8px; }
.group-caret {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--gc, var(--color-primary)); font-size: 12px; line-height: 1;
  transition: transform var(--transition);
}
.group-caret.collapsed { transform: rotate(-90deg); }
.group-title { font-size: 15px; font-weight: 700; color: var(--gc, var(--color-primary)); }
.group-title-count { font-size: 13px; color: var(--color-text-muted); font-weight: 500; }

/* ---------- 看板表格 ---------- */
.board-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: #fff; border: 1px solid var(--color-border);
  border-radius: 8px; overflow: hidden;
}
.board-table thead th {
  background: #fff; color: var(--color-text-secondary);
  font-weight: 500; font-size: 13px; text-align: left;
  padding: 9px 12px; border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.board-table thead th.col-check,
.board-table tbody td.col-check { width: 44px; text-align: center; padding: 0; }
.board-table tbody td {
  padding: 0 12px; height: 44px;
  border-bottom: 1px solid #eceef2; color: var(--color-text-primary);
  font-size: 13px; vertical-align: middle;
}
.board-table tbody tr:last-child td { border-bottom: 1px solid var(--color-border); }
.board-table tbody tr.board-row:hover td { background: var(--color-row-hover); cursor: pointer; }
.board-table tbody tr.board-row:hover td.status-cell { background: inherit; }

/* monday 复选框 */
.mday-check {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid #c3c6d4; background: #fff; display: inline-block;
  vertical-align: middle; transition: border-color var(--transition);
}
.board-row:hover .mday-check { border-color: var(--color-primary); }

/* 整格状态在看板表中的微调（去掉额外白边，monday 状态格之间是细缝）*/
.board-table td.status-cell { border-bottom: 2px solid #fff !important; height: 44px; }

/* + 添加行 */
.add-row td {
  height: 38px; color: var(--color-text-muted); font-size: 13px;
  padding-left: 12px; cursor: pointer;
}
.add-row:hover td { background: var(--color-row-hover); color: var(--color-primary); }

/* ---------- 分组底部汇总（对齐到各列下方）---------- */
.board-table tfoot td {
  height: 30px; padding: 6px 12px; background: #fcfcfd;
  border-top: 1px solid var(--color-border);
}
.foot-bar {
  display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: #eef0f4;
}
.foot-bar .seg { height: 100%; }
.foot-pill {
  display: inline-block; background: #333749; color: #fff;
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 11px;
}

/* ---------- monday 侧边栏结构 ---------- */
.sb-top { padding: 8px 8px 4px; }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; font-size: 14px; font-weight: 500;
  color: var(--color-sidebar-text); cursor: pointer; transition: background var(--transition);
}
.sb-item:hover { background: var(--color-sidebar-hover-bg); }
.sb-item .sb-ic { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-secondary); }
.sb-item .sb-ic svg { width: 18px; height: 18px; }
.sb-row-between { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 4px; }
.sb-row-between .sb-label { font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.sb-row-icons { display: flex; gap: 6px; color: var(--color-text-muted); }
.sb-row-icons svg { width: 16px; height: 16px; cursor: pointer; }
.sb-hr { height: 1px; background: var(--color-sidebar-border); margin: 8px 12px; }

.workspace-sel {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 8px 8px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--color-border); cursor: pointer;
}
.workspace-sel:hover { background: var(--color-sidebar-hover-bg); }
.ws-icon {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, #ff5ac4, #ff158a); color: #fff;
  font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.ws-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--color-text-primary); }
.ws-caret { color: var(--color-text-muted); font-size: 11px; }
.ws-add {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  background: var(--color-primary); color: #fff; border: none;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.ws-add:hover { background: var(--color-primary-hover); }

/* 板块（导航）项：monday 浅灰高亮 */
.board-nav { list-style: none; padding: 0 8px; flex: 1; }
.board-nav-item { margin-bottom: 1px; }
.board-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; font-size: 14px; font-weight: 500;
  color: var(--color-sidebar-text); transition: background var(--transition);
}
.board-nav-link:hover { background: var(--color-sidebar-hover-bg); }
.board-nav-link.active { background: #e6effc; color: var(--color-text-primary); font-weight: 600; }
.board-nav-link .bn-ic { width: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-secondary); }
.board-nav-link .bn-ic svg { width: 18px; height: 18px; }
.board-nav-link.active .bn-ic { color: var(--color-primary); }

/* ============================================================
   浮动圆角双面板布局（灰画布 + 白→灰渐变侧栏 + 白色主区，均圆角）
   覆盖前面的固定侧栏布局
   ============================================================ */
body.has-topbar .app-shell {
  margin-top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  padding: 6px 8px 10px;
  gap: 8px;
  box-sizing: border-box;
  overflow: hidden;
  align-items: stretch;
}

/* 左侧：白→灰渐变圆角长条 */
.sidebar {
  position: static;
  top: auto; left: auto; bottom: auto;
  width: 240px;
  min-height: 0;
  height: 100%;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 35%, #eceef4 100%);
  overflow-y: auto;
  z-index: 1;
}
.sidebar-logo { border-bottom: 1px solid rgba(0,0,0,0.05); }
.sidebar-footer { border-top: 1px solid rgba(0,0,0,0.05); }

/* 右侧：白色圆角长块 */
.main-wrapper {
  margin-left: 0;
  height: 100%;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow-y: auto;
}

/* 主区顶部标题栏：贴合白色面板、圆角，吸顶在面板内 */
body.has-topbar .top-header {
  position: sticky;
  top: 0;
  height: auto;
  min-height: 60px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  border-radius: 14px 14px 0 0;
  z-index: 20;
}

/* 主区内容直接坐落在白色面板上 */
.page-body { padding: 20px 28px 28px; }

/* 顶栏与背景同色（已设），确保整体画布为灰 */
body.has-topbar { background: var(--color-bg); }

@media (max-width: 768px) {
  body.has-topbar .app-shell { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: auto; height: auto; transform: none; }
  .main-wrapper { height: auto; }
}
