:root {
  --brand: #6d5efc;
  --brand-dark: #4c3fd7;
  --bg-soft: #f5f6fb;
  --ink: #1d1e2c;
  --mobile-card: #ffffff;
  --mobile-accent: #141833;
}

*, *::before, *::after { box-sizing: border-box; }
* { font-family: 'Hind Siliguri', 'Segoe UI', sans-serif; }

body {
  margin: 0;
  background: var(--bg-soft);
  color: var(--ink);
  overflow-x: hidden;
}

.topbar {
  background: linear-gradient(135deg, #1d1e2c 0%, #302b63 55%, #6d5efc 130%);
  min-height: 64px;
  padding: 0.55rem 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.topbar .navbar-brand { color: #fff; font-weight: 700; font-size: 1.15rem; }
.topbar .container-fluid { min-width: 0; }
.topbar .navbar-brand > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 1.05rem;
}
.navbar-toggler { color: #fff; border-color: rgba(255,255,255,0.35); padding: 0.3rem 0.5rem; }
.navbar-toggler:focus { box-shadow: 0 0 0 0.15rem rgba(255,255,255,0.2); }
.drawer-header { display: none; }

.layout-shell { display: flex; min-height: calc(100vh - 62px); }

.sidebar {
  width: 250px; min-height: calc(100vh - 62px); flex-shrink: 0;
  background: linear-gradient(180deg, #161a33 0%, #0e1328 100%);
  color: #cfd0e0;
}
.sidebar-inner { position: sticky; top: 0; padding: 1rem 0.9rem; max-height: calc(100vh - 62px); overflow-y: auto; scrollbar-width: none; }
.sidebar-inner::-webkit-scrollbar { display: none; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; color: #fff; padding: 0.25rem 0.6rem 1rem; }
.sidebar-title {
  text-transform: uppercase; font-size: 0.72rem; letter-spacing: .08em;
  color: #8f90ab; margin: 0.3rem 0.6rem 0.8rem;
}
.sidebar-group-title {
  color: #777b9b; font-size: 0.7rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; margin: 1rem 0 0.35rem 0.7rem;
}
.sidebar-group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  border: 0; background: transparent; color: #8f90ab; padding: 0.65rem 0.7rem 0.35rem;
  margin-top: 0.55rem; text-transform: uppercase; font-size: 0.7rem; font-weight: 700;
  letter-spacing: .06em; text-align: left;
}
.sidebar-group-toggle:hover { color: #fff; }
.sidebar-group-toggle i { font-size: 0.72rem; transition: transform .15s ease; }
.sidebar-group-toggle[aria-expanded="true"] i { transform: rotate(180deg); }
.sidebar-subnav.is-collapsed { display: none; }
.sidebar-subnav {
  border-left: 1px solid rgba(255,255,255,0.12); margin-left: 0.45rem; padding-left: 0.55rem;
}
.sidebar-subnav .nav-link { margin-bottom: 0.25rem; padding: 0.56rem 0.7rem; font-size: 0.88rem; }
.sidebar .nav-link {
  color: #cfd0e0; padding: 0.7rem 0.8rem; border-radius: 999px;
  margin-bottom: 0.35rem; font-size: 0.93rem; display: flex; align-items: center; gap: 0.6rem;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  transition: background .15s ease, color .15s ease;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar .nav-link.active {
  background: linear-gradient(135deg, #8b7bff, var(--brand));
  border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 8px 18px rgba(109,94,252,0.25);
}

.main-content { flex: 1; min-width: 0; }
.main-content > .container-fluid,
.main-content > .container { max-width: 1440px; margin-left: auto; margin-right: auto; }

.card {
  border: none; border-radius: 16px;
  box-shadow: 0 4px 18px rgba(29,30,44,0.06);
}
.card-header { background: #fff; border-bottom: 1px solid #eef0f7; border-radius: 16px 16px 0 0 !important; font-weight: 600; }
.table { min-width: 640px; }
.table th { white-space: nowrap; font-size: 0.82rem; }
.table td { vertical-align: middle; }
.form-control, .form-select { min-height: 38px; }
.dt-container { padding: 0.85rem 1rem; }
.dt-container .dt-search input,
.dt-container .dt-length select { border: 1px solid #dfe3ef; border-radius: 8px; min-height: 34px; }
.dt-container .dt-paging .pagination { margin-bottom: 0; }
.dt-container .dt-info { color: #6c7284; font-size: 0.82rem; }
.dt-container .dt-layout-table { overflow-x: auto; }
.dt-container table.dataTable { width: 100% !important; }
.dataTables_wrapper .invoice-modal-row { display: none !important; }

.stat-card {
  border-radius: 16px; padding: 1.25rem 1.4rem; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 8px 20px rgba(109,94,252,0.28);
}
.stat-card.alt1 { background: linear-gradient(135deg, #16b8a6, #0e8f82); box-shadow: 0 8px 20px rgba(14,143,130,0.25); }
.stat-card.alt2 { background: linear-gradient(135deg, #ff9f43, #e07b1c); box-shadow: 0 8px 20px rgba(224,123,28,0.25); }
.stat-card.alt3 { background: linear-gradient(135deg, #ff6b81, #e2445c); box-shadow: 0 8px 20px rgba(226,68,92,0.25); }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { opacity: 0.9; font-size: 0.88rem; }

.stream-pick {
  border: 2px solid #eef0f7; border-radius: 14px; padding: 0.9rem 1rem;
  cursor: pointer; transition: border-color .15s ease, background .15s ease; height: 100%;
}
.stream-pick:hover { border-color: #c9c4ff; }
.stream-pick.selected { border-color: var(--brand); background: #f2f0ff; }
.stream-pick .form-check-input { margin-top: 0.35rem; }

.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.auth-wrap {
  min-height: calc(100vh - 62px); display: flex; align-items: center; justify-content: center;
}
.auth-card { max-width: 440px; width: 100%; }

code.token { background: #f2f0ff; color: var(--brand-dark); padding: 0.15rem 0.4rem; border-radius: 6px; font-size: 0.85rem; }

@media (min-width: 992px) {
  .topbar .container-fluid { padding-left: 1.75rem; padding-right: 1.75rem; }

  .topbar .navbar-brand {
    min-width: 250px;
    font-size: 1.2rem;
  }

  .topbar .d-flex.align-items-center.gap-3 {
    margin-left: auto;
  }

  .sidebar {
    border-right: 1px solid rgba(255,255,255,0.06);
  }

  .sidebar-inner { padding: 1rem; }

  .sidebar-title {
    margin: 0.25rem 0.75rem 0.9rem;
  }

  .sidebar .nav-link { min-height: 42px; padding: 0.65rem 0.85rem; }

  .sidebar hr {
    margin: 1.15rem 0.75rem;
    opacity: 0.35;
  }

  .main-content > .container-fluid,
  .main-content > .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (max-width: 991.98px) {
  .sidebar { width: 290px; }
  .sidebar-inner { position: static; max-height: none; padding: 1rem 0.9rem; }
  .main-content .container-fluid {
    padding-left: 0.75rem; padding-right: 0.75rem;
  }
}

@media (max-width: 767.98px) {
  body {
    background: linear-gradient(180deg, #f3f4fb 0%, #eef2ff 100%);
  }

  .topbar {
    padding: 0.5rem 0;
  }

  .topbar .container-fluid { gap: 0.4rem; }

  .topbar .d-flex.align-items-center.gap-3 {
    gap: 0.4rem !important;
    margin-left: auto;
  }

  .topbar .btn { white-space: nowrap; }

  .topbar .navbar-brand {
    font-size: 1.08rem;
    letter-spacing: 0.04em;
  }

  .brand-icon {
    width: 30px; height: 30px; border-radius: 9px;
    font-size: 0.95rem;
  }

  .sidebar {
    background: linear-gradient(180deg, #161a33 0%, #0e1328 100%);
    border-right: 1px solid rgba(255,255,255,0.08);
  }

  .sidebar .nav-link {
    padding: 0.7rem 0.8rem; font-size: 0.86rem;
  }

  .main-content .container-fluid,
  .main-content .container {
    padding-top: 1.1rem !important;
    padding-bottom: 1.1rem !important;
  }

  h1, h2, h3, h4, h5, h6 { line-height: 1.25; }

  .row { --bs-gutter-x: 0.9rem; --bs-gutter-y: 0.9rem; }

  .card {
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(19,23,39,0.07);
    background: var(--mobile-card);
  }

  .card-header {
    border-radius: 14px 14px 0 0 !important;
    padding: 0.8rem 0.9rem;
    font-size: 0.92rem;
  }

  .card-body {
    padding: 0.9rem;
  }

  .card .d-flex.flex-wrap { align-items: stretch !important; }

  .stat-card {
    border-radius: 14px;
    padding: 1rem 1rem;
  }

  .stat-card .stat-value {
    font-size: 1.5rem;
  }

  .btn {
    border-radius: 10px;
  }

  .table-responsive {
    border-radius: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table { min-width: 620px; }

  .dt-container { padding: 0.75rem; overflow-x: auto; }
  .dt-container .dt-layout-row { gap: 0.65rem; }
  .dt-container .dt-search input { width: 150px; }

  .btn-group {
    display: flex;
    flex-wrap: wrap;
  }

  .btn-group > .btn { flex: 1 1 auto; }

  .input-group { flex-wrap: nowrap; }
  .input-group .form-control { min-width: 0; }

  form .row > [class*="col-"] { width: 100%; }

  .auth-card {
    max-width: 100%;
    margin: 0 0.75rem;
  }
}
