:root {
  --bg: #F6F8FB;
  --surface: #FFFFFF;
  --surface-subtle: #F8FAFC;
  --border: #E5E9F0;
  --border-strong: #CBD5E1;
  --text: #111827;
  --text-secondary: #475569;
  --text-muted: #64748B;

  /* Modern Royal Blue Primary (User's preferred reference palette) */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #EFF6FF;
  --primary-border: #BFDBFE;

  /* Semantic Status Colors */
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --danger-bg: #FFF7F7;
  --danger-border: #FAD5D5;

  --warning: #D97706;
  --warning-soft: #FFFBEB;
  --warning-border: #FDE68A;

  --success: #16A34A;
  --success-soft: #F0FDF4;
  --success-border: #BBF7D0;

  --radius-card: 12px;
  --radius-btn: 7px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-float: 0 18px 48px rgba(15, 23, 42, 0.14);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
.tabular { font-variant-numeric: tabular-nums; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 600; }

/* Slim Sticky Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1340px;
  margin: 0 auto;
  min-height: 52px;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: nowrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.brand-badge {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}
.brand-title em {
  font-style: normal;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-soft);
  padding: 1px 5px;
  border-radius: 5px;
  margin-left: 2px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
}
.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.14s, color 0.14s;
}
.nav-tab:hover { background: var(--surface-subtle); color: var(--text); }
.nav-tab.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
  font-weight: 600;
}
.nav-dot {
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--danger-soft);
  color: var(--danger);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.shop-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
}
.shop-picker select {
  border: 0;
  background: transparent;
  outline: none;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

/* Main Stage */
.stage {
  max-width: 1340px;
  margin: 0 auto;
  padding: 18px 20px 44px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Cards & Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 16px 18px; }

/* 4-Column KPI Row (Exact clean style from reference screenshot) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); }
.kpi-value { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.kpi-value.is-danger { color: var(--danger); }
.kpi-value.is-warning { color: var(--warning); }
.kpi-value.is-success { color: var(--success); }
.kpi-value.is-primary { color: var(--primary); }
.kpi-sub { font-size: 12px; color: var(--text-muted); }

/* Priority Alert Highlight Box (Exact rose-tinted 2-col alert card from reference screenshot!) */
.priority-panel {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.priority-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.priority-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
}
.priority-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
}
.priority-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.priority-item {
  background: var(--surface);
  border: 1px solid #F3E4E4;
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.priority-item-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.priority-item-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.priority-item-title { font-weight: 600; color: var(--text); font-size: 13px; }
.priority-item-desc { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.priority-item-actions { display: flex; align-items: center; gap: 6px; shrink: 0; }

/* Compact Horizontal Trend / Summary Strip (Matching reference image) */
.strip-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.strip-items {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}
.strip-chip {
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.strip-chip.is-highlight {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 600;
}

/* Filter Toolbar & Segmented Controls */
.toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: #F1F5F9;
  border: 1px solid var(--border);
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* Inputs & Buttons */
.input, .select, .textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-btn);
  background: var(--surface);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.input, .select { height: 32px; }
.textarea { width: 100%; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s;
}
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: var(--surface); color: var(--text-secondary); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--surface-subtle); color: var(--text); }
.btn-soft-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.btn-soft-success:hover:not(:disabled) { background: #DCFCE7; }
.btn-soft-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.btn-soft-danger:hover:not(:disabled) { background: #FEE2E2; }

/* Semantic Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-blue { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.pill-green { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.pill-amber { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.pill-red { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.pill-gray { background: #F1F5F9; color: var(--text-secondary); border-color: var(--border); }

/* Clean High-Density Data Table */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}
.data-table th {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #FAFCFF; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

.table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Forms & Grids */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.check-inline input { accent-color: var(--primary); margin: 0; }

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-header h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.section-header p { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }

.empty-box, .loading-box {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Drawer & Modal */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.36);
  display: flex;
  justify-content: flex-end;
}
.backdrop-center { justify-content: center; align-items: center; padding: 16px; }
.drawer {
  width: min(520px, 100vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
}
.modal {
  width: min(640px, 100%);
  max-height: 86vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer-header, .modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.drawer-header h3, .modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-header p { margin: 2px 0 0; }
.drawer-body, .modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* AI Candidate Thumbnails */
.cand-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cand-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: left;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cand-card.is-picked { border-color: var(--primary); background: var(--primary-soft); }
.cand-preview {
  height: 88px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 12px;
}

.thumb-badge {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  background: #111827;
  color: #fff;
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-float);
}

@media (max-width: 960px) {
  .topbar-inner, .topbar-left { flex-wrap: wrap; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .priority-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stage { padding: 14px 12px 32px; }
}
