/* ========================================================================
   Sales Target Tracking System — Design System
   Premium dark-theme with glassmorphism
   ======================================================================== */

/* --- CSS Variables / Design Tokens --- */
:root {
  /* Backgrounds */
  --bg-primary: #f3f4f6; /* light gray body */
  --bg-secondary: #ffffff; /* white sidebar/cards */
  --bg-tertiary: #f8fafc;
  --bg-card: #ffffff;
  --bg-glass: #f9fafb; /* flat light gray instead of glass */
  --border-glass: #e5e7eb;
  --border-hover: #d1d5db;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;

  /* Accent Colors */
  --accent-blue: #2563eb;
  --accent-purple: #7c3aed;
  --accent-cyan: #0891b2;
  --accent-green: #059669;
  --accent-yellow: #d97706;
  --accent-red: #dc2626;
  --accent-pink: #db2777;

  /* Gradients (flattened for clean theme) */
  --gradient-primary: #2563eb;
  --gradient-success: #059669;
  --gradient-danger: #dc2626;
  --gradient-purple: #7c3aed;

  /* Shadows (subtle flat shadows) */
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-glow-blue: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-glow-green: 0 1px 2px 0 rgba(0, 0, 0, 0.05);

  /* Radius (slightly sharper for clean data look) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Transition */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  display: flex;
  min-height: 100vh;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

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

/* Subtle gradient accent on right edge */
#sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(59, 130, 246, 0.4) 30%,
    rgba(139, 92, 246, 0.4) 70%,
    transparent 100%
  );
  pointer-events: none;
}

/* Logo */
.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.sidebar__logo .logo-icon {
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.sidebar__logo h1 {
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

/* Navigation */
.sidebar__nav {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
}

.sidebar__nav li {
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-glass);
  opacity: 0;
  transition: var(--transition);
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.nav-item:hover::before {
  opacity: 1;
}

.nav-icon {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.nav-item.active {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: var(--shadow-glow-blue);
  font-weight: 600;
}

.nav-item.active::before {
  display: none;
}

/* Footer */
.sidebar__footer {
  padding: 20px;
  border-top: 1px solid var(--border-glass);
  margin-top: auto;
}

.current-month {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}

/* ========================================================================
   Main Content
   ======================================================================== */
#main-content {
  margin-left: 260px;
  padding: 32px;
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
  background: var(--bg-primary);
}

/* ========================================================================
   Card Component
   ======================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

/* ========================================================================
   Metric Card
   ======================================================================== */
.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: var(--transition);
}

.metric-card:hover {
  border-color: var(--border-hover);
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.metric-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.metric-card__icon--blue {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.05));
  color: var(--accent-blue);
}

.metric-card__icon--green {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
  color: var(--accent-green);
}

.metric-card__icon--purple {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.05));
  color: var(--accent-purple);
}

.metric-card__icon--cyan {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(6, 182, 212, 0.05));
  color: var(--accent-cyan);
}

.metric-card__icon--yellow {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.05));
  color: var(--accent-yellow);
}

.metric-card__icon--red {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.05));
  color: var(--accent-red);
}

.metric-card__icon--pink {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(236, 72, 153, 0.05));
  color: var(--accent-pink);
}

