:root {
  --bg: #0a0f1f;
  --bg-2: #0f1630;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-solid: #111827;
  --panel-soft: rgba(30, 41, 59, 0.75);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(96, 165, 250, 0.28);
  --text: #f8fbff;
  --text-soft: #d7e2f2;
  --muted: #9fb0c9;
  --muted-2: #7f8da6;
  --primary: #635bff;
  --primary-2: #7c86ff;
  --success: #19c37d;
  --warning: #ffb020;
  --danger: #ff5a6f;
  --shadow: 0 24px 70px rgba(2, 8, 23, .45);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(99,91,255,.18), transparent 28%),
    radial-gradient(circle at top right, rgba(25,195,125,.10), transparent 24%),
    linear-gradient(180deg, #0a0f1f 0%, #0b1120 42%, #0e1630 100%);
}
body, p, div, span, small, label, td, th, input, textarea, select, li, code { color: var(--text); }
a { color: #aabfff; text-decoration: none; }
a:hover { color: #d4ddff; }
.text-secondary, .small.text-secondary, .form-text, .table .text-secondary, .list-group-item .text-secondary { color: var(--muted) !important; }
.text-muted { color: var(--muted) !important; }
hr { border-color: var(--border); opacity: 1; }
code {
  color: #dbe7ff;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 12px;
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 290px;
  background: linear-gradient(180deg, rgba(7,12,24,.97), rgba(10,16,32,.88));
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.03);
}
.brand-box { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.38rem;
  color: white;
  background: linear-gradient(135deg, var(--primary), #8b7cff 70%, #9e8cff);
  box-shadow: 0 12px 30px rgba(99,91,255,.38);
}
.brand-box h1 { font-size: 1.02rem; margin: 0; font-weight: 800; letter-spacing: -.02em; }
.brand-box small { color: var(--muted); }
.sidebar .nav-link {
  color: var(--text-soft);
  padding: 12px 14px;
  border-radius: 16px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: all .18s ease;
}
.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: linear-gradient(180deg, rgba(99,91,255,.17), rgba(99,91,255,.08));
  border-color: rgba(124,134,255,.28);
  color: white;
  transform: translateY(-1px);
}
.sidebar .nav-link i { margin-right: 10px; }
.sidebar-footer { padding-top: 16px; }
.content-area { flex: 1; padding: 30px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  padding: 22px 24px;
  background: linear-gradient(180deg, rgba(15,23,42,.72), rgba(15,23,42,.55));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.page-title { font-size: 2rem; font-weight: 800; margin: 0; letter-spacing: -.04em; }
.page-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(99,91,255,.13);
  border: 1px solid rgba(124,134,255,.20);
  color: #d8dfff;
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.panel-card, .stat-card, .metric-card {
  background: linear-gradient(180deg, rgba(15,23,42,.86), rgba(15,23,42,.74));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.panel-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 18px 20px;
  color: var(--text);
}
.panel-card .card-body { padding: 20px; }
.stat-card {
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), transparent 80%);
}
.stat-card small, .stat-card span { color: var(--muted); }
.stat-card h3 { font-size: 2rem; margin: 8px 0 6px; font-weight: 800; letter-spacing: -.04em; }
.stat-card.success::before { background: linear-gradient(90deg, var(--success), transparent 80%); }
.stat-card.warning::before { background: linear-gradient(90deg, var(--warning), transparent 80%); }
.stat-card.dark::before { background: linear-gradient(90deg, #7c86ff, transparent 80%); }

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  margin-bottom: 0;
}
.table thead th {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom-width: 1px;
  padding-top: 16px;
  padding-bottom: 16px;
}
.table tbody td { color: var(--text-soft); border-bottom-color: rgba(148,163,184,.10); }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: rgba(255,255,255,.02); color: var(--text); }

