* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--page-bg);
  color: var(--text-primary);
}

a {
  text-decoration: none;
  color: inherit;
}

.table-link-blue {
  color: #3b82f6;
}

.table-link-blue:hover {
  text-decoration: underline;
}

.icon-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-shell-portal {
  background:
    radial-gradient(900px circle at 15% -10%, rgba(var(--primary-rgb), 0.24), transparent 55%),
    radial-gradient(700px circle at 100% 10%, rgba(var(--primary-rgb), 0.16), transparent 50%),
    radial-gradient(800px circle at 0% 100%, rgba(var(--primary-rgb), 0.12), transparent 55%),
    var(--page-bg);
}

.login-shell-portal .login-card {
  box-shadow: 0 24px 60px -20px rgba(var(--primary-rgb), 0.35);
}

.login-shell-network {
  position: relative;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.06), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(255, 255, 255, 0.05), transparent 40%),
    linear-gradient(135deg, #1b1035 0%, #2c1a5c 45%, #3d2280 75%, #4c1d95 100%);
  overflow: hidden;
}

.login-shell-network::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.14)' stroke-width='1'%3E%3Cline x1='18' y1='24' x2='96' y2='58'/%3E%3Cline x1='96' y1='58' x2='168' y2='30'/%3E%3Cline x1='96' y1='58' x2='120' y2='140'/%3E%3Cline x1='120' y1='140' x2='40' y2='178'/%3E%3Cline x1='120' y1='140' x2='196' y2='168'/%3E%3Cline x1='18' y1='24' x2='40' y2='178'/%3E%3C/g%3E%3Cg fill='rgba(255,255,255,0.5)'%3E%3Ccircle cx='18' cy='24' r='2.5'/%3E%3Ccircle cx='96' cy='58' r='3'/%3E%3Ccircle cx='168' cy='30' r='2.5'/%3E%3Ccircle cx='120' cy='140' r='3'/%3E%3Ccircle cx='40' cy='178' r='2.5'/%3E%3Ccircle cx='196' cy='168' r='2.5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 220px 220px;
  background-repeat: repeat;
  pointer-events: none;
}

.login-shell-network .login-card {
  position: relative;
  z-index: 1;
}

.login-card-elevated {
  box-shadow: 0 24px 60px -12px rgba(20, 10, 50, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}

.login-title,
.login-subtitle {
  text-align: center;
}

.login-title {
  margin: 0 0 6px;
  font-size: 20px;
}

.login-subtitle {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.login-card .form-field {
  margin-bottom: 16px;
}

.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* ---------- Demo login (demo.xpressradius.com only) ---------- */

.login-shell-demo {
  position: relative;
  background: #f6f7fb;
  overflow: hidden;
}

.login-shell-demo::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='500' height='500'%3E%3Cg fill='none' stroke='rgba(124,92,252,0.16)' stroke-width='1.4'%3E%3Cpath d='M-20,50 C100,0 150,100 270,50 S440,0 520,50'/%3E%3Cpath d='M-20,120 C100,70 150,170 270,120 S440,70 520,120'/%3E%3Cpath d='M-20,190 C100,140 150,240 270,190 S440,140 520,190'/%3E%3Cpath d='M-20,260 C100,210 150,310 270,260 S440,210 520,260'/%3E%3Cpath d='M-20,330 C100,280 150,380 270,330 S440,280 520,330'/%3E%3Cpath d='M-20,400 C100,350 150,450 270,400 S440,350 520,400'/%3E%3Cpath d='M-20,470 C100,420 150,520 270,470 S440,420 520,470'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 500px 500px;
  background-repeat: repeat;
  pointer-events: none;
}

.demo-split-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: 260px 1fr;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 24px 60px -20px rgba(20, 10, 50, 0.25);
}

.demo-brand-panel {
  background: linear-gradient(165deg, rgba(var(--primary-rgb), 0.16), rgba(var(--primary-rgb), 0.05)), var(--primary-light);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 24px;
}

.demo-brand-panel-title {
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 17px;
  margin: 0;
}

