/* ============================================================
   ChordexBio Affiliate Portal — Main Stylesheet
   Brand: #8b459f (purple) · #dd5789 (rose) · #fedc2a (gold)
   Min-width: 320px
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── CSS Variables ── */
:root {
  --purple:     #8b459f;
  --purple-dk:  #6d3480;
  --purple-lt:  #b56ac8;
  --rose:       #dd5789;
  --rose-dk:    #c03d6e;
  --rose-lt:    #f07aaa;
  --gold:       #fedc2a;
  --gold-dk:    #e6c400;
  --gold-lt:    #fff0a0;

  --bg:         #0d0a12;
  --bg-card:    #16111e;
  --bg-hover:   #1e1729;
  --bg-sidebar: #110e18;
  --border:     rgba(139,69,159,0.2);
  --border-lt:  rgba(255,255,255,0.07);

  --text:       #f0eaf7;
  --text-muted: #9e8eb3;
  --text-dim:   #6b5e82;

  --gradient:   linear-gradient(135deg, var(--purple) 0%, var(--rose) 100%);
  --gradient-g: linear-gradient(135deg, var(--purple) 0%, var(--rose) 50%, var(--gold) 100%);
  --glow:       0 0 30px rgba(139,69,159,0.35);

  --sidebar-w:  260px;
  --header-h:   64px;
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  20px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --shadow-card:0 2px 16px rgba(0,0,0,0.3);

  --font-head:  'Syne', sans-serif;
  --font-body:  'DM Sans', sans-serif;
  --transition: all 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-width: 320px;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--purple-lt); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--rose-lt); }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: var(--font-body); }

/* ── Typography ── */
h1,h2,h3,h4,h5,h6 { font-family: var(--font-head); font-weight: 700; line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.5rem); }
h4 { font-size: 1.1rem; }
p  { margin-bottom: 0.75rem; color: var(--text-muted); }
small { font-size: 0.78rem; }

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

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; }
.sidebar-brand-text { font-family: var(--font-head); font-weight: 800; font-size: 1rem; line-height: 1.2; }
.sidebar-brand-text span { display: block; font-size: 0.65rem; font-weight: 400; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; }

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; color: var(--gold); text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 12px 20px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  position: relative;
  transition: var(--transition);
}
.nav-item:hover { color: var(--text); background: var(--bg-hover); }
.nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(139,69,159,0.2) 0%, transparent 100%);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 70%;
  background: var(--gradient);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; opacity: 0.8; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--rose);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.sidebar-footer .nav-item { padding: 8px 0; }

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

/* ── Header ── */
.topbar {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 4px;
}
.topbar-title { font-family: var(--font-head); font-size: 1rem; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: var(--transition);
}
.topbar-icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--purple); }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--rose);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 28px 24px;
  max-width: 1400px;
  width: 100%;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header-text h1 { font-size: clamp(1.3rem, 2.5vw, 1.75rem); }
.page-header-text p { margin: 4px 0 0; font-size: 0.875rem; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--purple-lt); }
.breadcrumb-sep { opacity: 0.4; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card-sm { padding: 16px; }
.card-lg { padding: 32px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 700; font-family: var(--font-head); }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--purple); transform: translateY(-2px); box-shadow: var(--glow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: var(--gradient);
  opacity: 0.06;
  border-radius: 0 0 0 100%;
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 14px;
}
.stat-icon.purple { background: rgba(139,69,159,0.2); color: var(--purple-lt); }
.stat-icon.rose   { background: rgba(221,87,137,0.2); color: var(--rose-lt); }
.stat-icon.gold   { background: rgba(254,220,42,0.2); color: var(--gold); }
.stat-icon.green  { background: rgba(52,211,153,0.2); color: #34d399; }
.stat-value { font-family: var(--font-head); font-size: 1.75rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-change { font-size: 0.75rem; margin-top: 8px; }
.stat-change.up   { color: #34d399; }
.stat-change.down { color: var(--rose); }

/* ── Grid System ── */
.grid { display: grid; gap: 20px; }
.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)); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn-sm  { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }

.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(139,69,159,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(139,69,159,0.5); color: white; }

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--purple);
  color: var(--purple-lt);
}
.btn-outline:hover { background: rgba(139,69,159,0.15); color: var(--purple-lt); }

