/* ═══════════════════════════════════════════════════
   PULSE - SaaS Dashboard Design System
   Inter + JetBrains Mono · Dark-first · Violet accent
═══════════════════════════════════════════════════ */

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

/* TOKENS */
:root {
  --canvas:#09090B; --surface:#111113; --surface-2:#1A1A1F;
  --surface-3:#26262C; --surface-4:#2F2F38;
  --brand:#7C3AED; --brand-2:#6D28D9; --brand-lt:rgba(124,58,237,.12);
  --brand-glow:rgba(124,58,237,.25);
  --ok:#10B981; --ok-lt:rgba(16,185,129,.12);
  --warn:#F59E0B; --warn-lt:rgba(245,158,11,.12);
  --err:#EF4444; --err-lt:rgba(239,68,68,.12);
  --info:#3B82F6; --info-lt:rgba(59,130,246,.12);
  --pink:#EC4899; --pink-lt:rgba(236,72,153,.12);
  --cyan:#06B6D4; --cyan-lt:rgba(6,182,212,.12);
  --t1:#FAFAFA; --t2:#A1A1AA; --t3:#52525B; --t4:#3F3F46;
  --r-xs:4px; --r-sm:6px; --r-md:8px; --r-lg:10px;
  --r-xl:14px; --r-2xl:18px; --r-full:9999px;
  --shadow-sm:0 1px 3px rgba(0,0,0,.4);
  --shadow-md:0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:0 8px 40px rgba(0,0,0,.5);
  --modal-shadow:0 24px 64px rgba(0,0,0,.6),0 4px 16px rgba(0,0,0,.3);
  --sidebar-bg:#0D0D10; --sidebar-w:248px; --header-h:56px;
}
[data-theme="light"] {
  --canvas:#F4F4F5; --surface:#FFFFFF; --surface-2:#F4F4F5;
  --surface-3:#E4E4E7; --surface-4:#F4F4F5;
  --t1:#09090B; --t2:#71717A; --t3:#A1A1AA; --t4:#D4D4D8;
  --shadow-sm:0 1px 3px rgba(0,0,0,.08);
  --shadow-md:0 4px 16px rgba(0,0,0,.08);
  --modal-shadow:0 24px 64px rgba(0,0,0,.15),0 4px 12px rgba(0,0,0,.08);
}

