/* ============ Root / Theme ============ */
:root{
  --bg: #07090b;
  --bg2: #060a0d;
  --bg3: #040607;
  --panel: rgba(10,14,16,.82);
  --panel2: rgba(12,18,20,.86);
  --card: rgba(8,12,14,.78);
  --stroke: rgba(255,105,180,.18);
  --stroke2: rgba(255,182,193,.10);
  --text: rgba(235,255,245,.92);
  --muted: rgba(190,220,205,.72);

  --accent: #e91e8c;
  --accent2: #ff69b4;
  --danger: #ff4d6d;
  --warn: #ffcf5a;

  --shadow: 0 16px 50px rgba(0,0,0,.55);
  --radius: 18px;
  --radius2: 24px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: "Manrope", "Inter", "Segoe UI", ui-sans-serif, system-ui, -apple-system, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

:root[data-theme="midnight"]{
  --bg:#05070d;
  --bg2:#070a15;
  --bg3:#03040a;
  --text:rgba(232,242,255,.94);
}

:root[data-theme="onyx"]{
  --bg:#0a0a0b;
  --bg2:#111113;
  --bg3:#070708;
  --text:rgba(245,245,245,.92);
}

html,body{height:100%;}
body{
  margin:0;
  background:
    radial-gradient(900px 600px at 20% -10%, rgba(233,30,140,.12), transparent 60%),
    radial-gradient(800px 520px at 90% 10%, rgba(255,105,180,.10), transparent 65%),
    radial-gradient(900px 700px at 40% 110%, rgba(233,30,140,.08), transparent 65%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 50%, var(--bg3) 100%);
  color:var(--text);
  font-family: var(--sans);
  overflow-x:hidden;
  line-height: 1.45;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:-1;
  background:
    radial-gradient(70% 40% at 50% -20%, rgba(233,30,140,.11), transparent 60%),
    radial-gradient(70% 40% at 100% 0%, rgba(255,105,180,.08), transparent 64%);
}

.bg-orb{
  position:fixed;
  width:42vmax;
  height:42vmax;
  border-radius:50%;
  filter: blur(70px);
  opacity:.22;
  pointer-events:none;
  z-index:-1;
  animation: orbFloat 16s ease-in-out infinite;
}
.bg-orb--left{
  left:-16vmax;
  top:-12vmax;
  background: radial-gradient(circle at 50% 50%, rgba(233,30,140,.38), transparent 66%);
}
.bg-orb--right{
  right:-14vmax;
  bottom:-18vmax;
  background: radial-gradient(circle at 50% 50%, rgba(255,105,180,.32), transparent 66%);
  animation-delay: -6s;
}

/* Full-height app background fix */
.app{
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

/* ============ Boot ============ */
.boot{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  z-index:50;
}
.boot-card{
  width:min(560px, 92vw);
  background:linear-gradient(180deg, rgba(12,20,18,.86), rgba(8,12,13,.78));
  border:1px solid var(--stroke);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  padding:22px 22px 18px;
}
.boot-title{
  font-weight:900;
  letter-spacing:.12em;
  font-size:14px;
  color:rgba(235,255,245,.92);
}
.boot-sub{margin-top:8px; color:var(--muted); font-size:13px;}
.boot-bar{
  height:10px;
  border-radius:999px;
  background:rgba(255,255,255,.06);
  border:1px solid var(--stroke2);
  overflow:hidden;
  margin-top:14px;
}
.boot-bar__fill{
  width:0%;
  height:100%;
  background:linear-gradient(90deg, rgba(233,30,140,.0), rgba(233,30,140,.9), rgba(255,105,180,.9));
  box-shadow: 0 0 18px rgba(233,30,140,.25);
}
.boot-pct{margin-top:10px; font-family:var(--mono); color:rgba(235,255,245,.8); font-size:12px;}
.boot-hint{margin-top:12px; color:rgba(200,230,215,.68); font-size:12px;}

.hidden{display:none !important;}

/* ============ Topbar ============ */
.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  background:linear-gradient(180deg, rgba(8,12,14,.86), rgba(8,12,14,.62));
  border-bottom:1px solid var(--stroke2);
  backdrop-filter: blur(16px);
  transition: border-color .28s ease, background .28s ease, transform .28s ease;
}

.brand{display:flex; align-items:center; gap:12px;}
.brand__logo{
  width:38px; height:38px;
  border-radius:14px;
  display:grid; place-items:center;
  background:rgba(233,30,140,.08);
  border:1px solid var(--stroke);
  box-shadow: 0 0 24px rgba(233,30,140,.12);
}
.brand__name{font-weight:900; letter-spacing:.03em;}
.brand__tag{margin-top:2px; color:var(--muted); font-size:12px;}

.top-actions{display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end;}

/* ============ Layout ============ */
.layout{
  display:grid;
  grid-template-columns: 290px 1fr;
  min-height: calc(100vh - 68px);
}

.sidebar{
  position:sticky;
  top:68px;
  height: calc(100vh - 68px);
  overflow:auto;
  padding:14px 12px 24px;
  border-right:1px solid var(--stroke2);
  background:linear-gradient(180deg, rgba(7,10,12,.55), rgba(7,10,12,.20));
  backdrop-filter: blur(14px);
  scrollbar-width: thin;
  scrollbar-color: rgba(233,30,140,.24) transparent;
}
.sidebar__section{
  background:rgba(10,14,16,.40);
  border:1px solid var(--stroke2);
  border-radius: var(--radius);
  padding:12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
  margin-bottom:12px;
}
.sidebar__title{
  font-size:12px;
  color:rgba(210,245,230,.74);
  letter-spacing:.12em;
  text-transform:uppercase;
  margin-bottom:10px;
}

.nav{display:flex; flex-direction:column; gap:6px;}
.navbtn{
  width:100%;
  text-align:left;
  border:1px solid transparent;
  background:rgba(255,255,255,.02);
  color:rgba(235,255,245,.88);
  border-radius: 14px;
  padding:10px 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  cursor:pointer;
  transition: .15s ease;
}
.navbtn:hover{
  border-color: rgba(233,30,140,.25);
  background: rgba(233,30,140,.06);
}
.navbtn.active{
  border-color: rgba(233,30,140,.35);
  background: rgba(233,30,140,.10);
  box-shadow: 0 0 0 1px rgba(233,30,140,.08) inset, 0 0 26px rgba(233,30,140,.10);
}
.navbtn__left{display:flex; align-items:center; gap:10px;}
.navbtn__ico{width:22px; text-align:center;}
.navbtn__meta{font-size:12px; color:rgba(200,230,215,.7); font-family:var(--mono);}

.quick{display:grid; gap:8px;}
.kv{display:grid; gap:8px;}
.kv__row{display:flex; justify-content:space-between; gap:12px; align-items:center;}
.kv__k{color:rgba(190,220,205,.74); font-size:12px;}
.kv__v{color:rgba(235,255,245,.9); font-size:12px;}
.mono{font-family:var(--mono);}

/* ============ Main ============ */
.main{
  padding:16px 16px 28px;
}

.page-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
  flex-wrap:wrap;
}
.page-title{
  margin:0;
  font-size:22px;
  letter-spacing:.02em;
}
.page-hint{
  margin-top:6px;
  color:rgba(190,220,205,.72);
  font-size:13px;
}