.demo-shield-icon svg {
  width: 60px;
  height: 60px;
  stroke: var(--primary);
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.demo-form-panel {
  padding: 40px 36px;
}

.demo-logo-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

/* Higher-specificity descendant selector -- a bare .demo-logo-img class rule
   here loses to .sidebar-logo-full's own max-height (defined later in this
   file) at equal specificity, since source order breaks the tie. */
.demo-logo-row .sidebar-logo-full {
  max-height: 70px;
}

.demo-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.demo-form-actions a {
  font-size: 13px;
  color: var(--text-muted);
}

.demo-form-actions .btn {
  width: auto;
}

@media (max-width: 640px) {
  .demo-split-card {
    grid-template-columns: 1fr;
  }

  .demo-brand-panel {
    padding: 24px;
    flex-direction: row;
  }

  .demo-shield-icon svg {
    width: 40px;
    height: 40px;
  }
}

/* ---------- Customer portal ---------- */

.portal-shell {
  min-height: 100vh;
  background:
    radial-gradient(1100px circle at 100% -15%, rgba(var(--primary-rgb), 0.12), transparent 50%),
    radial-gradient(800px circle at 0% 100%, rgba(var(--primary-rgb), 0.09), transparent 50%),
    var(--page-bg);
}

.portal-topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.portal-brand-logo {
  height: 52px;
  width: auto;
}

.portal-brand .logo-mark {
  width: 52px;
  height: 52px;
  font-size: 22px;
}

.portal-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-suspend-btn {
  font-weight: 700;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.portal-suspend-btn.btn-success {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.portal-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.portal-stat {
  background: var(--page-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.portal-stat-highlight {
  background: var(--primary-light);
  border: 1px solid var(--primary);
}

.portal-stat-highlight .portal-stat-label {
  color: var(--primary-dark);
}

.portal-stat-highlight .portal-stat-value {
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 700;
}

.portal-stat-label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.portal-stat-value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.portal-nav {
  display: flex;
  gap: 8px;
  flex: 1;
}

.portal-nav-link {
  padding: 8px 14px;
  border-radius: 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.portal-nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.portal-nav-link.active {
  background: var(--primary);
  color: #fff;
}

.portal-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 20px;
}

@media (max-width: 640px) {
  .portal-topbar {
    padding: 12px 16px;
    gap: 12px;
  }
  .portal-nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
  .portal-nav-link {
    padding: 8px 10px;
    font-size: 13px;
  }
  .portal-content {
    padding: 20px 14px;
  }
}

/* ---------- Shell layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
}

:root[data-sidebar="collapsed"] .sidebar {
  width: 72px;
}

:root[data-sidebar="collapsed"] .nav-link span,
:root[data-sidebar="collapsed"] .nav-toggle span,
:root[data-sidebar="collapsed"] .submenu,
:root[data-sidebar="collapsed"] .logo-text,
:root[data-sidebar="collapsed"] .nav-toggle-btn {
  display: none;
}

:root[data-sidebar="collapsed"] .sidebar-logo,
:root[data-sidebar="collapsed"] .nav-row {
  justify-content: center;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 20px;
  flex-shrink: 0;
}

.logo-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.sidebar-logo-full {
  max-height: 56px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
}

.logo-text {
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 140%);
  border-radius: 26px 26px 0 0;
  padding: 14px 14px 22px;
  overflow-y: auto;
}

.sidebar-nav > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 12px 10px;
}

.nav-item {
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
}

.nav-link,
.nav-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-align: left;
}

.nav-row {
  display: flex;
  align-items: center;
}

.nav-row .nav-link {
  flex: 1;
}

.nav-toggle-btn {
  border: none;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  padding: 8px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
}

.nav-link:hover,
.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item.active > .nav-link,
.nav-link.active {
  background: #fff;
  color: var(--primary-dark);
  font-weight: 600;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.3);
}

.nav-item.active-parent > .nav-toggle,
.nav-item.active-parent > .nav-row .nav-link {
  color: #fff;
  font-weight: 600;
}

/* A link that's both the active page AND its own row's "active-parent" (e.g.
   Packages, NAS Management) needs the white-on-white active-parent color
   above to lose to the white-background active-link style -- otherwise the
   label renders white text on the white active background, i.e. invisible. */
.nav-item.active-parent > .nav-row .nav-link.active {
  color: var(--primary-dark);
}

.chevron {
  margin-left: auto;
  display: flex;
  transition: transform 0.15s ease;
}

.nav-item.open > .nav-toggle .chevron,
.nav-item.open > .nav-row .nav-toggle-btn {
  transform: rotate(180deg);
}

.submenu {
  list-style: none;
  margin: 0 0 0 40px;
  padding: 0 0 0 18px;
  border-left: 2px solid rgba(255, 255, 255, 0.25);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, margin 0.25s ease;
}

.nav-item.open > .submenu {
  max-height: 400px;
  margin-top: 6px;
  margin-bottom: 6px;
}

.submenu li {
  margin-bottom: 2px;
}

.submenu li a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
}

.submenu li a::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.submenu li a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.submenu li a:hover::before {
  background: #fff;
}

.submenu li a.active {
  color: var(--primary-dark);
  font-weight: 600;
  background: #fff;
}

.submenu li a.active::before {
  background: var(--primary-dark);
}

.nav-item.nested {
  margin-top: 2px;
}

.nested-toggle {
  padding-left: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.nested-toggle::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}

.nav-item.nested.active-parent .nested-toggle::before {
  background: #fff;
}

.nav-link:focus-visible,
.nav-toggle:focus-visible,
.nav-toggle-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: -2px;
}

.nested .submenu {
  margin-left: 18px;
}

/* ---------- Main / topbar ---------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 28px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--page-bg);
  border-radius: 10px;
  padding: 8px 14px;
  width: 320px;
  color: var(--text-muted);
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  color: var(--text-primary);
  width: 100%;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 50;
}

.search-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--border-color);
}

.search-dropdown-item:last-child {
  border-bottom: none;
}

.search-dropdown-item:hover,
.search-dropdown-item.is-active {
  background: var(--primary-light);
}

.search-dropdown-main {
  min-width: 0;
}

.search-dropdown-item .name {
  font-weight: 600;
  font-size: 13.5px;
  display: block;
}

.search-dropdown-item .detail {
  font-size: 12px;
  color: var(--text-muted);
}

.search-dropdown-side {
  flex-shrink: 0;
  text-align: right;
}

.search-dropdown-side .phone {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
}

.search-dropdown-side .balance {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.search-dropdown-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dashboard-style-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--page-bg);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

.dashboard-style-option {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 16px;
  color: var(--text-muted);
}

.dashboard-style-option.is-active {
  background: var(--primary);
  color: #fff;
}

.theme-picker {
  position: relative;
}

.theme-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.theme-picker-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 150;
}

.theme-picker-dropdown[hidden] {
  display: none;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.swatch-purple {
  background: #7c5cfc;
}

.swatch-orange {
  background: #ff8a3d;
}

.swatch-green {
  background: #22c55e;
}

.swatch-blue {
  background: #3b82f6;
}

.swatch-pink {
  background: #ec4899;
}

.swatch-red {
  background: #ef4444;
}

.swatch-teal {
  background: #14b8a6;
}

.swatch-amber {
  background: #f59e0b;
}

.swatch-indigo {
  background: #6366f1;
}

.swatch-slate {
  background: #666363;
}

.swatch-deepteal {
  background: #143d44;
}

.swatch-mint {
  background: #09d8a0;
}

.swatch-skyblue {
  background: #8bb4f8;
}

.swatch.is-active {
  border-color: var(--text-primary);
}

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  display: flex;
  align-items: center;
}

.theme-toggle-btn .icon-sun,
.theme-toggle-btn .icon-moon {
  display: flex;
}

.theme-toggle-btn .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle-btn .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle-btn .icon-moon {
  display: flex;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- Content ---------- */

.content {
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13.5px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--page-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #0d9668;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  overflow-x: auto;
}

/* ---------- Settings sub-page tabs (e.g. Email Configuration / Email Templates) ---------- */
.settings-tabs {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.settings-tab {
  padding: 10px 2px 12px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.settings-tab:hover {
  color: var(--text-primary);
}

.settings-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- Dashboard overview ---------- */

.hero-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}

.hero-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-side-stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-side-stats .card {
  padding: 16px 20px;
}

.hero-side-stats .split-card {
  flex: 1;
  justify-content: center;
  border-left-width: 6px;
  border-left-style: solid;
}

.hero-side-stats .summary-kpi-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 9px;
}

.hero-side-stats .summary-kpi-icon .icon-svg {
  width: 16px;
  height: 16px;
}

.hero-side-stats .split-card-header {
  margin-bottom: 2px;
}

.hero-side-stats .panel-title {
  font-size: 14px;
}

.hero-side-stats .split-row {
  margin-top: 6px;
}

.hero-side-stats .kpi-value {
  font-size: 19px;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-label {
  opacity: 0.85;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  margin: 0 0 4px;
}

.hero-value {
  font-size: 27px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.hero-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.hero-badge {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hero-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
}

.hero-badge.is-quiet::before {
  background: rgba(255, 255, 255, 0.55);
}

.hero-actions {
  display: flex;
  gap: 10px;
}

.hero-action-btn {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.hero-action-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.hero-sub {
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.85;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.hero-stat {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 9px 8px;
  min-width: 0;
}

.hero-stat-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.hero-stat-link:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.hero-stat-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
}

.hero-stat-icon .icon-svg {
  width: 11px;
  height: 11px;
}

.hero-stat-label {
  font-size: 11.5px;
  opacity: 0.85;
  line-height: 1.25;
  white-space: nowrap;
}

.hero-stat-value {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  margin: 2px 0 0;
}

.summary-kpi-grid {
  display: grid;
  /* auto-fit rather than a fixed 3-column split -- this grid now holds a
     variable number of cards (M-Pesa/Kopo Kopo/Cash/Total) instead of always
     exactly 3, so it needs to reflow instead of assuming a fixed count. */
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 720px) {
  .summary-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.summary-kpi-card {
  border-left: 5px solid transparent;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.summary-kpi-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-kpi-icon-purple {
  background: #efe9ff;
  color: #6741e8;
}

.summary-kpi-icon-orange {
  background: #ffede0;
  color: #ee6f1a;
}

.summary-kpi-icon-green {
  background: #e3f9ea;
  color: #22c55e;
}

.summary-kpi-icon-blue {
  background: #e6f0ff;
  color: #2f6fed;
}

.summary-kpi-card .kpi-label {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.summary-kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 0;
}

.summary-kpi-purple {
  border-left-color: #7c5cfc;
}

.summary-kpi-value-purple {
  color: #7c5cfc;
}

.summary-kpi-orange {
  border-left-color: #ff8a3d;
}

.summary-kpi-value-orange {
  color: #ee6f1a;
}

.summary-kpi-green {
  border-left-color: #22c55e;
}

.summary-kpi-total .kpi-value {
  color: #22c55e;
}

.summary-kpi-value-green {
  color: #22c55e;
}

.summary-kpi-blue {
  border-left-color: #4d8dff;
}

.summary-kpi-value-blue {
  color: #2f6fed;
}

.summary-month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.summary-month-nav .panel-title {
  margin: 0;
  margin-right: auto;
}

.summary-month-nav form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.split-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.split-card-header .panel-title {
  margin: 0;
  text-align: left;
}

.quick-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.quick-stats-row[hidden],
.hero-card[hidden] {
  display: none;
}

@media (max-width: 720px) {
  .quick-stats-row {
    grid-template-columns: 1fr;
  }
}

.quick-stat-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quick-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quick-stat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--page-bg);
  border-radius: 20px;
  padding: 6px 14px 6px 6px;
}

.quick-stat-header-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.quick-stat-header-icon .icon-svg {
  width: 16px;
  height: 16px;
}

.quick-stat-header-label {
  font-weight: 700;
  font-size: 15px;
}

.quick-stat-filter-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}

.quick-stat-filter-btn .icon-svg {
  width: 15px;
  height: 15px;
}

.quick-stat-scope-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 14px;
}

.quick-stat-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-stat-bar-track {
  flex: 1;
  height: 34px;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  background: #e5e7eb;
}

.quick-stat-bar-online {
  background: #22c55e;
  height: 100%;
}

.quick-stat-bar-offline {
  background: #ef4444;
  height: 100%;
}

.quick-stat-bar-end {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 32px;
}

.quick-stat-bar-end.is-online {
  color: #22c55e;
}

.quick-stat-bar-end.is-offline {
  color: #ef4444;
  text-align: right;
}

.quick-stat-legend-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.quick-stat-legend-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
  flex: 1;
  color: inherit;
  text-decoration: none;
  padding: 6px;
  border-radius: 8px;
}

.quick-stat-legend-item:hover {
  background: var(--page-bg);
}

.quick-stat-legend-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
}

.quick-stat-legend-label .icon-svg {
  width: 13px;
  height: 13px;
}

.quick-stat-legend-value {
  font-size: 22px;
  font-weight: 700;
}

.quick-stat-legend-value.is-online {
  color: #22c55e;
}

.quick-stat-legend-value.is-offline {
  color: #ef4444;
}

.quick-stat-donut-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.quick-stat-donut {
  width: 130px;
  height: 130px;
  min-width: 130px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-stat-donut-hole {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.quick-stat-donut-label {
  font-size: 12px;
  color: var(--text-muted);
}

.quick-stat-donut-value {
  font-size: 20px;
  font-weight: 700;
}

.quick-stat-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.quick-stat-donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: inherit;
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 6px;
}

.quick-stat-donut-legend-item:hover {
  background: var(--page-bg);
}

.quick-stat-donut-legend-item .quick-stat-legend-label {
  justify-content: flex-start;
  font-size: 14px;
}

.quick-stat-donut-legend-value {
  font-weight: 700;
  font-size: 14px;
}

.quick-stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.quick-stat-dot.is-active {
  background: #16a34a;
}

.quick-stat-dot.is-suspended {
  background: #f59e0b;
}

.quick-stat-dot.is-expired {
  background: #ef4444;
}

.split-card {
  display: flex;
  flex-direction: column;
}

.split-row {
  display: flex;
  align-items: center;
  margin-top: 10px;
}

.split-stat {
  flex: 1;
  text-align: center;
}

.split-stat-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.split-stat-link:hover {
  background: var(--hover-bg, rgba(103, 65, 232, 0.08));
}

.split-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border-color);
  margin: 0 16px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* Fixes a real height (rather than letting Chart.js's default aspect-ratio
   sizing blow the canvas up to match the card's full width) -- paired with
   maintainAspectRatio: false on both charts' own JS config. */
.chart-container {
  position: relative;
  height: 240px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 720px) {
  .chart-container {
    height: 200px;
  }
}

.panel-title {
  margin: 0 0 4px;
  font-size: 16px;
}

.panel-subtitle {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Activity / expiry list panels ---------- */

.list-panel {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-panel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-color);
}

.list-panel-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-panel-item:first-child {
  padding-top: 0;
}

.list-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-icon .icon-svg {
  width: 17px;
  height: 17px;
}

.list-icon.is-warning {
  background: #fef3c7;
  color: #b45309;
}

.list-body {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 13.5px;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.list-title a {
  color: inherit;
  text-decoration: none;
}

.list-title a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.list-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.list-meta.is-warning {
  color: #b45309;
  font-weight: 500;
}

/* ---------- Tables / empty states ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table.client-table {
  table-layout: fixed;
}

.data-table.client-table th:first-child,
.data-table.client-table td:first-child {
  width: 44px;
  white-space: nowrap;
}

.data-table.client-table th:last-child,
.data-table.client-table td:last-child {
  width: 36px;
  text-align: center;
}

.data-table th {
  text-align: left;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 12px;
  overflow-wrap: break-word;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.sortable-header {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  text-decoration: none;
}

.sortable-header:hover {
  color: var(--primary-dark);
}

.sort-arrow {
  font-size: 10px;
  opacity: 0.4;
}

.sort-arrow.is-active {
  opacity: 1;
  color: var(--primary-dark);
}

.list-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1.5px solid var(--border-color);
  padding: 6px 2px;
  max-width: 360px;
  flex: 1;
  min-width: 220px;
  color: var(--text-muted);
}

.list-search-bar:focus-within {
  border-bottom-color: var(--primary);
}

.list-search-bar .icon-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.list-search-bar input {
  border: none;
  outline: none;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  width: 100%;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr.is-selected-row td {
  background: var(--primary-light);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.row-actions {
  display: flex;
  gap: 14px;
}

.row-actions a {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
}

.row-actions a.text-danger {
  color: #dc2626;
}

.row-actions button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.empty-state {
  text-align: center;
}

.empty-body {
  padding: 36px 16px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.empty-icon .icon-svg {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  margin: 0 0 6px;
}

.empty-state p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Forms ---------- */

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

.form-columns {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.form-column {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-type-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.radio-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.radio-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.radio-pill input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font: inherit;
  color: var(--text-primary);
  background: var(--page-bg);
}

.password-toggle-wrap {
  position: relative;
  display: flex;
}

.password-toggle-wrap input {
  flex: 1;
  padding-right: 40px;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  z-index: 2;
  border: none;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  padding: 8px;
  display: flex;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 6px;
  pointer-events: auto;
}

.password-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--primary-light);
}

.password-toggle-btn .icon-eye-off {
  display: none;
}

.password-toggle-btn.is-visible .icon-eye {
  display: none;
}

.password-toggle-btn.is-visible .icon-eye-off {
  display: flex;
}

.form-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: none;
  align-self: flex-start;
}

.days-input {
  width: 70px;
}

.form-field textarea {
  resize: vertical;
  min-height: 90px;
}

.form-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.form-note {
  color: var(--text-muted);
  font-size: 13px;
}

.field-error {
  color: #dc2626;
  font-size: 12.5px;
}

.required-asterisk {
  color: #dc2626;
  font-size: 12px;
}

.invoice-form-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.invoice-form-summary {
  position: sticky;
  top: 20px;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: 1.4fr 1.8fr 0.9fr 0.6fr 0.9fr auto;
  gap: 10px;
  align-items: end;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
}

.invoice-item-row:first-child {
  padding-top: 0;
}

.invoice-item-row .form-field {
  gap: 4px;
}

.invoice-item-total {
  font-weight: 600;
  color: var(--text-primary);
}

.invoice-item-line-total::before {
  content: "Ksh ";
}

.invoice-item-remove-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.invoice-item-remove-wrap input[type="checkbox"] {
  display: none;
}

.invoice-item-remove {
  padding: 7px 12px;
  font-size: 12.5px;
}

.invoice-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  color: var(--text-muted);
}

.invoice-summary-row:last-child {
  border-bottom: none;
}

.invoice-summary-total {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

@media (max-width: 900px) {
  .invoice-form-layout {
    grid-template-columns: 1fr;
  }

  .invoice-item-row {
    grid-template-columns: 1fr 1fr;
  }

  .invoice-item-remove-wrap {
    grid-column: span 2;
    justify-content: flex-end;
  }
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.target-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}

.target-mode-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.target-mode-box:hover {
  border-color: var(--primary);
}

.target-mode-box.is-selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.target-mode-box input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.target-mode-box .icon-svg {
  width: 22px;
  height: 22px;
  color: var(--primary-dark);
}

.target-mode-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text-primary);
}