/* RESET */
*{box-sizing:border-box;margin:0;padding:0}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body{font-family:'Inter',system-ui,sans-serif;font-size:14px;
  background:var(--canvas);color:var(--t1);line-height:1.5;
  -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
a{color:inherit;text-decoration:none}
button{font-family:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
img{max-width:100%;height:auto}
svg{display:block}

/* LAYOUT */
.sidebar{
  width:var(--sidebar-w);position:fixed;top:0;left:0;bottom:0;
  background:var(--sidebar-bg);
  border-right:1px solid rgba(255,255,255,.06);
  z-index:25;display:flex;flex-direction:column;
  /* no width transition - prevents fake collapse animation */
  overflow:clip; /* clip horizontally without affecting scroll */
  min-height:100vh;
}

.main-wrapper{margin-left:var(--sidebar-w);min-height:100vh;
  background:var(--canvas);/* no margin transition */}

/* Sidebar logo */
.sidebar-logo{
  height:var(--header-h);min-height:var(--header-h);
  padding:0 16px;
  border-bottom:1px solid rgba(255,255,255,.06);
  display:flex;align-items:center;gap:10px;flex-shrink:0;
}
.logo-mark{
  width:30px;height:30px;border-radius:var(--r-md);flex-shrink:0;
  background:linear-gradient(135deg,#7C3AED,#5B21B6);
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 0 16px rgba(124,58,237,.4);
}
.logo-mark svg{width:16px;height:16px;stroke:#fff;stroke-width:2;fill:none}
.logo-text{flex:1;min-width:0;overflow:hidden}
.logo-name{font-size:16px;font-weight:800;color:#fff;letter-spacing:-.4px;white-space:nowrap}
.logo-plan{font-size:10px;color:rgba(161,161,170,.5);white-space:nowrap}

/* Sidebar nav */
.sidebar-nav{flex:1;overflow-y:auto;overflow-x:hidden;padding:10px 0;scrollbar-width:none}
.sidebar-nav::-webkit-scrollbar{display:none}
.nav-group{margin-bottom:4px}
.nav-label{
  font-size:10px;font-weight:700;text-transform:uppercase;
  letter-spacing:.7px;color:rgba(82,82,91,.7);
  padding:8px 20px 4px;white-space:nowrap;overflow:hidden;
}
.nav-item{
  display:flex;align-items:center;gap:9px;
  padding:7px 12px;border-radius:var(--r-md);
  margin:1px 8px;color:var(--t3);font-size:13px;font-weight:500;
  transition:background .12s,color .12s;position:relative;
  white-space:nowrap;overflow:hidden;text-decoration:none;
}
.nav-item:hover{background:rgba(255,255,255,.05);color:var(--t2)}
.nav-item.active{
  background:rgba(124,58,237,.15);color:#C4B5FD;
}
.nav-item.active::before{
  content:'';position:absolute;left:0;top:50%;transform:translateY(-50%);
  width:3px;height:16px;background:var(--brand);border-radius:0 2px 2px 0;
  margin-left:-8px;
}
.nav-ico{width:15px;height:15px;stroke:currentColor;stroke-width:1.8;fill:none;flex-shrink:0}
.nav-text{flex:1;overflow:hidden;text-overflow:ellipsis}
.nav-badge{
  background:var(--err);color:#fff;font-size:10px;font-weight:700;
  padding:1px 5px;border-radius:var(--r-full);min-width:18px;text-align:center;
  flex-shrink:0;line-height:1.4;
}
.nav-badge.violet{background:var(--brand)}
.nav-badge.amber{background:var(--warn);color:#000}

/* Sidebar collapsed state */

.sidebar-user-info{flex:1;min-width:0;overflow:hidden}
.sidebar-user-name{font-size:12.5px;font-weight:600;color:#E4E4E7;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sidebar-user-role{font-size:11px;color:rgba(161,161,170,.55);white-space:nowrap}

.sidebar-user{
  padding:12px 14px;
  border-top:1px solid rgba(255,255,255,.06);
  display:flex;align-items:center;gap:10px;
  flex-shrink:0;
}
/* PAGE HEADER */
.page-header{
  height:var(--header-h);background:var(--surface);
  border-bottom:1px solid var(--surface-3);
  display:flex;align-items:center;padding:0 24px;gap:12px;
  position:sticky;top:0;z-index:20;
}
.breadcrumb{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--t3);flex:1;min-width:0;overflow:hidden;white-space:nowrap}
.bc-link{color:var(--t3);transition:color .12s}
.bc-link:hover{color:var(--t1)}
.bc-sep{width:14px;height:14px;stroke:var(--t4);stroke-width:2;fill:none;flex-shrink:0}
.bc-current{color:var(--t1);font-weight:500;overflow:hidden;text-overflow:ellipsis}
.search-wrap{position:relative;flex:1;max-width:400px}
.search-ico{position:absolute;left:10px;top:50%;transform:translateY(-50%);width:14px;height:14px;stroke:var(--t3);stroke-width:2;fill:none}
.search-input{width:100%;background:var(--surface-2);border:1px solid var(--surface-3);border-radius:var(--r-md);padding:7px 12px 7px 32px;font-size:13px;color:var(--t1);font-family:inherit;outline:none;transition:border .15s}
.search-input:focus{border-color:var(--brand);box-shadow:0 0 0 3px var(--brand-glow)}
.search-input::placeholder{color:var(--t3)}
.search-kbd{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:var(--surface-3);border-radius:4px;padding:2px 6px;font-size:10px;color:var(--t3);font-family:'JetBrains Mono',monospace}
.header-actions{display:flex;align-items:center;gap:6px}
.icon-btn{
  width:34px;height:34px;border-radius:var(--r-md);
  background:none;border:1px solid var(--surface-3);
  display:flex;align-items:center;justify-content:center;
  color:var(--t3);transition:all .12s;position:relative;
}
.icon-btn:hover{background:var(--surface-2);color:var(--t1);border-color:var(--surface-4)}
.icon-btn svg{width:15px;height:15px;stroke:currentColor;stroke-width:1.8;fill:none}
.notif-dot{position:absolute;top:5px;right:5px;width:6px;height:6px;border-radius:50%;background:var(--err);border:1.5px solid var(--surface)}
#mob-menu{display:none;width:34px;height:34px;border-radius:var(--r-md);align-items:center;justify-content:center;background:none;border:1px solid var(--surface-3);color:var(--t3)}
#mob-menu svg{width:16px;height:16px;stroke:currentColor;stroke-width:2;fill:none}

/* PROFILE */
.profile-wrap{position:relative}
.profile-btn{
  width:32px;height:32px;border-radius:var(--r-full);
  cursor:pointer;border:2px solid transparent;
  transition:border-color .15s;display:flex;align-items:center;justify-content:center;
}
.profile-btn:hover,.profile-btn.open{border-color:var(--brand)}
.profile-panel{
  position:absolute;right:0;top:calc(100% + 8px);width:220px;
  background:var(--surface);border:1px solid var(--surface-3);
  border-radius:var(--r-xl);box-shadow:var(--modal-shadow);
  z-index:50;overflow:hidden;display:none;
}
.profile-panel.open{display:block}
.profile-panel-head{padding:14px 16px;border-bottom:1px solid var(--surface-3)}
.profile-panel-name{font-size:13px;font-weight:700;color:var(--t1)}
.profile-panel-email{font-size:11px;color:var(--t3);margin-top:2px}
.profile-menu{padding:4px 0}
.profile-menu-item{
  display:flex;align-items:center;gap:9px;padding:8px 16px;
  font-size:13px;color:var(--t2);cursor:pointer;transition:background .12s;
  background:none;border:none;width:100%;text-align:left;font-family:inherit;
}
.profile-menu-item:hover{background:var(--surface-2);color:var(--t1)}
.profile-menu-item svg{width:14px;height:14px;stroke:currentColor;stroke-width:1.8;fill:none;flex-shrink:0}
.profile-menu-divider{height:1px;background:var(--surface-3);margin:4px 0}
.profile-menu-item.danger{color:var(--err)}
.profile-menu-item.danger:hover{background:var(--err-lt)}

/* PAGE BODY */
.page-body{padding:24px}
.page-top{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:24px}
.page-top-left{}
.page-title{font-size:22px;font-weight:700;color:var(--t1);letter-spacing:-.4px;margin-bottom:3px}
.page-sub{font-size:13px;color:var(--t3)}

/* CARDS */
.card{background:var(--surface);border:1px solid var(--surface-3);border-radius:var(--r-xl)}
.card-header{
  padding:16px 20px;border-bottom:1px solid var(--surface-3);
  display:flex;align-items:center;justify-content:space-between;gap:12px;
}
.card-title{font-size:14px;font-weight:700;color:var(--t1)}
.card-sub{font-size:12px;color:var(--t3);margin-top:2px}
.card-action{font-size:12.5px;font-weight:600;color:var(--brand);cursor:pointer;transition:opacity .15s}
.card-action:hover{opacity:.8}
.card-body{padding:20px}

/* STAT CARDS */
.stat-grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
.stat-grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.stat-grid-2{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}
.stat-card{
  background:var(--surface);border:1px solid var(--surface-3);
  border-radius:var(--r-xl);padding:20px;position:relative;overflow:hidden;
}
.stat-card::before{
  content:'';position:absolute;left:0;top:0;bottom:0;
  width:3px;border-radius:var(--r-xl) 0 0 var(--r-xl);
}
.stat-card.violet::before{background:var(--brand)}
.stat-card.green::before{background:var(--ok)}
.stat-card.amber::before{background:var(--warn)}
.stat-card.red::before{background:var(--err)}
.stat-card.blue::before{background:var(--info)}
.stat-card.cyan::before{background:var(--cyan)}
.stat-card.pink::before{background:var(--pink)}
.stat-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--t3);margin-bottom:10px;display:flex;align-items:center;justify-content:space-between}
.stat-value{font-family:'JetBrains Mono',monospace;font-size:26px;font-weight:600;color:var(--t1);line-height:1;margin-bottom:8px;letter-spacing:-.5px}
.stat-delta{font-size:12px;font-weight:600;display:inline-flex;align-items:center;gap:4px;padding:2px 7px;border-radius:var(--r-full)}
.stat-delta.up{background:var(--ok-lt);color:var(--ok)}
.stat-delta.down{background:var(--err-lt);color:var(--err)}
.stat-delta.neutral{background:var(--surface-3);color:var(--t3)}
.stat-delta svg{width:11px;height:11px;stroke:currentColor;stroke-width:2.5;fill:none}
.stat-meta{font-size:11.5px;color:var(--t3);margin-top:8px}
.sparkline{margin-top:14px;height:44px;width:100%}

/* TABLES */
.tbl-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:thin;scrollbar-color:var(--surface-3) transparent}
.tbl{width:100%;border-collapse:collapse;font-size:13.5px;min-width:600px}
.tbl th{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--t3);padding:10px 14px;border-bottom:1px solid var(--surface-3);text-align:left;white-space:nowrap;background:var(--surface)}
.tbl td{padding:12px 14px;border-bottom:1px solid var(--surface-3);color:var(--t2)}
.tbl tbody tr{transition:background .1s}
.tbl tbody tr:hover{background:var(--surface-2);cursor:pointer}
.tbl tbody tr:last-child td{border-bottom:none}
.tbl tbody tr.selected{background:var(--brand-lt)}
.tbl-check{width:40px;text-align:center!important}
.toolbar{display:flex;align-items:center;gap:10px;padding:14px 20px;border-bottom:1px solid var(--surface-3)}
.toolbar-search{position:relative;flex:1;max-width:280px}
.toolbar-search svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);width:13px;height:13px;stroke:var(--t3);stroke-width:2;fill:none}
.toolbar-search input{width:100%;background:var(--surface-2);border:1px solid var(--surface-3);border-radius:var(--r-md);padding:7px 10px 7px 30px;font-size:13px;color:var(--t1);font-family:inherit;outline:none}
.toolbar-search input:focus{border-color:var(--brand)}
.toolbar-search input::placeholder{color:var(--t3)}

