@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* ═══════════════════════════════════════
   TOKENS
═══════════════════════════════════════ */
:root {
  /* Sidebar */
  --sidebar-bg:    #14192e;
  --sidebar-w:     220px;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active:rgba(59,105,255,0.18);
  --sidebar-text:  rgba(255,255,255,0.55);
  --sidebar-head:  rgba(255,255,255,0.28);

  /* Surface */
  --bg-body:   #f5f6fa;
  --bg-card:   #ffffff;
  --bg-card2:  #f9fafb;

  /* Brand */
  --blue:      #3B69FF;
  --blue-lt:   #eef1ff;
  --blue-mid:  #c5cfff;

  /* Status */
  --green:     #12b76a;  --green-lt: #d1fadf;
  --red:       #f04438;  --red-lt:   #fde8e7;
  --amber:     #f79009;  --amber-lt: #fef0c7;
  --purple:    #7c3aed;  --purple-lt:#ede9fe;
  --gray:      #6b7280;  --gray-lt:  #f3f4f6;

  /* Text */
  --t1:  #0f172a;
  --t2:  #374151;
  --t3:  #6b7280;
  --t4:  #9ca3af;

  /* Border */
  --bdr: #e5e7eb;
  --bdr2:#d1d5db;

  /* Topbar */
  --topbar-h: 56px;

  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.08);
}

/* ═══════════════════════════════════════
   RESET
═══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg-body); color: var(--t1); font-size: 14px; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ═══════════════════════════════════════
   LAYOUT
═══════════════════════════════════════ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 20px;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-logo {
  display: flex; align-items: center; gap: 9px;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar-logo-mark { display: none; }
.logo-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}
.logo-mark-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.logo-mark--sm { width: 28px; height: 28px; }
.logo-mark--lg { width: 40px; height: 40px; }
.logo-mark-char,
.logo-mark-arc { display: none; }
.sidebar-logo-name {
  font-size: 14px; font-weight: 700; color: white;
}

.sidebar-section {
  padding: 20px 12px 4px;
}
.sidebar-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--sidebar-head);
  padding: 0 6px; margin-bottom: 4px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 450;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
}
.sidebar-item:hover { background: var(--sidebar-hover); color: rgba(255,255,255,0.85); }
.sidebar-item.active { background: var(--sidebar-active); color: white; }
.sidebar-item .si-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; color: currentColor; flex-shrink: 0; }
.sidebar-icon-svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-item .si-badge {
  margin-left: auto;
  background: var(--red); color: white;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
}
.sidebar-item .si-badge.blue { background: var(--blue); }
.sidebar-item .si-badge.green { background: var(--green); }
.sidebar-divider { border: none; border-top: 1px solid rgba(255,255,255,0.06); margin: 10px 12px; }

.sidebar-role-tag {
  display: flex; align-items: center; gap: 6px;
  padding: 0 18px;
  margin: 10px 0 4px;
}
.role-pill {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 100px;
}
.role-pill.buyer  { background: rgba(59,105,255,0.25); color: #8ba4ff; }
.role-pill.partner{ background: rgba(18,183,106,0.2); color: #34d399; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 12px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #6b8fff);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,0.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10.5px; color: var(--sidebar-head); }

/* ─── TOPBAR ─── */
.topbar {
  grid-area: topbar;
  background: var(--bg-card);
  border-bottom: 1px solid var(--bdr);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 10;
}
.topbar-heading { min-width: 0; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--t1); }
.topbar-sub { font-size: 12.5px; color: var(--t3); }
.topbar-spacer { flex: 1; }
.topbar-action { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.sidebar-toggle {
  display: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--bdr2);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: var(--t2);
  transition: transform 0.2s, opacity 0.2s;
}
.app-shell.sidebar-open .sidebar-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.app-shell.sidebar-open .sidebar-toggle span:nth-child(2) { opacity: 0; }
.app-shell.sidebar-open .sidebar-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
}

/* ─── MAIN ─── */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 24px;
}
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--bdr2); border-radius: 3px; }

/* ═══════════════════════════════════════
   COMPONENTS
═══════════════════════════════════════ */

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; transition: all 0.15s; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #2c58e8; }
.btn-ghost { background: transparent; color: var(--t2); border: 1px solid var(--bdr); }
.btn-ghost:hover { background: var(--gray-lt); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #d92d20; }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #0fa35e; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--bdr); border-radius: var(--radius-lg); padding: 20px; }
.card-sm { padding: 14px 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--t1); margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--t3); }

/* Stat cards */
.stat-card { display: flex; flex-direction: column; gap: 4px; }
.stat-val { font-size: 26px; font-weight: 700; color: var(--t1); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--t3); }
.stat-change { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 3px; }
.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }

