/* TSC CX Admin — design tokens lifted from customer-facing screenshots */
:root {
  --bg: #F4F4F7;
  --bg-soft: #FAFAFC;
  --surface: #FFFFFF;
  --border: #E8E8EE;
  --border-strong: #D8D8E2;

  --text: #14121F;
  --text-2: #4B4960;
  --text-3: #7A7892;
  --text-4: #A8A6B8;

  /* Primary purple gradient stack from the screenshots */
  --primary: #7C3AED;
  --primary-600: #6D28D9;
  --primary-700: #5B21B6;
  --primary-300: #B794F6;
  --primary-100: #EDE4FF;
  --primary-50: #F6F0FF;

  --accent-grad: linear-gradient(95deg, #5B21B6 0%, #7C3AED 50%, #A855F7 100%);

  --success: #16A34A;
  --success-bg: #DCFCE7;
  --warning: #B45309;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --info: #2563EB;
  --info-bg: #DBEAFE;

  --buy: #2563EB;
  --sell: #EF4444;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 1px 2px rgba(20, 18, 31, 0.04);
  --shadow: 0 4px 14px rgba(20, 18, 31, 0.06);
  --shadow-lg: 0 12px 40px rgba(20, 18, 31, 0.12);

  --row-h: 52px;
  --sidebar-w: 240px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body, #app {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13.5px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: all .12s ease;
}
.btn:hover { transform: translateY(-0.5px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-dark { background: #14121F; color: #fff; }
.btn-dark:hover { background: #2C2940; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-soft { background: var(--primary-50); color: var(--primary-600); }
.btn-soft:hover { background: var(--primary-100); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-icon {
  width: 32px; height: 32px; padding: 0; justify-content: center;
  border-radius: 8px;
  background: var(--primary-50); color: var(--primary-600);
}
.btn-icon:hover { background: var(--primary-100); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-weight: 600; font-size: 14.5px; }
.card-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

/* === Pills / Badges === */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  background: var(--primary-50); color: var(--primary-600);
  white-space: nowrap;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-neutral { background: #EEEEF3; color: #4B4960; }

/* === Tables === */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 12px 16px;
  background: var(--primary-50);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.tbl th:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.tbl th:last-child { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
.tbl td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-soft); }
.tbl-num { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* compact density */
body.density-compact .tbl td { padding: 9px 14px; }
body.density-compact .tbl th { padding: 9px 14px; }

/* === Inputs === */
.input, .select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.input::placeholder { color: var(--text-4); }
.search-input {
  padding-left: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A7892' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.label { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; display: block; font-weight: 500; }

/* === Layout === */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.brand-sub { font-size: 10.5px; color: var(--text-3); letter-spacing: .6px; text-transform: uppercase; }

.nav-section {
  font-size: 10.5px; color: var(--text-4);
  letter-spacing: .8px; text-transform: uppercase;
  padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active {
  background: var(--primary-50);
  color: var(--primary-600);
  font-weight: 500;
}
.nav-item .nav-count {
  margin-left: auto;
  background: var(--bg);
  color: var(--text-2);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 500;
}
.nav-item.active .nav-count { background: white; color: var(--primary-600); }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-search {
  position: relative; flex: 1; max-width: 460px;
}
.topbar-search .input { padding-left: 36px; background: var(--bg-soft); border-color: transparent; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  position: relative;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface);
}

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-100);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary-600);
  font-weight: 600;
  font-size: 12px;
}

.page { padding: 24px 28px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.page-sub { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }

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

/* === KPI === */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.kpi-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; }
.kpi-value { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.4px; }
.kpi-trend { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-50); color: var(--primary-600);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}

/* === Hero banner (from screenshot 1) === */
.hero {
  background: var(--accent-grad);
  border-radius: var(--radius-xl);
  padding: 22px 26px;
  color: white;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,0.07);
}
.hero::before {
  content: ""; position: absolute; right: 80px; bottom: -80px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,0.05);
}
.hero h2 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.hero p { margin: 0; opacity: .85; font-size: 13.5px; }

/* === Drawer / Modal === */
.scrim {
  position: fixed; inset: 0;
  background: rgba(20, 18, 31, .45);
  z-index: 50;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 720px; max-width: 96vw;
  background: var(--bg);
  z-index: 51;
  display: flex; flex-direction: column;
  animation: slideIn .22s cubic-bezier(.2,.8,.2,1);
  box-shadow: -20px 0 60px rgba(20,18,31,.2);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-head {
  padding: 18px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }

.modal {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 640px; max-width: 96vw; max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-xl);
  z-index: 51;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translate(-50%, -48%) scale(.96); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* === Tabs === */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 10px 14px; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-600); border-bottom-color: var(--primary); }

.tabs-pill { display: inline-flex; padding: 4px; background: var(--bg-soft); border-radius: 10px; border: 1px solid var(--border); gap: 2px; }
.tabs-pill .tab {
  padding: 6px 14px; font-size: 13px; border: none; margin: 0;
  border-radius: 7px;
}
.tabs-pill .tab.active { background: var(--primary); color: white; border: none; }

/* === Toggle switch === */
.switch { position: relative; width: 36px; height: 20px; display: inline-block; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: #D8D8E2; border-radius: 999px;
  transition: .15s;
}
.switch .slider::before {
  content: ""; position: absolute;
  width: 14px; height: 14px; left: 3px; top: 3px;
  background: white; border-radius: 50%;
  transition: .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* === Channel list rows (mirror screenshots) === */
.ch-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
}
.ch-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary-100); color: var(--primary-600);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

/* === RBAC matrix === */
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.matrix th, .matrix td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--border); }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix thead th { background: var(--primary-50); font-weight: 500; color: var(--text-2); }
.matrix .perm { display: inline-flex; gap: 4px; }

/* === Toast === */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #14121F; color: white;
  padding: 10px 16px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  z-index: 100;
  animation: pop .16s ease;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
}

/* === Misc === */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.dot-status { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.muted { color: var(--text-3); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12.5px; } .text-xs { font-size: 11.5px; }
.font-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D8D8E2; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
