:root {
  /* ==========================================================================
     1. Design Tokens (Atoms)
     ========================================================================== */
  
  /* Core Palette */
  --bg-body: #09090b; /* Zinc 950 */
  --bg-sidebar: #0f0f12;
  --bg-card: #18181b; /* Zinc 900 */
  --bg-input: #27272a; /* Zinc 800 */
  
  --border: #27272a;
  --border-hover: #3f3f46;
  
  /* Typography Colors */
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  
  /* Brand Colors */
  --primary: #8b5cf6; /* Violet 500 */
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.3);
  
  --secondary: #06b6d4; /* Cyan 500 */
  
  /* State Colors */
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  
  /* Spacing & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --space-unit: 4px;
  
  /* Components Dimensions */
  --input-height: 42px;
  --nav-item-pad: 10px 16px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  
  /* Typography */
  --font-sans: "Outfit", sans-serif;
  --font-size-base: 14px;
  --font-size-nav: 15px; /* Unified Nav Size */
}

/* Light Mode Override */
[data-theme="light"] {
  --bg-body: #f4f4f5; 
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --border: #e4e4e7;
  --border-hover: #d4d4d8;
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   2. Global Reset & Base
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

button, input, select, textarea {
  font-family: inherit;
}

*:focus-visible {
  outline: none;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s;
}

/* ==========================================================================
   3. Interactive Atoms (Mixins)
   ========================================================================== */
/* Shared properties for interactive elements like Nav Items, Tabs, Buttons */
.interactive-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: var(--nav-item-pad);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: var(--font-size-nav);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-secondary);
  border: 1px solid transparent; 
}

/* ==========================================================================
   4. Component: Navigation (Sidebar & Tabs)
   ========================================================================== */

/* 4.1 Sidebar Nav Items */
.nav-item {
  /* Inherit Interactive Base */
  display: flex; /* Override inline-flex */
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 15px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

[data-theme="light"] .nav-item:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.nav-item.active {
  background: linear-gradient(
    90deg,
    rgba(139, 92, 246, 0.1) 0%,
    transparent 100%
  );
  color: var(--primary);
  border-left: 3px solid var(--primary);
  border-radius: 4px var(--radius-md) var(--radius-md) 4px; 
}

.nav-item i {
  font-size: 20px;
}

/* 4.2 Top Tabs (Refactored to share DNA with Sidebar) */
.tab-nav-line {
  display: flex;
  gap: 12px;
}

.btn-tab {
  /* Reset Browser Defaults */
  -webkit-appearance: none;
  appearance: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;

  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  position: relative;
  
  /* Typography */
  color: var(--text-secondary) !important;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 15px; /* Synced with .nav-item */
  line-height: 1.5;
  
  /* Interactive */
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Borders */
  border-bottom: 3px solid transparent !important;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.btn-tab:hover {
  background-color: rgba(255, 255, 255, 0.03) !important;
  color: var(--text-primary) !important;
}

.btn-tab.active {
  background: linear-gradient(
    0deg, 
    rgba(139, 92, 246, 0.1) 0%, 
    transparent 100%
  ) !important;
  color: var(--primary) !important;
  border-bottom-color: var(--primary) !important;
}

.btn-tab i {
  font-size: 20px;
  margin-bottom: 0;
  color: inherit;
}

/* ==========================================================================
   5. Component: Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--font-size-base);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  height: var(--input-height); /* Align height with inputs */
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

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

.btn-secondary:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: var(--bg-input);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
}
.btn-icon i {
  font-size: 16px;
}

/* ==========================================================================
   6. Component: Forms & Inputs
   ========================================================================== */
.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Atomic Styling for all Inputs */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="month"],
select,
textarea {
  width: 100%;
  padding: 10px 16px; /* Matched to button padding */
  height: var(--input-height);
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-base);
  outline: none;
  transition: all 0.2s ease;
}

textarea {
  height: auto;
  min-height: 80px;
  padding-top: 12px;
}

input:hover,
select:hover {
  border-color: var(--border-hover);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background-color: var(--bg-card);
}

/* ==========================================================================
   7. Component: Layout & Structural Organisms
   ========================================================================== */
.app-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 40px;
  padding-left: 8px;
  gap: 12px;
}

.brand-icon {
  color: var(--primary);
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.nav-menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: auto;
}

.avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: white;
}

.user-info .name {
  font-weight: 600;
  font-size: 14px;
  display: block;
}
.user-info .role {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.main-content {
  padding: 40px;
  overflow-y: auto;
  position: relative;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

.page-title h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.page-title p {
  color: var(--text-secondary);
  font-size: 15px;
}

/* ==========================================================================
   8. Component: Cards & Data Display
   ========================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}

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

.card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card .value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.stat-card .trend {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.trend.up {
  color: var(--success);
}
.trend.down {
  color: var(--danger);
}
.trend span {
  color: var(--text-tertiary);
}

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  text-align: left;
  padding: 16px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
}

tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background-color: rgba(255, 255, 255, 0.01);
}

/* File Upload */
.file-upload-wrapper {
  position: relative;
  width: 100%;
  height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  transition: all 0.2s;
  cursor: pointer;
  overflow: hidden;
}

.file-upload-wrapper:hover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.05);
}

.file-upload-wrapper input[type="file"] {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.file-upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.file-upload-icon {
  font-size: 32px;
  color: var(--text-tertiary);
}

.file-upload-text {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Badges */
.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-block;
}

.status-active, .status-live, .status-domain, .status-apple_app_store {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}
.status-development, .status-hosting, .status-admob {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}
.status-saas_subscription, .status-vps {
  background: rgba(139, 92, 246, 0.1);
  color: var(--primary);
}
.status-gmail {
  background: rgba(234, 67, 53, 0.1);
  color: #ea4335;
} 
.status-outlook {
  background: rgba(0, 120, 212, 0.1);
  color: #0078d4;
}
.status-domain {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Utilities */
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }
.row-span-2 { grid-row: span 2; }

/* Responsive */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .col-span-3, .col-span-4 { grid-column: span 2; }
}

@media (max-width: 768px) {
  .app-container { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3, .col-span-4 { grid-column: span 1; }
}

/* Universal Focus Handling */
button:focus, a:focus, input:focus, select:focus, textarea:focus {
  outline: none;
}

/* ==========================================================================
   9. HTMX Smooth Transitions
   ========================================================================== */
.main-content {
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
  opacity: 1;
  transform: translateY(0);
}

/* When HTMX is loading new content */
.htmx-request .main-content {
  opacity: 0.6;
  pointer-events: none; /* Prevent clicks while loading */
}

/* Optional: Content Swapping Animation */
.htmx-swapping .main-content {
  opacity: 0;
  transform: translateY(10px);
}

/* Loading Indicator Bar (Top of screen) */
.htmx-indicator-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
  z-index: 9999;
  display: none;
}

.htmx-request .htmx-indicator-bar {
  display: block;
  transform: scaleX(0.7); /* Simulate progress */
  animation: loading-bar 1s infinite alternate;
}

@keyframes loading-bar {
  0% { transform: scaleX(0.1); }
  100% { transform: scaleX(0.9); }
}
