* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #00ff88;
  --bg-dark: #1a1a2e;
  --bg-card: rgba(255, 255, 255, 0.05);
  --text: #fff;
  --text-muted: #888;
  --warning: #ffaa00;
  --danger: #ff4444;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  color: var(--text);
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.login-logo {
  font-size: 4rem;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-card input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input:focus {
  border-color: var(--primary);
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* App Container */
.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 12px;
  padding-bottom: 80px;
  padding-top: calc(12px + var(--safe-top));
}

/* Header */
.header {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 2rem; }
.logo-text h1 { font-size: 1.1rem; font-weight: 600; line-height: 1.2; }
.logo-text .subtitle { font-size: 0.7rem; color: var(--text-muted); }

.header-right { display: flex; align-items: center; gap: 12px; }

.connection-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  transition: all 0.3s;
}

.status-dot.connected {
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}

.hostname {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}

.logout-btn, .sound-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.logout-btn:hover, .sound-btn:hover { opacity: 1; }

/* Quick Stats */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 600px) {
  .quick-stats { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-icon { font-size: 1.3rem; margin-bottom: 8px; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.stat-sublabel { font-size: 0.7rem; color: var(--text-muted); }

.stat-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* Navigation */
.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--bg-card);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  flex: 1;
  min-width: fit-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab .tab-icon { font-size: 1.2rem; }

.nav-tab.active {
  background: var(--primary);
  color: #000;
}

/* Content */
.main-content { margin-bottom: 12px; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.section { margin-bottom: 12px; }
.section-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.metric-badge {
  background: var(--primary);
  color: #000;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.info-card, .chart-card, .memory-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-card canvas { max-height: 200px; }

/* Info Grid */
.info-grid, .process-grid, .uptime-grid {
  display: grid;
  gap: 8px;
}

.info-grid > div, .process-grid > div, .uptime-grid > div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-grid > div:last-child, .process-grid > div:last-child, .uptime-grid > div:last-child {
  border-bottom: none;
}

.label { color: var(--text-muted); font-size: 0.85rem; }
.value { color: var(--text); font-weight: 500; font-size: 0.85rem; }
.value.highlight { color: var(--primary); }

/* CPU Cores */
.cores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.core-item {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.core-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress.warning { background: var(--warning); }
.progress.danger { background: var(--danger); }

/* Memory */
.memory-bar {
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}

.memory-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #00cc6a);
  border-radius: 10px;
  transition: width 0.5s ease;
}

.memory-fill.warning { background: linear-gradient(90deg, var(--warning), #ff8800); }
.memory-fill.danger { background: linear-gradient(90deg, var(--danger), #cc0000); }

.memory-details {
  display: grid;
  gap: 6px;
}

/* Disk */
.disk-list { display: grid; gap: 10px; }

.disk-item {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.disk-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.disk-details {
  margin-top: 8px;
  font-size: 0.8rem;
}

/* Network */
.network-list { display: grid; gap: 10px; }

.network-item {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.network-header { margin-bottom: 10px; }

.network-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}


/* Docker */
.docker-list { display: grid; gap: 10px; }

.docker-item {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--text-muted);
}

.docker-item.running { border-left-color: var(--primary); }
.docker-item.exited { border-left-color: var(--danger); }
.docker-item.paused { border-left-color: var(--warning); }

.docker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.docker-name {
  font-weight: 600;
  color: var(--text);
}

.docker-state {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 600;
}

.docker-state.running { background: rgba(0, 255, 136, 0.2); color: var(--primary); }
.docker-state.exited { background: rgba(255, 68, 68, 0.2); color: var(--danger); }
.docker-state.paused { background: rgba(255, 170, 0, 0.2); color: var(--warning); }

.docker-image {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  word-break: break-all;
}

.docker-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.docker-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.docker-stat .label { font-size: 0.7rem; }
.docker-stat .value { font-size: 0.85rem; font-weight: 600; }

/* Alerts */
.threshold-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.threshold-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.threshold-item label {
  min-width: 70px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.threshold-item input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

.threshold-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
}

.threshold-item span {
  min-width: 45px;
  text-align: right;
  font-weight: 600;
  color: var(--primary);
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #000;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

#integration-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.integration-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.integration-item .status-icon { font-size: 1.2rem; }
.integration-item .status-text { flex: 1; }
.integration-item.active { border-left: 3px solid var(--primary); }
.integration-item.inactive { border-left: 3px solid var(--text-muted); opacity: 0.6; }

#alert-history { max-height: 400px; overflow-y: auto; }

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border-left: 3px solid var(--warning);
}

.alert-item.critical { border-left-color: var(--danger); }
.alert-item.warning { border-left-color: var(--warning); }

.alert-item .alert-icon { font-size: 1.3rem; }
.alert-item .alert-content { flex: 1; }
.alert-item .alert-type { font-weight: 600; text-transform: uppercase; font-size: 0.7rem; color: var(--text-muted); }
.alert-item .alert-message { margin: 4px 0; font-size: 0.9rem; }
.alert-item .alert-time { font-size: 0.7rem; color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 10px; }

/* Footer */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: linear-gradient(transparent, var(--bg-dark));
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.update-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.refresh-btn {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1rem;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 1000;
  transition: opacity 0.3s;
}

.toast.hidden { opacity: 0; pointer-events: none; }

/* Responsive */
@media (max-width: 400px) {
  .app { padding: 8px; padding-bottom: 80px; }
  .header-content { flex-wrap: wrap; }
  .stat-value { font-size: 1.1rem; }
  .nav-tab { padding: 8px; }
  .nav-tab .tab-label { display: none; }
  .nav-tab .tab-icon { font-size: 1.4rem; }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; }
}


/* Toast Alerts */
.toast-container {
  position: fixed;
  top: calc(70px + var(--safe-top));
  right: 12px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 350px;
}

.toast-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 170, 0, 0.95);
  color: #000;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

.toast-alert.critical {
  background: rgba(255, 68, 68, 0.95);
  color: #fff;
}

.toast-alert .toast-icon {
  font-size: 1.2rem;
}

.toast-alert.fade-out {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Locked Features */
.locked-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  min-height: 150px;
}

.locked-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.locked-text {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.btn-upgrade {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.btn-locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.feature-locked {
  position: relative;
  pointer-events: none;
  opacity: 0.4;
}

.feature-locked::after {
  content: '🔒 Upgrade necessário';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-dark);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Plan Badge */
.plan-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.plan-free { background: #666; color: #fff; }
.plan-starter { background: #00ff88; color: #000; }
.plan-pro { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.plan-business { background: linear-gradient(135deg, #f093fb, #f5576c); color: #fff; }

/* Upgrade Modal */
.upgrade-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.upgrade-modal.hidden { display: none; }

.upgrade-modal-content {
  background: var(--bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 30px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.upgrade-modal-content h2 {
  margin-bottom: 12px;
}

.upgrade-modal-content p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.upgrade-plans {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.upgrade-plan-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.upgrade-plan-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.upgrade-plan-option .plan-name {
  font-weight: 600;
}

.upgrade-plan-option .plan-price {
  color: var(--primary);
  font-weight: 700;
}

/* Process List */
.process-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  margin-bottom: 6px;
}

.process-name {
  font-weight: 500;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-stats {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
}