.range{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.chip{
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  color:rgba(235,255,245,.92);
  padding:8px 10px;
  border-radius:999px;
  cursor:pointer;
  transition:.15s ease;
}
.chip:hover{border-color: rgba(233,30,140,.25); background: rgba(233,30,140,.06);}
.chip.active{border-color: rgba(233,30,140,.40); background: rgba(233,30,140,.10);}

.range__dates{display:flex; align-items:end; gap:10px; flex-wrap:wrap; justify-content:flex-end;}

.field{display:grid; gap:6px;}
.field__label{font-size:11px; color:rgba(190,220,205,.7); font-family:var(--mono);}
input[type="date"], input[type="text"], input[type="number"], textarea, select{
  background: rgba(0,0,0,.28);
  border:1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding:10px 12px;
  color: rgba(235,255,245,.92);
  outline:none;
}
textarea{min-height:120px; resize:vertical;}
input:focus, textarea:focus, select:focus{border-color: rgba(233,30,140,.35); box-shadow: 0 0 0 3px rgba(233,30,140,.12);}

.content{
  display:grid;
  gap:12px;
  transition: opacity .28s ease, transform .28s ease, filter .28s ease;
}

/* ============ Cards / Tables ============ */
.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:12px;
}
.card{
  grid-column: span 12;
  background: linear-gradient(180deg, rgba(12,18,20,.78), rgba(8,12,14,.66));
  border:1px solid var(--stroke2);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  padding:14px;
  overflow:hidden;
}
.card__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.card__title{
  font-weight:800;
  letter-spacing:.02em;
}
.card__sub{color:rgba(190,220,205,.72); font-size:12px; margin-top:4px;}
.card__tools{display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end;}

