/* ========================================
   Dashboard — Layout
   ======================================== */

/* Hide notifications globally */
.topbar-notif, .notif-badge, .notif-panel { display: none !important; }

/* Crypto icons: invert in dark mode */
[data-theme="dark"] { --crypto-icon-filter: invert(0.85); }

/* Spin animation for rotation */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* Proxy table alignment fix */
.data-table td { vertical-align: middle; }
.data-table .action-btns { display: flex; align-items: center; gap: 4px; }

.dashboard-body {
  display: block;
  min-height: 100vh;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 60px;
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
}

.dashboard-body.sidebar-collapsed .dashboard-main {
  margin-left: var(--sidebar-collapsed-width);
}

.page-content {
  flex: 1;
  padding: 28px 32px 48px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: -16px;
  margin-bottom: 24px;
}


/* ========================================
   Dashboard — Sidebar
   ======================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-collapse {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  transition: all 0.2s;
  flex-shrink: 0;
}

.sidebar-collapse:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-section {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 16px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 450;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-link.active svg {
  stroke: var(--accent);
}

.sidebar-footer {
  padding: 16px 16px;
  border-top: 1px solid var(--border-light);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user-name {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.sidebar-user-plan {
  font-size: 0.6875rem;
  color: var(--accent);
  font-weight: 500;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 0.75rem;
}

/* Collapsed sidebar */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-header .logo {
  display: none;
}

.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

.sidebar-collapsed .sidebar-collapse svg {
  opacity: 1;
  transform: rotate(180deg);
}

.sidebar-collapsed .sidebar-link span,
.sidebar-collapsed .sidebar-user-info,
.sidebar-collapsed .sidebar-section {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-collapsed .sidebar-header {
  padding: 20px 12px 16px;
}

.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 10px;
}

.sidebar-collapsed .sidebar-user {
  justify-content: center;
}

.sidebar-collapsed .sidebar-footer {
  padding: 16px 12px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}


/* ========================================
   Dashboard — Topbar
   ======================================== */

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: rgba(255, 251, 245, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  z-index: 50;
  transition: background-color 0.4s ease;
}

[data-theme="dark"] .topbar {
  background: rgba(14, 12, 10, 0.85);
}

.topbar-menu {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.topbar-menu:hover {
  background: var(--bg-tertiary);
}

.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.topbar-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  padding: 8px 12px 8px 38px;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
}

.topbar-search input::placeholder {
  color: var(--text-tertiary);
}

.topbar-search input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.topbar-notif {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.2s;
}

.topbar-notif:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: #E53E3E;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-user-dropdown {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.2s;
}

.topbar-user-dropdown:hover {
  background: var(--bg-tertiary);
}


/* ========================================
   Dashboard — Dropdowns (Notifs + User)
   ======================================== */

.notif-panel,
.user-panel {
  position: fixed;
  top: var(--topbar-height);
  right: 32px;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

.notif-panel.open,
.user-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-light);
}

.notif-mark-all {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.notif-list {
  max-height: 320px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.notif-item:hover {
  background: var(--bg-secondary);
}

.notif-unread {
  background: var(--accent-glow);
}

.notif-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.notif-content p {
  font-size: 0.8125rem;
  line-height: 1.4;
  margin-bottom: 2px;
}

.notif-time {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.notif-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.user-panel {
  width: 220px;
  padding: 8px;
}

.user-panel-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
}

.user-panel-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.user-panel-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.user-panel-sep {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

.user-panel-link.danger {
  color: #E53E3E;
}

.user-panel-link.danger:hover {
  background: rgba(229, 62, 62, 0.06);
}


/* ========================================
   Dashboard — Stat Cards
   ======================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
}

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

.stat-card-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  color: var(--accent);
}

.stat-card-icon svg { width: 18px; height: 18px; }

.stat-card-trend {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-card-trend.up {
  background: rgba(40, 200, 64, 0.1);
  color: #22C55E;
}

.stat-card-trend.down {
  background: rgba(229, 62, 62, 0.1);
  color: #E53E3E;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.stat-card-label {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.stat-card.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stat-card.accent .stat-card-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stat-card.accent .stat-card-label {
  color: rgba(255,255,255,0.7);
}


/* ========================================
   Dashboard — Cards & Panels
   ======================================== */

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.dash-card-title {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
}

.dash-card-body {
  padding: 20px;
}

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

.dash-row > .dash-card {
  display: flex;
  flex-direction: column;
}

.dash-row > .dash-card > .dash-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}


/* ========================================
   Dashboard — Chart (CSS bars)
   ======================================== */

.chart-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  padding: 2px;
}

.chart-toggle-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
}