.metric-card__value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.metric-card__label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.metric-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.metric-card__trend--up {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.metric-card__trend--down {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* ========================================================================
   Channel Card
   ======================================================================== */
.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  border-left: 3px solid var(--accent-blue);
}

.channel-card:hover {
  border-color: var(--border-hover);
  border-left-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.channel-card--purple {
  border-left-color: var(--accent-purple);
}

.channel-card--purple:hover {
  border-left-color: var(--accent-purple);
}

.channel-card--green {
  border-left-color: var(--accent-green);
}

.channel-card--green:hover {
  border-left-color: var(--accent-green);
}

.channel-card--cyan {
  border-left-color: var(--accent-cyan);
}

.channel-card--cyan:hover {
  border-left-color: var(--accent-cyan);
}

.channel-card--yellow {
  border-left-color: var(--accent-yellow);
}

.channel-card--yellow:hover {
  border-left-color: var(--accent-yellow);
}

.channel-card--pink {
  border-left-color: var(--accent-pink);
}

.channel-card--pink:hover {
  border-left-color: var(--accent-pink);
}

.channel-card--red {
  border-left-color: var(--accent-red);
}

.channel-card--red:hover {
  border-left-color: var(--accent-red);
}

.channel-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.channel-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.channel-card__name {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.channel-card__assignee {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-glass);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-glass);
}

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

.channel-card__progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.channel-card__percentage {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.channel-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.channel-card__footer span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-card__footer small {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ========================================================================
   Progress Bar
   ======================================================================== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 1s ease;
  position: relative;
  background: var(--gradient-primary);
}

/* shimmer removed for stable data readability */

.progress-bar__fill--green {
  background: var(--gradient-success);
}

.progress-bar__fill--yellow {
  background: linear-gradient(135deg, var(--accent-yellow), #f97316);
}

.progress-bar__fill--red {
  background: var(--gradient-danger);
}

/* ========================================================================
   Grid Layout
   ======================================================================== */
.grid {
  display: grid;
  gap: 24px;
}

.grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid--auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.grid--2-asymmetric {
  grid-template-columns: 2fr 3fr;
}

/* ========================================================================
   Data Table
   ======================================================================== */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-glass);
  text-align: left;
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.data-table th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #f9fafb;
}

.data-table input,
.data-table select {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  width: 100%;
  transition: var(--transition);
  font-family: inherit;
}

.data-table input:focus,
.data-table select:focus {
  border-color: var(--accent-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.data-table__total td {
  font-weight: 700;
  background: rgba(59, 130, 246, 0.05);
  border-top: 2px solid var(--border-glass);
}

/* ========================================================================
   Page Header
   ======================================================================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-header__title {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.page-header__subtitle {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 0.9rem;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Aliases used by JS pages */
.page-title {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 0.9rem;
}

/* Metric card content layout */
.metric-card__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-card__sub {
  margin-top: 4px;
}

/* Channel card icon (emoji) */
.channel-card__icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* Channel card body and rows */
.channel-card__body {
  margin-bottom: 12px;
}

.channel-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 4px 0;
}

.channel-card__row span:last-child {
  font-weight: 600;
  color: var(--text-primary);
}

/* Card header/title used inside .card */
.card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========================================================================
   Button
   ======================================================================== */
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
}

.btn--primary {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.2);
}

.btn--primary:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-glow-blue);
}

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

.btn--secondary {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
}

.btn--secondary:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.btn--danger {
  background: var(--accent-red);
  color: #ffffff;
}

.btn--danger:hover {
  background: #dc2626;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.btn--success {
  background: var(--gradient-success);
  color: #ffffff;
}

.btn--success:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-glow-green);
}

.btn--sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
}

.btn--icon:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ========================================================================
   Chart Container
   ======================================================================== */
.chart-container {
  width: 100%;
  min-height: 300px;
  border-radius: var(--radius-md);
}

/* ========================================================================
   Alert Item
   ======================================================================== */
.alert-item {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 16px;
}

.alert-item:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.alert-item__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.alert-item__content {
  flex: 1;
  min-width: 0;
}

.alert-item__title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.alert-item__desc {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.4;
}

.alert-item__time {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.alert-item--danger {
  border-left: 3px solid var(--accent-red);
}

.alert-item--danger .alert-item__icon {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.alert-item--warning {
  border-left: 3px solid var(--accent-yellow);
}

.alert-item--warning .alert-item__icon {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-yellow);
}

.alert-item--success {
  border-left: 3px solid var(--accent-green);
}

.alert-item--success .alert-item__icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.alert-item--info {
  border-left: 3px solid var(--accent-blue);
}

.alert-item--info .alert-item__icon {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

/* ========================================================================
   Form Elements
   ======================================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.form-input {
  width: 100%;
  padding: 10px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--accent-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  width: 100%;
  padding: 10px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%238892a8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--accent-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ========================================================================
   Tabs
   ======================================================================== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-glass);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  overflow-x: auto;
}

.tab-item {
  padding: 8px 20px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  border: none;
  background: none;
  font-family: inherit;
}

.tab-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.tab-item--active {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.tab-item--active:hover {
  background: var(--gradient-primary);
  color: #ffffff;
}

/* tab-btn aliases (used by JS) */
.tab-btn {
  padding: 8px 20px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  border: none;
  background: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.tab-btn--active {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.tab-btn--active:hover {
  background: var(--gradient-primary);
  color: #ffffff;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(0,0,0,0.06);
  font-size: 0.75rem;
  font-weight: 600;
}

.tab-btn--active .tab-count {
  background: rgba(255,255,255,0.2);
}

/* ========================================================================
   Badge
   ======================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 4px;
}

.badge--green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.badge--yellow {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-yellow);
}

.badge--red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.badge--blue {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.badge--purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
}

.badge--cyan {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

/* Badge semantic aliases (used by JS) */
.badge--success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.badge--warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-yellow);
}

.badge--danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* ========================================================================
   Progress Ring
   ======================================================================== */
.progress-ring {
  width: 200px;
  height: 200px;
  position: relative;
  margin: 0 auto;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
}

.progress-ring__text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.progress-ring__percentage {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  display: block;
}

.progress-ring__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: block;
  margin-top: 4px;
}

/* ========================================================================
   Modal
   ======================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 600px;
  width: 90%;
  animation: fadeIn 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.modal__header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal__close {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.2rem;
}

.modal__close:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-glass);
}

/* ========================================================================
   Empty State
   ======================================================================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state__icon {
  font-size: 4rem;
  margin-bottom: 16px;
  display: block;
}

.empty-state__title {
  font-size: 1.2rem;
  font-weight: 600;
}

.empty-state__desc {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ========================================================================
   Tooltip
   ======================================================================== */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  white-space: nowrap;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
  z-index: 50;
}