/* Badges / Pills */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 100px; }
.badge-blue   { background: var(--blue-lt); color: var(--blue); }
.badge-green  { background: var(--green-lt); color: #067647; }
.badge-red    { background: var(--red-lt); color: #b42318; }
.badge-amber  { background: var(--amber-lt); color: #b54708; }
.badge-purple { background: var(--purple-lt); color: var(--purple); }
.badge-gray   { background: var(--gray-lt); color: var(--gray); }

/* Dot indicator */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }
.dot-amber { background: var(--amber); }
.dot-blue  { background: var(--blue); }
.dot-gray  { background: var(--t4); }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--bdr); gap: 0; margin-bottom: 20px; }
.tab { padding: 10px 16px; font-size: 13.5px; font-weight: 500; color: var(--t3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s, border-color 0.15s; }
.tab:hover { color: var(--t1); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 11.5px; font-weight: 600; color: var(--t3); text-transform: uppercase; letter-spacing: 0.05em; padding: 9px 14px; background: var(--bg-card2); border-bottom: 1px solid var(--bdr); text-align: left; }
td { padding: 12px 14px; border-bottom: 1px solid var(--bdr); font-size: 13.5px; color: var(--t2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card2); }

/* Form fields */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--t2); margin-bottom: 5px; }
.form-input { width: 100%; padding: 8px 12px; border: 1px solid var(--bdr2); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--t1); font-size: 13.5px; transition: border-color 0.15s, box-shadow 0.15s; }
.form-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,105,255,0.12); }
.form-input::placeholder { color: var(--t4); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--t3); margin-top: 4px; }

/* Alert / Warning banner */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid; }
.alert-warn { background: var(--amber-lt); border-color: #fcd34d; }
.alert-danger { background: var(--red-lt); border-color: #fca5a5; }
.alert-success { background: var(--green-lt); border-color: #a7f3d0; }
.alert-info { background: var(--blue-lt); border-color: var(--blue-mid); }
.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-size: 13px; font-weight: 600; color: var(--t1); margin-bottom: 2px; }
.alert-body  { font-size: 12.5px; color: var(--t2); }

/* Countdown */
.countdown-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--blue-lt); border: 1px solid var(--blue-mid); border-radius: var(--radius); font-size: 13px; color: var(--blue); font-weight: 500; }
.countdown-time { font-family: 'Space Mono', monospace; font-size: 13.5px; font-weight: 700; }

/* Progress bar */
.progress { height: 6px; background: var(--gray-lt); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--blue); transition: width 0.3s; }
.progress-fill.green { background: var(--green); }
.progress-fill.amber { background: var(--amber); }
.progress-fill.red   { background: var(--red); }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Spacing */
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

/* Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--t1); }
.page-desc  { font-size: 13px; color: var(--t3); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--t1); }

/* Chip tags */
.chip { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; background: var(--gray-lt); color: var(--t2); border: 1px solid var(--bdr); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* Divider */
.hr { border: none; border-top: 1px solid var(--bdr); margin: 20px 0; }

/* Empty state */
.empty { text-align: center; padding: 56px 20px; color: var(--t3); }
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--t2); margin-bottom: 4px; }
.empty-desc { font-size: 13px; }

/* Video thumbnail */
.video-thumb { width: 100%; aspect-ratio: 16/9; background: #e5e7eb; border-radius: var(--radius-sm); overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-thumb-placeholder { font-size: 28px; color: var(--t4); }
.video-play-btn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.2s; border-radius: var(--radius-sm); }
.video-thumb:hover .video-play-btn { opacity: 1; }
.video-play-icon { width: 36px; height: 36px; border-radius: 50%; background: white; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--t1); }
.video-duration { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,0.7); color: white; font-size: 10px; font-family: 'Space Mono', monospace; padding: 2px 5px; border-radius: 3px; }

/* Avatar group */
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--blue-lt); color: var(--blue); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid white; }

/* Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; background: var(--t4); border-radius: 20px; cursor: pointer; transition: 0.2s; }
.switch input:checked + .switch-slider { background: var(--blue); }
.switch-slider::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }

/* Score ring placeholder */
.score-ring { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.score-high   { background: var(--green-lt); color: #067647; border: 2px solid var(--green); }
.score-mid    { background: var(--amber-lt); color: #b54708; border: 2px solid var(--amber); }
.score-low    { background: var(--red-lt); color: #b42318; border: 2px solid var(--red); }

/* Upload zone */
.upload-zone { border: 2px dashed var(--bdr2); border-radius: var(--radius-lg); padding: 40px 20px; text-align: center; background: var(--bg-card2); cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.upload-zone:hover { border-color: var(--blue); background: var(--blue-lt); }
.upload-icon { font-size: 32px; margin-bottom: 10px; }
.upload-title { font-size: 14px; font-weight: 600; color: var(--t2); margin-bottom: 4px; }
.upload-desc { font-size: 12.5px; color: var(--t3); }

/* Chart placeholder */
.chart-area { background: var(--bg-card2); border: 1px solid var(--bdr); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; }

/* Mini bar chart */
.mini-bars { display: flex; align-items: flex-end; gap: 4px; height: 56px; }
.mini-bar { flex: 1; border-radius: 3px 3px 0 0; background: var(--blue-mid); transition: background 0.2s; min-width: 6px; }
.mini-bar:hover { background: var(--blue); }

/* Scrollable list */
.list-scroll { max-height: 320px; overflow-y: auto; }
.list-scroll::-webkit-scrollbar { width: 4px; }
.list-scroll::-webkit-scrollbar-thumb { background: var(--bdr2); border-radius: 2px; }

/* Notification dot */
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; }

/* Filter row */
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row .form-input { width: auto; }

/* Responsive collapse */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 86vw);
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.25);
  }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
  .topbar { padding: 0 14px; }
  .topbar-sub { display: none; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