.kpi{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:12px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.02);
  border:1px solid rgba(255,255,255,.08);
}
.kpi__k{font-size:12px; color:rgba(190,220,205,.72);}
.kpi__v{font-size:20px; font-weight:900; letter-spacing:.02em;}
.kpi__h{font-size:11px; color:rgba(190,220,205,.62); font-family:var(--mono);}

.table{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: 18px;
}
.table th, .table td{
  padding:10px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  vertical-align:top;
  font-size:13px;
}
.table th{
  text-align:left;
  color:rgba(210,245,230,.76);
  font-size:12px;
  letter-spacing:.10em;
  text-transform:uppercase;
}
.table tr:hover td{background: rgba(233,30,140,.05);}

.chart-canvas{
  width:100%;
  height:340px;
  min-height:340px;
  display:block;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius: 999px;
  font-size:12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
}
.badge.ok{border-color: rgba(233,30,140,.30); background: rgba(233,30,140,.08);}
.badge.warn{border-color: rgba(255,207,90,.32); background: rgba(255,207,90,.08);}
.badge.bad{border-color: rgba(255,77,109,.32); background: rgba(255,77,109,.08);}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius: 999px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
}
.pill__label{font-size:11px; color:rgba(190,220,205,.7); font-family:var(--mono);}
.pill__value{font-size:12px; color:rgba(235,255,245,.92); font-family:var(--mono);}

