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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
}

.header-left { display: flex; align-items: center; gap: 16px; }

h1 { font-size: 1.4rem; font-weight: 700; color: #fff; }

.back-btn {
  color: #64b5f6;
  text-decoration: none;
  font-size: 0.9rem;
}
.back-btn:hover { text-decoration: underline; }

.last-updated { font-size: 0.75rem; color: #666; }

#fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 24px;
}

.loading { color: #666; font-style: italic; grid-column: 1/-1; text-align: center; padding: 40px; }

/* Robot Card */
.robot-card {
  background: #1e1e1e;
  border: 1px solid #2d2d2d;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
}
.robot-card:hover { border-color: #555; transform: translateY(-2px); }
.robot-card.offline { opacity: 0.4; cursor: default; pointer-events: none; }

/* Card header */
.card-header { display: flex; align-items: center; justify-content: space-between; }
.robot-name { font-size: 1.1rem; font-weight: 700; color: #fff; }
.robot-model { font-size: 0.75rem; color: #888; margin-top: 2px; }

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-online  { background: #1b5e20; color: #81c784; }
.status-busy    { background: #4a1a00; color: #ffab40; }
.status-offline { background: #212121; color: #757575; }

/* System status */
.system-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
  text-align: center;
}
.sys-idle      { background: #0d3b2e; color: #4caf50; }
.sys-working   { background: #3e2400; color: #ff9800; }
.sys-ready     { background: #0d2340; color: #42a5f5; }
.sys-error     { background: #3b0000; color: #ef5350; }
.sys-emergency { background: #1a0000; color: #b71c1c; }
.sys-unknown   { background: #1a1a1a; color: #757575; }

/* Metrics */
.metrics { display: flex; flex-direction: column; gap: 8px; }

.metric-row { display: flex; align-items: center; gap: 8px; }
.metric-label { font-size: 0.72rem; color: #888; width: 36px; flex-shrink: 0; }
.metric-bar-wrap { flex: 1; background: #2a2a2a; border-radius: 4px; height: 6px; overflow: hidden; }
.metric-bar { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.bar-cpu   { background: #42a5f5; }
.bar-gpu   { background: #ab47bc; }
.bar-ram   { background: #26a69a; }
.bar-bat   { background: #66bb6a; }
.bar-bat.low    { background: #ef5350; }
.bar-bat.medium { background: #ffa726; }
.metric-value { font-size: 0.72rem; color: #aaa; width: 34px; text-align: right; }

/* Battery row */
.battery-row { display: flex; align-items: center; gap: 8px; }
.charging-icon {
  font-size: 0.85rem;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Uptime */
.uptime { font-size: 0.72rem; color: #666; text-align: right; }

/* Network */
.network-row { display: flex; align-items: flex-start; gap: 8px; }
.network-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.net-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: #2a2a2a;
  color: #bbb;
}
.net-dot { width: 6px; height: 6px; border-radius: 50%; background: #555; flex-shrink: 0; }
.net-chip.net-ok .net-dot { background: #66bb6a; }
.net-chip.net-fail { background: #3b0000; color: #ef9a9a; }
.net-chip.net-fail .net-dot { background: #ef5350; }

.recovery-status {
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: -6px;
}
.recovery-active { background: #0d2340; color: #64b5f6; }
.recovery-fail   { background: #3b0000; color: #ef5350; }
.recovery-manual { background: #1a1a1a; color: #888; }
.recovery-warn   { background: #3e2400; color: #ffab40; }

.spinner {
  width: 10px; height: 10px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Monitor button */
.monitor-btn {
  margin-top: 4px;
  padding: 8px;
  background: #1565c0;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.monitor-btn:hover { background: #1976d2; }
