/* ================== GLOBAL LAYOUT FIX ================== */
* {
  min-width: 0;
}

/* ================== CSS VARIABLES ================== */
:root {
  --bg-primary: #0a0e14;
  --bg-secondary: #111820;
  --bg-tertiary: #1a2330;
  --bg-elevated: #232d3d;
  --border-color: #2a3548;
  --border-light: #3a4a63;
  
  --text-primary: #f0f4f8;
  --text-secondary: #8b9aae;
  --text-muted: #5a6a7d;
  
  --accent-primary: #3b82f6;
  --accent-secondary: #60a5fa;
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  
  --online: #22c55e;
  --offline: #ef4444;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  
  /* ================== Z-INDEX HIERARCHY ================== */
  --z-base: 1;
  --z-dropdown: 10;
  --z-pagination: 20;
  --z-header: 50;
  --z-sidebar-overlay: 60;
  --z-sidebar: 70;
  --z-bottom-bar: 80;
  --z-floating-widget: 90;
  --z-modal: 500; /* Modal root - must be above all page content */
  --z-toast: 600; /* Toasts above modal */
  
  /* ================== LAYOUT DIMENSIONS ================== */
  --header-height: 56px;
  --sidebar-width: 260px;
  --bottom-bar-height: 72px;
  --pagination-height: 64px;
  --stats-bar-height: 80px;
}

/* ================== RESET & BASE ================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ================== ICONS ================== */
.icon-xs { width: 14px; height: 14px; stroke-width: 2; }
.icon-sm { width: 18px; height: 18px; stroke-width: 2; }
.icon-md { width: 22px; height: 22px; stroke-width: 2; }
.icon-lg { width: 28px; height: 28px; stroke-width: 2; }

/* ================== AUTH SCREEN ================== */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.auth-container {
  width: 100%;
  max-width: 360px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo-icon {
  width: 56px;
  height: 56px;
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-form {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}

.auth-form h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.input-group input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 44px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  transition: transform, opacity, background-color, background, border-color, box-shadow 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

.input-group input[type="password"] {
  padding-right: 44px;
}

.toggle-password {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-primary, .btn-secondary {
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform, opacity, background-color, background, border-color, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:active {
  transform: scale(0.98);
  background: #2563eb;
}

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

.btn-secondary:active {
  background: var(--bg-elevated);
}

.btn-danger {
  background: var(--accent-danger);
  color: white;
}

.btn-danger:disabled {
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-danger:not(:disabled):active {
  transform: scale(0.98);
  background: #dc2626;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
}

.btn-loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auth-error, .form-error {
  color: var(--accent-danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

.auth-footer {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 4px;
}