.chart-toggle-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.chart-container {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
  padding: 16px 0 0;
}

.chart-bar {
  flex: 1;
  background: var(--accent-soft);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: height 0.4s ease, background 0.2s;
  cursor: pointer;
  position: relative;
}

.chart-bar:hover {
  background: var(--accent);
}

.chart-bar:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 0.6875rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.chart-labels {
  display: flex;
  gap: 3px;
  padding-top: 8px;
}

.chart-labels span {
  flex: 1;
  text-align: center;
  font-size: 0.625rem;
  color: var(--text-tertiary);
}


/* ========================================
   Dashboard — Activity Feed
   ======================================== */

.activity-list {
  max-height: 360px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  transition: background 0.15s;
}

.activity-item:hover {
  background: var(--bg-secondary);
}

.activity-item + .activity-item {
  border-top: 1px solid var(--border-light);
}

.activity-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.activity-text {
  flex: 1;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.activity-time {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  margin-top: 2px;
}


/* ========================================
   Dashboard — Data Tables
   ======================================== */

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.1s;
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

.data-table .mono {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
}

.data-table .text-right {
  text-align: right;
}

.data-table .text-center {
  text-align: center;
}


/* ========================================
   Dashboard — Status Dots
   ======================================== */

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online { background: #22C55E; }
.status-dot.offline { background: #9A8C80; }
.status-dot.rotating { background: var(--accent); animation: pulse 1.5s ease-in-out infinite; }
.status-dot.operational { background: #22C55E; }
.status-dot.degraded { background: #F59E0B; }
.status-dot.down { background: #E53E3E; }


/* ========================================
   Dashboard — Tags
   ======================================== */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.tags-wrap {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}


/* ========================================
   Dashboard — Toolbar & Filters
   ======================================== */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-search {
  position: relative;
  min-width: 240px;
}

.toolbar-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.toolbar-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
}

.toolbar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-select {
  padding: 7px 28px 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%237A6B62' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s;
}

.filter-select:focus {
  border-color: var(--accent);
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-count {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}


/* ========================================
   Dashboard — Bulk Actions Bar
   ======================================== */

.bulk-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 0.8125rem;
}

.bulk-bar.visible {
  display: flex;
}

.bulk-bar-count {
  font-weight: 600;
  color: var(--accent);
}

.bulk-bar .btn {
  padding: 6px 14px;
  font-size: 0.75rem;
}


/* ========================================
   Dashboard — Pagination
   ======================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 0 0;
}

.pagination-btn {
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pagination-info {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}


/* ========================================
   Dashboard — Inline Edit
   ======================================== */

.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inline-edit-value {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.inline-edit-value:hover {
  background: var(--bg-tertiary);
}

.inline-edit-input {
  padding: 3px 8px;
  font-size: 0.8125rem;
  font-family: var(--font-body);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  width: 140px;
}

.inline-edit-placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}


/* ========================================
   Dashboard — Copy Button
   ======================================== */

.copyable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.copy-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.copy-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}


/* ========================================
   Dashboard — Action Buttons (table)
   ======================================== */

.action-btns {
  display: flex;
  gap: 4px;
}

.action-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

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


/* ========================================
   Dashboard — Toggle Switch
   ======================================== */

.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  position: relative;
  transition: all 0.3s;
  flex-shrink: 0;
}

.toggle-switch.active {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  transition: left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch.active::after {
  left: 22px;
}


/* ========================================
   Dashboard — Forms (extends base)
   ======================================== */

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.form-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.form-help {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}


/* ========================================
   Dashboard — Buy Page
   ======================================== */

.buy-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: start;
}

.buy-summary {
  position: sticky;
  top: calc(var(--topbar-height) + 28px);
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.duration-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.duration-card:hover {
  border-color: var(--accent);
}

.duration-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.duration-card-days {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.duration-card-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.duration-card-price {
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 6px;
}

.operator-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.operator-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s;
}

.operator-card:hover { border-color: var(--accent); }
.operator-card.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.range-input {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  outline: none;
  margin: 12px 0;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.count-input {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.count-input:focus { border-color: var(--accent); }

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.summary-row.total {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
}


/* ========================================
   Dashboard — Wallet
   ======================================== */

.wallet-balance {
  text-align: center;
  padding: 40px 20px;
}

.wallet-balance-amount {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.wallet-balance-label {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.amount-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.amount-btn {
  padding: 8px 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  color: var(--text-primary);
}

.amount-btn:hover { border-color: var(--accent); }
.amount-btn.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }


/* ========================================
   Dashboard — Payment Methods
   ======================================== */

.payment-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.payment-method-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.payment-method-card:hover { border-color: var(--accent); }
.payment-method-card.selected { border-color: var(--accent); background: var(--accent-soft); }

.payment-method-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.payment-method-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.875rem;
}


/* ========================================
   Dashboard — API Page
   ======================================== */

.api-key-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.api-key-display .key-value {
  flex: 1;
  word-break: break-all;
}

.endpoint-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  overflow: hidden;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.endpoint-header:hover {
  background: var(--surface-hover);
}

.method-badge {
  font-family: 'SF Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.method-badge.get {
  background: rgba(34, 197, 94, 0.1);
  color: #22C55E;
}

.method-badge.post {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
}

.endpoint-path {
  font-family: 'SF Mono', monospace;
  font-size: 0.8125rem;
  font-weight: 500;
}

.endpoint-desc {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-left: 8px;
}

.endpoint-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-light);
}

.endpoint-card.open .endpoint-body {
  display: block;
}

.code-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}

.code-tab {
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
}

.code-tab.active {
  background: var(--code-bg);
  color: var(--code-text);
}


/* ========================================
   Dashboard — Referral
   ======================================== */

.referral-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.referral-stat {
  text-align: center;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.referral-stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.referral-stat-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}


/* ========================================
   Dashboard — Status Page (public)
   ======================================== */

.status-page-body {
  display: block;
  min-height: 100vh;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.status-main {
  padding: 48px 24px;
  max-width: 720px;
  margin: 0 auto;
}

.status-banner {
  text-align: center;
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 32px;
}

.status-banner.all-ok {
  border-color: rgba(34, 197, 94, 0.3);
}

.status-banner-text {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.status-banner-uptime {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.status-components {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 32px;
}

.status-component {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

.status-component + .status-component {
  border-top: 1px solid var(--border-light);
}

.status-component-name {
  font-weight: 500;
  font-size: 0.9375rem;
}

.status-component-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-component-uptime {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.incident-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.incident-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.incident-date {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.incident-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 4px;
}

.incident-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.incident-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: 8px;
}

.incident-badge.resolved {
  background: rgba(34, 197, 94, 0.1);
  color: #22C55E;
}


/* ========================================
   Dashboard — Toast
   ======================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 340px;
}

.toast-visible {
  transform: translateX(0);
}

.toast-icon {
  font-size: 0.875rem;
  flex-shrink: 0;
}

.toast-success { border-left: 3px solid #22C55E; }
.toast-success .toast-icon { color: #22C55E; }
.toast-error { border-left: 3px solid #E53E3E; }
.toast-error .toast-icon { color: #E53E3E; }
.toast-info { border-left: 3px solid var(--accent); }
.toast-info .toast-icon { color: var(--accent); }


/* ========================================
   Dashboard — Utility Classes
   ======================================== */

.text-accent { color: var(--accent); }
.text-muted { color: var(--text-tertiary); }
.text-success { color: #22C55E; }
.text-danger { color: #E53E3E; }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }


/* ========================================
   Dashboard — Protocol Info
   ======================================== */

.protocol-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.protocol-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 600;
}

.protocol-badge.http {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.protocol-badge.socks {
  background: rgba(168, 85, 247, 0.1);
  color: #A855F7;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.protocol-port {
  font-family: 'SF Mono', monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  opacity: 0.8;
  margin-left: 4px;
}

.protocol-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-left: 4px;
}

.port-pool-info {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-glow);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.8125rem;
}

.port-pool-info strong {
  font-family: 'SF Mono', monospace;
  color: var(--accent);
}


/* ========================================
   Dashboard — Transaction Type Badges
   ======================================== */

.tx-badge {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
}

.tx-badge.purchase { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }
.tx-badge.recharge { background: rgba(34, 197, 94, 0.1); color: #22C55E; }
.tx-badge.refund { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }
.tx-badge.referral { background: rgba(168, 85, 247, 0.1); color: #A855F7; }
.tx-badge.completed { background: rgba(34, 197, 94, 0.1); color: #22C55E; }


/* ========================================
   Dashboard — Checkbox
   ======================================== */

.checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}


/* ========================================
   Dashboard — Modal wide
   ======================================== */

.modal-wide {
  max-width: 560px;
}

.modal-body h3 {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 16px;
}


/* ========================================
   Dashboard — Welcome Banner
   ======================================== */

.welcome-banner {
  background: linear-gradient(135deg, var(--accent) 0%, #C0621F 100%);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
}

.welcome-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.welcome-sub {
  font-size: 0.875rem;
  opacity: 0.85;
}


/* ========================================
   Dashboard — IP Whitelist
   ======================================== */

.whitelist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-family: 'SF Mono', monospace;
  font-size: 0.8125rem;
}

.whitelist-remove {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}

.whitelist-remove:hover {
  background: rgba(229, 62, 62, 0.1);
  color: #E53E3E;
}


/* ========================================
   Dashboard — Sub-accounts
   ======================================== */

.subaccount-role {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
}

.subaccount-role.operator { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }
.subaccount-role.viewer { background: rgba(168, 85, 247, 0.1); color: #A855F7; }
.subaccount-role.admin { background: rgba(212, 113, 42, 0.1); color: var(--accent); }


/* ========================================
   Dashboard — Responsive
   ======================================== */

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .buy-layout {
    grid-template-columns: 1fr;
  }

  .buy-summary {
    position: static;
  }

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

  .duration-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .referral-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dashboard-main {
    margin-left: 0;
  }

  .dashboard-body.sidebar-collapsed .dashboard-main {
    margin-left: 0;
  }

  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-open .sidebar-overlay {
    display: block;
  }

  .topbar-menu {
    display: flex;
  }

  .page-content {
    padding: 20px 16px 40px;
  }

  .topbar {
    padding: 0 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search {
    min-width: 100%;
  }

  .toolbar-right {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .operator-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .payment-methods {
    grid-template-columns: 1fr;
  }

  .notif-panel,
  .user-panel {
    right: 16px;
    width: calc(100vw - 32px);
    max-width: 340px;
  }
}

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

  .page-title {
    font-size: 1.25rem;
  }

  .welcome-banner {
    padding: 20px;
  }

  .welcome-title {
    font-size: 1.2rem;
  }

  .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 600px;
  }

  .amount-btns {
    grid-template-columns: repeat(3, 1fr);
  }

  .payment-methods {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .filter-select {
    width: 100%;
  }

  .form-section {
    padding: 16px;
  }

  .admin-tab {
    font-size: 0.75rem;
    padding: 8px 12px;
  }

  .topbar-search {
    display: none;
  }
}
