/* StudySmarter Brand Tokens */
:root {
  --smarter-blue: #1300FF;
  --smarter-blue-light: #e8e5ff;
  --neon-lime: #C6FA02;
  --neon-lime-light: #f0ffc4;
  --hot-rod: #FF5C41;
  --charcoal: #232323;
  --stone: #F6F4F1;
  --stone-200: #E7E4E0;
  --stone-400: #D8D4CF;
  --white: #FCFCFD;
  --grey-200: #D3D3D3;
  --grey-400: #A7A7A7;
  --grey-600: #4F4F4F;
  --font-heading: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter Tight', sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--charcoal);
  background: var(--stone);
  line-height: 1.5;
}

/* Header */
.header {
  background: var(--smarter-blue);
  color: var(--white);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.header-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
}
.header-actions { display: flex; gap: 8px; }

/* Main */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--charcoal);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.card-header .card-title { margin-bottom: 0; }
.toggle-icon {
  font-size: 20px;
  color: var(--grey-400);
  width: 24px;
  text-align: center;
}

/* Buttons */
.btn {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-blue { background: var(--smarter-blue); color: var(--white); }
.btn-lime { background: var(--neon-lime); color: var(--charcoal); }

/* Input */
.input {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--stone-400);
  border-radius: var(--radius-sm);
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--smarter-blue); }

/* Campaign Selector */
.selector-card { position: relative; }
.selector-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.campaign-select-wrap {
  flex: 1;
  position: relative;
}
.campaign-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--stone-400);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
}
.campaign-list.open { display: block; }
.campaign-group-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--grey-600);
  padding: 8px 12px 4px;
  background: var(--stone);
  position: sticky;
  top: 0;
}
.campaign-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}
.campaign-item:hover { background: var(--smarter-blue-light); }
.campaign-item input[type="checkbox"] { accent-color: var(--smarter-blue); }
.campaign-item .badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.badge-active { background: #d4edda; color: #155724; }
.badge-inactive { background: #f8d7da; color: #721c24; }
.badge-merging { background: var(--smarter-blue-light); color: var(--smarter-blue); }

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  background: var(--smarter-blue-light);
  color: var(--smarter-blue);
  padding: 3px 10px;
  border-radius: 12px;
}
.selected-tag .remove {
  cursor: pointer;
  font-size: 14px;
  margin-left: 2px;
  opacity: 0.7;
}
.selected-tag .remove:hover { opacity: 1; }

/* Merging Card */
.merging-card {
  background: var(--smarter-blue-light);
  border-left: 4px solid var(--smarter-blue);
}
.merging-card .card-title { color: var(--smarter-blue); }
.merging-item {
  font-size: 13px;
  padding: 3px 0;
  color: var(--grey-600);
}

/* Overview KPI Grid */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-wide { grid-column: span 2; }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--grey-600);
}
.kpi-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--smarter-blue);
}
.kpi-value-sm { font-size: 16px; }

/* Targeting Override Panel */
.targeting-body { margin-top: 16px; }
.targeting-hint {
  font-size: 12px;
  color: var(--grey-600);
  margin-bottom: 16px;
  font-style: italic;
}
.targeting-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Manual Corrections Panel */
.corrections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.correction-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.correction-field label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--grey-600);
}
.correction-field .input {
  width: 100%;
}
.corrections-actions {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.corrections-applied-label {
  font-size: 12px;
  color: var(--grey-600);
  font-style: italic;
}
.targeting-group {
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.targeting-group.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.targeting-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.targeting-group-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--grey-600);
}
.targeting-count {
  font-size: 11px;
  color: var(--grey-400);
}
.targeting-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 13px;
}
.targeting-item input[type="checkbox"] { accent-color: var(--smarter-blue); }
.targeting-item.unchecked { color: var(--grey-400); text-decoration: line-through; }

/* Targeting badges (restricted / unrestricted) */
.targeting-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}
.targeting-badge-targeted {
  background: var(--smarter-blue-light);
  color: var(--smarter-blue);
}
.targeting-badge-all {
  background: var(--stone-200);
  color: var(--grey-600);
}
/* Subtle visual for unrestricted groups */
.targeting-group.unrestricted {
  border-style: dashed;
  border-color: var(--stone-400);
}

/* Data Tables */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--smarter-blue);
  color: var(--white);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
  border: 1px solid var(--smarter-blue);
}
.data-table th:first-child { text-align: left; }
.data-table td {
  padding: 6px 10px;
  text-align: right;
  border: 1px solid var(--stone-200);
  white-space: nowrap;
}
.data-table td:first-child {
  text-align: left;
  font-weight: 600;
}
.data-table tbody tr:nth-child(even) { background: var(--stone); }
.data-table tbody tr:hover { background: var(--smarter-blue-light); }
.data-table tr.total-row td {
  background: var(--neon-lime);
  font-weight: 700;
  font-family: var(--font-heading);
  border-color: var(--stone-400);
}

/* Dimension cards */
.dim-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.dim-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.dim-card-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
}
.dim-card-body { margin-top: 12px; }

/* QA Bar */
.qa-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
#qa-status {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
}
.qa-pass { color: #155724; }
.qa-fail { color: var(--hot-rod); }

/* Client selector */
.client-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.client-select { max-width: 300px; }

/* Date range */
.date-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--stone-200);
}
.date-label {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--grey-600);
  white-space: nowrap;
}
.date-input { max-width: 150px; }
.date-sep { color: var(--grey-400); font-size: 13px; }

/* Button variants */
.btn-outline {
  background: transparent;
  color: var(--smarter-blue);
  border: 1px solid var(--smarter-blue);
}
.btn-outline:hover { background: var(--smarter-blue-light); }
.btn-outline-light {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.4);
}
.btn-outline-light:hover { background: rgba(255,255,255,0.1); }
.btn-sm { padding: 5px 12px; font-size: 11px; }

/* Selector header row (title + refresh) */
.selector-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.campaign-count-badge {
  font-size: 11px;
  color: var(--grey-400);
  margin-left: auto;
}

/* View tabs */
.view-tabs {
  display: flex;
  gap: 0;
  margin-bottom: -1px;
}
.tab-btn {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 24px;
  border: 1px solid var(--stone-400);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--stone);
  color: var(--grey-600);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: var(--stone-200); }
.tab-btn.active {
  background: var(--white);
  color: var(--smarter-blue);
  border-color: var(--stone-400);
  border-bottom: 1px solid var(--white);
  margin-bottom: -1px;
}

/* Responsive */
@media (max-width: 768px) {
  .main { padding: 12px; }
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .kpi-wide { grid-column: span 2; }
  .targeting-groups { grid-template-columns: 1fr; }
  .kpi-value { font-size: 20px; }
}