.tooltip:hover::after {
  opacity: 1;
}

/* ========================================================================
   Animations
   ======================================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

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

@keyframes glowPulse {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.15);
  }
  50% {
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.3);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.animate-slide-in {
  animation: slideIn 0.4s ease forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Animation delay utilities */
.delay-1 {
  animation-delay: 100ms;
}

.delay-2 {
  animation-delay: 200ms;
}

.delay-3 {
  animation-delay: 300ms;
}

.delay-4 {
  animation-delay: 400ms;
}

.delay-5 {
  animation-delay: 500ms;
}

/* ========================================================================
   Utility Classes
   ======================================================================== */
.text-center {
  text-align: center;
}

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

.text-green {
  color: var(--accent-green);
}

.text-red {
  color: var(--accent-red);
}

.text-yellow {
  color: var(--accent-yellow);
}

.text-blue {
  color: var(--accent-blue);
}

.text-purple {
  color: var(--accent-purple);
}

.text-cyan {
  color: var(--accent-cyan);
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mb-32 {
  margin-bottom: 32px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.gap-16 {
  gap: 16px;
}

.gap-24 {
  gap: 24px;
}

.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

.hidden {
  display: none !important;
}

.overflow-hidden {
  overflow: hidden;
}

.w-full {
  width: 100%;
}

.w-1\/2 { width: 50%; }
.w-1\/3 { width: 33.3333%; }
.w-2\/3 { width: 66.6666%; }

.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ========================================================================
   Tag Input & Color Picker (Channel Management)
   ======================================================================== */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-chip__remove {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
  border-radius: 50%;
}

.tag-chip__remove:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.08);
}

.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  min-height: 42px;
}

.tag-input-wrapper:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.tag-input-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.color-swatch {
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch--active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent-blue);
}

/* Tag chip small variant */
.tag-chip--small {
  padding: 2px 8px;
  font-size: 0.8rem;
}

/* Person select wrapper */
.person-select-wrapper {
  min-height: 32px;
}

.person-select-add {
  outline: none;
}

.person-select-add:focus {
  border-color: var(--accent-blue);
}

.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ========================================================================
   Section Title (reusable within pages)
   ======================================================================== */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 3px;
  height: 18px;
  background: var(--gradient-primary);
  border-radius: 2px;
}

/* ========================================================================
   Status Indicator
   ======================================================================== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot--online {
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.status-dot--warning {
  background: var(--accent-yellow);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.status-dot--danger {
  background: var(--accent-red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

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

/* ========================================================================
   Loading / Skeleton
   ======================================================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-glass) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    var(--bg-glass) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton--text {
  height: 14px;
  width: 70%;
  margin-bottom: 8px;
}

.skeleton--title {
  height: 24px;
  width: 50%;
  margin-bottom: 12px;
}

.skeleton--card {
  height: 160px;
  border-radius: var(--radius-lg);
}

/* ========================================================================
   Responsive Design
   ======================================================================== */
@media (max-width: 1400px) {
  .grid--4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1200px) {
  .grid--3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -260px;
    transition: left 0.3s ease;
    z-index: 200;
  }

  #sidebar.sidebar--open {
    left: 0;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .sidebar-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
  }

  #main-content {
    margin-left: 0;
    padding: 20px 16px;
  }

  .grid--2 {
    grid-template-columns: 1fr;
  }

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

  .grid--4 {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .page-header__title {
    font-size: 1.4rem;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal {
    max-width: 95%;
    padding: 24px;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile hamburger button */
  .mobile-menu-btn {
    display: flex;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.2rem;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn {
    display: none;
  }

  .sidebar-backdrop {
    display: none;
  }
}

/* ========================================================================
   Print Styles
   ======================================================================== */
@media print {
  #sidebar {
    display: none;
  }

  #main-content {
    margin-left: 0;
  }

  .card,
  .metric-card,
  .channel-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  body {
    background: #fff;
    color: #333;
  }
}