/* BADGES */
.badge{font-size:11px;font-weight:700;padding:2px 8px;border-radius:var(--r-sm);display:inline-flex;align-items:center;gap:4px;white-space:nowrap}
.badge svg{width:9px;height:9px;stroke:currentColor;stroke-width:2.5;fill:none}
.badge-active{background:var(--ok-lt);color:var(--ok)}
.badge-trial{background:var(--info-lt);color:var(--info)}
.badge-canceled{background:var(--surface-3);color:var(--t3)}
.badge-past-due{background:var(--err-lt);color:var(--err)}
.badge-paused{background:var(--warn-lt);color:var(--warn)}
.badge-free{background:var(--pink-lt);color:var(--pink)}
.badge-starter{background:rgba(16,185,129,.15);color:var(--ok)}
.badge-growth{background:rgba(59,130,246,.15);color:var(--info)}
.badge-scale{background:rgba(124,58,237,.15);color:#C4B5FD}
.badge-enterprise{background:rgba(245,158,11,.15);color:var(--warn)}
.badge-paid{background:var(--ok-lt);color:var(--ok)}
.badge-pending{background:var(--warn-lt);color:var(--warn)}
.badge-failed{background:var(--err-lt);color:var(--err)}
.badge-refunded{background:var(--surface-3);color:var(--t3)}
.badge-live{background:var(--ok-lt);color:var(--ok)}
.badge-dev{background:var(--surface-3);color:var(--t3)}
.badge-owner{background:rgba(124,58,237,.15);color:#C4B5FD}
.badge-admin{background:var(--info-lt);color:var(--info)}
.badge-member{background:var(--surface-3);color:var(--t3)}

/* BUTTONS */
.btn{display:inline-flex;align-items:center;gap:7px;padding:8px 16px;border-radius:var(--r-md);font-size:13px;font-weight:600;cursor:pointer;border:none;font-family:inherit;transition:all .15s;white-space:nowrap}
.btn svg{width:14px;height:14px;stroke:currentColor;stroke-width:2;fill:none;flex-shrink:0}
.btn-primary{background:var(--brand);color:#fff}
.btn-primary:hover{background:var(--brand-2);box-shadow:0 0 0 3px var(--brand-glow)}
.btn-ghost{background:transparent;color:var(--t2);border:1px solid var(--surface-3)}
.btn-ghost:hover{background:var(--surface-2);color:var(--t1);border-color:var(--surface-4)}
.btn-danger{background:var(--err-lt);color:var(--err);border:1px solid rgba(239,68,68,.2)}
.btn-danger:hover{background:var(--err);color:#fff}
.btn-success{background:var(--ok-lt);color:var(--ok);border:1px solid rgba(16,185,129,.2)}
.btn-sm{padding:5px 12px;font-size:12.5px;border-radius:var(--r-sm)}
.btn-xs{padding:3px 8px;font-size:11.5px;border-radius:var(--r-sm)}
.btn-icon{width:32px;height:32px;padding:0;justify-content:center;background:var(--surface-2);border:1px solid var(--surface-3);color:var(--t2);border-radius:var(--r-md)}
.btn-icon:hover{background:var(--surface-3);color:var(--t1)}

/* AVATARS */
.av{width:32px;height:32px;border-radius:var(--r-full);display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;flex-shrink:0;color:#fff}
.av-sm{width:24px;height:24px;font-size:9px}
.av-md{width:36px;height:36px;font-size:12px}
.av-lg{width:44px;height:44px;font-size:15px}
.av-xl{width:56px;height:56px;font-size:18px}
.av-am{background:linear-gradient(135deg,#7C3AED,#5B21B6)}
.av-js{background:linear-gradient(135deg,#2563EB,#1D4ED8)}
.av-rk{background:linear-gradient(135deg,#059669,#047857)}
.av-ct{background:linear-gradient(135deg,#D97706,#B45309)}
.av-pw{background:linear-gradient(135deg,#DB2777,#BE185D)}
.av-generic{background:linear-gradient(135deg,#374151,#1F2937)}

/* FORMS */
.form-group{display:flex;flex-direction:column;gap:6px;margin-bottom:16px}
.form-label{font-size:12.5px;font-weight:600;color:var(--t2)}
.form-hint{font-size:11.5px;color:var(--t3);margin-top:4px}
.form-error{font-size:11.5px;color:var(--err);margin-top:4px}
.form-input,.form-select,.form-textarea{
  background:var(--surface-4);border:1px solid var(--surface-3);
  border-radius:var(--r-md);padding:9px 12px;font-size:13.5px;
  color:var(--t1);font-family:inherit;outline:none;transition:border .15s,box-shadow .15s;
  width:100%;
}
.form-input:focus,.form-select:focus,.form-textarea:focus{
  border-color:var(--brand);box-shadow:0 0 0 3px var(--brand-glow);
}
.form-input::placeholder,.form-textarea::placeholder{color:var(--t3)}
.form-select{-webkit-appearance:none;appearance:none;cursor:pointer;
  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='%2352525B' 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}
.form-textarea{resize:vertical;min-height:80px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.input-with-btn{display:flex;gap:8px}
.input-with-btn .form-input{flex:1}
.form-prefix{display:flex;align-items:center;border:1px solid var(--surface-3);border-radius:var(--r-md);overflow:hidden}
.form-prefix-label{padding:0 12px;background:var(--surface-2);color:var(--t3);font-size:13px;border-right:1px solid var(--surface-3);white-space:nowrap;height:38px;display:flex;align-items:center}
.form-prefix .form-input{border:none;border-radius:0;flex:1}
.form-prefix .form-input:focus{box-shadow:none}

/* Checkboxes */
input[type="checkbox"]{
  -webkit-appearance:none;appearance:none;
  width:15px;height:15px;border:1.5px solid var(--surface-3);
  border-radius:4px;background:var(--surface-4);cursor:pointer;
  position:relative;transition:background .15s,border-color .15s;flex-shrink:0;
}
input[type="checkbox"]:checked{background:var(--brand);border-color:var(--brand)}
input[type="checkbox"]:checked::after{
  content:'';position:absolute;left:3px;top:1px;
  width:5px;height:8px;border:1.5px solid #fff;
  border-top:none;border-left:none;transform:rotate(45deg);
}
input[type="checkbox"]:indeterminate{background:var(--brand);border-color:var(--brand)}
input[type="checkbox"]:indeterminate::after{
  content:'';position:absolute;left:2px;top:5px;
  width:7px;height:1.5px;background:#fff;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
input[type="number"]{-moz-appearance:textfield}

/* Toggle */
.toggle{width:40px;height:22px;border-radius:var(--r-full);background:var(--surface-3);position:relative;cursor:pointer;transition:background .2s;flex-shrink:0}
.toggle.on{background:var(--brand)}
.toggle::after{content:'';position:absolute;width:16px;height:16px;background:#fff;border-radius:50%;top:3px;left:3px;transition:transform .2s;box-shadow:0 1px 3px rgba(0,0,0,.3)}
.toggle.on::after{transform:translateX(18px)}

/* TABS */
.tabs{display:flex;border-bottom:1px solid var(--surface-3);gap:0;overflow-x:auto;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tab{
  padding:10px 18px;font-size:13px;font-weight:500;color:var(--t3);
  cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;
  transition:color .15s,border-color .15s;white-space:nowrap;
  background:none;border-top:none;border-left:none;border-right:none;
  font-family:inherit;flex-shrink:0;
}
.tab:hover{color:var(--t2)}
.tab.active{color:var(--brand);border-bottom-color:var(--brand);font-weight:600}

/* Filter tabs (pill style) */
.filter-tabs{display:flex;gap:6px;flex-wrap:wrap}
.filter-tab{
  padding:5px 14px;border-radius:var(--r-full);font-size:12.5px;
  font-weight:500;cursor:pointer;border:none;font-family:inherit;
  background:var(--surface-2);color:var(--t3);transition:all .15s;
}
.filter-tab:hover{color:var(--t2)}
.filter-tab.active{background:var(--brand);color:#fff}

/* BULK BAR */
.bulk-bar{
  display:none;align-items:center;gap:10px;
  padding:10px 20px;background:var(--brand);
  border-radius:var(--r-xl);margin-bottom:16px;
}
.bulk-bar span{font-size:13px;font-weight:700;color:#fff}
.bulk-bar .btn-bulk{
  display:inline-flex;align-items:center;gap:6px;padding:5px 12px;
  border-radius:var(--r-sm);font-size:12.5px;font-weight:600;cursor:pointer;
  background:rgba(255,255,255,.15);color:#fff;border:none;font-family:inherit;
  transition:background .12s;
}
.bulk-bar .btn-bulk:hover{background:rgba(255,255,255,.25)}
.bulk-bar .btn-bulk svg{width:13px;height:13px;stroke:currentColor;stroke-width:2;fill:none}
.bulk-bar .btn-clear{background:rgba(255,255,255,.08)}

/* MODALS */
.modal-backdrop{
  display:none;position:fixed;inset:0;background:rgba(0,0,0,.7);
  z-index:70;align-items:center;justify-content:center;padding:20px;
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);
}
.modal-backdrop.open{display:flex}
.modal{
  background:var(--surface);border:1px solid var(--surface-3);
  border-radius:var(--r-2xl);width:100%;
  box-shadow:var(--modal-shadow);max-height:90vh;overflow-y:auto;
}
.modal-sm{max-width:440px}
.modal-md{max-width:540px}
.modal-lg{max-width:680px}
.modal-header{
  display:flex;align-items:center;gap:12px;
  padding:20px 22px;border-bottom:1px solid var(--surface-3);
}
.modal-icon{
  width:36px;height:36px;border-radius:var(--r-lg);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.modal-icon svg{width:18px;height:18px;stroke:currentColor;stroke-width:1.8;fill:none}
.modal-title{font-size:15px;font-weight:700;color:var(--t1)}
.modal-close{
  margin-left:auto;width:28px;height:28px;border-radius:var(--r-sm);
  border:none;background:none;cursor:pointer;color:var(--t3);
  display:flex;align-items:center;justify-content:center;transition:all .12s;
}
.modal-close:hover{background:var(--surface-3);color:var(--t1)}
.modal-close svg{width:15px;height:15px;stroke:currentColor;stroke-width:2;fill:none}
.modal-body{padding:22px}
.modal-footer{
  padding:16px 22px;border-top:1px solid var(--surface-3);
  display:flex;justify-content:flex-end;gap:10px;
}

/* CALLOUTS */
.callout{padding:12px 16px;border-radius:var(--r-md);display:flex;align-items:flex-start;gap:10px;font-size:13px;margin-bottom:16px}
.callout svg{width:15px;height:15px;stroke:currentColor;stroke-width:2;fill:none;flex-shrink:0;margin-top:1px}
.callout-warn{background:var(--warn-lt);color:var(--warn);border:1px solid rgba(245,158,11,.2)}
.callout-err{background:var(--err-lt);color:var(--err);border:1px solid rgba(239,68,68,.2)}
.callout-ok{background:var(--ok-lt);color:var(--ok);border:1px solid rgba(16,185,129,.2)}
.callout-info{background:var(--info-lt);color:var(--info);border:1px solid rgba(59,130,246,.2)}
.callout-brand{background:var(--brand-lt);color:#C4B5FD;border:1px solid rgba(124,58,237,.2)}

/* HEALTH BAR */
.health-bar{height:4px;background:var(--surface-3);border-radius:var(--r-full);overflow:hidden}
.health-fill{height:100%;border-radius:var(--r-full);transition:width .3s}
.health-fill.good{background:var(--ok)}
.health-fill.warn{background:var(--warn)}
.health-fill.danger{background:var(--err)}

/* INTEGRATION CARD */
.integration-card{border:1px solid var(--surface-3);border-radius:var(--r-xl);padding:20px;transition:border-color .15s}
.integration-card:hover{border-color:var(--surface-4)}
.integration-card.connected{border-color:rgba(16,185,129,.25);background:rgba(16,185,129,.03)}
.int-logo{width:44px;height:44px;border-radius:var(--r-lg);background:var(--surface-2);border:1px solid var(--surface-3);display:flex;align-items:center;justify-content:center;margin-bottom:12px}
.int-logo svg{width:22px;height:22px;stroke:var(--t2);stroke-width:1.5;fill:none}
.int-name{font-size:14px;font-weight:700;color:var(--t1);margin-bottom:4px}
.int-desc{font-size:12px;color:var(--t3);line-height:1.5;margin-bottom:14px}
.status-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}
.status-dot.live{background:var(--ok);box-shadow:0 0 6px var(--ok)}
.status-dot.off{background:var(--surface-3)}
.status-dot.error{background:var(--err);box-shadow:0 0 6px var(--err)}

/* API KEY */
.api-key-val{font-family:'JetBrains Mono',monospace;font-size:12.5px;background:var(--surface-2);border:1px solid var(--surface-3);padding:8px 12px;border-radius:var(--r-md);color:var(--t2);letter-spacing:.5px;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.scope-badge{background:var(--surface-3);color:var(--t3);font-size:10px;font-weight:600;padding:2px 6px;border-radius:var(--r-sm);font-family:'JetBrains Mono',monospace}

/* COHORT TABLE */
.cohort-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.cohort-table{border-collapse:collapse;font-size:12px;min-width:800px}
.cohort-table th{background:var(--surface-2);padding:8px 12px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.5px;color:var(--t3);border:1px solid var(--surface-3);white-space:nowrap;text-align:center}
.cohort-table th:first-child{text-align:left}
.cohort-cell{padding:7px 10px;text-align:center;border:1px solid var(--surface-3);font-family:'JetBrains Mono',monospace;font-size:11.5px;color:var(--t1)}
.cohort-cell.pct-100{background:rgba(16,185,129,.3);color:#34D399}
.cohort-cell.pct-high{background:rgba(16,185,129,.15);color:var(--ok)}
.cohort-cell.pct-mid{background:rgba(245,158,11,.12);color:var(--warn)}
.cohort-cell.pct-low{background:rgba(239,68,68,.1);color:var(--err)}
.cohort-cell.pct-empty{background:transparent;color:var(--t4)}
.cohort-label{padding:7px 12px;font-size:12px;font-weight:600;color:var(--t2);white-space:nowrap;border:1px solid var(--surface-3)}

/* NOTIFICATION */
.notif-item{padding:14px 20px;border-bottom:1px solid var(--surface-3);display:flex;gap:12px;align-items:flex-start;transition:background .1s}
.notif-item:hover{background:var(--surface-2)}
.notif-item.unread{background:rgba(124,58,237,.04)}
.notif-icon{width:32px;height:32px;border-radius:var(--r-md);display:flex;align-items:center;justify-content:center;flex-shrink:0}
.notif-icon svg{width:15px;height:15px;stroke:currentColor;stroke-width:2;fill:none}
.notif-title{font-size:13px;font-weight:600;color:var(--t1);margin-bottom:2px}
.notif-desc{font-size:12.5px;color:var(--t3);line-height:1.5}
.notif-time{font-size:11px;color:var(--t4);margin-top:4px;font-family:'JetBrains Mono',monospace}

/* TIMELINE / ACTIVITY */
.timeline{display:flex;flex-direction:column;gap:0}
.tl-item{display:flex;gap:14px;padding:12px 0;border-bottom:1px solid var(--surface-3)}
.tl-item:last-child{border-bottom:none}
.tl-icon{width:30px;height:30px;border-radius:var(--r-md);display:flex;align-items:center;justify-content:center;flex-shrink:0;margin-top:2px}
.tl-icon svg{width:13px;height:13px;stroke:currentColor;stroke-width:2;fill:none}
.tl-content{flex:1;min-width:0}
.tl-title{font-size:13px;font-weight:500;color:var(--t1);margin-bottom:2px}
.tl-meta{font-size:11.5px;color:var(--t3)}
.tl-time{font-size:11px;color:var(--t4);font-family:'JetBrains Mono',monospace;white-space:nowrap;margin-top:4px}

/* PLAN CARDS */
.plan-card{border:1px solid var(--surface-3);border-radius:var(--r-xl);padding:24px;transition:border-color .15s;position:relative}
.plan-card:hover{border-color:var(--surface-4)}
.plan-card.popular{border-color:var(--brand);background:var(--brand-lt)}
.plan-popular-badge{position:absolute;top:-1px;right:20px;background:var(--brand);color:#fff;font-size:10px;font-weight:700;padding:2px 10px;border-radius:0 0 var(--r-sm) var(--r-sm);letter-spacing:.3px}
.plan-name{font-size:16px;font-weight:700;color:var(--t1);margin-bottom:6px}
.plan-price{font-family:'JetBrains Mono',monospace;font-size:30px;font-weight:600;color:var(--t1);line-height:1;margin-bottom:4px}
.plan-price span{font-size:14px;font-weight:400;color:var(--t3)}
.plan-desc{font-size:13px;color:var(--t3);margin-bottom:16px}
.plan-features{display:flex;flex-direction:column;gap:8px;margin-bottom:20px}
.plan-feature{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--t2)}
.plan-feature svg{width:13px;height:13px;stroke:var(--ok);stroke-width:2.5;fill:none;flex-shrink:0}

/* TOAST */
.toast-container{position:fixed;bottom:24px;right:24px;z-index:90;display:flex;flex-direction:column;gap:8px}
.toast{
  background:var(--surface);border:1px solid var(--surface-3);
  border-radius:var(--r-lg);padding:12px 16px;
  box-shadow:var(--shadow-lg);display:flex;align-items:center;gap:10px;
  font-size:13px;font-weight:500;color:var(--t1);
  animation:toastIn .2s ease;min-width:240px;max-width:340px;
}
@keyframes toastIn{from{transform:translateY(12px);opacity:0}to{transform:translateY(0);opacity:1}}
.toast.success{border-color:rgba(16,185,129,.3)}
.toast.error{border-color:rgba(239,68,68,.3)}
.toast svg{width:16px;height:16px;stroke:currentColor;stroke-width:2;fill:none;flex-shrink:0}

/* COMMAND PALETTE */
.overlay{position:fixed;inset:0;background:rgba(0,0,0,.7);z-index:60;display:none;align-items:flex-start;justify-content:center;padding-top:120px;backdrop-filter:blur(4px)}
.overlay.open{display:flex}
.palette{background:var(--surface);border:1px solid var(--surface-3);border-radius:var(--r-xl);width:100%;max-width:560px;box-shadow:var(--modal-shadow);overflow:hidden}
.palette-search{display:flex;align-items:center;gap:10px;padding:14px 18px;border-bottom:1px solid var(--surface-3)}
.palette-search svg{width:16px;height:16px;stroke:var(--t3);stroke-width:2;fill:none;flex-shrink:0}
.palette-search input{flex:1;background:none;border:none;font-size:15px;color:var(--t1);font-family:inherit;outline:none}
.palette-search input::placeholder{color:var(--t3)}
.palette-results{padding:8px 0;max-height:360px;overflow-y:auto}
.palette-item{display:flex;align-items:center;gap:10px;padding:9px 18px;cursor:pointer;font-size:13.5px;color:var(--t2);transition:background .1s}
.palette-item:hover,.palette-item.focused{background:var(--surface-2);color:var(--t1)}
.palette-item svg{width:14px;height:14px;stroke:currentColor;stroke-width:1.8;fill:none;flex-shrink:0}

/* MOBILE */
#mob-bd{display:none;position:fixed;inset:0;z-index:24;background:rgba(0,0,0,.6);backdrop-filter:blur(2px)}
#mob-bd.open{display:block}
body.sidebar-open{overflow:hidden}
.mobile-nav{display:none;position:fixed;bottom:0;left:0;right:0;height:58px;background:var(--sidebar-bg);border-top:1px solid rgba(255,255,255,.06);z-index:30;align-items:center;justify-content:space-around;padding:0 8px}
.mob-nav-item{display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 10px;border-radius:var(--r-md);cursor:pointer;color:rgba(161,161,170,.4);font-size:9px;font-weight:500;text-decoration:none;transition:color .15s;flex:1;position:relative}
.mob-nav-item.active,.mob-nav-item:hover{color:var(--brand)}
.mob-nav-item svg{width:18px;height:18px;stroke:currentColor;stroke-width:1.8;fill:none}
.mob-nav-dot{width:5px;height:5px;border-radius:50%;background:var(--err);position:absolute;top:4px;right:50%;transform:translateX(12px)}

/* RESPONSIVE */

/* ======================================================
   RESPONSIVE BREAKPOINTS
   >768px  : Full sidebar always visible (desktop/tablet)
   <=768px : Mobile drawer mode, hamburger, bottom nav
   <=420px : Ultra compact
====================================================== */

/* 1280px: minor layout adjustments */


/* ============================================
   RESPONSIVE SYSTEM
   Desktop (>768px) : Sidebar always visible
   Mobile (<=768px) : Hamburger + drawer
   Tablet (768-1024): Sidebar 200px, text shown
============================================ */

/* 1100px: plan/int cards */
@media(max-width:1100px){
  .plan-cards-grid{ grid-template-columns:repeat(2,1fr) }
  .int-cards-grid{  grid-template-columns:repeat(2,1fr) }
}

/* 1024px: stats 2×2 */
@media(max-width:1024px){
  .stat-grid-4{ grid-template-columns:repeat(2,1fr); gap:14px }
}

/* chart-row stacking moved to 900px media query below */

/* 900px: stack chart rows */
@media(max-width:900px){
  .chart-row{ grid-template-columns:1fr }
  .chart-row-wide{ grid-template-columns:1fr }
}

/* 768px : MOBILE MODE */
@media(max-width:768px){

  /* Sidebar becomes off-canvas drawer */
  .sidebar{
    transform:translateX(-100%);
    width:268px !important;
    transition:transform .24s cubic-bezier(.4,0,.2,1);
    z-index:40;
    position:fixed;
  }
  /* All sidebar text visible in drawer */
  .sidebar .nav-text,
  .sidebar .nav-label,
  .sidebar .nav-badge,
  .sidebar .logo-text,
  .sidebar .sidebar-user-info{ display:block !important }
  .sidebar .logo-text{ display:flex !important; flex-direction:column }
  .sidebar .nav-item{
    padding:9px 14px !important;
    justify-content:flex-start !important;
    margin:1px 8px !important;
  }

  /* Open state */
  .sidebar.mob-open{
    transform:translateX(0) !important;
    box-shadow:4px 0 40px rgba(0,0,0,.5);
  }

  /* Main takes full width */
  .main-wrapper{ margin-left:0 !important }

  /* Show hamburger */
  #mob-menu{ display:flex !important }

  /* Show bottom nav */
  .mobile-nav{ display:flex }

  /* Page body clears bottom nav */
  .page-body{ padding:14px 14px 72px !important }

  /* Layout */
  .form-row{ grid-template-columns:1fr !important }
  .page-top{ flex-direction:column; align-items:flex-start; gap:10px }
  .page-top > div:last-child{ width:100%; display:flex; gap:8px; flex-wrap:wrap }
  .page-title{ font-size:20px }
  .stat-grid-4,.stat-grid-3{ grid-template-columns:repeat(2,1fr); gap:10px }
  .search-wrap{ display:none }
  .plan-cards-grid{ grid-template-columns:repeat(2,1fr) }
  .int-cards-grid{ grid-template-columns:repeat(2,1fr) }
  .team-cards-grid{ grid-template-columns:repeat(2,1fr) }
  .rep-cards-grid{ grid-template-columns:1fr }
  .detail-grid{ grid-template-columns:1fr }

  /* Sticky elements flatten */
  [style*="position:sticky"]{ position:static !important }

  /* Modals bottom-sheet */
  .modal-backdrop{ align-items:flex-end; padding:0 }
  .modal,.modal-sm,.modal-md,.modal-lg{
    max-width:100% !important;
    border-radius:var(--r-2xl) var(--r-2xl) 0 0;
    max-height:90vh;
  }
}

/* 480px */
@media(max-width:480px){
  .plan-cards-grid,.int-cards-grid,.team-cards-grid{ grid-template-columns:1fr }
  .filter-tabs{ gap:4px }
  .filter-tab{ padding:4px 10px; font-size:11.5px }
  .tbl-wrap{ overflow-x:auto; -webkit-overflow-scrolling:touch }
  .tbl{ min-width:500px }
}

/* 380px: single column everything */
@media(max-width:380px){
  .stat-grid-4,.stat-grid-3,.stat-grid-2{ grid-template-columns:1fr !important; gap:8px }
  .page-body{ padding:12px 10px 72px !important }
  .stat-value{ font-size:20px }
}

/* NO-SCROLL on mobile sidebar open */
body.no-scroll{ overflow:hidden }

/* FEATURE QUERIES */
@supports not (backdrop-filter:blur(1px)){
  .modal-backdrop,#mob-bd,.overlay{ background:rgba(0,0,0,.88) }
}
@media(prefers-reduced-motion:reduce){
  *{ transition-duration:.01ms !important; animation-duration:.01ms !important }
}
@media(hover:none){
  .btn,.icon-btn,.tab,.nav-item,.filter-tab{ min-height:44px }
}
/* iOS: prevent input zoom */
@supports(-webkit-touch-callout:none){
  input:focus,select:focus,textarea:focus{ font-size:16px !important }
}

/* Scrollbar */
::-webkit-scrollbar{ width:4px; height:4px }
::-webkit-scrollbar-track{ background:transparent }
::-webkit-scrollbar-thumb{ background:var(--surface-3); border-radius:2px }

/* Focus */
:focus-visible{ outline:2px solid var(--brand); outline-offset:2px }
button:focus:not(:focus-visible),
a:focus:not(:focus-visible){ outline:none }

/* Print */
@media print{
  .sidebar,.page-header,.bulk-bar,#mob-menu,
  .mobile-nav,#mob-bd,.overlay,.toast-container{ display:none !important }
  .main-wrapper{ margin-left:0 !important }
  .page-body{ padding:0 !important }
  body{ background:#fff !important; color:#000 !important }
  .card{ box-shadow:none !important; border:1px solid #ddd !important; break-inside:avoid }
}

/* Responsive grids */
.chart-row{ display:grid; grid-template-columns:2fr 1fr; gap:16px }
.chart-row-wide{ display:grid; grid-template-columns:3fr 2fr; gap:16px }
.plan-cards-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:16px }
.int-cards-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:16px }
.team-cards-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:16px }
.rep-cards-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:16px }
.detail-grid{ display:grid; grid-template-columns:1fr 1fr; gap:20px }

/* CHART CONTAINERS (fixed heights prevent shrink) */
/* CHART CONTAINERS
   Chart.js with responsive:true + maintainAspectRatio:false
   fills its parent. Parent must have explicit height.
   DO NOT set position/width/height on the canvas itself.
*/
.chart-wrap    { position:relative; width:100%; height:220px }
.chart-wrap-sm { position:relative; width:100%; height:150px }
.chart-wrap-lg { position:relative; width:100%; height:280px }

/* sidebar transition: see base .sidebar block */


/* NOTIFICATION DROPDOWN PANEL */
.notif-wrap{ position:relative }
.notif-btn{ position:relative }
.notif-panel{
  display:none;
  position:absolute;
  right:0;
  top:calc(100% + 10px);
  width:360px;
  background:var(--surface);
  border:1px solid var(--surface-3);
  border-radius:var(--r-xl);
  box-shadow:var(--modal-shadow);
  z-index:50;
  overflow:hidden;
  max-height:480px;
}
.notif-panel.open{ display:block }
.notif-panel-head{
  padding:14px 18px;
  border-bottom:1px solid var(--surface-3);
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.notif-panel-title{ font-size:14px;font-weight:700;color:var(--t1) }
.notif-panel-meta{ font-size:12px;color:var(--t3) }
.notif-panel-body{ overflow-y:auto;max-height:340px }
.notif-panel-footer{
  padding:10px 18px;
  border-top:1px solid var(--surface-3);
  text-align:center;
}
.notif-panel-footer a{
  font-size:12.5px;font-weight:600;color:var(--brand);text-decoration:none;
}
.notif-row{
  display:flex;align-items:flex-start;gap:10px;
  padding:12px 16px;
  border-bottom:1px solid var(--surface-3);
  cursor:pointer;transition:background .12s;
}
.notif-row:last-child{ border-bottom:none }
.notif-row:hover{ background:var(--surface-2) }
.notif-row.unread{ background:rgba(124,58,237,.04) }
.notif-row.unread:hover{ background:rgba(124,58,237,.08) }
.notif-row-ico{
  width:32px;height:32px;border-radius:var(--r-md);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;margin-top:1px;
}
.notif-row-ico svg{ width:14px;height:14px;stroke:currentColor;stroke-width:2;fill:none }
.notif-row-body{ flex:1;min-width:0 }
.notif-row-title{ font-size:12.5px;font-weight:600;color:var(--t1);margin-bottom:2px;line-height:1.4 }
.notif-row-sub{ font-size:11.5px;color:var(--t3);line-height:1.4 }
.notif-row-time{ font-size:10.5px;color:var(--t4);margin-top:3px;font-family:'JetBrains Mono',monospace }
.notif-unread-dot{
  width:7px;height:7px;border-radius:50%;background:var(--brand);
  flex-shrink:0;margin-top:5px;
}
@media(max-width:480px){
  .notif-panel{ width:calc(100vw - 24px);right:-8px }
}

/* EXPORT MODAL */
.export-formats{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:4px }
.export-fmt{
  border:1.5px solid var(--surface-3);
  border-radius:var(--r-lg);
  padding:12px 8px;
  text-align:center;
  cursor:pointer;
  transition:all .15s;
  background:var(--surface-2);
}
.export-fmt:hover{ border-color:var(--brand); background:var(--brand-lt) }
.export-fmt.selected{ border-color:var(--brand); background:var(--brand-lt) }
.export-fmt-icon{ font-size:20px; margin-bottom:4px }
.export-fmt-label{ font-size:11px; font-weight:700; color:var(--t1) }
.export-fmt-ext{ font-size:10px; color:var(--t3); font-family:'JetBrains Mono',monospace }
.export-preview{
  background:var(--surface-2); border:1px solid var(--surface-3);
  border-radius:var(--r-md); padding:10px 14px;
  display:flex; align-items:center; gap:10px;
  font-size:12.5px; color:var(--t2); margin-top:4px;
}
.export-preview-name{
  font-family:'JetBrains Mono',monospace; font-size:12px;
  color:var(--t1); font-weight:600; flex:1;
}
.export-progress{
  height:4px; background:var(--surface-3); border-radius:var(--r-full);
  overflow:hidden; margin-top:10px; display:none;
}
.export-progress-bar{
  height:100%; background:linear-gradient(90deg,var(--brand),var(--cyan));
  border-radius:var(--r-full); width:0%;
  transition:width .4s ease;
}
.field-checks{ display:grid; grid-template-columns:1fr 1fr; gap:6px }
.field-check{
  display:flex; align-items:center; gap:7px;
  padding:7px 10px; border-radius:var(--r-sm);
  cursor:pointer; font-size:12.5px; color:var(--t2);
  border:1px solid transparent; transition:background .12s;
}
.field-check:hover{ background:var(--surface-2) }
.field-check input[type="checkbox"]{ flex-shrink:0 }

/* Stack wide chart rows on small screens (placed last so it wins over the rule above) */
@media(max-width:900px){
  .chart-row-wide{ grid-template-columns:1fr }
}

/* Small screens: keep wide tables and tab rows inside the screen.
   Tables scroll sideways inside their card instead of stretching the page. */
@media(max-width:900px){
  .card, .card-body, .card-header{ min-width:0; max-width:100% }
  .tbl, .cohort-table{ display:block; max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch }
  .tabs{ overflow-x:auto; max-width:100% }
  .card-header{ flex-wrap:wrap; gap:8px }
}

/* Phones: stack card grids and let rows wrap. Desktop layout is unchanged. */
@media(max-width:640px){
  .main *, main *{ min-width:0 }
  svg, .av, .btn{ flex-shrink:0 }
  [class*="grid"], [style*="grid-template-columns"]{ grid-template-columns:1fr !important }
  [style*="display:flex"], [style*="display: flex"], .page-header, .card-body, .toolbar{ flex-wrap:wrap }
  .tbl, .cohort-table{ width:100% }
}
@media(max-width:900px){
  .chart-row{ grid-template-columns:1fr }
}
@media(max-width:640px){
  [style*="monospace"], code, pre{ overflow-wrap:anywhere }
}
