@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg-main: #f0f3f8;
  --sidebar-bg: #ffffff;
  --sidebar-w: 250px;
  --card-bg: #ffffff;
  --text-main: #19223c;
  --text-muted: #828ca2;
  --border-color: #e5eaf2;
  --primary-blue: #3b82f6;
  --primary-indigo: #6366f1;
  --accent-teal: #06b6d4;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --accent-orange: #f97316;
  --accent-red: #ef4444;
  --radius-card: 18px;
  --shadow-subtle: 0 4px 20px -2px rgba(18, 38, 63, 0.05);
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.sidebar.collapsed {
  width: 76px;
}
.sidebar.collapsed .sidebar-profile-text,
.sidebar.collapsed .menu-header,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-arrow {
  display: none !important;
}
.sidebar.collapsed .sidebar-profile {
  padding: 24px 8px 16px;
}
.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 12px;
}

.sidebar-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 20px;
  text-align: center;
}

.sidebar-avatar-wrap {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #fff0f0;
  border: 2px solid #fee2e2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.12);
}

.sidebar-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-avatar-wrap svg {
  width: 34px;
  height: 34px;
  color: #ef4444;
}

.sidebar-profile-text h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.sidebar-profile-text p {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 14px 30px;
}

.menu-header {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 16px 14px 6px;
}

.nav-item {
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  color: #55627a;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  user-select: none;
}

.nav-link:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.nav-link.active {
  background: #eff6ff;
  color: var(--primary-blue);
  font-weight: 700;
}

.nav-item.open .nav-link {
  color: var(--primary-blue);
}

