/* ──── SIDEBAR ──── */
.sidebar {
  width: 228px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  overflow-y: auto;
  flex-shrink: 0;
}
.sb-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sb-logo a {
  font-family: var(--fontd);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}
.sb-logo a span {
  color: var(--teal);
}
.sb-badge {
  background: rgba(0, 212, 170, .12);
  border: 1px solid rgba(0, 212, 170, .25);
  color: var(--teal);
  font-size: .6rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 20px;
}
.sb-sect {
  padding: .75rem 1.25rem .3rem;
  font-size: .63rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.sb-nav {
  list-style: none;
  padding: 0 .75rem;
}
.sb-nav li {
  margin-bottom: 1px;
}
.sb-nav li a,
.sb-nav li button {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .62rem .85rem;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: .855rem;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font);
}
.sb-nav li a:hover,
.sb-nav li button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .05);
}
.sb-nav li a.active,
.sb-nav li button.active {
  color: var(--teal);
  background: rgba(0, 212, 170, .1);
}
.sb-nav li a i,
.sb-nav li button i {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.sb-nav .badge-n {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.sb-bottom {
  margin-top: auto;
  padding: .75rem;
  border-top: 1px solid var(--border);
}
.sb-user {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .75rem;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s;
}
.sb-user:hover {
  background: rgba(255, 255, 255, .05);
}
.sb-ava {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 212, 170, .2);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .82rem;
  flex-shrink: 0;
}
.sb-uname {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.sb-uemail {
  font-size: .7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* ──── MAIN ──── */
.main {
  flex: 1;
  margin-left: 228px;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ──── TOPBAR ──── */
.topbar {
  background: rgba(10, 20, 40, .85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 1.75rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.tb-search {
  flex: 1;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .45rem .85rem;
}
.tb-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .855rem;
  font-family: var(--font);
  flex: 1;
}
.tb-search input::placeholder {
  color: var(--muted);
}
.tb-search i {
  color: var(--muted);
  font-size: .9rem;
}
.tb-date {
  font-size: .78rem;
  color: var(--muted);
  margin-left: .5rem;
  white-space: nowrap;
}
.tb-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.tb-ico {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
  position: relative;
  font-size: 1rem;
}
.tb-ico:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .05);
}
.tb-ico .n-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--bg2);
}
.tb-role {
  font-size: .7rem;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-weight: 600;
  background: rgba(0, 212, 170, .12);
  color: var(--teal);
}

/* ──── TICKER ──── */
.ticker-wrap {
  background: rgba(0, 212, 170, .04);
  border-bottom: 1px solid rgba(0, 212, 170, .08);
  padding: .33rem 0;
  overflow: hidden;
  position: sticky;
  top: 60px;
  z-index: 90;
  flex-shrink: 0;
}
.ticker-track {
  display: flex;
  gap: 2.5rem;
  animation: tick 28s linear infinite;
  white-space: nowrap;
}
.ti-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .72rem;
  flex-shrink: 0;
}
.ti-l {
  color: var(--muted);
}
.ti-v {
  font-weight: 500;
}
.t-up {
  color: var(--teal);
}
.t-dn {
  color: var(--red);
}
@keyframes tick {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

/* ──── PAGE ──── */
.page {
  display: none;
  padding: 1.75rem 2rem;
  min-height: calc(100vh - 60px - 26px);
  flex: 1;
}
.page.active {
  display: block;
}
.pg-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.pg-title {
  font-family: var(--fontd);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -.5px;
}
.pg-sub {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .2rem;
}

/* ──── MODAL ──── */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 26, .82);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-bg.open {
  display: flex;
}
.modal {
  background: var(--surf);
  border: 1px solid rgba(0, 212, 170, .18);
  border-radius: 20px;
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title {
  font-family: var(--fontd);
  font-size: 1.15rem;
  font-weight: 800;
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color .2s;
}
.modal-close:hover {
  color: var(--text);
}
.modal-footer {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ──── TOAST ──── */
#toast {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  background: var(--surf2);
  border: 1px solid rgba(0, 212, 170, .3);
  border-radius: 12px;
  padding: .85rem 1.25rem;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  z-index: 900;
  transform: translateY(100px);
  opacity: 0;
  transition: all .35s;
  max-width: 320px;
}
#toast.show {
  transform: translateY(0);
  opacity: 1;
}
#toast.err {
  border-color: rgba(255, 107, 107, .3);
}
#toast i {
  font-size: 1.1rem;
}

/* ──── FORM ──── */
.fld {
  margin-bottom: .95rem;
}
.fld label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .35rem;
}
.fld input,
.fld select,
.fld textarea {
  width: 100%;
  background: rgba(5, 12, 26, .7);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .68rem 1rem;
  border-radius: 9px;
  font-size: .86rem;
  font-family: var(--font);
  outline: none;
  transition: border .2s;
  resize: vertical;
}
.fld input:focus,
.fld select:focus,
.fld textarea:focus {
  border-color: var(--teal);
}
.fld input::placeholder,
.fld textarea::placeholder {
  color: rgba(232, 240, 255, .3);
}
.fld select option {
  background: var(--bg2);
}
.frow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}
.frow3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .75rem;
}

/* ──── QUICK ACTION ──── */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .65rem;
}
.qa-btn {
  background: var(--surf2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}
.qa-btn:hover {
  border-color: rgba(0, 212, 170, .3);
  background: rgba(0, 212, 170, .05);
  transform: translateY(-2px);
}
.qa-ico {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.qa-lbl {
  font-size: .74rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}
.qa-btn.disabled {
  opacity: .4;
  cursor: not-allowed;
}
.qa-btn.disabled:hover {
  transform: none;
  border-color: var(--border);
  background: var(--surf2);
}

/* ──── CHART AREA ──── */
.chart-area {
  position: relative;
}

/* ──── RESPONSIVE ──── */
@media (max-width: 1024px) {
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .g7-3,
  .g6-4 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  .sidebar .sb-logo a,
  .sidebar .sb-badge,
  .sidebar .sb-sect,
  .sidebar .sb-nav li a span,
  .sidebar .sb-nav .badge-n,
  .sidebar .sb-user .sb-uname,
  .sidebar .sb-user .sb-uemail {
    display: none;
  }
  .sidebar .sb-nav li a,
  .sidebar .sb-nav li button {
    justify-content: center;
    padding: .7rem;
  }
  .sidebar .sb-nav li a i,
  .sidebar .sb-nav li button i {
    width: auto;
    font-size: 1.2rem;
  }
  .sidebar .sb-user {
    justify-content: center;
  }
  .main {
    margin-left: 60px;
  }
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
  .g2,
  .g3 {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 0 1rem;
    flex-wrap: wrap;
    height: auto;
    gap: .5rem;
    padding: .6rem 1rem;
  }
  .tb-date {
    display: none;
  }
  .page {
    padding: 1rem;
  }
  .frow,
  .frow3 {
    grid-template-columns: 1fr;
  }
  .qa-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }
  .tb-search {
    max-width: 100%;
  }
  .tb-right .btn span {
    display: none;
  }
}