/* --- Design System Variables --- */
:root {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-hover: #f8fafc;
  
  --border-light: transparent;
  --border-subtle: #f1f5f9;
  --border-strong: transparent;
  --border-focus: #0f172a;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --accent-primary: #0f172a;
  --accent-primary-hover: #1e293b;
  --accent-blue: #2563eb;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.04);

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 68px;
  --header-height: 64px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --transition-fast: 0.15s ease-in-out;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Sidebar Navigation --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border: none;
  box-shadow: 2px 0 12px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  padding: 1.25rem 1rem;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), padding 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 1.25rem 0.5rem;
  border-bottom: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-primary);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
  border: none;
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav-section {
  margin-top: 1.25rem;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 0.5rem 0.65rem;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 1.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border: none;
  box-shadow: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface-subtle);
}

.nav-link.active {
  color: var(--accent-blue);
  background: #eff6ff;
  font-weight: 600;
  box-shadow: none;
  border: none;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.nav-link.active svg {
  color: var(--accent-blue);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: none;
}

.nav-badge.live {
  background: #ecfdf5;
  color: var(--accent-emerald);
  border: none;
}

/* --- Collapsed Sidebar State --- */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
  padding: 1.25rem 0.5rem;
}

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

.sidebar-collapsed .brand {
  padding: 0.25rem 0 1.25rem 0;
  justify-content: center;
}

.sidebar-collapsed .brand-text {
  display: none;
}

.sidebar-collapsed .nav-label {
  display: none;
}

.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 0.7rem 0;
  gap: 0;
  position: relative;
  border: none;
  box-shadow: none;
}

.sidebar-collapsed .nav-link span {
  display: none;
}

.sidebar-collapsed .nav-badge {
  display: none;
}

.sidebar-collapsed .nav-link svg {
  width: 20px;
  height: 20px;
  margin: 0 auto;
}

.sidebar-collapsed .nav-link[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: 100;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  border: none;
}

.sidebar-collapsed .nav-link[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  left: calc(100% + 5px);
  top: 50%;
  transform: translateY(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent #0f172a transparent transparent;
  z-index: 100;
  pointer-events: none;
}

/* --- Main Viewport and Topbar Band --- */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar {
  height: var(--header-height);
  background: var(--bg-surface);
  border: none;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.sidebar-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.topbar-divider {
  width: 1px;
  height: 20px;
  background: #e2e8f0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.breadcrumbs .sep {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 0.8rem;
}

.breadcrumbs span.current {
  color: var(--text-primary);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.version-pill {
  font-size: 0.72rem;
  font-family: monospace;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
}

/* --- Profile Container and Dropdown --- */
.profile-container {
  position: relative;
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  border: none;
  background: var(--bg-surface-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.profile-trigger:hover {
  background: #e2e8f0;
}

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--text-inverse);
  font-weight: 700;
  font-size: 0.72rem;
  display: grid;
  place-items: center;
  border: none;
}

.profile-info-compact {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.profile-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.profile-role {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.profile-chevron {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 270px;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0.5rem;
  z-index: 100;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.profile-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem 0.75rem 0.75rem;
}

.profile-avatar-lg {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--text-inverse);
  font-weight: 700;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: none;
}

.profile-details {
  min-width: 0;
}

.profile-name-lg {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.profile-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: #ecfdf5;
  color: var(--accent-emerald);
  border: none;
}

.dropdown-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 0.4rem 0;
}

.dropdown-section {
  padding: 0.2rem 0;
}

.dropdown-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.3rem 0.75rem 0.15rem 0.75rem;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  border: none;
}

.dropdown-item:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.dropdown-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.dropdown-item:hover svg {
  color: var(--text-primary);
}

.dropdown-item.danger {
  color: var(--accent-rose);
}

.dropdown-item.danger:hover {
  background: #fff1f2;
  color: var(--accent-rose);
}

.dropdown-item.danger svg {
  color: var(--accent-rose);
}

.content-container {
  padding: 2rem;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* --- Page Header and Action Buttons --- */
.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-title p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  background: var(--accent-primary);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.15);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* --- Metric Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.stat-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: none;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.stat-footer {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
}

/* --- Content Panels and Grids --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

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

.panel {
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0;
  border-bottom: none;
}

.panel-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Status Badges --- */
.status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
  border: none;
}

.status-badge.paid {
  background: #ecfdf5;
  color: #047857;
  border: none;
}

.status-badge.pending {
  background: #fffbeb;
  color: #b45309;
  border: none;
}

.status-badge.online {
  background: #eff6ff;
  color: #1d4ed8;
  border: none;
}

/* --- Empty States --- */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-surface-subtle);
  border: none;
  display: grid;
  place-items: center;
  margin: 0 auto 1.25rem auto;
  color: var(--text-muted);
}

.empty-state h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.empty-state p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 440px;
  margin: 0 auto 1.5rem auto;
}

/* --- Server Health List --- */
.health-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid #f1f5f9;
}

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

.health-info h5 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.health-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

/* --- Filter Tabs --- */
.filter-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface-subtle);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  width: fit-content;
}

.filter-tab {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  border: none;
}

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

.filter-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* --- Data Table --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  padding: 0.75rem 1rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-page);
  border: none;
}

.data-table th:first-child {
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.data-table th:last-child {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

.data-table td {
  padding: 0.9rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid #f8fafc;
  vertical-align: middle;
}

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

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

.contact-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* --- Form and Modal Elements --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: none;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

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

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

.modal-close-btn {
  background: var(--bg-surface-subtle);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  background: var(--bg-surface-subtle);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
  color: var(--text-primary);
  font-family: inherit;
  transition: all var(--transition-fast);
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  background: var(--bg-surface);
  box-shadow: 0 0 0 2px var(--accent-blue);
}

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

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #f8fafc;
}

.btn-danger-subtle {
  background: transparent;
  color: var(--accent-rose);
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-danger-subtle:hover {
  background: #fff1f2;
}