/* Buttons */
.btn, .ghost-btn, .icon-btn{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: rgba(235,255,245,.92);
  border-radius: 16px;
  padding:10px 12px;
  cursor:pointer;
  transition:transform .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.btn:hover, .ghost-btn:hover, .icon-btn:hover{
  border-color: rgba(233,30,140,.25);
  background: rgba(233,30,140,.06);
  box-shadow: 0 10px 26px rgba(0,0,0,.22);
}
.btn:active, .ghost-btn:active, .icon-btn:active{transform: translateY(1px);}

.ghost-btn{padding:10px 12px;}
.ghost-btn.danger{border-color: rgba(255,77,109,.22); }
.ghost-btn.danger:hover{border-color: rgba(255,77,109,.35); background: rgba(255,77,109,.08);}
.btn.primary{
  border-color: rgba(233,30,140,.35);
  background: linear-gradient(90deg, rgba(233,30,140,.18), rgba(255,105,180,.12));
}
.btn.primary:hover{border-color: rgba(233,30,140,.50);}

.icon-btn{
  width:40px; height:40px;
  display:grid; place-items:center;
  border-radius: 14px;
  padding:0;
}

/* ============ Modal / Toasts ============ */
.modal{position:fixed; inset:0; z-index:40;}
.modal__backdrop{position:absolute; inset:0; background: rgba(0,0,0,.55); backdrop-filter: blur(6px);}
.modal__card{
  position:relative;
  width:min(820px, 94vw);
  margin: 6vh auto;
  max-height: 88vh;
  background: linear-gradient(180deg, rgba(12,18,20,.92), rgba(8,12,14,.86));
  border:1px solid rgba(233,30,140,.18);
  border-radius: var(--radius2);
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  animation: modalIn .22s cubic-bezier(.2,.8,.2,1);
}
.modal__head{
  padding:12px 14px;
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.modal__title{font-weight:900; letter-spacing:.02em;}
.modal__body{
  padding:14px;
  overflow:auto;
  flex:1 1 auto;
  min-height:0;
}
.modal__foot{
  padding:12px 14px;
  display:flex; justify-content:flex-end; gap:10px; flex-wrap:wrap;
  border-top:1px solid rgba(255,255,255,.08);
}

.toasts{
  position:fixed;
  right:14px;
  bottom:14px;
  display:grid;
  gap:10px;
  z-index:60;
}
.toast{
  width:min(420px, 92vw);
  padding:12px 12px;
  border-radius: 18px;
  background: rgba(12,18,20,.92);
  border:1px solid rgba(255,255,255,.10);
  box-shadow: 0 16px 50px rgba(0,0,0,.55);
  animation: toastIn .22s ease;
}
.toast__t{font-weight:800;}
.toast__m{margin-top:6px; color:rgba(190,220,205,.78); font-size:13px;}
.toast.ok{border-color: rgba(233,30,140,.28);}
.toast.warn{border-color: rgba(255,207,90,.30);}
.toast.bad{border-color: rgba(255,77,109,.30);}

/* ============ Responsive ============ */
@media (max-width: 980px){
  .layout{grid-template-columns: 1fr;}
  .sidebar{
    position:relative;
    top:auto;
    height:auto;
    border-right:none;
    border-bottom:1px solid var(--stroke2);
  }
}
@media (max-width: 520px){
  .top-actions{gap:8px;}
  .brand__tag{display:none;}
  .range__dates{width:100%;}
  input[type="date"]{width:160px;}
}

/* ============ Premium Refresh ============ */
:root{
  --bg-soft: rgba(12,16,20,.72);
  --bg-elev: rgba(16,22,27,.82);
  --shine: rgba(255,105,180,.20);
}

*{
  box-sizing:border-box;
}

.topbar{
  background:
    linear-gradient(180deg, rgba(9,13,16,.92), rgba(9,13,16,.58)),
    radial-gradient(420px 180px at 20% -120%, rgba(233,30,140,.14), transparent 70%);
  border-bottom:1px solid rgba(233,30,140,.14);
}

.brand__logo{
  width:42px;
  height:42px;
  border-radius:15px;
  overflow:hidden;
  background:linear-gradient(180deg, rgba(15,22,26,.9), rgba(8,12,14,.82));
  border:1px solid rgba(233,30,140,.26);
}

.brand__logo-img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}

.brand__name{
  font-size:14px;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.layout{
  gap:14px;
  padding:12px;
}

.sidebar{
  top:80px;
  height: calc(100vh - 92px);
  border-radius:22px;
  border:1px solid rgba(233,30,140,.12);
  box-shadow: 0 18px 52px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.02);
}

.main{
  padding:4px 2px 22px;
}

.crumbs{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:8px;
  font-size:11px;
  color:rgba(180,220,205,.7);
  font-family:var(--mono);
  text-transform:uppercase;
  letter-spacing:.08em;
}

.crumbs__item{
  color:rgba(180,220,205,.75);
}

.crumbs__sep{
  color:rgba(120,160,150,.6);
}

.page-title{
  font-size:28px;
  letter-spacing:.01em;
}

.page-hint{
  max-width:780px;
}

.card{
  border-color:rgba(233,30,140,.09);
  background:
    linear-gradient(180deg, rgba(16,24,28,.86), rgba(10,15,18,.74)),
    radial-gradient(450px 120px at 10% -20%, rgba(233,30,140,.06), transparent 72%);
  transition:transform .22s ease, border-color .22s ease, box-shadow .22s ease, background .22s ease;
}

.card:hover{
  transform:translateY(-1px);
  border-color:rgba(233,30,140,.16);
  box-shadow:0 20px 52px rgba(0,0,0,.45);
}

.kpi{
  position:relative;
  overflow:hidden;
  background:linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.015));
}

.kpi::after{
  content:"";
  position:absolute;
  inset:auto -30% -60% -30%;
  height:80%;
  background:radial-gradient(circle at 50% 0%, rgba(233,30,140,.16), transparent 70%);
  pointer-events:none;
}

.table th{
  position:sticky;
  top:0;
  backdrop-filter:blur(8px);
  background:rgba(7,10,12,.74);
}

.content{
  animation:fadeInUp .28s ease;
}