.btn-danger  { background: rgba(221,87,137,0.2); color: var(--rose-lt); border: 1px solid rgba(221,87,137,0.3); }
.btn-danger:hover  { background: var(--rose); color: white; }
.btn-success { background: rgba(52,211,153,0.15); color: #34d399; border: 1px solid rgba(52,211,153,0.3); }
.btn-success:hover { background: #34d399; color: #0d0a12; }
.btn-gold    { background: var(--gold); color: #1a1208; font-weight: 700; }
.btn-gold:hover { background: var(--gold-dk); color: #1a1208; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: var(--transition);
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(139,69,159,0.15); }
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239e8eb3' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 5px; }
.form-error { font-size: 0.75rem; color: var(--rose); margin-top: 5px; }
.input-group { position: relative; }
.input-group .form-control { padding-left: 40px; }
.input-group .input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.input-group .input-action { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); background: none; border: none; cursor: pointer; }
.input-group .input-action:hover { color: var(--purple-lt); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  background: var(--bg);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-lt); transition: var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 12px 16px; color: var(--text-muted); vertical-align: middle; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.badge-success  { background: rgba(52,211,153,0.15); color: #34d399; }
.badge-warning  { background: rgba(254,220,42,0.15); color: var(--gold); }
.badge-danger   { background: rgba(221,87,137,0.15); color: var(--rose-lt); }
.badge-info     { background: rgba(96,165,250,0.15); color: #60a5fa; }
.badge-secondary{ background: rgba(255,255,255,0.06); color: var(--text-dim); }
.badge-purple   { background: rgba(139,69,159,0.2); color: var(--purple-lt); }

/* ── Alerts ── */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); font-size: 0.875rem; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: #34d399; }
.alert-danger   { background: rgba(221,87,137,0.1); border: 1px solid rgba(221,87,137,0.3); color: var(--rose-lt); }
.alert-warning  { background: rgba(254,220,42,0.1); border: 1px solid rgba(254,220,42,0.3); color: var(--gold); }
.alert-info     { background: rgba(96,165,250,0.1); border: 1px solid rgba(96,165,250,0.3); color: #60a5fa; }
.alert-dismiss  { margin-left: auto; background: none; border: none; color: inherit; opacity: 0.6; cursor: pointer; }

/* ── Task / Program Cards ── */
.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}
.task-card:hover { border-color: var(--purple); transform: translateY(-3px); box-shadow: var(--glow); }
.task-card-banner {
  height: 120px;
  background: var(--gradient);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.task-card-banner img { width: 100%; height: 100%; object-fit: cover; }
.task-card-banner-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.3); }
.task-card-type {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: white;
}
.task-card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; }
.task-card-title { font-family: var(--font-head); font-weight: 700; font-size: 1rem; margin-bottom: 6px; color: var(--text); }
.task-card-desc { font-size: 0.8rem; color: var(--text-muted); flex: 1; margin-bottom: 14px; }
.task-card-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.task-meta-item { display: flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--text-dim); }
.task-payout { font-family: var(--font-head); font-size: 1.1rem; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 1px solid var(--border); gap: 4px; overflow-x: auto; margin-bottom: 24px; }
.tab-item { padding: 10px 16px; font-size: 0.875rem; font-weight: 600; color: var(--text-muted); border: none; background: none; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: var(--transition); }
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--purple-lt); border-bottom-color: var(--purple); }