.form-label { color: #dbe6ff; font-weight: 600; margin-bottom: 8px; }
.form-control, .form-select {
  background: rgba(2, 6, 23, .52) !important;
  border: 1px solid rgba(148,163,184,.16) !important;
  color: var(--text) !important;
  border-radius: 16px;
  padding: 13px 15px;
  box-shadow: none !important;
}
.form-control::placeholder, textarea::placeholder { color: #7f8da6 !important; }
.form-control:focus, .form-select:focus {
  background: rgba(2, 6, 23, .72) !important;
  border-color: rgba(124,134,255,.65) !important;
  box-shadow: 0 0 0 .22rem rgba(99,91,255,.14) !important;
  color: var(--text) !important;
}
.form-check-input {
  background-color: rgba(2,6,23,.72);
  border-color: rgba(148,163,184,.28);
}
.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.btn {
  border-radius: 14px;
  font-weight: 700;
  padding: 11px 16px;
  border-width: 1px;
}
.btn-primary {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  border-color: rgba(124,134,255,.9);
  box-shadow: 0 12px 22px rgba(99,91,255,.22);
}
.btn-primary:hover { background: linear-gradient(180deg, #8790ff, #6c63ff); border-color: #8790ff; }
.btn-success {
  background: linear-gradient(180deg, #22d38a, #19c37d);
  border-color: rgba(25,195,125,.95);
  box-shadow: 0 12px 22px rgba(25,195,125,.18);
}
.btn-outline-light,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-dark {
  background: rgba(255,255,255,.025);
  color: var(--text-soft);
  border-color: rgba(148,163,184,.18);
}
.btn-outline-light:hover,
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-dark:hover {
  background: rgba(255,255,255,.07);
  color: white;
  border-color: rgba(148,163,184,.28);
}
.btn-warning { color: #131c2e; font-weight: 800; }

.alert {
  border-radius: 18px;
  border: 1px solid transparent;
  color: var(--text);
}
.alert-success { background: rgba(25,195,125,.14); border-color: rgba(25,195,125,.2); }
.alert-danger { background: rgba(255,90,111,.14); border-color: rgba(255,90,111,.22); }
.alert-warning { background: rgba(255,176,32,.14); border-color: rgba(255,176,32,.22); }
.alert-info { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.2); }
.alert .btn-close { filter: invert(1); opacity: .8; }

.user-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,.03);
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(148,163,184,.12);
}
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #8b7cff, var(--primary));
  font-weight: 800;
  color: white;
}
.user-card strong, .user-card small { color: var(--text); }
.user-card small { color: var(--muted); display: block; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid transparent;
}
.status-pill.online { background: rgba(25,195,125,.12); color: #90efc4; border-color: rgba(25,195,125,.22); }
.status-pill.offline { background: rgba(255,90,111,.12); color: #ff9fae; border-color: rgba(255,90,111,.2); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }

.template-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255,255,255,.02);
}
.dropdown-menu {
  background: rgba(11, 18, 35, .98);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.dropdown-item { color: var(--text-soft); }
.dropdown-menu .form-label { color: #dfe7ff; }

.badge {
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 700;
}
.text-bg-success { background: rgba(25,195,125,.15) !important; color: #99f4cb !important; border: 1px solid rgba(25,195,125,.22); }
.text-bg-warning { background: rgba(255,176,32,.16) !important; color: #ffd589 !important; border: 1px solid rgba(255,176,32,.22); }
.text-bg-secondary { background: rgba(148,163,184,.12) !important; color: #d8e3f7 !important; border: 1px solid rgba(148,163,184,.18); }
.text-bg-primary { background: rgba(99,91,255,.16) !important; color: #d7d3ff !important; border: 1px solid rgba(124,134,255,.22); }
.text-bg-danger { background: rgba(255,90,111,.14) !important; color: #ffadba !important; border: 1px solid rgba(255,90,111,.22); }

.list-group-item {
  color: var(--text-soft);
  background: transparent !important;
  border-color: rgba(148,163,184,.12) !important;
}
.card { color: var(--text); }

.auth-body { display: grid; place-items: center; padding: 30px; }
.auth-wrapper { width: 100%; max-width: 1180px; }
.auth-card {
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  overflow: hidden;
  border-radius: 30px;
  background: rgba(15,23,42,.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.auth-card-side {
  padding: 44px;
  background:
    radial-gradient(circle at 10% 10%, rgba(99,91,255,.40), transparent 28%),
    radial-gradient(circle at 90% 15%, rgba(25,195,125,.14), transparent 20%),
    linear-gradient(135deg, #121d3b, #18254a 55%, #10182f);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 640px;
}
.auth-card-side h1 { font-size: 2.8rem; line-height: 1.03; font-weight: 800; letter-spacing: -.05em; margin: 0 0 16px; }
.auth-card-side p, .auth-mini-list { color: #d8e2fa; }
.auth-mini-list { display: grid; gap: 12px; font-weight: 600; }
.auth-card-form { padding: 44px; display: flex; flex-direction: column; justify-content: center; }
.auth-card-form h2 { font-weight: 800; margin-bottom: 8px; font-size: 2rem; letter-spacing: -.04em; }
.auth-card-form p, .auth-card-form .small { color: var(--muted) !important; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(124,134,255,.28); border-radius: 999px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.03); }

@media (max-width: 992px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .app-shell { flex-direction: column; }
  .auth-card { grid-template-columns: 1fr; }
  .auth-card-side { min-height: auto; }
  .content-area { padding: 18px; }
  .topbar { padding: 18px; }
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(99,91,255,.24), rgba(25,195,125,.16));
  border: 1px solid var(--border);
}

.panel-inner {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.billing-table-wrap {
  overflow-x: auto;
}

.modal-backdrop.show {
  backdrop-filter: blur(4px);
  background: rgba(3, 7, 18, .72);
}

.panel-modal {
  background: linear-gradient(180deg, rgba(11,17,32,.96), rgba(15,23,42,.93));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.panel-modal .modal-body,
.panel-modal .modal-header,
.panel-modal .modal-footer {
  color: var(--text);
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(.8);
  cursor: pointer;
}

.was-validated .form-control:invalid,
.was-validated .form-select:invalid,
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: rgba(255,90,111,.72) !important;
  box-shadow: 0 0 0 .18rem rgba(255,90,111,.12) !important;
}

.invalid-feedback {
  color: #ff9baa;
}


.billing-table th,
.billing-table td {
  white-space: nowrap;
}

.billing-actions-modal .modal-dialog {
  max-width: 1100px;
}

.billing-modal-kicker {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(99,91,255,.14);
  border: 1px solid rgba(124,134,255,.22);
  color: #dbe3ff;
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.billing-modal-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.billing-summary-item {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  min-height: 110px;
}

.billing-summary-item span {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}

.billing-summary-item strong {
  display: block;
  font-size: 1.02rem;
  color: var(--text);
  margin-bottom: 6px;
}

.billing-summary-item small {
  color: var(--muted);
}

.billing-action-card {
  padding: 0;
  overflow: hidden;
}

.billing-action-card-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
}

.billing-action-card-body h6 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.billing-action-card-body p {
  color: var(--muted);
  margin: 0;
}

.billing-action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.billing-actions-trigger {
  min-width: 96px;
}

.billing-template-preview-img-wrap {
  min-height: 140px;
}

.billing-template-preview-img {
  max-height: 200px;
  width: 100%;
  object-fit: contain;
}

.billing-template-preview-text {
  font-size: 0.8125rem;
  line-height: 1.45;
  resize: vertical;
}

.template-page-image-wrap {
  min-height: 140px;
  min-width: 140px;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.85));
  border-style: dashed;
  border-color: var(--border);
}

.template-page-preview-img {
  max-height: 200px;
  min-width: 64px;
  min-height: 64px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

img.template-preview-img-error {
  outline: 2px dashed var(--danger);
  min-height: 80px;
  min-width: 80px;
  object-fit: none;
  background: rgba(255, 90, 111, 0.12);
}

@media (max-width: 1200px) {
  .billing-modal-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .billing-modal-summary {
    grid-template-columns: 1fr;
  }

  .billing-action-card-body {
    padding: 18px;
  }

  .billing-table th,
  .billing-table td {
    white-space: normal;
  }
}