.target-mode-desc {
  font-size: 12.5px;
  color: var(--text-muted);
}

.target-panel {
  margin: 16px 0;
  padding: 14px;
  background: var(--page-bg);
  border-radius: 10px;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.target-count-badge {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-hover, #f1f3f6);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.target-recipient-total {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--primary-light, #eef2ff);
  color: var(--text-primary);
  font-size: 14px;
}

.target-recipient-total strong {
  color: var(--primary);
}

.template-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.template-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.template-card:hover {
  border-color: var(--primary);
}

.template-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.template-card input[type="radio"] {
  position: absolute;
  top: 10px;
  left: 10px;
  accent-color: var(--primary);
}

.template-card-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.quick-tokens {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.pending {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.status-pill.active {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.status-pill.suspended {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.status-pill.terminated {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.status-pill.credit {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.status-pill.info {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.client-header-row {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.client-header-card {
  margin-bottom: 0;
  padding: 20px 20px;
  min-height: 96px;
  overflow: visible;
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.client-header-left {
  gap: 10px;
}

.client-header-right {
  align-items: center;
  gap: 20px;
}

.btn-suspend {
  background: #717835;
  border: 1px solid #717835;
  color: #ffffff;
}

.btn-suspend:hover {
  background: #60662d;
  border-color: #60662d;
}

.btn-recharge {
  background: #09d8a0;
  border: 1px solid #09d8a0;
  color: #ffffff;
}

.btn-recharge:hover {
  background: #08c293;
  border-color: #08c293;
}

.btn-ticket {
  background: #143d44;
  border: 1px solid #143d44;
  color: #ffffff;
}

.btn-ticket:hover {
  background: #0e2e33;
  border-color: #0e2e33;
}

.btn-live-graph {
  background: #666363;
  border: 1px solid #666363;
  color: #ffffff;
}

.btn-live-graph:hover {
  background: #545252;
  border-color: #545252;
}

.client-avatar-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.client-avatar-block h2 {
  margin: 0;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.client-avatar-block p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.client-summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.client-stat-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.client-stat-chip {
  flex: 1 1 0;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  text-align: center;
}

.client-stat-chip-invoice {
  background: #f6aea9;
  border-color: #f6aea9;
}

.client-stat-chip-receipt {
  background: #8bb4f8;
  border-color: #8bb4f8;
}

.client-stat-chip-payment {
  background: #a8dbb5;
  border-color: #a8dbb5;
}

.client-stat-chip-invoice .client-stat-chip-label,
.client-stat-chip-receipt .client-stat-chip-label,
.client-stat-chip-payment .client-stat-chip-label {
  color: #1f2130;
  opacity: 0.7;
}

.client-stat-chip-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.client-stat-chip-value {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.client-status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.client-name-edit {
  display: inline-flex;
  color: var(--text-muted);
  opacity: 0.65;
}

.client-name-edit:hover {
  opacity: 1;
  color: var(--primary);
}

.client-name-edit .icon-svg {
  width: 14px;
  height: 14px;
}

.client-summary-package {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.client-usage-bar-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-muted);
}

.client-usage-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--primary-light);
  overflow: hidden;
}

.client-usage-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary-dark);
}

.client-summary-expiry {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.client-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.client-badges {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.detail-card {
  padding: 14px 18px;
}

.detail-list {
  margin: 0;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Rows with a value plus one or two action buttons (Package, MAC, Client
     IP) can be wider than the card -- wrap dd onto its own line below dt
     instead of forcing a horizontal scrollbar to reach it. */
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 7px 0;
  min-height: 41px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  box-sizing: border-box;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-row dd {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  font-weight: 600;
  text-align: right;
}

.link-action {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary-dark);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.link-action.text-danger-link {
  color: #dc2626;
}

.link-action-icon {
  display: inline-flex;
  align-items: center;
}

.link-action-icon .icon-svg {
  width: 15px;
  height: 15px;
}

.icon-circle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: var(--card-bg);
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.icon-circle-btn .icon-svg {
  width: 16px;
  height: 16px;
}

.icon-circle-btn:hover {
  background: currentColor;
}

.icon-circle-btn:hover .icon-svg {
  color: var(--card-bg);
}

.icon-circle-blue {
  color: #3b82f6;
}

.icon-circle-green {
  color: #22c55e;
}

.icon-circle-purple {
  color: #8b5cf6;
}

.icon-circle-teal {
  color: #14b8a6;
}

.row-actions-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kebab-menu {
  position: relative;
  display: inline-flex;
}

.kebab-toggle {
  color: var(--text-muted);
}

.kebab-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 150;
  overflow: hidden;
}

.kebab-dropdown[hidden] {
  display: none;
}

.kebab-dropdown-item {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
}

.kebab-dropdown-item:hover {
  background: var(--page-bg);
}

.kebab-dropdown form {
  display: contents;
}

button.kebab-dropdown-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  color: #fff;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.pill-btn:hover {
  opacity: 0.88;
}

.pill-btn:active {
  transform: scale(0.96);
}

.pill-btn-blue {
  background: #3b82f6;
}

.pill-btn-purple {
  background: #8b5cf6;
}

.pill-btn-pink {
  background: #ec4899;
}

.pill-btn-teal {
  background: #14b8a6;
}

.pill-btn-green {
  background: #22c55e;
}

.pill-btn-red {
  background: #ef4444;
}

.inline-form {
  display: inline-flex;
  align-items: center;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: #9ca3af;
}

.status-dot.online {
  background: #00e676;
}

.status-dot.offline {
  background: #ef4444;
}

.status-pill.online {
  background: rgba(0, 230, 118, 0.15);
  color: #00b359;
}

.status-pill.offline {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

.bulk-toolbar[hidden] {
  display: none;
}

.bulk-toolbar span {
  font-weight: 600;
  color: var(--primary-dark);
  margin-right: auto;
}

.data-table th input[type="checkbox"],
.data-table td input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.messages {
  margin-bottom: 16px;
}

.message-banner {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 8px;
}

.message-banner.success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.message-banner.error {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.message-banner.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.message-banner.info {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.option-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.option-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--page-bg);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
}

.option-pill .icon-svg {
  width: 16px;
  height: 16px;
}

.option-pill.is-active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.option-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}

.logo-preview-img {
  display: none;
  max-width: 140px;
  max-height: 80px;
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  object-fit: contain;
  background: var(--page-bg);
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .hero-stats,
  .hero-row,
  .panel-grid,
  .form-grid,
  .settings-grid,
  .detail-grid,
  .target-mode-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  :root[data-sidebar="collapsed"] .sidebar {
    width: var(--sidebar-width);
  }
  :root[data-sidebar="collapsed"] .nav-link span,
  :root[data-sidebar="collapsed"] .nav-toggle span,
  :root[data-sidebar="collapsed"] .submenu,
  :root[data-sidebar="collapsed"] .logo-text,
  :root[data-sidebar="collapsed"] .nav-toggle-btn {
    display: revert;
  }
  .sidebar.is-open {
    transform: translateX(0) !important;
  }
  .sidebar-backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 250;
  }
}

@media (max-width: 640px) {
  /* The topbar's fixed-width search box + full icon row don't fit a phone
     viewport and force the whole page to scroll sideways -- shrink/hide the
     lower-priority controls instead. */
  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .topbar-start {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }
  .search-box {
    width: 100%;
    min-width: 0;
    padding: 6px 10px;
  }
  .search-box input {
    min-width: 0;
  }
  .topbar-actions {
    gap: 4px;
  }
  .theme-picker {
    display: none;
  }
  .dashboard-style-toggle {
    display: none;
  }
  .avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .content {
    padding: 16px;
  }

  /* Previously collapsed into a compact card-grid that hid several columns
     (#, Contact, Bill, Online dot) on phones -- the operator wants every
     column visible and reachable by scrolling sideways instead, so this
     table is left as a real <table> at every width. The .card wrapper
     already has overflow-x: auto, which is what makes that scroll work. */
  .client-table {
    min-width: 720px;
  }
}

/* ---------- Email Template builder (trimmed GrapesJS: canvas + block panel + save) ---------- */
.email-body-source {
  display: none;
}

.email-builder-shell {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 6px;
}

.email-builder-canvas {
  flex: 1;
  min-width: 0;
  background: #f4f4f7;
}

.email-side-panel {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  background: var(--card-bg);
  overflow-y: auto;
  max-height: 600px;
  display: flex;
  flex-direction: column;
}

.email-side-panel-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 10px 12px 6px;
  border-top: 1px solid var(--border-color);
}

.email-side-panel-heading:first-child {
  border-top: none;
}

.email-blocks-panel {
  flex-shrink: 0;
}

/* GrapesJS's Style Manager ships with its own dark-theme colors baked into
   these class names -- since the surrounding panel bars are hidden (see the
   .gjs-pn-* rule below), only the sector content itself needs restyling to
   match this app's light card look instead of clashing with it. */
.email-style-panel .gjs-sm-sector-title {
  display: none;
}

.email-style-panel .gjs-sm-properties {
  padding: 0;
}

/* The newsletter preset injects its own full property set (Dimension,
   Typography, Decorations, Flex, Border, ...) regardless of the `sectors`
   config passed to grapesjs.init -- same override behavior already worked
   around for the panel bars, confirmed by inspecting the rendered DOM
   directly. Hiding by property name is what actually sticks: keep only
   background-color and text color, everything else stays hidden. This is a
   two-color email template, not a general web page. */
.email-style-panel .gjs-sm-property {
  display: none;
}

.email-style-panel .gjs-sm-property__color,
.email-style-panel .gjs-sm-property__background-color {
  display: block;
  margin-bottom: 10px;
}

/* A sector with none of the two kept properties would otherwise still show
   as an empty padded, titleless box. */
.email-style-panel .gjs-sm-sector:not(:has(.gjs-sm-property__color, .gjs-sm-property__background-color)) {
  display: none;
}

.email-style-panel .gjs-sm-sector {
  border: none;
  padding: 8px 12px;
}

.email-style-panel .gjs-sm-label,
.email-style-panel .gjs-field,
.email-style-panel .gjs-sm-label .gjs-sm-icon {
  color: var(--text-primary);
  background: transparent;
}

.email-style-panel .gjs-field {
  background: var(--input-bg, #f4f4f7);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.email-style-panel .gjs-field-color .gjs-checker-bg {
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.email-blocks-panel .gjs-block-category .gjs-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 10px 12px 6px;
}

.email-blocks-panel .gjs-block {
  width: auto;
  min-height: 0;
  margin: 4px 10px;
  padding: 10px 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12.5px;
}

.email-blocks-panel .gjs-block:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.email-builder-toolbar {
  margin-bottom: 10px;
}

/* The newsletter preset injects its own commands/devices/options/views panels
   regardless of the panels.defaults:[] editor config -- those come from the
   plugin's own init code, not core GrapesJS's default panel set. Hiding them
   directly is the only reliable way to get the trimmed canvas-plus-blocks-only
   layout, since appendTo/panels config alone doesn't suppress plugin-added ones. */
.gjs-pn-commands,
.gjs-pn-devices-c,
.gjs-pn-options,
.gjs-pn-views,
.gjs-pn-views-container {
  display: none !important;
}

/* Hiding the panels above doesn't reclaim the space GrapesJS still reserves
   for them -- .gjs-cv-canvas sizes/positions itself off the
   --gjs-canvas-top/--gjs-left-width CSS vars regardless, leaving a blank
   strip above the canvas and the white editable area sitting off-center.
   Forcing the canvas to fill its container directly fixes the alignment. */
.email-builder-canvas .gjs-cv-canvas {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

/* Searchable client combobox (Unmatched Payments "Match to Client") --
   see static/js/client_combo.js. The real <select> stays in the DOM
   (hidden) for form semantics; this is purely the visible search UI. */
.client-combo {
  position: relative;
  display: inline-block;
}

.client-combo-input {
  min-width: 200px;
}

.client-combo-input-error {
  border-color: #dc2626 !important;
}

.client-combo-list {
  /* position: fixed, not absolute -- this table's .card has overflow-x:
     auto, which per the CSS spec silently forces overflow-y to clip too
     (an ancestor can't scroll one axis without clipping the other unless
     both are auto). An absolutely-positioned dropdown gets cut off by that
     clip; fixed positioning (computed in JS from the input's real screen
     position, see client_combo.js) escapes it entirely by anchoring to the
     viewport instead of the clipped ancestor. */
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.35);
  padding: 6px;
}

.client-combo-item {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.client-combo-item-due {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.client-combo-item:hover,
.client-combo-item.is-active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Server Health panel (Tenants page, platform-operator only) */
.server-health-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.server-health-badge {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: capitalize;
}

.server-health-badge.healthy {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.server-health-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.server-health-badge.critical {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.server-gauge-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.server-gauge-card {
  flex: 1;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.server-gauge-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0;
}

.server-gauge-caption {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* Full-bleed colored header bar on a .card (e.g. Client Detail's "Client
   Information"/"More Information" cards) -- negative-margined out to the
   card's own padding so it spans edge-to-edge and rounds to match the
   card's top corners, rather than sitting as plain text inside the card. */
.detail-card-header {
  background: var(--primary);
  color: #ffffff;
  /* Must match .detail-card's own padding (14px 18px) exactly, not the
     generic .card padding (22px) -- a mismatch here overhangs the card's
     real edges, which is what was causing both the misaligned title and
     the phantom horizontal scrollbar (the .detail-row wrap fix alone never
     could have fixed that, since the actual cause was this bar sticking out
     past the card boundary, not the rows themselves). */
  margin: -14px -18px 10px -18px;
  padding: 0 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 16px;
  font-weight: 700;
  height: 44px;
  line-height: 44px;
}