.nav-item.open .nav-arrow {
  transform: rotate(180deg);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.nav-icon svg {
  width: 19px;
  height: 19px;
}

.nav-text {
  flex: 1;
}

.nav-arrow {
  width: 14px;
  height: 14px;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

/* ── SUBMENU ACCORDION ── */
.submenu {
  display: none;
  padding: 4px 0 6px 36px;
  flex-direction: column;
  gap: 2px;
}

.nav-item.open .submenu {
  display: flex;
}

.submenu-link {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.submenu-link:hover {
  background: #f1f5f9;
  color: var(--primary-blue);
}

.submenu-link.active {
  color: var(--primary-blue);
  background: #eff6ff;
  font-weight: 700;
}

.submenu-link::before {
  content: '•';
  margin-right: 8px;
  font-size: 14px;
  color: #cbd5e1;
}

.submenu-link.active::before {
  color: var(--primary-blue);
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  vertical-align: middle;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .25s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: #3b82f6;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.action-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-square {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon-square.edit {
  background: #2563eb;
  color: #ffffff;
}
.btn-icon-square.edit:hover {
  background: #1d4ed8;
}

.btn-icon-square.delete {
  background: #ef4444;
  color: #ffffff;
}
.btn-icon-square.delete:hover {
  background: #dc2626;
}

.flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

/* ── MAIN CONTENT SHELL ── */
.main-shell {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-shell.sidebar-collapsed {
  margin-left: 76px;
}

/* ── TOPBAR ── */
.topbar {
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
}

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

.btn-toggle-sidebar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-sidebar:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.btn-toggle-sidebar svg {
  width: 18px;
  height: 18px;
}

.api-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: #ecfdf5;
  color: #059669;
}

.api-status-pill.offline {
  background: #fef2f2;
  color: #dc2626;
}

.api-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

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

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.topbar-icon-btn:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
}

.topbar-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  transition: background 0.2s;
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

.topbar-profile-btn:hover {
  background: #f1f5f9;
}

.btn-action {
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-sync {
  background: var(--accent-green);
  color: #ffffff;
}
.btn-sync:hover {
  background: #0d9488;
}

.btn-logout {
  background: #fee2e2;
  color: #ef4444;
}
.btn-logout:hover {
  background: #ef4444;
  color: #ffffff;
}

/* ── PAGES CONTAINER ── */
.content-body {
  padding: 32px;
  flex: 1;
  max-width: 1440px;
  width: 100%;
}

.page-section {
  display: none;
}

.page-section.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

/* ── DASHBOARD HEADER ── */
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.dash-header-title h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.dash-header-title p {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.date-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  box-shadow: var(--shadow-subtle);
}

.date-badge svg {
  width: 16px;
  height: 16px;
  color: var(--primary-blue);
}

/* ── 8 STAT CARDS GRID ── */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 1280px) {
  .stat-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .stat-cards-grid {
    grid-template-columns: 1fr;
  }
}

.stat-box {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 22px 24px;
  box-shadow: var(--shadow-subtle);
  border: 1px solid rgba(229, 234, 242, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px -4px rgba(18, 38, 63, 0.08);
}

.stat-box-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-box-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #8c9ba5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-icon-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Specific Badge Colors */
.badge-blue { background: #e0f2fe; color: #0284c7; }
.badge-indigo { background: #e0e7ff; color: #4f46e5; }
.badge-teal { background: #ccfbf1; color: #0d9488; }
.badge-orange { background: #ffedd5; color: #ea580c; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-purple { background: #f3e8ff; color: #9333ea; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-amber { background: #fef3c7; color: #d97706; }

.stat-box-num {
  font-size: 34px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}

.stat-progress-bg {
  height: 5px;
  background: #f1f5f9;
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.stat-progress-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 0.6s ease;
}

.stat-box-footer {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

/* ── CHARTS SECTION ── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 28px;
}

@media (max-width: 1024px) {
  .charts-row {
    grid-template-columns: 1fr;
  }
}

.chart-panel {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-subtle);
  border: 1px solid var(--border-color);
}

.chart-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-panel-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.chart-panel-header p {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.chart-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-icon-box svg {
  width: 20px;
  height: 20px;
}

.chart-container-inner {
  height: 230px;
  position: relative;
  width: 100%;
}

/* ── DATA CARD & TABLES ── */
.panel-card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-subtle);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-card-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.panel-card-header p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.table-search-input {
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
  width: 220px;
  transition: all 0.2s;
}

.table-search-input:focus {
  background: #ffffff;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.custom-table th {
  padding: 12px 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #8c9ba5;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 14px;
  font-size: 13.5px;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

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

.custom-table tr:hover td {
  background: #f8fafc;
}

/* Status Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}

.status-pill.online { background: #dcfce7; color: #15803d; }
.status-pill.offline { background: #fee2e2; color: #b91c1c; }
.status-pill.free { background: #e0f2fe; color: #0369a1; }
.status-pill.premium { background: #f3e8ff; color: #7e22ce; }

.status-dot-sm {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Buttons */
.btn-primary-btn {
  background: var(--primary-blue);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-primary-btn:hover {
  background: #2563eb;
}

.btn-table-action {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-table-action.disable { background: #fee2e2; color: #dc2626; }
.btn-table-action.disable:hover { background: #ef4444; color: #fff; }
.btn-table-action.enable { background: #dcfce7; color: #16a34a; }
.btn-table-action.enable:hover { background: #10b981; color: #fff; }
.btn-table-action.delete { background: #f1f5f9; color: #64748b; margin-left: 4px; }
.btn-table-action.delete:hover { background: #ef4444; color: #fff; }

/* ── MODAL OVERLAY ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: 20px;
  padding: 32px;
  width: 540px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-content h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.modal-content p.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}

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

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

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: #ffffff;
  transition: border-color 0.2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary-blue);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.btn-cancel {
  background: #f1f5f9;
  color: #64748b;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

/* ── LOGIN OVERLAY ── */
.login-screen {
  position: fixed;
  inset: 0;
  background: #f0f3f8;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card-inner {
  background: #ffffff;
  border-radius: 24px;
  padding: 44px 40px;
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 12px 40px rgba(18, 38, 63, 0.08);
  border: 1px solid var(--border-color);
}

.login-brand-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  margin: 0 auto 20px;
}

.login-card-inner h2 {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
}

.login-card-inner p.login-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
}

/* Plan Cards */
.plans-container-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.plan-card-item {
  background: #ffffff;
  border-radius: var(--radius-card);
  padding: 28px;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-subtle);
  position: relative;
}

.plan-card-item.featured {
  border-color: var(--primary-blue);
}

.plan-card-tag {
  position: absolute;
  top: 14px;
  right: 18px;
  background: #eff6ff;
  color: var(--primary-blue);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.plan-card-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 8px;
}

.plan-card-price {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary-blue);
  margin-bottom: 18px;
}

.plan-card-price span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.plan-feature-list {
  list-style: none;
}

.plan-feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: #475569;
  padding: 6px 0;
}

.plan-feature-list li::before {
  content: '✓';
  color: var(--accent-green);
  font-weight: 800;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-msg {
  background: #1e293b;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  animation: slideToast 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-msg.success { background: #059669; }
.toast-msg.error { background: #dc2626; }

@keyframes slideToast {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