/* ── Modals ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: translateY(16px) scale(0.97);
  transition: all 0.25s ease;
}
.modal-overlay.open .modal { transform: none; }
.modal-lg { max-width: 760px; }
.modal-header { padding: 24px 24px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ── Notices ── */
.notice-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: var(--transition);
}
.notice-card:hover { border-color: var(--border-lt); }
.notice-card.pinned { border-left: 3px solid var(--gold); }
.notice-card.urgent { border-left: 3px solid var(--rose); }
.notice-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1rem; }
.notice-body { flex: 1; min-width: 0; }
.notice-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.notice-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice-date { font-size: 0.75rem; color: var(--text-dim); }

/* ── Avatar ── */
.avatar { border-radius: 50%; object-fit: cover; display: inline-block; }
.avatar-sm  { width: 32px; height: 32px; }
.avatar-md  { width: 48px; height: 48px; }
.avatar-lg  { width: 72px; height: 72px; }
.avatar-xl  { width: 96px; height: 96px; }
.avatar-placeholder {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient);
  color: white;
  font-weight: 700;
  font-family: var(--font-head);
}

/* ── Progress ── */
.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--gradient); border-radius: 3px; transition: width 0.5s ease; }

/* ── Dropdown ── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 300;
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}
.dropdown-menu.open { opacity: 1; pointer-events: auto; transform: none; }
.dropdown-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--text-muted); transition: var(--transition); cursor: pointer; }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-item.danger:hover { color: var(--rose-lt); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px; }

/* ── Empty States ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-icon  { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-family: var(--font-head); font-size: 1.1rem; color: var(--text-muted); margin-bottom: 8px; }
.empty-text  { font-size: 0.875rem; }

/* ── Login Page ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); position: relative; overflow: hidden; }
.auth-bg-orb { position: fixed; border-radius: 50%; filter: blur(80px); pointer-events: none; z-index: 0; }
.auth-bg-orb.orb1 { width: 400px; height: 400px; background: rgba(139,69,159,0.25); top: -100px; left: -100px; }
.auth-bg-orb.orb2 { width: 350px; height: 350px; background: rgba(221,87,137,0.2); bottom: -80px; right: -80px; }
.auth-bg-orb.orb3 { width: 200px; height: 200px; background: rgba(254,220,42,0.1); top: 50%; left: 50%; transform: translate(-50%,-50%); }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 40px 36px; width: 100%; max-width: 420px; position: relative; z-index: 1; box-shadow: var(--shadow); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo img { height: 48px; margin: 0 auto 10px; }
.auth-title { font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; text-align: center; margin-bottom: 4px; }
.auth-subtitle { text-align: center; font-size: 0.875rem; color: var(--text-muted); margin-bottom: 28px; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--border); background: none; color: var(--text-muted); font-size: 0.875rem; cursor: pointer; transition: var(--transition); }
.page-btn:hover { border-color: var(--purple); color: var(--text); }
.page-btn.active { background: var(--gradient); border-color: transparent; color: white; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 199; }

/* ── Utilities ── */
.d-flex     { display: flex; }
.d-grid     { display: grid; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.p-0 { padding: 0; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.8rem; }
.text-xs     { font-size: 0.72rem; }
.fw-bold     { font-weight: 700; }
.w-100       { width: 100%; }
.overflow-hidden { overflow: hidden; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex-1      { flex: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Loading Spinner ── */
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--purple-lt); border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner-lg { width: 40px; height: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; inset: 0; background: rgba(13,10,18,0.8); display: flex; align-items: center; justify-content: center; z-index: 9999; }

/* ── Toast Notifications ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 5000; display: flex; flex-direction: column; gap: 10px; max-width: 360px; width: calc(100% - 32px); }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: flex-start; gap: 12px; box-shadow: var(--shadow); animation: slideUp 0.3s ease; }
.toast.toast-success { border-left: 3px solid #34d399; }
.toast.toast-danger  { border-left: 3px solid var(--rose); }
.toast.toast-warning { border-left: 3px solid var(--gold); }
.toast.toast-info    { border-left: 3px solid var(--purple-lt); }
.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 700; font-size: 0.875rem; margin-bottom: 2px; }
.toast-message { font-size: 0.8rem; color: var(--text-muted); }
.toast-close { background: none; border: none; color: var(--text-dim); cursor: pointer; flex-shrink: 0; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

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

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; --header-h: 56px; }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; align-items: center; justify-content: center; }

  .page-content { padding: 20px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .card { padding: 16px; }
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar { padding: 0 16px; }
  .toast-container { bottom: 16px; right: 16px; left: 16px; max-width: none; width: auto; }
}

@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 20px 16px; }
}

/* ── Print ── */
@media print {
  .sidebar, .topbar, .toast-container { display: none !important; }
  .main-content { margin-left: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}

/* ============================================================
   v1.1 additions — Onboarding, Task Detail, Support, Editor
   ============================================================ */

/* ── Task Detail Modal / Drawer ── */
.task-detail-header {
  position: relative;
  height: 200px;
  background: var(--gradient);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  flex-shrink: 0;
}
.task-detail-header img { width:100%; height:100%; object-fit:cover; }
.task-detail-header-overlay { position:absolute; inset:0; background:linear-gradient(to top, rgba(13,10,18,.85) 0%, transparent 60%); }
.task-detail-header-content { position:absolute; bottom:0; left:0; right:0; padding:20px 24px; }
.task-detail-header-content h2 { font-size:clamp(1.1rem,2.5vw,1.5rem); color:#fff; margin-bottom:6px; }
.task-detail-badges { display:flex; gap:6px; flex-wrap:wrap; }

/* ── Onboarding content (rich HTML rendered) ── */
.onboarding-content {
  line-height: 1.8;
  color: var(--text-muted);
  font-size: .9rem;
}
.onboarding-content h1,.onboarding-content h2,.onboarding-content h3,
.onboarding-content h4,.onboarding-content h5 {
  font-family: var(--font-head);
  color: var(--text);
  margin: 1.4em 0 .5em;
}
.onboarding-content h1 { font-size:1.6rem; }
.onboarding-content h2 { font-size:1.3rem; border-bottom:1px solid var(--border); padding-bottom:.4em; }
.onboarding-content h3 { font-size:1.1rem; }
.onboarding-content p  { margin-bottom:.85em; }
.onboarding-content ul,.onboarding-content ol { padding-left:1.4em; margin-bottom:.85em; }
.onboarding-content li { margin-bottom:.35em; }
.onboarding-content a  { color:var(--purple-lt); text-decoration:underline; }
.onboarding-content a:hover { color:var(--rose-lt); }
.onboarding-content blockquote {
  border-left:3px solid var(--purple);
  margin:1em 0; padding:.6em 1em;
  background:rgba(139,69,159,.08);
  border-radius:0 var(--radius-sm) var(--radius-sm) 0;
  color:var(--text-muted);
  font-style:italic;
}
.onboarding-content img {
  max-width:100%; border-radius:var(--radius-sm);
  margin:1em 0; display:block;
}
.onboarding-content iframe {
  width:100%; aspect-ratio:16/9; border-radius:var(--radius-sm);
  border:1px solid var(--border); margin:1em 0; display:block;
}
.onboarding-content table {
  width:100%; border-collapse:collapse; margin:1em 0; font-size:.85rem;
}
.onboarding-content table th {
  background:var(--bg); padding:8px 12px; text-align:left;
  border:1px solid var(--border); font-weight:700; color:var(--text-dim);
  font-size:.72rem; text-transform:uppercase; letter-spacing:.06em;
}
.onboarding-content table td {
  padding:8px 12px; border:1px solid var(--border-lt); color:var(--text-muted);
}
.onboarding-content code {
  background:rgba(139,69,159,.12); color:var(--purple-lt);
  padding:1px 6px; border-radius:4px; font-family:monospace; font-size:.88em;
}
.onboarding-content pre {
  background:var(--bg); border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:14px; overflow-x:auto; margin:1em 0;
}
.onboarding-content pre code { background:none; padding:0; }
.onboarding-content hr { border:none; border-top:1px solid var(--border); margin:1.5em 0; }

/* ── Rich Text Editor (EasyMDE / custom toolbar) ── */
.editor-toolbar {
  display:flex; flex-wrap:wrap; gap:4px;
  padding:8px 10px; background:var(--bg);
  border:1px solid var(--border); border-bottom:none;
  border-radius:var(--radius-sm) var(--radius-sm) 0 0;
}
.editor-toolbar button {
  background:none; border:1px solid transparent;
  border-radius:4px; color:var(--text-muted);
  width:30px; height:30px; display:flex; align-items:center; justify-content:center;
  font-size:.85rem; cursor:pointer; transition:var(--transition);
}
.editor-toolbar button:hover { background:var(--bg-hover); color:var(--text); border-color:var(--border); }
.editor-toolbar button.active { background:rgba(139,69,159,.2); color:var(--purple-lt); border-color:var(--purple); }
.editor-toolbar .toolbar-sep { width:1px; background:var(--border); margin:4px 2px; align-self:stretch; }
.editor-content {
  border:1px solid var(--border);
  border-radius:0 0 var(--radius-sm) var(--radius-sm);
  min-height:320px;
  background:var(--bg);
}
.editor-content .ql-editor, .editor-content [contenteditable] {
  min-height:320px; padding:16px;
  color:var(--text); font-family:var(--font-body); font-size:.9rem; line-height:1.8;
  outline:none;
}
.editor-preview {
  min-height:320px; padding:16px;
  border:1px solid var(--border); border-radius:var(--radius-sm);
  background:var(--bg);
}
.editor-tabs { display:flex; gap:0; margin-bottom:-1px; position:relative; z-index:1; }
.editor-tab {
  padding:6px 16px; font-size:.8rem; font-weight:600; cursor:pointer;
  border:1px solid var(--border); background:var(--bg); color:var(--text-muted);
  border-radius:var(--radius-sm) var(--radius-sm) 0 0; border-bottom:none;
}
.editor-tab.active { background:var(--bg-card); color:var(--text); border-bottom:1px solid var(--bg-card); }

/* ── Support ticket cards ── */
.ticket-card {
  background:var(--bg-card); border:1px solid var(--border);
  border-radius:var(--radius); padding:18px 20px;
  display:flex; gap:14px; align-items:flex-start;
  transition:var(--transition);
}
.ticket-card:hover { border-color:var(--purple); }
.ticket-card.open   { border-left:3px solid var(--gold); }
.ticket-card.in_progress { border-left:3px solid var(--purple-lt); }
.ticket-card.resolved { border-left:3px solid #34d399; opacity:.75; }
.ticket-card.closed  { border-left:3px solid var(--text-dim); opacity:.6; }
.ticket-priority-dot {
  width:8px; height:8px; border-radius:50%; flex-shrink:0; margin-top:6px;
}
.priority-low     { background:#34d399; }
.priority-normal  { background:var(--purple-lt); }
.priority-high    { background:var(--gold); }
.priority-urgent  { background:var(--rose); }

/* ── Onboarding page (dedicated full page) ── */
.onboarding-hero {
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.onboarding-hero::before {
  content:'';
  position:absolute; top:-40px; right:-40px;
  width:220px; height:220px;
  background:rgba(255,255,255,.06);
  border-radius:50%;
}
.onboarding-hero h1 { color:#fff; margin-bottom:8px; }
.onboarding-hero p  { color:rgba(255,255,255,.8); margin:0; }

.onboarding-step {
  display:flex; gap:16px; align-items:flex-start;
  padding:16px 0; border-bottom:1px solid var(--border-lt);
}
.onboarding-step:last-child { border-bottom:none; }
.onboarding-step-num {
  width:32px; height:32px; border-radius:50%;
  background:var(--gradient); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:.85rem; flex-shrink:0;
}

@media (max-width:768px) {
  .task-detail-header { height:150px; }
  .onboarding-hero { padding:24px 20px; }
}