.content.is-loading{
  opacity:.64;
  transform:translateY(2px) scale(.997);
  filter:saturate(.9);
}

.content.route-enter{
  opacity:0;
  transform:translateY(9px);
  filter: blur(2px);
}

.navbtn{
  backdrop-filter:blur(8px);
}

.quick-rail{
  position:fixed;
  right:14px;
  top:50%;
  transform:translateY(-50%);
  z-index:20;
  display:grid;
  gap:8px;
}

.quick-rail .icon-btn{
  width:42px;
  height:42px;
  background:var(--bg-elev);
  border-color:rgba(233,30,140,.16);
}

.cmdk{
  position:fixed;
  inset:0;
  z-index:70;
}

.cmdk__backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.55);
  backdrop-filter:blur(8px);
}

.cmdk__dialog{
  position:relative;
  width:min(760px, 92vw);
  margin:10vh auto 0;
  border-radius:20px;
  background:linear-gradient(180deg, rgba(16,22,27,.94), rgba(10,14,18,.92));
  border:1px solid rgba(233,30,140,.2);
  box-shadow:0 30px 90px rgba(0,0,0,.72);
  overflow:hidden;
  animation:fadeInUp .2s ease;
}

/* Progressive route loader */
.route-loader{
  position:fixed;
  left:0;
  top:0;
  width:100%;
  height:2px;
  z-index:120;
  opacity:0;
  background: linear-gradient(90deg, transparent, rgba(233,30,140,.86), rgba(255,105,180,.86), transparent);
  background-size: 30% 100%;
  transition: opacity .2s ease;
}

body[data-busy="1"] .route-loader{
  opacity:1;
  animation: routeFlow 1s linear infinite;
}

/* Skeleton loading */
.loading-card{
  display:grid;
  gap:14px;
}

.skeleton{
  position:relative;
  overflow:hidden;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.08), rgba(255,255,255,.04));
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton--title{height:22px; width:min(320px, 70%);}
.skeleton--line{height:12px; width:100%;}
.skeleton--line.short{width:62%;}
.skeleton--grid{
  display:grid;
  gap:10px;
  grid-template-columns: repeat(3, minmax(0,1fr));
}
.skeleton--tile{
  height:88px;
  border-radius:16px;
}

.cmdk__head{
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px;
  border-bottom:1px solid rgba(255,255,255,.08);
}

.cmdk__input{
  width:100%;
  border:none !important;
  background:rgba(255,255,255,.03) !important;
  border-radius:12px !important;
  outline:none;
  color:var(--text);
}

.cmdk__kbd{
  padding:6px 8px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,.18);
  font-family:var(--mono);
  font-size:11px;
  color:rgba(190,220,205,.84);
}

.cmdk__list{
  max-height:50vh;
  overflow:auto;
  padding:10px;
  display:grid;
  gap:8px;
}

.cmdk__item{
  border:1px solid rgba(255,255,255,.1);
  border-radius:12px;
  background:rgba(255,255,255,.03);
  color:var(--text);
  text-align:left;
  padding:10px 12px;
  cursor:pointer;
  transition:all .16s ease;
}

.cmdk__item:hover,
.cmdk__item.active{
  border-color:rgba(233,30,140,.36);
  background:rgba(233,30,140,.09);
}

.cmdk__title{
  font-weight:700;
}

.cmdk__hint{
  margin-top:4px;
  color:var(--muted);
  font-size:12px;
}

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

@keyframes modalIn{
  from{opacity:0; transform:translateY(12px) scale(.985);}
  to{opacity:1; transform:translateY(0) scale(1);}
}

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

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

@keyframes routeFlow{
  from{background-position: 130% 0;}
  to{background-position: -30% 0;}
}

@keyframes orbFloat{
  0%,100%{transform: translate3d(0,0,0);}
  50%{transform: translate3d(0,-2.2vmax,0);}
}

@media (max-width: 980px){
  .layout{
    padding:8px;
  }
  .quick-rail{
    right:10px;
    top:auto;
    bottom:16px;
    transform:none;
    grid-auto-flow:column;
  }
}

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation:none !important;
    transition:none !important;
    scroll-behavior:auto !important;
  }
  .bg-orb{display:none;}
  .route-loader{display:none;}
}
